return androidSdkVersion;
}
+static const uint32_t dimension_for_scalar[1] = {1};
+
} // namespace
NNAPIAllocation::NNAPIAllocation(const char* filename,
// WORKAROUND Some model have dimension zero
switch (tensor->type) {
case kTfLiteFloat32:
- nn_type = ANEURALNETWORKS_FLOAT32;
+ nn_type = ANEURALNETWORKS_TENSOR_FLOAT32;
break;
case kTfLiteInt32:
- nn_type = ANEURALNETWORKS_INT32;
+ nn_type = ANEURALNETWORKS_TENSOR_INT32;
break;
default:
logError("NNAPI doesn't support tensors with rank 0 (index %d name %s)",
ANeuralNetworksOperandType operand_type{
nn_type, static_cast<uint32_t>(tensor->dims->size),
reinterpret_cast<uint32_t*>(tensor->dims->data), scale, zeroPoint};
+ if (tensor->dims->size == 0) {
+ // WORKAROUND Some model have dimension zero
+ // Consider scalar as vector size 1
+ operand_type.dimensions = dimension_for_scalar;
+ operand_type.dimensionCount = 1;
+ }
RETURN_ERROR_IF_NN_FAILED(
ANeuralNetworksModel_addOperand(nn_model, &operand_type));
// TODO(aselle): Based on Michael's suggestion, limiting this to read