| 30 | constexpr int kOutputTensor = 0; |
| 31 | |
| 32 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 33 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); |
| 34 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 35 | |
| 36 | const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
| 37 | const TfLiteTensor* axis = GetInput(context, node, kAxisTensor); |
| 38 | TF_LITE_ENSURE_EQ(context, NumDimensions(axis), 1); |
| 39 | TF_LITE_ENSURE(context, NumDimensions(input) >= NumElements(axis)); |
| 40 | |
| 41 | if (input->type != kTfLiteInt32 && input->type != kTfLiteFloat32 && |
| 42 | input->type != kTfLiteUInt8 && input->type != kTfLiteInt16 && |
| 43 | input->type != kTfLiteInt64) { |
| 44 | context->ReportError(context, "Type '%s' is not supported by reverse.", |
| 45 | TfLiteTypeGetName(input->type)); |
| 46 | return kTfLiteError; |
| 47 | } |
| 48 | |
| 49 | if (axis->type != kTfLiteInt32) { |
| 50 | context->ReportError(context, "Axis Type '%s' is not supported by reverse.", |
| 51 | TfLiteTypeGetName(axis->type)); |
| 52 | return kTfLiteError; |
| 53 | } |
| 54 | |
| 55 | // TODO(renjieliu): support multi-axis case. |
| 56 | if (NumElements(axis) > 1) { |
| 57 | context->ReportError(context, "Current does not support more than 1 axis."); |
| 58 | } |
| 59 | |
| 60 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 61 | TfLiteIntArray* output_shape = TfLiteIntArrayCopy(input->dims); |
| 62 | TF_LITE_ENSURE_EQ(context, output->type, input->type); |
| 63 | |
| 64 | return context->ResizeTensor(context, output, output_shape); |
| 65 | } |
| 66 | |
| 67 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 68 | const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
nothing calls this directly
no test coverage detected