| 28 | constexpr int kOutputTensor = 0; |
| 29 | |
| 30 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 31 | const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
| 32 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 33 | switch (input->type) { |
| 34 | // TODO(wangtz): handle for kTfLiteInt8 |
| 35 | case kTfLiteFloat32: |
| 36 | reference_ops::Negate(GetTensorShape(input), GetTensorData<float>(input), |
| 37 | GetTensorShape(output), |
| 38 | GetTensorData<float>(output)); |
| 39 | break; |
| 40 | default: |
| 41 | context->ReportError( |
| 42 | context, "Neg only currently supports float32, got %d.", input->type); |
| 43 | return kTfLiteError; |
| 44 | } |
| 45 | return kTfLiteOk; |
| 46 | } |
| 47 | |
| 48 | } // namespace neg |
| 49 | |