You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by lu...@apache.org on 2022/05/09 10:50:54 UTC
[tvm] branch main updated: [ETHOSN] Minor corner case fixes (#11218)
This is an automated email from the ASF dual-hosted git repository.
lukhut pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 5ecb8c384a [ETHOSN] Minor corner case fixes (#11218)
5ecb8c384a is described below
commit 5ecb8c384a66933fec8c7f033cba03337eb1a726
Author: Leo-arm <Le...@arm.com>
AuthorDate: Mon May 9 11:50:49 2022 +0100
[ETHOSN] Minor corner case fixes (#11218)
Minor issues in corner cases from static analysis and a code standard
violation fix.
---
src/relay/backend/contrib/ethosn/codegen.cc | 2 +-
src/relay/backend/contrib/ethosn/ethosn_api.cc | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/relay/backend/contrib/ethosn/codegen.cc b/src/relay/backend/contrib/ethosn/codegen.cc
index 37f66cb51c..674793e1bd 100644
--- a/src/relay/backend/contrib/ethosn/codegen.cc
+++ b/src/relay/backend/contrib/ethosn/codegen.cc
@@ -205,7 +205,7 @@ sl::TensorsAndId MakeOps(const sl::TensorAndId<sl::Operand>& op) {
return ops;
}
-String MakeVariant(auto configuration) {
+String MakeVariant(Optional<EthosnCompilerConfig> configuration) {
String variant = configuration.value()->variant;
// Transform variant string to lowercase for comparison
std::string variant_string = variant.c_str();
diff --git a/src/relay/backend/contrib/ethosn/ethosn_api.cc b/src/relay/backend/contrib/ethosn/ethosn_api.cc
index 14fda4651f..7a9cb37847 100644
--- a/src/relay/backend/contrib/ethosn/ethosn_api.cc
+++ b/src/relay/backend/contrib/ethosn/ethosn_api.cc
@@ -395,6 +395,7 @@ EthosnError EthosnAPI::Sigmoid(const Expr& expr, SigmoidParams* params) {
sl::QuantizationInfo(input_zp, input_sc));
return err;
}
+
EthosnError EthosnAPI::Mean(const Expr& expr, MeanParams* params) {
Call requantize = Downcast<Call>(expr);
Call mean = Downcast<Call>(requantize->args[0]);
@@ -598,8 +599,8 @@ EthosnError EthosnAPI::Tvm2Npu(const Array<IndexExpr>& size, uint32_t* x, uint32
}
EthosnError EthosnAPI::Tvm2Npu(const std::string& dformat, sl::DataFormat* data_format) {
+ *data_format = sl::DataFormat::NCHW;
if (dformat == "NCHW") {
- *data_format = sl::DataFormat::NCHW;
return EthosnError();
} else if (dformat == "NHWC") {
*data_format = sl::DataFormat::NHWC;
@@ -624,12 +625,12 @@ EthosnError EthosnAPI::Tvm2Npu(const Array<IndexExpr>& shape, sl::TensorShape* n
}
EthosnError EthosnAPI::Tvm2Npu(const tvm::DataType& dtype, sl::DataType* data_type) {
+ *data_type = sl::DataType::INT8_QUANTIZED;
if (dtype.is_scalar() == 1) {
if (dtype.is_uint() && dtype.bits() == 8) {
*data_type = sl::DataType::UINT8_QUANTIZED;
return EthosnError();
} else if (dtype.is_int() && dtype.bits() == 8) {
- *data_type = sl::DataType::INT8_QUANTIZED;
return EthosnError();
} else if (dtype.is_int() && dtype.bits() == 32) {
*data_type = sl::DataType::INT32_QUANTIZED;
@@ -723,6 +724,7 @@ EthosnError EthosnAPI::AsConstant(const Expr& expr, std::valarray<float>* out) {
// Get a T from a constant represented by a NDArray.
template <typename T>
EthosnError EthosnAPI::AsConstant(const Expr& expr, T* out) {
+ *out = {0};
if (!expr->IsInstance<ConstantNode>()) {
return EthosnError("expected constant data");
}