MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ResizeAndTransposeWeights

Function ResizeAndTransposeWeights

tensorflow/lite/kernels/transpose_conv.cc:183–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183TfLiteStatus 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
214template <KernelType kernel_type>
215TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {

Callers 2

PrepareFunction · 0.85
EvalFunction · 0.85

Calls 5

TfLiteIntArrayCreateFunction · 0.85
DimsMethod · 0.80
ResizeTensorMethod · 0.80
GetTensorShapeFunction · 0.50
TransposeFunction · 0.50

Tested by

no test coverage detected