!7749 Remove open cv from minddata lite build.

Merge pull request !7749 from EricZ/remove_cv_crop
pull/7749/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 674f856bfa

@ -636,7 +636,6 @@ build_minddata_lite_deps()
else
CMAKE_MINDDATA_ARGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
fi
build_opencv
build_eigen
build_jpeg_turbo
}

@ -31,23 +31,14 @@ if (BUILD_MINDDATA STREQUAL "full")
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_core.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_imgcodecs.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_imgproc.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
elseif (PLATFORM_ARM32)
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_core.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_imgcodecs.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_imgproc.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
else ()
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so.62.3.0 DESTINATION ${TURBO_DIR_RUN_X86}/lib RENAME libjpeg.so.62 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so.0.2.0 DESTINATION ${TURBO_DIR_RUN_X86}/lib RENAME libturbojpeg.so.0 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_core.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_core.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_imgcodecs.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_imgcodecs.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_imgproc.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_imgproc.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
endif ()
endif ()
@ -57,23 +48,14 @@ if (BUILD_MINDDATA STREQUAL "lite")
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_core.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_imgcodecs.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/arm64-v8a/libopencv_imgproc.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
elseif (PLATFORM_ARM32)
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so DESTINATION ${TURBO_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_core.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_imgcodecs.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/armeabi-v7a/libopencv_imgproc.so DESTINATION ${OPENCV_DIR}/lib COMPONENT ${COMPONENT_NAME})
else ()
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so.62.3.0 DESTINATION ${TURBO_DIR_RUN_X86}/lib RENAME libjpeg.so.62 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so.0.2.0 DESTINATION ${TURBO_DIR_RUN_X86}/lib RENAME libturbojpeg.so.0 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_core.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_core.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_imgcodecs.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_imgcodecs.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/third_party/opencv/build/lib/libopencv_imgproc.so.4.2.0 DESTINATION ${OPENCV_DIR_RUN_X86}/lib RENAME libopencv_imgproc.so.4.2 COMPONENT ${RUN_X86_COMPONENT_NAME})
endif ()
endif ()

@ -21,6 +21,11 @@
#include "mindspore/core/ir/dtype/type_id.h"
#include "mindspore/lite/internal/include/ms_tensor.h"
#include "utils/hashing.h"
#ifndef ENABLE_ANDROID
#include "utils/log_adapter.h"
#else
#include "mindspore/lite/src/common/log_adapter.h"
#endif
namespace mindspore {
namespace tensor {
@ -43,7 +48,7 @@ MSTensor *DETensor::CreateFromMemory(TypeId data_type, const std::vector<int> &s
[](int s) -> dataset::dsize_t { return static_cast<dataset::dsize_t>(s); });
(void)dataset::Tensor::CreateFromMemory(dataset::TensorShape(t_shape), dataset::MSTypeToDEType(data_type),
static_cast<uchar *>(data), &t);
static_cast<uint8_t *>(data), &t);
return new DETensor(std::move(t));
}

