/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_RUNTIME_SHAPE_H_ #define TENSORFLOW_LITE_KERNELS_INTERNAL_RUNTIME_SHAPE_H_ // This file is copied to MLIR to avoid a dependency on TFLite. // LINT.IfChange #include <cstdint> #include <cstring> #include <initializer_list> #include <iterator> #include <memory> #include "tensorflow/lite/kernels/internal/compatibility.h" namespace tflite { template <int N> struct Dims { … }; class RuntimeShape { … }; // Converts inference-style shape to legacy tflite::Dims<4>. inline tflite::Dims<4> ToRuntimeDims(const tflite::RuntimeShape& array_shape) { … } // TODO(b/80418076): Move to legacy ops file, update invocations. inline RuntimeShape DimsToShape(const tflite::Dims<4>& dims) { … } // Since tensors with '0' in their shape are valid in TF, these offset functions // allow that as long as the corresponding index is also 0. It is upto the // calling ops to ensure that they perform verification checks on tensor shapes // if they don't support a particular behavior. inline int Offset(const RuntimeShape& shape, int i0, int i1, int i2, int i3) { … } inline int Offset(const RuntimeShape& shape, int i0, int i1, int i2, int i3, int i4) { … } inline int Offset(const RuntimeShape& shape, int* index) { … } } // namespace tflite // LINT.ThenChange(//tensorflow/compiler/mlir/lite/kernels/internal/runtime_shape.h) #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_RUNTIME_SHAPE_H_