| 181 | } |
| 182 | |
| 183 | TfLiteStatus ResizeAndTransposeWeights(TfLiteContext* context, |
| 184 | const TfLiteTensor* weights, |
| 185 | TfLiteTensor* transposed_weights) { |
| 186 | TfLiteIntArray* transposed_weights_shape_array = TfLiteIntArrayCreate(4); |
| 187 | const RuntimeShape& input_shape = GetTensorShape(weights); |
| 188 | transposed_weights_shape_array->data[0] = input_shape.Dims(1); |
| 189 | transposed_weights_shape_array->data[1] = input_shape.Dims(2); |
| 190 | transposed_weights_shape_array->data[2] = input_shape.Dims(0); |
| 191 | transposed_weights_shape_array->data[3] = input_shape.Dims(3); |
| 192 | |
| 193 | transposed_weights->type = weights->type; |
| 194 | transposed_weights->allocation_type = kTfLiteDynamic; |
| 195 | TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, transposed_weights, |
| 196 | transposed_weights_shape_array)); |
| 197 | |
| 198 | // Transpose the weights from from OHWI order to HWOI order. |
| 199 | TransposeParams transpose_params; |
| 200 | transpose_params.perm_count = 4; |
| 201 | transpose_params.perm[0] = 1; |
| 202 | transpose_params.perm[1] = 2; |
| 203 | transpose_params.perm[2] = 0; |
| 204 | transpose_params.perm[3] = 3; |
| 205 | |
| 206 | optimized_ops::Transpose(transpose_params, input_shape, |
| 207 | GetTensorData<float>(weights), |
| 208 | GetTensorShape(transposed_weights), |
| 209 | GetTensorData<float>(transposed_weights)); |
| 210 | |
| 211 | return kTfLiteOk; |
| 212 | } |
| 213 | |
| 214 | template <KernelType kernel_type> |
| 215 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
no test coverage detected