@ -18,6 +18,11 @@
#include "minddata/dataset/include/de_tensor.h"
#include "minddata/dataset/include/tensor.h"
#include "minddata/dataset/kernels/tensor_op.h"
#ifndef ENABLE_ANDROID
#include "utils/log_adapter.h"
#else
#include "mindspore/lite/src/common/log_adapter.h"
#endif
namespace mindspore {
namespace dataset {

@ -15,7 +15,6 @@
*/
#include "minddata/dataset/include/transforms.h"
#include "minddata/dataset/kernels/image/image_utils.h"
// Kernel data headers (in alphabetical order)
#include "minddata/dataset/kernels/data/one_hot_op.h"

@ -16,17 +16,25 @@
#include "minddata/dataset/include/transforms.h"
#include "minddata/dataset/include/vision.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#endif
// Kernel image headers (in alphabetical order)
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/center_crop_op.h"
#endif
#include "minddata/dataset/kernels/image/crop_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/cutmix_batch_op.h"
#include "minddata/dataset/kernels/image/cut_out_op.h"
#endif
#include "minddata/dataset/kernels/image/decode_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/hwc_to_chw_op.h"
#include "minddata/dataset/kernels/image/mixup_batch_op.h"
#endif
#include "minddata/dataset/kernels/image/normalize_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/pad_op.h"
#include "minddata/dataset/kernels/image/random_affine_op.h"
#include "minddata/dataset/kernels/image/random_color_op.h"
@ -41,11 +49,14 @@
#include "minddata/dataset/kernels/image/random_solarize_op.h"
#include "minddata/dataset/kernels/image/random_vertical_flip_op.h"
#include "minddata/dataset/kernels/image/rescale_op.h"
#endif
#include "minddata/dataset/kernels/image/resize_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/rgba_to_bgr_op.h"
#include "minddata/dataset/kernels/image/rgba_to_rgb_op.h"
#include "minddata/dataset/kernels/image/swap_red_blue_op.h"
#include "minddata/dataset/kernels/image/uniform_aug_op.h"
#endif
namespace mindspore {
namespace dataset {
@ -53,7 +64,7 @@ namespace api {
// Transform operations for computer vision.
namespace vision {
#ifndef ENABLE_ANDROID
// FUNCTIONS TO CREATE VISION TRANSFORM OPERATIONS
// (In alphabetical order)
@ -66,6 +77,7 @@ std::shared_ptr<CenterCropOperation> CenterCrop(std::vector<int32_t> size) {
}
return op;
}
#endif
// Function to create CropOperation.
std::shared_ptr<CropOperation> Crop(std::vector<int32_t> coordinates, std::vector<int32_t> size) {
@ -76,7 +88,7 @@ std::shared_ptr<CropOperation> Crop(std::vector<int32_t> coordinates, std::vecto
}
return op;
}
#ifndef ENABLE_ANDROID
// Function to create CutMixBatchOperation.
std::shared_ptr<CutMixBatchOperation> CutMixBatch(ImageBatchFormat image_batch_format, float alpha, float prob) {
auto op = std::make_shared<CutMixBatchOperation>(image_batch_format, alpha, prob);
@ -301,6 +313,7 @@ std::shared_ptr<RescaleOperation> Rescale(float rescale, float shift) {
return op;
}
#endif
// Function to create ResizeOperation.
std::shared_ptr<ResizeOperation> Resize(std::vector<int32_t> size, InterpolationMode interpolation) {
auto op = std::make_shared<ResizeOperation>(size, interpolation);
@ -311,6 +324,7 @@ std::shared_ptr<ResizeOperation> Resize(std::vector<int32_t> size, Interpolation
return op;
}
#ifndef ENABLE_ANDROID
// Function to create RgbaToBgrOperation.
std::shared_ptr<RgbaToBgrOperation> RGBA2BGR() {
auto op = std::make_shared<RgbaToBgrOperation>();
@ -352,6 +366,7 @@ std::shared_ptr<UniformAugOperation> UniformAugment(std::vector<std::shared_ptr<
return op;
}
#endif
/* ####################################### Validator Functions ############################################ */
Status ValidateVectorPositive(const std::string &dataset_name, const std::vector<int32_t> &size) {
for (int32_t i = 0; i < size.size(); ++i) {
@ -371,7 +386,7 @@ bool CmpFloat(const float &a, const float &b, float epsilon = 0.0000000001f) { r
/* ####################################### Derived TensorOperation classes ################################# */
// (In alphabetical order)
#ifndef ENABLE_ANDROID
// CenterCropOperation
CenterCropOperation::CenterCropOperation(std::vector<int32_t> size) : size_(size) {}
@ -410,6 +425,7 @@ std::shared_ptr<TensorOp> CenterCropOperation::Build() {
return tensor_op;
}
#endif
// CropOperation.
CropOperation::CropOperation(std::vector<int32_t> coordinates, std::vector<int32_t> size)
: coordinates_(coordinates), size_(size) {}
@ -467,6 +483,7 @@ std::shared_ptr<TensorOp> CropOperation::Build() {
return tensor_op;
}
#ifndef ENABLE_ANDROID
// CutMixBatchOperation
CutMixBatchOperation::CutMixBatchOperation(ImageBatchFormat image_batch_format, float alpha, float prob)
: image_batch_format_(image_batch_format), alpha_(alpha), prob_(prob) {}
@ -1369,6 +1386,7 @@ std::shared_ptr<TensorOp> RescaleOperation::Build() {
return tensor_op;
}
#endif
// ResizeOperation
ResizeOperation::ResizeOperation(std::vector<int32_t> size, InterpolationMode interpolation)
: size_(size), interpolation_(interpolation) {}
@ -1397,6 +1415,7 @@ std::shared_ptr<TensorOp> ResizeOperation::Build() {
return std::make_shared<ResizeOp>(height, width, interpolation_);
}
#ifndef ENABLE_ANDROID
// RgbaToBgrOperation.
RgbaToBgrOperation::RgbaToBgrOperation() {}
@ -1461,6 +1480,7 @@ std::shared_ptr<TensorOp> UniformAugOperation::Build() {
std::shared_ptr<UniformAugOp> tensor_op = std::make_shared<UniformAugOp>(tensor_ops, num_ops_);
return tensor_op;
}
#endif
} // namespace vision
} // namespace api

@ -43,6 +43,7 @@ py::dtype DataType::AsNumpyType() const {
}
#endif
#ifndef ENABLE_ANDROID
uint8_t DataType::AsCVType() const {
uint8_t res = kCVInvalidType;
if (type_ < DataType::NUM_OF_TYPES) {
@ -80,6 +81,7 @@ DataType DataType::FromCVType(int cv_type) {
return DataType(DataType::DE_UNKNOWN);
}
}
#endif
DataType::DataType(const std::string &type_str) {
if (type_str == "bool")

@ -16,7 +16,9 @@
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DATA_TYPE_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DATA_TYPE_H_
#ifndef ENABLE_ANDROID
#include <opencv2/core/hal/interface.h>
#endif
#include <string>
#ifdef ENABLE_PYTHON
@ -79,6 +81,7 @@ class DataType {
{"string", 0, "bytes", "S", kCVInvalidType} // DE_STRING
};
#else
#ifndef ENABLE_ANDROID
static inline const TypeInfo kTypeInfo[] = {
// name, sizeInBytes, pybindTypem formatDescriptor, openCV
{"unknown", 0, "object", "", kCVInvalidType}, // DE_UNKNOWN
@ -96,8 +99,27 @@ class DataType {
{"float64", 8, "double", "", CV_64F}, // DE_FLOAT64
{"string", 0, "bytes", "", kCVInvalidType} // DE_STRING
};
#else
// android and no python
static inline const TypeInfo kTypeInfo[] = {
// name, sizeInBytes, formatDescriptor
{"unknown", 0, "object", "", kCVInvalidType}, // DE_UNKNOWN
{"bool", 1, "bool", ""}, // DE_BOOL
{"int8", 1, "int8", ""}, // DE_INT8
{"uint8", 1, "uint8", ""}, // DE_UINT8
{"int16", 2, "int16", ""}, // DE_INT16
{"uint16", 2, "uint16", ""}, // DE_UINT16
{"int32", 4, "int32", ""}, // DE_INT32
{"uint32", 4, "uint32", "", kCVInvalidType}, // DE_UINT32
{"int64", 8, "int64", "", kCVInvalidType}, // DE_INT64
{"uint64", 8, "uint64", "", kCVInvalidType}, // DE_UINT64
{"float16", 2, "float16", ""}, // DE_FLOAT16
{"float32", 4, "float32", ""}, // DE_FLOAT32
{"float64", 8, "double", ""}, // DE_FLOAT64
{"string", 0, "bytes", "", kCVInvalidType} // DE_STRING
};
#endif
#endif
// No arg constructor to create an unknown shape
DataType() : type_(DE_UNKNOWN) {}
@ -132,6 +154,7 @@ class DataType {
/// \return
uint8_t SizeInBytes() const;
#ifndef ENABLE_ANDROID
// Convert from DataType to OpenCV type
/// \return
uint8_t AsCVType() const;
@ -140,6 +163,7 @@ class DataType {
/// \param cv_type
/// \return
static DataType FromCVType(int cv_type);
#endif
// Returns a string representation of the type
/// \return

@ -19,7 +19,9 @@
#include <mutex>
#include "minddata/dataset/core/config_manager.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/core/cv_tensor.h"
#endif
#include "minddata/dataset/core/tensor.h"
#include "minddata/dataset/util/allocator.h"
#include "minddata/dataset/util/circular_pool.h"
@ -56,7 +58,9 @@ Status GlobalContext::Init() {
// Create some tensor allocators for the different types and hook them into the pool.
tensor_allocator_ = std::make_unique<Allocator<Tensor>>(mem_pool_);
#ifndef ENABLE_ANDROID
cv_tensor_allocator_ = std::make_unique<Allocator<CVTensor>>(mem_pool_);
#endif
int_allocator_ = std::make_unique<IntAlloc>(mem_pool_);
return Status::OK();
}

@ -26,7 +26,11 @@
#include "utils/ms_utils.h"
#include "minddata/dataset/core/constants.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/core/cv_tensor.h"
#endif
#include "minddata/dataset/core/global_context.h"
#ifdef ENABLE_PYTHON

@ -96,6 +96,7 @@ TensorShape::TensorShape(py::list l)
}
#endif
#ifndef ENABLE_ANDROID
TensorShape::TensorShape(cv::MatSize cv_size, uint32_t type)
: raw_shape_(*GlobalContext::Instance()->int_allocator()), strides_(*GlobalContext::Instance()->int_allocator()) {
for (int i = 0; i < cv_size.dims(); i++) {
@ -107,6 +108,7 @@ TensorShape::TensorShape(cv::MatSize cv_size, uint32_t type)
}
known_ = true;
}
#endif
TensorShape TensorShape::CreateUnknownRankShape() {
TensorShape s({});

@ -22,7 +22,9 @@
#include <string>
#include <vector>
#ifndef ENABLE_ANDROID
#include <opencv2/core/mat.hpp>
#endif
#ifdef ENABLE_PYTHON
#include "pybind11/pybind11.h"
@ -105,10 +107,12 @@ class TensorShape {
/// \return
TensorShape AppendDim(dsize_t dim) const;
#ifndef ENABLE_ANDROID
/// \brief Create a shape based on OpenCV shape and type
/// \param[in] cv_size
/// \param[in] type int that represent the type in OpenCV, example CV_8U, CV_64S
TensorShape(cv::MatSize cv_size, uint32_t type);
#endif
dsize_t Size() const { return raw_shape_.size(); }

@ -22,7 +22,11 @@
#include "minddata/dataset/engine/db_connector.h"
#include "minddata/dataset/engine/execution_tree.h"
#include "minddata/dataset/engine/opt/pass.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
namespace mindspore {
namespace dataset {

@ -24,7 +24,11 @@
#include "minddata/dataset/engine/data_schema.h"
#include "minddata/dataset/engine/execution_tree.h"
#include "minddata/dataset/engine/opt/pass.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
namespace mindspore {
namespace dataset {

@ -28,7 +28,11 @@
#include "minddata/dataset/engine/data_schema.h"
#include "minddata/dataset/engine/datasetops/parallel_op.h"
#include "minddata/dataset/engine/datasetops/source/sampler/sampler.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
#include "minddata/dataset/util/path.h"
#include "minddata/dataset/util/queue.h"
#include "minddata/dataset/util/status.h"

@ -30,7 +30,11 @@
#include "minddata/dataset/engine/data_schema.h"
#include "minddata/dataset/engine/datasetops/parallel_op.h"
#include "minddata/dataset/engine/datasetops/source/sampler/sampler.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
#include "minddata/dataset/util/path.h"
#include "minddata/dataset/util/queue.h"
#include "minddata/dataset/util/services.h"

@ -26,9 +26,9 @@
#include "minddata/dataset/engine/opt/pre/cache_transform_pass.h"
#include "minddata/dataset/engine/opt/post/repeat_pass.h"
#include "minddata/dataset/engine/opt/pre/cache_error_pass.h"
#include "mindspore/ccsrc/minddata/dataset/engine/opt/optional/tensor_op_fusion_pass.h"
#endif
#include "minddata/dataset/engine/opt/pre/epoch_injection_pass.h"
#include "mindspore/ccsrc/minddata/dataset/engine/opt/optional/tensor_op_fusion_pass.h"
#include "minddata/dataset/engine/perf/profiling.h"
#include "minddata/dataset/engine/perf/monitor.h"
@ -222,7 +222,6 @@ Status ExecutionTree::Prepare(int32_t num_epochs) {
if (optimize_) {
RETURN_IF_NOT_OK(this->Optimize());
}
// Post optimization compulsory transformation
RETURN_IF_NOT_OK(this->PrepareTreePostAction());
@ -276,7 +275,9 @@ Status ExecutionTree::PrepareTreePostAction() {
Status ExecutionTree::Optimize() {
// Vector of optimizations, currently only 1, add more as necessary
std::vector<std::unique_ptr<NodePass>> optimizations;
#ifndef ENABLE_ANDROID
optimizations.push_back(std::make_unique<TensorOpFusionPass>());
#endif
// vector of flags for each optimization
std::vector<bool> modified(optimizations.size(), false);
for (auto i = 0; i < optimizations.size(); i++) {

@ -31,14 +31,21 @@ namespace api {
namespace vision {
// Transform Op classes (in alphabetical order)
#ifndef ENABLE_ANDROID
class CenterCropOperation;
#endif
class CropOperation;
#ifndef ENABLE_ANDROID
class CutMixBatchOperation;
class CutOutOperation;
#endif
class DecodeOperation;
#ifndef ENABLE_ANDROID
class HwcToChwOperation;
class MixUpBatchOperation;
#endif
class NormalizeOperation;
#ifndef ENABLE_ANDROID
class PadOperation;
class RandomAffineOperation;
class RandomColorOperation;
@ -53,7 +60,9 @@ class RandomSharpnessOperation;
class RandomSolarizeOperation;
class RandomVerticalFlipOperation;
class RescaleOperation;
#endif
class ResizeOperation;
#ifndef ENABLE_ANDROID
class RgbaToBgrOperation;
class RgbaToRgbOperation;
class SwapRedBlueOperation;
@ -66,14 +75,14 @@ class UniformAugOperation;
/// If size has 2 values, it should be (height, width).
/// \return Shared pointer to the current TensorOperation.
std::shared_ptr<CenterCropOperation> CenterCrop(std::vector<int32_t> size);
#endif
/// \brief Function to create a Crop TensorOp
/// \notes Crop an image based on location and crop size
/// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}
/// \param[in] size Size of the cropped area. Must be a vector of two values, in the form of {height, width}
/// \return Shared pointer to the current TensorOp
std::shared_ptr<CropOperation> Crop(std::vector<int32_t> coordinates, std::vector<int32_t> size);
#ifndef ENABLE_ANDROID
/// \brief Function to apply CutMix on a batch of images
/// \notes Masks a random section of each image with the corresponding part of another randomly
/// selected image in that batch
@ -91,12 +100,14 @@ std::shared_ptr<CutMixBatchOperation> CutMixBatch(ImageBatchFormat image_batch_f
/// \return Shared pointer to the current TensorOp
std::shared_ptr<CutOutOperation> CutOut(int32_t length, int32_t num_patches = 1);
#endif
/// \brief Function to create a Decode TensorOperation.
/// \notes Decode the input image in RGB mode.
/// \param[in] rgb A boolean of whether to decode in RGB mode or not.
/// \return Shared pointer to the current TensorOperation.
std::shared_ptr<DecodeOperation> Decode(bool rgb = true);
#ifndef ENABLE_ANDROID
/// \brief Function to create a HwcToChw TensorOperation.
/// \notes Transpose the input image; shape (H, W, C) to shape (C, H, W).
/// \return Shared pointer to the current TensorOperation.
@ -109,6 +120,7 @@ std::shared_ptr<HwcToChwOperation> HWC2CHW();
/// \return Shared pointer to the current TensorOperation.
std::shared_ptr<MixUpBatchOperation> MixUpBatch(float alpha = 1);
#endif
/// \brief Function to create a Normalize TensorOperation.
/// \notes Normalize the input image with respect to mean and standard deviation.
/// \param[in] mean A vector of mean values for each channel, w.r.t channel order.
@ -118,6 +130,7 @@ std::shared_ptr<MixUpBatchOperation> MixUpBatch(float alpha = 1);
/// \return Shared pointer to the current TensorOperation.
std::shared_ptr<NormalizeOperation> Normalize(std::vector<float> mean, std::vector<float> std);
#ifndef ENABLE_ANDROID
/// \brief Function to create a Pad TensorOp
/// \notes Pads the image according to padding parameters
/// \param[in] padding A vector representing the number of pixels to pad the image
@ -287,6 +300,7 @@ std::shared_ptr<RandomVerticalFlipOperation> RandomVerticalFlip(float prob = 0.5
/// \return Shared pointer to the current TensorOperation.
std::shared_ptr<RescaleOperation> Rescale(float rescale, float shift);
#endif
/// \brief Function to create a Resize TensorOperation.
/// \notes Resize the input image to the given size.
/// \param[in] size A vector representing the output size of the resized image.
@ -297,6 +311,7 @@ std::shared_ptr<RescaleOperation> Rescale(float rescale, float shift);
std::shared_ptr<ResizeOperation> Resize(std::vector<int32_t> size,
InterpolationMode interpolation = InterpolationMode::kLinear);
#ifndef ENABLE_ANDROID
/// \brief Function to create a RgbaToBgr TensorOperation.
/// \notes Changes the input 4 channel RGBA tensor to 3 channel BGR.
/// \return Shared pointer to the current TensorOperation.
@ -335,7 +350,7 @@ class CenterCropOperation : public TensorOperation {
private:
std::vector<int32_t> size_;
};
#endif
class CropOperation : public TensorOperation {
public:
CropOperation(std::vector<int32_t> coordinates, std::vector<int32_t> size);
@ -350,7 +365,7 @@ class CropOperation : public TensorOperation {
std::vector<int32_t> coordinates_;
std::vector<int32_t> size_;
};
#ifndef ENABLE_ANDROID
class CutMixBatchOperation : public TensorOperation {
public:
explicit CutMixBatchOperation(ImageBatchFormat image_batch_format, float alpha = 1.0, float prob = 1.0);
@ -383,6 +398,7 @@ class CutOutOperation : public TensorOperation {
ImageBatchFormat image_batch_format_;
};
#endif
class DecodeOperation : public TensorOperation {
public:
explicit DecodeOperation(bool rgb = true);
@ -397,6 +413,7 @@ class DecodeOperation : public TensorOperation {
bool rgb_;
};
#ifndef ENABLE_ANDROID
class HwcToChwOperation : public TensorOperation {
public:
~HwcToChwOperation() = default;
@ -420,6 +437,7 @@ class MixUpBatchOperation : public TensorOperation {
float alpha_;
};
#endif
class NormalizeOperation : public TensorOperation {
public:
NormalizeOperation(std::vector<float> mean, std::vector<float> std);
@ -435,6 +453,7 @@ class NormalizeOperation : public TensorOperation {
std::vector<float> std_;
};
#ifndef ENABLE_ANDROID
class PadOperation : public TensorOperation {
public:
PadOperation(std::vector<int32_t> padding, std::vector<uint8_t> fill_value = {0},
@ -672,6 +691,7 @@ class RescaleOperation : public TensorOperation {
float shift_;
};
#endif
class ResizeOperation : public TensorOperation {
public:
explicit ResizeOperation(std::vector<int32_t> size,
@ -688,6 +708,7 @@ class ResizeOperation : public TensorOperation {
InterpolationMode interpolation_;
};
#ifndef ENABLE_ANDROID
class RgbaToBgrOperation : public TensorOperation {
public:
RgbaToBgrOperation();
@ -735,6 +756,8 @@ class UniformAugOperation : public TensorOperation {
std::vector<std::shared_ptr<TensorOperation>> transforms_;
int32_t num_ops_;
};
#endif
} // namespace vision
} // namespace api
} // namespace dataset

@ -649,6 +649,7 @@ Status Concatenate(const TensorRow &input, TensorRow *output, int8_t axis, std::
return Status::OK();
}
#ifndef ENABLE_ANDROID
Status BatchTensorToCVTensorVector(const std::shared_ptr<Tensor> &input,
std::vector<std::shared_ptr<CVTensor>> *output) {
std::vector<int64_t> tensor_shape = input->shape().AsVector();
@ -673,6 +674,7 @@ Status BatchTensorToCVTensorVector(const std::shared_ptr<Tensor> &input,
}
return Status::OK();
}
#endif
Status BatchTensorToTensorVector(const std::shared_ptr<Tensor> &input, std::vector<std::shared_ptr<Tensor>> *output) {
std::vector<int64_t> tensor_shape = input->shape().AsVector();

@ -21,7 +21,9 @@
#include <vector>
#include <unordered_map>
#include "minddata/dataset/core/constants.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/core/cv_tensor.h"
#endif
#include "minddata/dataset/core/data_type.h"
#include "minddata/dataset/core/tensor.h"
#include "minddata/dataset/core/tensor_row.h"

@ -15,7 +15,11 @@
*/
#include "minddata/dataset/kernels/image/crop_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
#include "minddata/dataset/util/status.h"
namespace mindspore {

@ -21,7 +21,11 @@
#include <string>
#include "minddata/dataset/core/tensor.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
#include "minddata/dataset/kernels/tensor_op.h"
#include "minddata/dataset/util/status.h"

@ -15,7 +15,11 @@
*/
#include "minddata/dataset/kernels/image/decode_op.h"
#ifndef ENABLE_ANDROID
#include "minddata/dataset/kernels/image/image_utils.h"
#else
#include "minddata/dataset/kernels/image/lite_image_utils.h"
#endif
#include "minddata/dataset/util/status.h"
namespace mindspore {

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "lite_cv/image_process.h"
#include "minddata/dataset/kernels/image/lite_cv/image_process.h"
#include <string.h>
#include <cmath>

@ -22,7 +22,7 @@
#include <algorithm>
#include <iostream>
#include "lite_cv/lite_mat.h"
#include "minddata/dataset/kernels/image/lite_cv/lite_mat.h"
namespace mindspore {
namespace dataset {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save