| 150 | } |
| 151 | |
| 152 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 153 | OpContext op_context(context, node); |
| 154 | |
| 155 | // When the 'size_splits' and the 'axis' tensor is non-const we can't resize |
| 156 | // output tensors in Prepare(), and we have to do it now. |
| 157 | if (!IsConstantTensor(op_context.axis) || |
| 158 | !IsConstantTensor(op_context.size_splits)) { |
| 159 | TF_LITE_ENSURE_OK( |
| 160 | context, ResizeOutputTensors(context, node, op_context.input, |
| 161 | op_context.size_splits, op_context.axis)); |
| 162 | } |
| 163 | |
| 164 | int axis_value = GetTensorData<int>(op_context.axis)[0]; |
| 165 | |
| 166 | // Use split function to build the outputs since they share the same logic. |
| 167 | #define TF_LITE_SPLIT_V(scalar) \ |
| 168 | VectorOfTensors<scalar> all_outputs(*context, *node->outputs); \ |
| 169 | tflite::SplitParams op_params; \ |
| 170 | op_params.num_split = NumOutputs(node); \ |
| 171 | op_params.axis = axis_value; \ |
| 172 | reference_ops::Split(op_params, GetTensorShape(op_context.input), \ |
| 173 | GetTensorData<scalar>(op_context.input), \ |
| 174 | all_outputs.shapes(), all_outputs.data()); |
| 175 | switch (op_context.input->type) { |
| 176 | case kTfLiteFloat32: { |
| 177 | TF_LITE_SPLIT_V(float); |
| 178 | break; |
| 179 | } |
| 180 | case kTfLiteUInt8: { |
| 181 | TF_LITE_SPLIT_V(uint8_t); |
| 182 | break; |
| 183 | } |
| 184 | case kTfLiteInt16: { |
| 185 | TF_LITE_SPLIT_V(int16_t); |
| 186 | break; |
| 187 | } |
| 188 | case kTfLiteInt32: { |
| 189 | TF_LITE_SPLIT_V(int32_t); |
| 190 | break; |
| 191 | } |
| 192 | case kTfLiteInt64: { |
| 193 | TF_LITE_SPLIT_V(int64_t); |
| 194 | break; |
| 195 | } |
| 196 | default: |
| 197 | context->ReportError(context, "Type %s currently not supported.", |
| 198 | TfLiteTypeGetName(op_context.input->type)); |
| 199 | return kTfLiteError; |
| 200 | } |
| 201 | #undef TF_LITE_SPLIT_V |
| 202 | |
| 203 | return kTfLiteOk; |
| 204 | } |
| 205 | |
| 206 | } // namespace split_v |
| 207 |
nothing calls this directly
no test coverage detected