| 118 | } |
| 119 | |
| 120 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 121 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 4); |
| 122 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 123 | |
| 124 | OneHotContext op_context{context, node}; |
| 125 | switch (op_context.dtype) { |
| 126 | // TODO(b/111744875): Support uint8 and quantization. |
| 127 | case kTfLiteFloat32: |
| 128 | case kTfLiteInt16: |
| 129 | case kTfLiteInt32: |
| 130 | case kTfLiteInt64: |
| 131 | case kTfLiteBool: |
| 132 | op_context.output->type = op_context.dtype; |
| 133 | break; |
| 134 | default: |
| 135 | context->ReportError(context, "Unknown output data type: %d", |
| 136 | op_context.dtype); |
| 137 | return kTfLiteError; |
| 138 | } |
| 139 | |
| 140 | TF_LITE_ENSURE(context, op_context.indices->type == kTfLiteInt32 || |
| 141 | op_context.indices->type == kTfLiteInt64); |
| 142 | TF_LITE_ENSURE(context, op_context.axis >= 0 && |
| 143 | op_context.axis < op_context.output_dims); |
| 144 | TF_LITE_ENSURE_EQ(context, NumElements(op_context.depth), 1); |
| 145 | TF_LITE_ENSURE_EQ(context, NumElements(op_context.on_value), 1); |
| 146 | TF_LITE_ENSURE_EQ(context, NumElements(op_context.off_value), 1); |
| 147 | TF_LITE_ENSURE_EQ(context, op_context.on_value->type, op_context.dtype); |
| 148 | TF_LITE_ENSURE_EQ(context, op_context.off_value->type, op_context.dtype); |
| 149 | |
| 150 | if (!IsConstantTensor(op_context.depth)) { |
| 151 | SetTensorToDynamic(op_context.output); |
| 152 | return kTfLiteOk; |
| 153 | } |
| 154 | |
| 155 | return ResizeOutputTensor(context, op_context); |
| 156 | } |
| 157 | |
| 158 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 159 | OneHotContext op_context{context, node}; |
nothing calls this directly
no test coverage detected