This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/master by this push:
new 7e671cb [BUG_FIX] Fixes #6608: CHECK(data != nullptr) causes type
checking to fail (#6610)
7e671cb is described below
commit 7e671cbf7289fa7f93baf1573f714450ded8fb5c
Author: Lily Orth-Smith <[email protected]>
AuthorDate: Fri Oct 2 06:36:06 2020 -0700
[BUG_FIX] Fixes #6608: CHECK(data != nullptr) causes type checking to fail
(#6610)
---
src/relay/op/tensor/transform.cc | 22 ++++++++++++++++++----
src/relay/op/tensor/unary.cc | 6 +++++-
src/relay/op/vision/multibox_op.cc | 5 ++++-
src/relay/qnn/op/dequantize.cc | 6 +++++-
src/relay/qnn/op/quantize.cc | 6 +++++-
src/relay/qnn/op/requantize.cc | 6 +++++-
src/relay/quantize/quantize.cc | 6 +++++-
7 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/src/relay/op/tensor/transform.cc b/src/relay/op/tensor/transform.cc
index 4faface..8d2d391 100644
--- a/src/relay/op/tensor/transform.cc
+++ b/src/relay/op/tensor/transform.cc
@@ -797,7 +797,11 @@ bool ArgWhereRel(const Array<Type>& types, int num_inputs,
const Attrs& attrs,
const TypeReporter& reporter) {
CHECK_EQ(num_inputs, 1);
auto tt = types[0].as<TensorTypeNode>();
- CHECK(tt != nullptr);
+
+ if (tt == nullptr) {
+ return false;
+ }
+
const auto& input_shape = tt->shape;
const auto& input_rank = input_shape.size();
std::vector<IndexExpr> result_shape;
@@ -1676,7 +1680,10 @@ bool WhereRel(const Array<Type>& types, int num_inputs,
const Attrs& attrs,
const auto* condition = types[0].as<TensorTypeNode>();
const auto* x = types[1].as<TensorTypeNode>();
const auto* y = types[2].as<TensorTypeNode>();
- CHECK(condition != nullptr && x != nullptr && y != nullptr);
+
+ if (condition == nullptr || x == nullptr || y == nullptr) {
+ return false;
+ }
const auto& cond_shape = condition->shape;
const auto& x_shape = x->shape;
@@ -2023,7 +2030,11 @@ bool StridedSliceRel(const Array<Type>& types, int
num_inputs, const Attrs& attr
const StridedSliceAttrs* param = attrs.as<StridedSliceAttrs>();
CHECK(param != nullptr);
const auto* data = types[0].as<TensorTypeNode>();
- CHECK(data != nullptr);
+
+ if (data == nullptr) {
+ return false;
+ }
+
auto dshape = data->shape;
int64_t num_axis = dshape.size();
@@ -3054,7 +3065,10 @@ bool SparseToDenseRel(const Array<Type>& types, int
num_inputs, const Attrs& att
auto sparse_indices = types[0].as<TensorTypeNode>();
auto sparse_values = types[1].as<TensorTypeNode>();
auto default_value = types[2].as<TensorTypeNode>();
- CHECK(sparse_indices != nullptr && sparse_values != nullptr && default_value
!= nullptr);
+
+ if (sparse_indices == nullptr || sparse_values == nullptr || default_value
== nullptr) {
+ return false;
+ }
CHECK(sparse_indices->dtype.is_int()) << "sparse_indices must be tensor of
integers";
diff --git a/src/relay/op/tensor/unary.cc b/src/relay/op/tensor/unary.cc
index ba8833e..59ef47f 100644
--- a/src/relay/op/tensor/unary.cc
+++ b/src/relay/op/tensor/unary.cc
@@ -458,7 +458,11 @@ bool NdarraySizeRel(const Array<Type>& types, int
num_inputs, const Attrs& attrs
const TypeReporter& reporter) {
CHECK_EQ(num_inputs, 1);
auto tt = types[0].as<TensorTypeNode>();
- CHECK(tt != nullptr);
+
+ if (tt == nullptr) {
+ return false;
+ }
+
const auto* param = attrs.as<NdarraySizeAttrs>();
CHECK(param != nullptr);
reporter->Assign(types[1], TensorType({}, param->dtype));
diff --git a/src/relay/op/vision/multibox_op.cc
b/src/relay/op/vision/multibox_op.cc
index 18a2edb..b766fac 100644
--- a/src/relay/op/vision/multibox_op.cc
+++ b/src/relay/op/vision/multibox_op.cc
@@ -83,7 +83,10 @@ bool MultiBoxTransformLocRel(const Array<Type>& types, int
num_inputs, const Att
const auto* cls_prob = types[0].as<TensorTypeNode>();
const auto* loc_pred = types[1].as<TensorTypeNode>();
const auto* anchor = types[2].as<TensorTypeNode>();
- CHECK(cls_prob != nullptr && loc_pred != nullptr && anchor != nullptr);
+
+ if (cls_prob == nullptr || loc_pred == nullptr || anchor == nullptr) {
+ return false;
+ }
const auto& cls_shape = cls_prob->shape;
const auto& loc_shape = loc_pred->shape;
diff --git a/src/relay/qnn/op/dequantize.cc b/src/relay/qnn/op/dequantize.cc
index da804da..3a5f81e 100644
--- a/src/relay/qnn/op/dequantize.cc
+++ b/src/relay/qnn/op/dequantize.cc
@@ -40,7 +40,11 @@ bool DequantizeRel(const Array<Type>& types, int num_inputs,
const Attrs& attrs,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 4);
const auto* data = types[0].as<TensorTypeNode>();
- CHECK(data != nullptr);
+
+ if (data == nullptr) {
+ return false;
+ }
+
const auto input_dtype = data->dtype;
CHECK(input_dtype == DataType::Int(8) || input_dtype == DataType::UInt(8) ||
input_dtype == DataType::Int(32))
diff --git a/src/relay/qnn/op/quantize.cc b/src/relay/qnn/op/quantize.cc
index 28f0b89..fb7ef97 100644
--- a/src/relay/qnn/op/quantize.cc
+++ b/src/relay/qnn/op/quantize.cc
@@ -40,7 +40,11 @@ bool QuantizeRel(const Array<Type>& types, int num_inputs,
const Attrs& attrs,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 4);
const auto* data = types[0].as<TensorTypeNode>();
- CHECK(data != nullptr);
+
+ if (data == nullptr) {
+ return false;
+ }
+
const auto input_dtype = data->dtype;
CHECK(input_dtype == DataType::Float(32))
<< "Input type should be one of float32 but was " << input_dtype;
diff --git a/src/relay/qnn/op/requantize.cc b/src/relay/qnn/op/requantize.cc
index 222d910..817a734 100644
--- a/src/relay/qnn/op/requantize.cc
+++ b/src/relay/qnn/op/requantize.cc
@@ -258,7 +258,11 @@ bool RequantizeRel(const Array<Type>& types, int
num_inputs, const Attrs& attrs,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 6);
const auto* data = types[0].as<TensorTypeNode>();
- CHECK(data != nullptr);
+
+ if (data == nullptr) {
+ return false;
+ }
+
const auto in_dtype = data->dtype;
CHECK(in_dtype == DataType::Int(8) || in_dtype == DataType::UInt(8) ||
in_dtype == DataType::Int(32))
diff --git a/src/relay/quantize/quantize.cc b/src/relay/quantize/quantize.cc
index 28fc68e..64a02ff 100644
--- a/src/relay/quantize/quantize.cc
+++ b/src/relay/quantize/quantize.cc
@@ -44,7 +44,11 @@ bool SimulatedQuantizeRel(const Array<Type>& types, int
num_inputs, const Attrs&
CHECK(param != nullptr);
const auto* data = types[0].as<TensorTypeNode>();
- CHECK(data != nullptr);
+
+ if (data == nullptr) {
+ return false;
+ }
+
CHECK_NE(data->shape.size(), 0) << "Input shape cannot be empty";
reporter->Assign(types[1], TensorType({}, DataType::Float(32))); //
dom_scale