From 58940a5f8b85a23e5724e46a7ee881f4bb34bb37 Mon Sep 17 00:00:00 2001 From: Cathy Wong Date: Tue, 13 Jul 2021 12:27:52 -0400 Subject: [PATCH] MD CI pclint warning fixes --- .../engine/ir/datasetops/source/bindings.cc | 2 +- .../bindings/dataset/kernels/ir/bindings.cc | 28 ++++++++++--------- .../dataset/text/kernels/ir/bindings.cc | 2 +- mindspore/ccsrc/minddata/dataset/api/text.cc | 7 ++--- .../ccsrc/minddata/dataset/api/transforms.cc | 17 +++++------ .../dataset/include/dataset/transforms.h | 8 +++--- .../dataset/kernels/ir/data/transforms_ir.cc | 6 ++-- .../dataset/kernels/ir/data/transforms_ir.h | 6 ++-- .../dataset/text/ir/kernels/text_ir.cc | 6 ++-- .../dataset/text/ir/kernels/text_ir.h | 6 ++-- 10 files changed, 45 insertions(+), 43 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/engine/ir/datasetops/source/bindings.cc b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/engine/ir/datasetops/source/bindings.cc index fc38dc16537..f51ea19b50d 100644 --- a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/engine/ir/datasetops/source/bindings.cc +++ b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/engine/ir/datasetops/source/bindings.cc @@ -250,7 +250,7 @@ PYBIND_REGISTER(TFRecordNode, 2, ([](const py::module *m) { THROW_IF_ERROR(tfrecord->ValidateParams()); return tfrecord; })) - .def(py::init([](const py::list dataset_files, std::string schema, py::list columns_list, + .def(py::init([](const py::list dataset_files, std::string schema, const py::list columns_list, int64_t num_samples, int32_t shuffle, int32_t num_shards, int32_t shard_id, bool shard_equal_rows) { std::shared_ptr tfrecord = std::make_shared( diff --git a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/kernels/ir/bindings.cc b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/kernels/ir/bindings.cc index f9a5be8d370..3db2e30a5c3 100644 --- a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/kernels/ir/bindings.cc +++ b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/kernels/ir/bindings.cc @@ -76,15 +76,17 @@ PYBIND_REGISTER( })); })); -PYBIND_REGISTER(ConcatenateOperation, 1, ([](const py::module *m) { - (void)py::class_>(*m, "ConcatenateOperation") - .def(py::init([](int8_t axis, std::shared_ptr prepend, std::shared_ptr append) { - auto concatenate = std::make_shared(axis, prepend, append); - THROW_IF_ERROR(concatenate->ValidateParams()); - return concatenate; - })); - })); +PYBIND_REGISTER( + ConcatenateOperation, 1, ([](const py::module *m) { + (void) + py::class_>( + *m, "ConcatenateOperation") + .def(py::init([](int8_t axis, const std::shared_ptr &prepend, const std::shared_ptr &append) { + auto concatenate = std::make_shared(axis, prepend, append); + THROW_IF_ERROR(concatenate->ValidateParams()); + return concatenate; + })); + })); PYBIND_REGISTER( DuplicateOperation, 1, ([](const py::module *m) { @@ -101,7 +103,7 @@ PYBIND_REGISTER(FillOperation, 1, ([](const py::module *m) { (void) py::class_>( *m, "FillOperation") - .def(py::init([](std::shared_ptr fill_value) { + .def(py::init([](const std::shared_ptr &fill_value) { auto fill = std::make_shared(fill_value); THROW_IF_ERROR(fill->ValidateParams()); return fill; @@ -112,7 +114,7 @@ PYBIND_REGISTER(MaskOperation, 1, ([](const py::module *m) { (void) py::class_>( *m, "MaskOperation") - .def(py::init([](RelationalOp op, std::shared_ptr constant, DataType dtype) { + .def(py::init([](RelationalOp op, const std::shared_ptr &constant, DataType dtype) { auto mask = std::make_shared(op, constant, dtype); THROW_IF_ERROR(mask->ValidateParams()); return mask; @@ -134,7 +136,7 @@ PYBIND_REGISTER( PadEndOperation, 1, ([](const py::module *m) { (void)py::class_>( *m, "PadEndOperation") - .def(py::init([](TensorShape pad_shape, std::shared_ptr pad_value) { + .def(py::init([](TensorShape pad_shape, const std::shared_ptr &pad_value) { auto pad_end = std::make_shared(pad_shape, pad_value); THROW_IF_ERROR(pad_end->ValidateParams()); return pad_end; @@ -213,7 +215,7 @@ PYBIND_REGISTER( TypeCastOperation, 1, ([](const py::module *m) { (void)py::class_>( *m, "TypeCastOperation") - .def(py::init([](std::string data_type) { + .def(py::init([](const std::string &data_type) { auto type_cast = std::make_shared(data_type); THROW_IF_ERROR(type_cast->ValidateParams()); return type_cast; diff --git a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/text/kernels/ir/bindings.cc b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/text/kernels/ir/bindings.cc index b5adc3b1072..e71073d6aba 100644 --- a/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/text/kernels/ir/bindings.cc +++ b/mindspore/ccsrc/minddata/dataset/api/python/bindings/dataset/text/kernels/ir/bindings.cc @@ -201,7 +201,7 @@ PYBIND_REGISTER( PYBIND_REGISTER(ToNumberOperation, 1, ([](const py::module *m) { (void)py::class_>( *m, "ToNumberOperation") - .def(py::init([](std::string data_type) { + .def(py::init([](const std::string &data_type) { auto to_number = std::make_shared(data_type); THROW_IF_ERROR(to_number->ValidateParams()); return to_number; diff --git a/mindspore/ccsrc/minddata/dataset/api/text.cc b/mindspore/ccsrc/minddata/dataset/api/text.cc index 91c438dd7ef..70e93251f6c 100644 --- a/mindspore/ccsrc/minddata/dataset/api/text.cc +++ b/mindspore/ccsrc/minddata/dataset/api/text.cc @@ -152,7 +152,7 @@ Status JiebaTokenizer::AddWordChar(const std::vector &word, int64_t freq) MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } - data_->words_list_.emplace_back(CharToString(word), freq); + (void)data_->words_list_.emplace_back(CharToString(word), freq); return Status::OK(); } @@ -192,12 +192,11 @@ Status JiebaTokenizer::ParserFile(const std::string &file_path, } std::regex regex("^\\s*([^\\s*]+?)\\s*([0-9]+)?\\s*$"); std::smatch tokens; - std::regex_match(line, tokens, regex); if (std::regex_match(line, tokens, regex)) { if (tokens.size() == size_two) { - user_dict->emplace_back(tokens.str(value_one), 0); + (void)user_dict->emplace_back(tokens.str(value_one), 0); } else if (tokens.size() == size_three) { - user_dict->emplace_back(tokens.str(value_one), strtoll(tokens.str(value_two).c_str(), NULL, 0)); + (void)user_dict->emplace_back(tokens.str(value_one), strtoll(tokens.str(value_two).c_str(), NULL, 0)); } else { continue; } diff --git a/mindspore/ccsrc/minddata/dataset/api/transforms.cc b/mindspore/ccsrc/minddata/dataset/api/transforms.cc index 2b01a08de88..91cb1ab47c5 100644 --- a/mindspore/ccsrc/minddata/dataset/api/transforms.cc +++ b/mindspore/ccsrc/minddata/dataset/api/transforms.cc @@ -62,13 +62,14 @@ std::shared_ptr Compose::Parse() { return std::make_shared(axis, prepend, append)) {} std::shared_ptr Concatenate::Parse() { @@ -95,11 +96,11 @@ std::shared_ptr Duplicate::Parse() { return std::make_shared(fill_value)) {} +Fill::Fill(const MSTensor &fill_value) : data_(std::make_shared(fill_value)) {} std::shared_ptr Fill::Parse() { std::shared_ptr out_fill_value; @@ -113,14 +114,14 @@ std::shared_ptr Fill::Parse() { // Constructor to Mask struct Mask::Data { - explicit Data(RelationalOp op, MSTensor constant, mindspore::DataType ms_type) + explicit Data(RelationalOp op, const MSTensor &constant, mindspore::DataType ms_type) : op_(op), constant_(constant), ms_type_(ms_type) {} RelationalOp op_; MSTensor constant_; mindspore::DataType ms_type_; }; -Mask::Mask(RelationalOp op, MSTensor constant, mindspore::DataType ms_type) +Mask::Mask(RelationalOp op, const MSTensor &constant, mindspore::DataType ms_type) : data_(std::make_shared(op, constant, ms_type)) {} std::shared_ptr Mask::Parse() { @@ -149,13 +150,13 @@ std::shared_ptr OneHot::Parse() { return std::make_shared &pad_shape, MSTensor pad_value) + explicit Data(const std::vector &pad_shape, const MSTensor &pad_value) : pad_shape_(pad_shape), pad_value_(pad_value) {} std::vector pad_shape_; MSTensor pad_value_; }; -PadEnd::PadEnd(const std::vector &pad_shape, MSTensor pad_value) +PadEnd::PadEnd(const std::vector &pad_shape, const MSTensor &pad_value) : data_(std::make_shared(pad_shape, pad_value)) {} std::shared_ptr PadEnd::Parse() { diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h b/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h index 7dbce809553..df59cba96b2 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h @@ -160,7 +160,7 @@ class Concatenate final : public TensorTransform { /// \param[in] axis Concatenate the tensors along given axis, only support 0 or -1 so far (default=0). /// \param[in] prepend MSTensor to be prepended to the concatenated tensors (default={}). /// \param[in] append MSTensor to be appended to the concatenated tensors (default={}). - explicit Concatenate(int8_t axis = 0, MSTensor prepend = {}, MSTensor append = {}); + explicit Concatenate(int8_t axis = 0, const MSTensor &prepend = {}, const MSTensor &append = {}); /// \brief Destructor ~Concatenate() = default; @@ -199,7 +199,7 @@ class Fill final : public TensorTransform { /// \param[in] fill_value Scalar value to fill the tensor with. /// It can only be MSTensor of the following types from mindspore::DataType: /// String, Bool, Int8/16/32/64, UInt8/16/32/64, Float16/32/64. - explicit Fill(MSTensor fill_value); + explicit Fill(const MSTensor &fill_value); /// \brief Destructor ~Fill() = default; @@ -224,7 +224,7 @@ class Mask final : public TensorTransform { /// from mindspore::DataType: String, Int, Float, Bool. /// \param[in] de_type Type of the generated mask. It can only be numeric or boolean datatype. /// (default=mindspore::DataType::kNumberTypeBool) - explicit Mask(RelationalOp op, MSTensor constant, + explicit Mask(RelationalOp op, const MSTensor &constant, mindspore::DataType ms_type = mindspore::DataType(mindspore::DataType::kNumberTypeBool)); /// \brief Destructor @@ -268,7 +268,7 @@ class PadEnd final : public TensorTransform { /// Dimensions that set to `-1` will not be padded (i.e., original dim will be used). /// Shorter dimensions will truncate the values. /// \param[in] pad_value Value used to pad (default={}). - explicit PadEnd(const std::vector &pad_shape, MSTensor pad_value = {}); + explicit PadEnd(const std::vector &pad_shape, const MSTensor &pad_value = {}); /// \brief Destructor ~PadEnd() = default; diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc index f7c0bd05b73..26542868c9a 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc @@ -116,7 +116,7 @@ std::shared_ptr DuplicateOperation::Build() { return std::make_shared< #ifndef ENABLE_ANDROID // FillOperation -FillOperation::FillOperation(std::shared_ptr fill_value) : fill_value_(fill_value) {} +FillOperation::FillOperation(const std::shared_ptr &fill_value) : fill_value_(fill_value) {} Status FillOperation::ValidateParams() { if (fill_value_->shape() != TensorShape::CreateScalar()) { @@ -246,10 +246,10 @@ std::shared_ptr SliceOperation::Build() { return std::make_shared fill_value); + explicit FillOperation(const std::shared_ptr &fill_value); ~FillOperation() = default; @@ -235,8 +235,8 @@ class SliceOperation : public TensorOperation { class TypeCastOperation : public TensorOperation { public: - explicit TypeCastOperation(DataType data_type); // Used for C++ API - explicit TypeCastOperation(std::string data_type); // Used for Pybind + explicit TypeCastOperation(const DataType &data_type); // Used for C++ API + explicit TypeCastOperation(const std::string &data_type); // Used for Pybind ~TypeCastOperation() = default; diff --git a/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.cc b/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.cc index a126cc3a413..64c7dacb188 100644 --- a/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.cc @@ -169,7 +169,7 @@ Status JiebaTokenizerOperation::AddWord(const std::string &word, int64_t freq) { // LookupOperation // DataType data_type - required for C++ API LookupOperation::LookupOperation(const std::shared_ptr &vocab, const std::optional &unknown_token, - DataType data_type) + const DataType &data_type) : vocab_(vocab), unknown_token_(unknown_token), default_id_(Vocab::kNoTokenExists), data_type_(data_type) {} // std::string data_type - required for Pybind @@ -364,10 +364,10 @@ std::shared_ptr SlidingWindowOperation::Build() { // ToNumberOperation // DataType data_type - required for C++ API -ToNumberOperation::ToNumberOperation(DataType data_type) : data_type_(data_type) {} +ToNumberOperation::ToNumberOperation(const DataType &data_type) : data_type_(data_type) {} // std::string data_type - required for Pybind -ToNumberOperation::ToNumberOperation(std::string data_type) { +ToNumberOperation::ToNumberOperation(const std::string &data_type) { // Convert from string to DEType DataType temp_data_type(data_type); data_type_ = temp_data_type; diff --git a/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.h b/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.h index 662cff69db2..8b2cee15618 100644 --- a/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.h +++ b/mindspore/ccsrc/minddata/dataset/text/ir/kernels/text_ir.h @@ -142,7 +142,7 @@ class JiebaTokenizerOperation : public TensorOperation { class LookupOperation : public TensorOperation { public: explicit LookupOperation(const std::shared_ptr &vocab, const std::optional &unknown_token, - DataType data_type); // Used for C++ API + const DataType &data_type); // Used for C++ API explicit LookupOperation(const std::shared_ptr &vocab, const std::optional &unknown_token, const std::string &data_type); // Used for Pybind @@ -275,8 +275,8 @@ class SlidingWindowOperation : public TensorOperation { class ToNumberOperation : public TensorOperation { public: - explicit ToNumberOperation(DataType data_type); // Used for C++ API - explicit ToNumberOperation(std::string data_type); // Used for Pybind + explicit ToNumberOperation(const DataType &data_type); // Used for C++ API + explicit ToNumberOperation(const std::string &data_type); // Used for Pybind ~ToNumberOperation() = default;