#include <cker/Shape.h>
-#include "tensorflow/contrib/lite/c/builtin_op_data.h"
-#include "tensorflow/contrib/lite/kernels/internal/types.h"
-#include "tensorflow/contrib/lite/kernels/internal/tensor.h"
#include "model/operand/Object.h"
#include "model/operand/DataType.h"
uint32_t getSizeOfDimension(const Shape &shape, uint32_t dimensionIdx);
-inline ::tflite::Dims<4> convertShapeToDims(const Shape &shape)
-{
- // nnAssert(shape.dimensions.size() <= 4);
- ::tflite::Dims<4> dims;
- // The dimensions are reversed in Dims<4>.
- for (int i = 0; i < 4; ++i)
- {
- int src = static_cast<int>(shape.dimensions.size()) - i - 1;
- if (src >= 0)
- {
- dims.sizes[i] = static_cast<int>(getSizeOfDimension(shape, src));
- }
- else
- {
- dims.sizes[i] = 1;
- }
- }
- dims.strides[0] = 1;
- for (int i = 1; i < 4; i++)
- {
- dims.strides[i] = dims.strides[i - 1] * dims.sizes[i - 1];
- }
- return dims;
-}
-
-inline ::tflite::RuntimeShape convertShapeToTFLiteShape(const Shape &shape)
-{
- std::vector<int32_t> raw_shape;
- raw_shape.resize(4);
-
- for (uint32_t i = 0; i < 4; ++i)
- {
- if (i >= shape.dimensions.size())
- {
- raw_shape[i] = 1;
- }
- else
- {
- raw_shape[i] = shape.dimensions[i];
- }
- }
-
- return ::tflite::GetTensorShape(raw_shape);
-}
-
inline nnfw::cker::Shape convertToExtendedCkerShape(const Shape &shape)
{
std::vector<int32_t> raw_shape;
return nnfw::cker::GetShape(raw_shape);
}
-inline TfLiteFusedActivation convertFusedActivation(FuseCode act)
-{
- if (act == ANEURALNETWORKS_FUSED_NONE)
- {
- return kTfLiteActNone;
- }
-
- if (act == ANEURALNETWORKS_FUSED_RELU)
- {
- return kTfLiteActRelu;
- }
-
- if (act == ANEURALNETWORKS_FUSED_RELU1)
- {
- return kTfLiteActRelu1;
- }
-
- if (act == ANEURALNETWORKS_FUSED_RELU6)
- {
- return kTfLiteActRelu6;
- }
-
- return kTfLiteActNone;
-}
-
bool QuantizeMultiplier(double double_multiplier, int32_t *quantized_multiplier, int *shift);
__wur bool QuantizeMultiplierSmallerThanOne(double double_multiplier, int32_t *quantized_multiplier,