Reduce code size by removing GetTensorShape() from inline and move to CC file.

This file reduces ARM-builds by 1,896kb for files that include the 'add' kernel.

PiperOrigin-RevId: 329346614
Change-Id: Ib8fa28632ec81978e2ea0418679f81a654b71859
This commit is contained in:
Nick Kreeger 2020-08-31 11:48:49 -07:00 committed by TensorFlower Gardener
parent bd6739c504
commit 5e0fecffdb
2 changed files with 11 additions and 9 deletions

View File

@ -27,5 +27,15 @@ bool HaveSameShapes(const TfLiteEvalTensor* input1,
return TfLiteIntArrayEqual(input1->dims, input2->dims);
}
const RuntimeShape GetTensorShape(const TfLiteEvalTensor* tensor) {
if (tensor == nullptr || tensor->dims == nullptr) {
return RuntimeShape();
}
TfLiteIntArray* dims = tensor->dims;
const int dims_size = dims->size;
const int32_t* dims_data = reinterpret_cast<const int32_t*>(dims->data);
return RuntimeShape(dims_size, dims_data);
}
} // namespace micro
} // namespace tflite

View File

@ -63,15 +63,7 @@ const T* GetTensorData(const TfLiteEvalTensor* tensor) {
}
// Returns the shape of a TfLiteEvalTensor struct.
inline const RuntimeShape GetTensorShape(const TfLiteEvalTensor* tensor) {
if (tensor == nullptr || tensor->dims == nullptr) {
return RuntimeShape();
}
TfLiteIntArray* dims = tensor->dims;
const int dims_size = dims->size;
const int32_t* dims_data = reinterpret_cast<const int32_t*>(dims->data);
return RuntimeShape(dims_size, dims_data);
}
const RuntimeShape GetTensorShape(const TfLiteEvalTensor* tensor);
// Return true if the given tensors have the same shape.
bool HaveSameShapes(const TfLiteEvalTensor* input1,