17#include "kernels/ReverseV2.h"
18#include "kernels/Utils.h"
19#include <tensorflow/lite/kernels/internal/reference/reference_ops.h>
32void ReverseV2::configure()
34 assert(axes()->shape().num_dims() == 1);
36 if (
input()->element_type() != DataType::S32 &&
input()->element_type() != DataType::FLOAT32 &&
37 input()->element_type() != DataType::U8 &&
input()->element_type() != DataType::S16 &&
38 input()->element_type() != DataType::S64)
40 assert(
false &&
"Unsupported input type.");
42 if (axes()->element_type() != DataType::S32)
44 assert(
false &&
"Unsupported axes type.");
48 assert(
false &&
"Current implementation does not support more than 1 axis.");
50 int axis_value = getTensorData<int32_t>(axes())[0];
51 if (axis_value < 0 || axis_value >=
input()->shape().num_dims())
53 assert(
false &&
"Invalid axes value");
55 assert(
input()->element_type() ==
output()->element_type());
61void ReverseV2::execute()
const
63 int axis_value = getTensorData<int32_t>(axes())[0];
64 switch (
output()->element_type())
66 case DataType::FLOAT32:
69 getTensorData<float>(
output()));
72 tflite::reference_ops::Reverse<uint8_t>(
77 assert(
false &&
"Unsupported output type");
ReverseV2(const Tensor *input, const Tensor *axes, Tensor *output)
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
uint32_t num_elements(const Shape &shape)
The number of elements of a feature map of a given shape.