-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23a4f73
commit 1cd3b47
Showing
19 changed files
with
747 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
edgeimpulse/edge-impulse-sdk/tensorflow/lite/kernels/internal/reduce_common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ | ||
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ | ||
|
||
namespace tflite { | ||
namespace ops { | ||
namespace builtin { | ||
namespace reduce { | ||
|
||
enum ReduceType { | ||
kSum, | ||
kProd, | ||
kMax, | ||
kMin, | ||
kAny, | ||
kAll, | ||
}; | ||
|
||
} // namespace reduce | ||
} // namespace builtin | ||
} // namespace ops | ||
} // namespace tflite | ||
|
||
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
edgeimpulse/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/scatter_nd.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SCATTER_ND_H_ | ||
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SCATTER_ND_H_ | ||
|
||
#include "edge-impulse-sdk/tensorflow/lite/kernels/internal/common.h" | ||
#include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" | ||
#include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" | ||
#include "edge-impulse-sdk/tensorflow/lite/kernels/kernel_util.h" | ||
#include "edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h" | ||
|
||
namespace tflite { | ||
|
||
namespace reference_ops { | ||
|
||
template <typename IndicesT, typename UpdatesT> | ||
inline TfLiteStatus ScatterNd(const RuntimeShape& indices_shape, | ||
const IndicesT* indices_data, | ||
const RuntimeShape& updates_shape, | ||
const UpdatesT* updates_data, | ||
const RuntimeShape& output_shape, | ||
UpdatesT* output_data) { | ||
int n_slices = 1; | ||
int slice_size = 1; | ||
const int outer_dims = indices_shape.DimensionsCount() - 1; | ||
const int indices_nd = indices_shape.Dims(outer_dims); | ||
const int updates_dims = updates_shape.DimensionsCount(); | ||
for (int i = 0; i < outer_dims; ++i) { | ||
n_slices *= indices_shape.Dims(i); | ||
} | ||
for (int i = outer_dims; i < updates_dims; ++i) { | ||
slice_size *= updates_shape.Dims(i); | ||
} | ||
|
||
int output_flat_size = output_shape.FlatSize(); | ||
int remain_flat_size = output_flat_size; | ||
std::vector<int> dims_to_count(indices_nd, 0); | ||
for (int i = 0; i < indices_nd; ++i) { | ||
dims_to_count[i] = remain_flat_size / output_shape.Dims(i); | ||
remain_flat_size = dims_to_count[i]; | ||
} | ||
|
||
if (n_slices * slice_size > updates_shape.FlatSize()) { | ||
return kTfLiteError; | ||
} | ||
memset(output_data, 0, sizeof(UpdatesT) * output_flat_size); | ||
for (int i = 0; i < n_slices; ++i) { | ||
int to_pos = 0; | ||
for (int j = 0; j < indices_nd; ++j) { | ||
IndicesT idx = indices_data[i * indices_nd + j]; | ||
to_pos += idx * dims_to_count[j]; | ||
} | ||
if (to_pos < 0 || to_pos + slice_size > output_flat_size) { | ||
return kTfLiteError; | ||
} | ||
for (int j = 0; j < slice_size; j++) { | ||
output_data[to_pos + j] += updates_data[i * slice_size + j]; | ||
} | ||
} | ||
return kTfLiteOk; | ||
} | ||
|
||
} // namespace reference_ops | ||
} // namespace tflite | ||
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SCATTER_ND_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.