| 74 | } |
| 75 | |
| 76 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 77 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 3); |
| 78 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 79 | |
| 80 | const TfLiteTensor* start = GetInput(context, node, kStartTensor); |
| 81 | const TfLiteTensor* limit = GetInput(context, node, kLimitTensor); |
| 82 | const TfLiteTensor* delta = GetInput(context, node, kDeltaTensor); |
| 83 | // Make sure all the inputs are scalars. |
| 84 | TF_LITE_ENSURE_EQ(context, NumDimensions(start), 0); |
| 85 | TF_LITE_ENSURE_EQ(context, NumDimensions(limit), 0); |
| 86 | TF_LITE_ENSURE_EQ(context, NumDimensions(delta), 0); |
| 87 | |
| 88 | // Currently only supports int32 and float. |
| 89 | // TODO(b/117912892): Support quantization as well. |
| 90 | const auto dtype = start->type; |
| 91 | if (dtype != kTfLiteFloat32 && dtype != kTfLiteInt32) { |
| 92 | context->ReportError(context, "Unknown index output data type: %s", |
| 93 | TfLiteTypeGetName(dtype)); |
| 94 | return kTfLiteError; |
| 95 | } |
| 96 | |
| 97 | TF_LITE_ENSURE_EQ(context, limit->type, dtype); |
| 98 | TF_LITE_ENSURE_EQ(context, delta->type, dtype); |
| 99 | |
| 100 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 101 | output->type = dtype; |
| 102 | |
| 103 | if (IsConstantTensor(start) && IsConstantTensor(limit) && |
| 104 | IsConstantTensor(delta)) { |
| 105 | return ResizeOutput(context, start, limit, delta, output); |
| 106 | } |
| 107 | |
| 108 | SetTensorToDynamic(output); |
| 109 | return kTfLiteOk; |
| 110 | } |
| 111 | |
| 112 | template <typename T> |
| 113 | void EvalImpl(const TfLiteTensor* start, const TfLiteTensor* delta, |
nothing calls this directly
no test coverage detected