From 026cdcd6fc09bbaaac730c0d1f6fd95efe2ac45f Mon Sep 17 00:00:00 2001 From: xulei2020 Date: Thu, 7 Jan 2021 20:22:31 +0800 Subject: [PATCH] fix build for md pipeline --- mindspore/ccsrc/minddata/dataset/api/samplers.cc | 2 ++ mindspore/ccsrc/minddata/dataset/api/vision.cc | 7 ++++--- .../dataset/engine/datasetops/batch_op.cc | 2 +- .../ccsrc/minddata/dataset/include/samplers.h | 2 +- .../ccsrc/minddata/dataset/include/vision_lite.h | 16 +--------------- .../dataset/kernels/image/CMakeLists.txt | 1 + .../kernels/image/lite_cv/image_process.cc | 8 +++++--- .../minddata/dataset/kernels/image/rotate_op.cc | 4 ++++ mindspore/lite/CMakeLists.txt | 2 +- mindspore/lite/minddata/CMakeLists.txt | 10 +++------- 10 files changed, 23 insertions(+), 31 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/api/samplers.cc b/mindspore/ccsrc/minddata/dataset/api/samplers.cc index 2b7fb725fd..bdffc873f3 100644 --- a/mindspore/ccsrc/minddata/dataset/api/samplers.cc +++ b/mindspore/ccsrc/minddata/dataset/api/samplers.cc @@ -31,6 +31,8 @@ #include "minddata/mindrecord/include/shard_sequential_sample.h" #include "minddata/mindrecord/include/shard_shuffle.h" #include "minddata/dataset/util/random.h" +#else +#include "minddata/dataset/core/config_manager.h" #endif namespace mindspore { diff --git a/mindspore/ccsrc/minddata/dataset/api/vision.cc b/mindspore/ccsrc/minddata/dataset/api/vision.cc index 8d157e2483..af7092e69b 100644 --- a/mindspore/ccsrc/minddata/dataset/api/vision.cc +++ b/mindspore/ccsrc/minddata/dataset/api/vision.cc @@ -75,6 +75,7 @@ #include "minddata/dataset/kernels/image/swap_red_blue_op.h" #include "minddata/dataset/kernels/image/uniform_aug_op.h" #endif +#include "minddata/dataset/kernels/image/rotate_op.h" namespace mindspore { namespace dataset { @@ -1987,7 +1988,6 @@ std::shared_ptr ResizeOperation::Build() { return std::make_shared(height, width, interpolation_); } -#ifdef ENABLE_ANDROID // RotateOperation RotateOperation::RotateOperation() { rotate_op = std::make_shared(0); } @@ -1995,8 +1995,9 @@ Status RotateOperation::ValidateParams() { return Status::OK(); } std::shared_ptr RotateOperation::Build() { return rotate_op; } -void RotateOperation::setAngle(uint64_t angle_id) { rotate_op->setAngle(angle_id); } -#endif +void RotateOperation::setAngle(uint64_t angle_id) { + std::dynamic_pointer_cast(rotate_op)->setAngle(angle_id); +} #ifndef ENABLE_ANDROID // ResizeWithBBoxOperation diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc index e30e1bbaa0..f542cdd4e4 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/batch_op.cc @@ -133,7 +133,7 @@ Status BatchOp::operator()() { RETURN_IF_NOT_OK(GetBatchSize(&cur_batch_size, CBatchInfo(epoch_num, batch_num, cnt - epoch_num))); RETURN_IF_NOT_OK(child_iterator_->FetchNextTensorRow(&new_row)); -#if !defined(_WIN32) && !defined(_WIN64) +#if !defined(_WIN32) && !defined(_WIN64) && ENABLE_PYTHON if ((num_workers_ > 1 || batch_map_func_) && GetMemoryUsage() > MAX_MEMORY_USAGE_THRESHOLD) { MS_LOG(WARNING) << "Memory consumption is more than " << MAX_MEMORY_USAGE_THRESHOLD * 100 << "%, " << "which may cause oom error. Please reduce num_parallel_workers size / " diff --git a/mindspore/ccsrc/minddata/dataset/include/samplers.h b/mindspore/ccsrc/minddata/dataset/include/samplers.h index b52860d58d..99a364da57 100644 --- a/mindspore/ccsrc/minddata/dataset/include/samplers.h +++ b/mindspore/ccsrc/minddata/dataset/include/samplers.h @@ -21,8 +21,8 @@ #include #include -#ifndef ENABLE_ANDROID #include "minddata/dataset/util/status.h" +#ifndef ENABLE_ANDROID #include "minddata/mindrecord/include/shard_column.h" #include "minddata/mindrecord/include/shard_error.h" #include "minddata/mindrecord/include/shard_reader.h" diff --git a/mindspore/ccsrc/minddata/dataset/include/vision_lite.h b/mindspore/ccsrc/minddata/dataset/include/vision_lite.h index e5c764ac12..aa7d56b031 100644 --- a/mindspore/ccsrc/minddata/dataset/include/vision_lite.h +++ b/mindspore/ccsrc/minddata/dataset/include/vision_lite.h @@ -26,10 +26,6 @@ #include "minddata/dataset/include/transforms.h" #include "minddata/dataset/include/status.h" -#ifdef ENABLE_ANDROID -#include "minddata/dataset/kernels/image/rotate_op.h" -#endif - namespace mindspore { namespace dataset { @@ -42,20 +38,14 @@ constexpr char kCropOperation[] = "Crop"; constexpr char kDecodeOperation[] = "Decode"; constexpr char kNormalizeOperation[] = "Normalize"; constexpr char kResizeOperation[] = "Resize"; - -#ifdef ENABLE_ANDROID constexpr char kRotateOperation[] = "Rotate"; -#endif // Transform Op classes (in alphabetical order) class CenterCropOperation; class CropOperation; class DecodeOperation; class NormalizeOperation; class ResizeOperation; - -#ifdef ENABLE_ANDROID class RotateOperation; -#endif /// \brief Function to create a CenterCrop TensorOperation. /// \notes Crops the input image at the center to the given size. @@ -98,12 +88,10 @@ std::shared_ptr Normalize(std::vector mean, std::vect /// \return Shared pointer to the current TensorOperation. std::shared_ptr Resize(std::vector size, InterpolationMode interpolation = InterpolationMode::kLinear); -#ifdef ENABLE_ANDROID /// \brief Applies an rotate transformation to an image. /// \notes Rotate the input image using a specified angle id. /// \return Shared pointer to the current TensorOperation. std::shared_ptr Rotate(); -#endif class CenterCropOperation : public TensorOperation { public: @@ -188,7 +176,6 @@ class ResizeOperation : public TensorOperation { InterpolationMode interpolation_; }; -#ifdef ENABLE_ANDROID class RotateOperation : public TensorOperation { public: RotateOperation(); @@ -204,9 +191,8 @@ class RotateOperation : public TensorOperation { void setAngle(uint64_t angle_id); private: - std::shared_ptr rotate_op; + std::shared_ptr rotate_op; }; -#endif } // namespace vision } // namespace dataset } // namespace mindspore diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/CMakeLists.txt b/mindspore/ccsrc/minddata/dataset/kernels/image/CMakeLists.txt index 7b1bc772fb..2f41ee00bd 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/CMakeLists.txt +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/CMakeLists.txt @@ -53,6 +53,7 @@ add_library(kernels-image OBJECT resize_with_bbox_op.cc random_resize_with_bbox_op.cc random_color_op.cc + rotate_op.cc ) if (ENABLE_ACL) add_dependencies(kernels-image kernels-soft-dvpp-image kernels-dvpp-image) diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc index c3635393c4..7c13fb3f12 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc @@ -674,9 +674,11 @@ bool ExtractChannel(LiteMat &src, LiteMat &dst, int col) { return false; } - if (dst.IsEmpty() || dst.width_ != src.width_ || dst.height_ != src.height_ || dst.channel_ != 1 || - dst.data_type_ != src.data_type_) { - dst.Init(src.width_, src.height_, 1, src.data_type_); + if (dst.data_type_ == LDataType::FLOAT32 || dst.data_type_ == LDataType::UINT8) { + if (dst.IsEmpty() || dst.width_ != src.width_ || dst.height_ != src.height_ || dst.channel_ != 1 || + dst.data_type_ != src.data_type_) { + dst.Init(src.width_, src.height_, 1, src.data_type_); + } } if (dst.data_type_ == LDataType::FLOAT32) { diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/rotate_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/rotate_op.cc index c5eb281ade..c8ca0fb906 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/rotate_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/rotate_op.cc @@ -15,7 +15,9 @@ */ #include "minddata/dataset/kernels/image/rotate_op.h" +#ifdef ENABLE_ANDROID #include "minddata/dataset/kernels/image/lite_image_utils.h" +#endif namespace mindspore { namespace dataset { @@ -26,7 +28,9 @@ Status RotateOp::Compute(const std::shared_ptr &input, std::shared_ptrshape().Size() >= 2, "The shape size " + std::to_string(input->shape().Size()) + " of input tensor is invalid"); +#ifdef ENABLE_ANDROID Rotate(input, output, angle_id_); +#endif return Status::OK(); } diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index cff4cb9e16..3e5bae9214 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -116,7 +116,7 @@ if (SUPPORT_GPU) include(${TOP_DIR}/cmake/external_libs/opencl.cmake) endif() -if (ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full") +if (ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper") include(${TOP_DIR}/cmake/external_libs/json.cmake) endif() diff --git a/mindspore/lite/minddata/CMakeLists.txt b/mindspore/lite/minddata/CMakeLists.txt index a3f34fcfaa..a5954aea24 100644 --- a/mindspore/lite/minddata/CMakeLists.txt +++ b/mindspore/lite/minddata/CMakeLists.txt @@ -90,16 +90,11 @@ AUX_SOURCE_DIRECTORY(${MINDDATA_DIR}/util MINDDATA_UTIL_SRC_FILES) AUX_SOURCE_DIRECTORY(${MINDDATA_DIR}/kernels/image/lite_cv MINDDATA_KERNELS_IMAGE_LITE_CV_FILES) - -if (BUILD_MINDDATA STREQUAL "full") - set(BUILD_MINDDATA "wrapper") -endif () - - if (BUILD_MINDDATA STREQUAL "full") include_directories("${CMAKE_SOURCE_DIR}/../ccsrc/minddata/dataset/kernels/image") list(REMOVE_ITEM MINDDATA_API_SRC_FILES "${MINDDATA_DIR}/api/text.cc" + "${MINDDATA_DIR}/api/minddata_eager.cc" ) list(REMOVE_ITEM MINDDATA_CALLBACK_SRC_FILES @@ -198,6 +193,7 @@ if (BUILD_MINDDATA STREQUAL "full") "${MINDDATA_DIR}/kernels/image/mixup_batch_op.cc" "${MINDDATA_DIR}/kernels/image/pad_op.cc" "${MINDDATA_DIR}/kernels/image/posterize_op.cc" + ${MINDDATA_DIR}/kernels/image/normalize_pad_op.cc "${MINDDATA_DIR}/kernels/image/random_affine_op.cc" "${MINDDATA_DIR}/kernels/image/random_color_adjust_op.cc" "${MINDDATA_DIR}/kernels/image/random_crop_and_resize_with_bbox_op.cc" @@ -438,7 +434,7 @@ elseif (BUILD_MINDDATA STREQUAL "lite") add_library(minddata-lite SHARED ${MINDDATA_CORE_SRC_FILES} ${MINDDATA_KERNELS_SRC_FILES} - ${MINDDATA_KERNELS_IMAGE_LITE_CV_FILES} + ${MINDDATA_KERNELS_IMAGE_LITE_CV_FILES} ${MINDDATA_KERNELS_IMAGE_SRC_FILES} ${MINDDATA_KERNELS_DATA_SRC_FILES} ${MINDDATA_DIR}/util/status.cc