From 37e7dea39a45d35f712aa16780a68329e74d1082 Mon Sep 17 00:00:00 2001 From: masahi Date: Fri, 24 Jan 2020 12:08:19 +0900 Subject: [PATCH] add missing nullptr check --- src/relay/qnn/op/add.cc | 1 + src/relay/qnn/op/dequantize.cc | 1 + src/relay/qnn/op/mul.cc | 1 + src/relay/qnn/op/quantize.cc | 1 + src/relay/qnn/op/requantize.cc | 1 + 5 files changed, 5 insertions(+) diff --git a/src/relay/qnn/op/add.cc b/src/relay/qnn/op/add.cc index e970e2b44fa9..67ca10d8e110 100644 --- a/src/relay/qnn/op/add.cc +++ b/src/relay/qnn/op/add.cc @@ -55,6 +55,7 @@ Expr QnnAddCanonicalize(const Attrs& attrs, const Array& new_args, // Get the input dtype and shape. CHECK_EQ(arg_types.size(), 9); auto tensor_type = arg_types[0].as(); + CHECK(tensor_type != nullptr); auto input_dtype = tensor_type->dtype; auto input_shape = tensor_type->shape; diff --git a/src/relay/qnn/op/dequantize.cc b/src/relay/qnn/op/dequantize.cc index ee6799799011..6233246d7bae 100644 --- a/src/relay/qnn/op/dequantize.cc +++ b/src/relay/qnn/op/dequantize.cc @@ -39,6 +39,7 @@ bool DequantizeRel(const Array& types, const TypeReporter& reporter) { CHECK_EQ(types.size(), 4); const auto* data = types[0].as(); + CHECK(data != nullptr); const auto input_dtype = data->dtype; CHECK(input_dtype == DataType::Int(8) || input_dtype == DataType::UInt(8) || diff --git a/src/relay/qnn/op/mul.cc b/src/relay/qnn/op/mul.cc index c8ea3fc025eb..89193ed4556d 100644 --- a/src/relay/qnn/op/mul.cc +++ b/src/relay/qnn/op/mul.cc @@ -55,6 +55,7 @@ Expr QnnMulCanonicalize(const Attrs& attrs, const Array& new_args, // Get the input dtype and shape. CHECK_EQ(arg_types.size(), 9); auto tensor_type = arg_types[0].as(); + CHECK(tensor_type != nullptr); auto input_dtype = tensor_type->dtype; auto input_shape = tensor_type->shape; diff --git a/src/relay/qnn/op/quantize.cc b/src/relay/qnn/op/quantize.cc index e2472c6c5453..66c40a27c437 100644 --- a/src/relay/qnn/op/quantize.cc +++ b/src/relay/qnn/op/quantize.cc @@ -41,6 +41,7 @@ bool QuantizeRel(const Array& types, const TypeReporter& reporter) { CHECK_EQ(types.size(), 4); const auto* data = types[0].as(); + 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; diff --git a/src/relay/qnn/op/requantize.cc b/src/relay/qnn/op/requantize.cc index cf5b31377784..29c8e3e915cf 100644 --- a/src/relay/qnn/op/requantize.cc +++ b/src/relay/qnn/op/requantize.cc @@ -169,6 +169,7 @@ bool RequantizeRel(const Array& types, int num_inputs, const Attrs& attrs, const TypeReporter& reporter) { CHECK_EQ(types.size(), 6); const auto* data = types[0].as(); + CHECK(data != nullptr); const auto in_dtype = data->dtype; CHECK(in_dtype == DataType::Int(8) || in_dtype == DataType::UInt(8) ||