aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser/TfLiteParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp51
1 files changed, 9 insertions, 42 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index 4e0efbbf3c..15ca36d906 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -2545,11 +2545,9 @@ void TfLiteParserImpl::ParseReshape(size_t subgraphIndex, size_t operatorIndex)
// If there is no built-in option given or if the built-in new_shape parameter was empty
if (!targetShapeFound)
{
- bool secondInputTensorExists = inputs.size() > 1 && inputs[1] != nullptr;
- if (secondInputTensorExists)
+ // Check for a second input tensor
+ if (inputs.size() > 1 && inputs[1] != nullptr)
{
- armnn::TensorInfo shapeInfo = ToTensorInfo(inputs[1]);
-
if (inputs[1]->is_variable)
{
ARMNN_THROW_PARSE_EXCEPTION( "Target shapes defined in non-const input tensors is not supported");
@@ -2565,47 +2563,16 @@ void TfLiteParserImpl::ParseReshape(size_t subgraphIndex, size_t operatorIndex)
ARMNN_THROW_PARSE_EXCEPTION("Target 'shape' input is not an int32 type");
}
- // If the provided shape is constant, we can load in from the buffer ...
- if (shapeInfo.IsConstant())
+ // Extract target shape from input
+ auto bufferPtr = GetBuffer(m_Model, inputs[1]->buffer);
+ auto values = reinterpret_cast<const int32_t*>(bufferPtr->data.data());
+ if (!values)
{
- // Extract target shape from input
- auto bufferPtr = GetBuffer(m_Model, inputs[1]->buffer);
- auto values = reinterpret_cast<const int32_t*>(bufferPtr->data.data());
- if (!values)
- {
- ARMNN_THROW_PARSE_EXCEPTION("Reshape operator target shape input buffer data is null");
- }
- for (int i=0; i < inputs[1]->shape[0]; ++i)
- {
- targetShape.push_back(values[i]);
- }
+ ARMNN_THROW_PARSE_EXCEPTION("Reshape operator target shape input buffer data is null");
}
- // ... otherwise, we have to infer it during Runtime.
- else
+ for (int i=0; i < inputs[1]->shape[0]; ++i)
{
- // The parser only supports shape (batch, -1) or (-1) for non-constant shape input.
- unsigned int dims = shapeInfo.GetNumDimensions();
- TensorShape shapes = shapeInfo.GetShape();
- if (dims != 1 || shapes[0] > 2)
- {
- throw ParseException(fmt::format("Invalid input shape '{}' in Reshape layer '{}' {}. "
- "The parser only supports shape (batch, -1) or (-1) for "
- "non-constant shape input.",
- shapes[0],
- layerName,
- CHECK_LOCATION().AsString()));
- }
-
- const int32_t numInputElements = inputTensorInfo.GetNumElements();
- const int32_t inputTensorShape = inputTensorInfo.GetShape()[0];
- if (shapes[0] == 1)
- {
- targetShape = { numInputElements };
- }
- else if (shapes[0] == 2)
- {
- targetShape = { inputTensorShape , numInputElements / inputTensorShape };
- }
+ targetShape.push_back(values[i]);
}
}
else