Skip to content

Commit

Permalink
add missing nullptr check (apache#4773)
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi authored and alexwong committed Feb 28, 2020
1 parent 46cda65 commit 89e214a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/relay/qnn/op/add.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Expr QnnAddCanonicalize(const Attrs& attrs, const Array<Expr>& new_args,
// Get the input dtype and shape.
CHECK_EQ(arg_types.size(), 9);
auto tensor_type = arg_types[0].as<TensorTypeNode>();
CHECK(tensor_type != nullptr);
auto input_dtype = tensor_type->dtype;
auto input_shape = tensor_type->shape;

Expand Down
1 change: 1 addition & 0 deletions src/relay/qnn/op/dequantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bool DequantizeRel(const Array<Type>& types,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 4);
const auto* data = types[0].as<TensorTypeNode>();
CHECK(data != nullptr);
const auto input_dtype = data->dtype;
CHECK(input_dtype == DataType::Int(8) ||
input_dtype == DataType::UInt(8) ||
Expand Down
1 change: 1 addition & 0 deletions src/relay/qnn/op/mul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Expr QnnMulCanonicalize(const Attrs& attrs, const Array<Expr>& new_args,
// Get the input dtype and shape.
CHECK_EQ(arg_types.size(), 9);
auto tensor_type = arg_types[0].as<TensorTypeNode>();
CHECK(tensor_type != nullptr);
auto input_dtype = tensor_type->dtype;
auto input_shape = tensor_type->shape;

Expand Down
1 change: 1 addition & 0 deletions src/relay/qnn/op/quantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool QuantizeRel(const Array<Type>& types,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 4);
const auto* data = types[0].as<TensorTypeNode>();
CHECK(data != nullptr);
const auto input_dtype = data->dtype;
CHECK(input_dtype == DataType::Float(32))
<< "Input type should be one of float32 but was " << input_dtype;
Expand Down
1 change: 1 addition & 0 deletions src/relay/qnn/op/requantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ 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);
const auto in_dtype = data->dtype;
CHECK(in_dtype == DataType::Int(8) ||
in_dtype == DataType::UInt(8) ||
Expand Down

0 comments on commit 89e214a

Please sign in to comment.