From 7587db9eaae88ea0fa3fb85f936f6ed0bd71a5b0 Mon Sep 17 00:00:00 2001 From: luoyang Date: Fri, 18 Dec 2020 17:34:29 +0800 Subject: [PATCH] fix to_number --- mindspore/ccsrc/minddata/dataset/api/text.cc | 5 ++--- .../ccsrc/minddata/dataset/text/kernels/to_number_op.cc | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/api/text.cc b/mindspore/ccsrc/minddata/dataset/api/text.cc index 2e3abe4e48..60185bb22c 100644 --- a/mindspore/ccsrc/minddata/dataset/api/text.cc +++ b/mindspore/ccsrc/minddata/dataset/api/text.cc @@ -485,9 +485,8 @@ std::shared_ptr SlidingWindowOperation::Build() { ToNumberOperation::ToNumberOperation(DataType data_type) : data_type_(data_type) {} Status ToNumberOperation::ValidateParams() { - if (!data_type_.IsNumeric()) { - std::string err_msg = - "ToNumber : The parameter data_type must be a numeric type: " + std::to_string(data_type_.value()); + if (!data_type_.IsNumeric() || data_type_.IsBool()) { + std::string err_msg = "ToNumber : The parameter data_type must be a numeric type, got: " + data_type_.ToString(); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } diff --git a/mindspore/ccsrc/minddata/dataset/text/kernels/to_number_op.cc b/mindspore/ccsrc/minddata/dataset/text/kernels/to_number_op.cc index 3fda769ea2..52c224136d 100644 --- a/mindspore/ccsrc/minddata/dataset/text/kernels/to_number_op.cc +++ b/mindspore/ccsrc/minddata/dataset/text/kernels/to_number_op.cc @@ -73,6 +73,8 @@ Status ToNumberOp::Compute(const std::shared_ptr &input, std::shared_ptr case DataType::DE_FLOAT64: RETURN_IF_NOT_OK(ToDouble(input, output)); break; + default: + RETURN_STATUS_UNEXPECTED("Unsupported cast type: " + cast_to_type_.ToString()); } return Status::OK();