|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/ceil.h" |
|
|
|
|
|
#include "edge-impulse-sdk/tensorflow/lite/c/common.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 ops { |
|
|
namespace micro { |
|
|
namespace ceil { |
|
|
|
|
|
constexpr int kInputTensor = 0; |
|
|
constexpr int kOutputTensor = 0; |
|
|
|
|
|
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
|
|
const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
|
|
TF_LITE_ENSURE(context, input != nullptr); |
|
|
TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
|
|
TF_LITE_ENSURE(context, output != nullptr); |
|
|
TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); |
|
|
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
|
|
TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32); |
|
|
TF_LITE_ENSURE_TYPES_EQ(context, output->type, input->type); |
|
|
TF_LITE_ENSURE_EQ(context, output->bytes, input->bytes); |
|
|
TF_LITE_ENSURE_EQ(context, output->dims->size, input->dims->size); |
|
|
for (int i = 0; i < output->dims->size; ++i) { |
|
|
TF_LITE_ENSURE_EQ(context, output->dims->data[i], input->dims->data[i]); |
|
|
} |
|
|
return kTfLiteOk; |
|
|
} |
|
|
|
|
|
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
|
|
const TfLiteEvalTensor* input = |
|
|
tflite::micro::GetEvalInput(context, node, kInputTensor); |
|
|
TfLiteEvalTensor* output = |
|
|
tflite::micro::GetEvalOutput(context, node, kOutputTensor); |
|
|
|
|
|
reference_ops::Ceil(tflite::micro::GetTensorShape(input), |
|
|
tflite::micro::GetTensorData<float>(input), |
|
|
tflite::micro::GetTensorShape(output), |
|
|
tflite::micro::GetTensorData<float>(output)); |
|
|
|
|
|
return kTfLiteOk; |
|
|
} |
|
|
} |
|
|
|
|
|
TfLiteRegistration Register_CEIL() { |
|
|
return {nullptr, |
|
|
nullptr, |
|
|
ceil::Prepare, |
|
|
ceil::Eval, |
|
|
nullptr, |
|
|
0, |
|
|
nullptr, |
|
|
0}; |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|