From b98a07bd382203e76b0e5c67108bfdad023d35c8 Mon Sep 17 00:00:00 2001 From: Tao Li Date: Sat, 11 Jan 2020 14:02:40 +0800 Subject: [PATCH 1/3] Fix #17267, add expected and got datatype when non-uniform dtype fount in concat --- src/operator/nn/concat.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/operator/nn/concat.cc b/src/operator/nn/concat.cc index 1eeef7db5cb5..663bbe1e933e 100644 --- a/src/operator/nn/concat.cc +++ b/src/operator/nn/concat.cc @@ -149,9 +149,10 @@ bool ConcatType(const nnvm::NodeAttrs& attrs, if (dtype == -1) { dtype = i; } else { - CHECK(i == dtype || - i == -1) << - "Non-uniform data type in Concat"; + CHECK( i == dtype || i == -1) + << "Non-uniform data type in Concat: " + << "expected data type " << mxnet::op::type_string(dtype) + << ", got data type " << mxnet::op::type_string(i); } } From 0e2c9cd50c6bc2d9a5cc27d684ad761ee4047277 Mon Sep 17 00:00:00 2001 From: Tao Li Date: Sun, 12 Jan 2020 20:12:23 +0800 Subject: [PATCH 2/3] Add op name and input index to concat type error msg --- src/operator/nn/concat.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/operator/nn/concat.cc b/src/operator/nn/concat.cc index 663bbe1e933e..03c590ea1f2e 100644 --- a/src/operator/nn/concat.cc +++ b/src/operator/nn/concat.cc @@ -145,14 +145,15 @@ bool ConcatType(const nnvm::NodeAttrs& attrs, int dtype = -1; // checks uniformity of input - for (int i : *in_type) { + for (size_t i =0; isize(); ++i) { if (dtype == -1) { - dtype = i; + dtype = in_type->at(i); } else { - CHECK( i == dtype || i == -1) - << "Non-uniform data type in Concat: " - << "expected data type " << mxnet::op::type_string(dtype) - << ", got data type " << mxnet::op::type_string(i); + CHECK( in_type->at(i) == dtype || in_type->at(i) == -1) + << "Non-uniform data type in " << attrs.op->name + << ", expected data type " << mxnet::op::type_string(dtype) + << ", got data type " << mxnet::op::type_string(in_type->at(i)) + << " for input " << i; } } From c835c36af6f43c245674362c6ccb2f51ab52e67d Mon Sep 17 00:00:00 2001 From: Tao Li Date: Mon, 13 Jan 2020 20:00:55 +0800 Subject: [PATCH 3/3] Fix lint error --- src/operator/nn/concat.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/operator/nn/concat.cc b/src/operator/nn/concat.cc index 03c590ea1f2e..a9e744cc58d1 100644 --- a/src/operator/nn/concat.cc +++ b/src/operator/nn/concat.cc @@ -145,13 +145,13 @@ bool ConcatType(const nnvm::NodeAttrs& attrs, int dtype = -1; // checks uniformity of input - for (size_t i =0; isize(); ++i) { + for (size_t i =0; i < in_type->size(); ++i) { if (dtype == -1) { dtype = in_type->at(i); } else { - CHECK( in_type->at(i) == dtype || in_type->at(i) == -1) + CHECK(in_type->at(i) == dtype || in_type->at(i) == -1) << "Non-uniform data type in " << attrs.op->name - << ", expected data type " << mxnet::op::type_string(dtype) + << ", expected data type " << mxnet::op::type_string(dtype) << ", got data type " << mxnet::op::type_string(in_type->at(i)) << " for input " << i; }