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

Function ToRuntimeDims

tensorflow/lite/kernels/internal/types.h:302–315  ·  view source on GitHub ↗

Converts inference-style shape to legacy tflite::Dims<4>.

Source from the content-addressed store, hash-verified

300
301// Converts inference-style shape to legacy tflite::Dims<4>.
302inline tflite::Dims<4> ToRuntimeDims(const tflite::RuntimeShape& array_shape) {
303 tflite::Dims<4> result;
304 const int dimensions_count = array_shape.DimensionsCount();
305 TFLITE_CHECK_LE(dimensions_count, 4);
306 int cum_prod = 1;
307 for (int i = 0; i < 4; i++) {
308 const int new_dim =
309 (i < dimensions_count) ? array_shape.Dims(dimensions_count - 1 - i) : 1;
310 result.sizes[i] = new_dim;
311 result.strides[i] = cum_prod;
312 cum_prod *= new_dim;
313 }
314 return result;
315}
316
317// TODO(b/80418076): Move to legacy ops file, update invocations.
318inline RuntimeShape DimsToShape(const tflite::Dims<4>& dims) {

Callers

nothing calls this directly

Calls 2

DimensionsCountMethod · 0.80
DimsMethod · 0.80

Tested by

no test coverage detected