| @@ -134,6 +134,20 @@ void ExecutionTree::PrintNode(std::ostream &out, const std::shared_ptr<DatasetOp | |||||
| // Start the execution of the tree | // Start the execution of the tree | ||||
| Status ExecutionTree::Launch() { | Status ExecutionTree::Launch() { | ||||
| // opencv limit too many threads | |||||
| #ifndef ENABLE_ANDROID | |||||
| #if !defined(_WIN32) && !defined(_WIN64) | |||||
| int32_t thread_num = get_nprocs(); | |||||
| if (thread_num == 0) { | |||||
| std::string err_msg = "Invalid thread number."; | |||||
| RETURN_STATUS_UNEXPECTED(err_msg); | |||||
| } | |||||
| if (thread_num > 8) | |||||
| cv::setNumThreads(8); | |||||
| else | |||||
| cv::setNumThreads(thread_num); | |||||
| #endif | |||||
| #endif | |||||
| // Tree must be built and prepared before it can be launched! | // Tree must be built and prepared before it can be launched! | ||||
| if (tree_state_ != kDeTStateReady) { | if (tree_state_ != kDeTStateReady) { | ||||
| std::string err_msg = | std::string err_msg = | ||||
| @@ -21,6 +21,12 @@ | |||||
| #include <stack> | #include <stack> | ||||
| #include <string> | #include <string> | ||||
| #include <vector> | #include <vector> | ||||
| #ifndef ENABLE_ANDROID | |||||
| #if !defined(_WIN32) && !defined(_WIN64) | |||||
| #include <sys/sysinfo.h> | |||||
| #include <opencv2/imgproc/imgproc.hpp> | |||||
| #endif | |||||
| #endif | |||||
| #include "minddata/dataset/engine/datasetops/dataset_op.h" | #include "minddata/dataset/engine/datasetops/dataset_op.h" | ||||
| #include "minddata/dataset/util/status.h" | #include "minddata/dataset/util/status.h" | ||||
| #include "mindspore/ccsrc/minddata/dataset/engine/perf/profiling.h" | #include "mindspore/ccsrc/minddata/dataset/engine/perf/profiling.h" | ||||
| @@ -97,8 +97,6 @@ Status Resize(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *out | |||||
| if (input_cv->Rank() != 3 && input_cv->Rank() != 2) { | if (input_cv->Rank() != 3 && input_cv->Rank() != 2) { | ||||
| RETURN_STATUS_UNEXPECTED("Input Tensor is not in shape of <H,W,C> or <H,W>"); | RETURN_STATUS_UNEXPECTED("Input Tensor is not in shape of <H,W,C> or <H,W>"); | ||||
| } | } | ||||
| // OpenCv lanuch too many threads. | |||||
| cv::setNumThreads(8); | |||||
| cv::Mat in_image = input_cv->mat(); | cv::Mat in_image = input_cv->mat(); | ||||
| // resize image too large or too small | // resize image too large or too small | ||||
| if (output_height == 0 || output_height > in_image.rows * 1000 || output_width == 0 || | if (output_height == 0 || output_height > in_image.rows * 1000 || output_width == 0 || | ||||