diff --git a/mindspore-src/source/cmake/external_libs/robin.cmake b/mindspore-src/source/cmake/external_libs/robin.cmake index 85956c4a424c483f69b639c12e1b94474c831f91..ea1c9dd0c458532e25ec7bb719171d2024993d4e 100644 --- a/mindspore-src/source/cmake/external_libs/robin.cmake +++ b/mindspore-src/source/cmake/external_libs/robin.cmake @@ -11,6 +11,9 @@ mindspore_add_pkg(robin_hood_hashing VER 3.11.5 HEAD_ONLY ${INCLUDE} URL ${REQ_URL} - SHA256 ${SHA256}) + SHA256 ${SHA256} + PATCHES ${TOP_DIR}/third_party/patch/robin_hood_hashing/0001-fix-unused-var-warning.patch + PATCHES ${TOP_DIR}/third_party/patch/robin_hood_hashing/0002-fix-string-isflat-symbol.patch + ) include_directories(${robin_hood_hashing_INC}) diff --git a/mindspore-src/source/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/quant_dtype_cast_int8.c b/mindspore-src/source/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/quant_dtype_cast_int8.c index 4b1546b16eacf2fea8f7c75166f15a79119ffd0d..b859bba6a8a726709a446099df32a24dd4a1ff89 100644 --- a/mindspore-src/source/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/quant_dtype_cast_int8.c +++ b/mindspore-src/source/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/int8/quant_dtype_cast_int8.c @@ -328,9 +328,9 @@ int DoChannelColFp32ToInt8(const float *real_values, int8_t *quant_values, float int8_t *quant_current = quant_values + r * row_length; for (int c = 0; c < row_length; c++) { const float inverse_scale = 1.0f / scale[c]; - if (real_current[c] == INFINITY) { + if (isinf(real_current[c]) && real_current[c] > 0) { quant_current[c] = max_value; - } else if (real_current[c] == -INFINITY) { + } else if (isinf(real_current[c]) && real_current[c] < 0) { quant_current[c] = min_value; } else { int temp = round(real_current[c] * inverse_scale + zp[c]); @@ -352,9 +352,9 @@ int DoQuantizeFp32ToInt8FromUint8Source(const float *real_values, int8_t *quant_ zp += 128; const float inverse_scale = 1.0f / scale; for (int i = 0; i < size; ++i) { - if (real_values[i] == INFINITY) { + if (isinf(real_values[i]) && real_values[i] > 0) { quant_values[i] = max_value; - } else if (real_values[i] == -INFINITY) { + } else if (isinf(real_values[i]) && real_values[i] < 0) { quant_values[i] = min_value; } else { int temp = round(real_values[i] * inverse_scale + zp); diff --git a/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/AppDelegate.mm b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/AppDelegate.mm index 48e9dd00961491b3260bea1b13ab468d049065b3..9ae171422ba0c5aae3fb7a779292819b1dade111 100644 --- a/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/AppDelegate.mm +++ b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/AppDelegate.mm @@ -25,7 +25,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - mindspore::lite::main_benchmark(); + NSString *modelFilePath = [[NSBundle mainBundle] pathForResource:@"mobilenetv2" ofType:@"ms"]; + if (modelFilePath) { + NSLog(@"model path: %@", modelFilePath); + const char *cString = [modelFilePath UTF8String]; + std::string model_path(cString); + mindspore::lite::main_benchmark(&model_path); + } return YES; } diff --git a/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.cpp b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf72a754e278933f170956d9e3bbb4acb951a7bb --- /dev/null +++ b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.cpp @@ -0,0 +1,208 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "Benchmark.hpp" +#include "include/api/model.h" +#include "include/api/context.h" +#include "include/api/status.h" +#include "include/api/types.h" + +namespace { +constexpr int kNumPrintOfOutData = 50; +} +std::string RealPath(const char *path) { + const size_t max = 4096; + if (path == nullptr) { + std::cerr << "path is nullptr" << std::endl; + return ""; + } + if ((strlen(path)) >= max) { + std::cerr << "path is too long" << std::endl; + return ""; + } + auto resolved_path = std::make_unique(max); + if (resolved_path == nullptr) { + std::cerr << "new resolved_path failed" << std::endl; + return ""; + } + char *real_path = realpath(path, resolved_path.get()); + if (real_path == nullptr || strlen(real_path) == 0) { + std::cerr << "file path is not valid : " << path << std::endl; + return ""; + } + std::string res = resolved_path.get(); + return res; +} + +char *ReadFile(const char *file, size_t *size) { + if (file == nullptr) { + std::cerr << "file is nullptr." << std::endl; + return nullptr; + } + + std::ifstream ifs(file, std::ifstream::in | std::ifstream::binary); + if (!ifs.good()) { + std::cerr << "file: " << file << " is not exist." << std::endl; + return nullptr; + } + + if (!ifs.is_open()) { + std::cerr << "file: " << file << " open failed." << std::endl; + return nullptr; + } + + ifs.seekg(0, std::ios::end); + *size = ifs.tellg(); + std::unique_ptr buf(new (std::nothrow) char[*size]); + if (buf == nullptr) { + std::cerr << "malloc buf failed, file: " << file << std::endl; + ifs.close(); + return nullptr; + } + + ifs.seekg(0, std::ios::beg); + ifs.read(buf.get(), *size); + ifs.close(); + + return buf.release(); +} + +template +void GenerateRandomData(int size, void *data, Distribution distribution) { + std::mt19937 random_engine; + int elements_num = size / sizeof(T); + (void)std::generate_n(static_cast(data), elements_num, + [&distribution, &random_engine]() { return static_cast(distribution(random_engine)); }); +} + +int GenerateInputDataWithRandom(std::vector inputs) { + for (auto tensor : inputs) { + auto input_data = tensor.MutableData(); + if (input_data == nullptr) { + std::cerr << "MallocData for inTensor failed." << std::endl; + return -1; + } + GenerateRandomData(tensor.DataSize(), input_data, std::uniform_real_distribution(0.1f, 1.0f)); + } + return mindspore::kSuccess; +} + +int QuickStart(const std::string& model_path) { + // Read model file. + size_t size = 0; + char *model_buf = ReadFile(model_path.c_str(), &size); + if (model_buf == nullptr) { + std::cerr << "Read model file failed." << std::endl; + return -1; + } + + // Create and init context, add CPU device info + auto context = std::make_shared(); + if (context == nullptr) { + delete[](model_buf); + std::cerr << "New context failed." << std::endl; + return -1; + } + auto &device_list = context->MutableDeviceInfo(); + auto device_info = std::make_shared(); + if (device_info == nullptr) { + delete[](model_buf); + std::cerr << "New CPUDeviceInfo failed." << std::endl; + return -1; + } + device_list.push_back(device_info); + + // Create model + auto model = new (std::nothrow) mindspore::Model(); + if (model == nullptr) { + delete[](model_buf); + std::cerr << "New Model failed." << std::endl; + return -1; + } + // Build model + auto build_ret = model->Build(model_buf, size, mindspore::kMindIR, context); + delete[](model_buf); + if (build_ret != mindspore::kSuccess) { + delete model; + std::cerr << "Build model error " << build_ret << std::endl; + return -1; + } + + // Get Input + auto inputs = model->GetInputs(); + // Generate random data as input data. + auto ret = GenerateInputDataWithRandom(inputs); + if (ret != mindspore::kSuccess) { + delete model; + std::cerr << "Generate Random Input Data failed." << std::endl; + return -1; + } + // Get Output + auto outputs = model->GetOutputs(); + auto begin_time = std::chrono::high_resolution_clock::now(); + // Model Predict + auto predict_ret = model->Predict(inputs, &outputs); + if (predict_ret != mindspore::kSuccess) { + delete model; + std::cerr << "Predict error " << predict_ret << std::endl; + return -1; + } else { + std::cout << "Predict ok " << std::endl; + auto end_time = std::chrono::high_resolution_clock::now(); + std::cout << "Predict file: " << model_path << " cost time " + << std::chrono::duration(end_time - begin_time).count() + << std::endl; + } + + + // Print Output Tensor Data. + for (auto tensor : outputs) { + std::cout << "tensor name is:" << tensor.Name() << " tensor size is:" << tensor.DataSize() + << " tensor elements num is:" << tensor.ElementNum() << std::endl; + auto out_data = reinterpret_cast(tensor.Data().get()); + std::cout << "output data is:"; + for (int i = 0; i < tensor.ElementNum() && i <= 50; i++) { + std::cout << out_data[i] << " "; + } + float sum_tensor = 0; + for (int i = 0; i < tensor.ElementNum(); i++) { + sum_tensor += out_data[i]; + } + std::cout << "\n sum_tensor: " << sum_tensor << " \n"; + + std::cout << std::endl; + } + + // Delete model. + delete model; + return mindspore::kSuccess; +} + +namespace mindspore::lite { +int main_benchmark(std::string* model_path) +{ + int ret_code = QuickStart(*model_path); + std::cout << "model run over! ret code is " << ret_code << std::endl; + return 0; +} +} // namespace mindspore::lite diff --git a/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.hpp b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.hpp index 78eeb19c8569588b7eb67f4e9cc360c4f65dbe74..481395952fc13ca66122fc23f52b0f5cecd9b777 100644 --- a/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.hpp +++ b/mindspore-src/source/mindspore/lite/examples/quick_start_ios/mindspore-lite/Benchmark.hpp @@ -16,261 +16,9 @@ #ifndef BENCHMARK_H_ #define BENCHMARK_H_ +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mindspore-lite/include/model.h" -#include "mindspore-lite/include/lite_session.h" -#include "mindspore-lite/include/errorcode.h" - -constexpr float kNumRelativeTolerance = 1e-5; -constexpr float kNumAbsoluteTolerance = 1e-8; -constexpr float kNumMinAbsoluteError = 1e-5; -constexpr float kNumDefaultLoopCount = 10; -constexpr float kNumDefaultNumThread = 2; -constexpr float kNumDefaultWarmUpLoopCount = 3; -constexpr float kNumDefaultAccuracyThreshold = 0.5; -constexpr float kNumDefaultPrintLen = 50; -constexpr float kNumPercentage = 100; -constexpr float kNumMinMeanError = 0.0000001; - -enum InDataType { kImage = 0, kBinary = 1 }; namespace mindspore::lite { -#ifdef ENABLE_ARM64 -struct PerfResult { - int64_t nr; - struct { - int64_t value; - int64_t id; - } values[2]; -}; -struct PerfCount { - int64_t value[2]; -}; -#endif - -struct CheckTensor { - CheckTensor(const std::vector &shape, const std::vector &data, - const std::vector &strings_data = {""}) { - this->shape = shape; - this->data = data; - this->strings_data = strings_data; - } - std::vector shape; - std::vector data; - std::vector strings_data; -}; - -struct Flag { - std::string model_file_; - std::string in_data_file_; - std::vector input_data_list_; - InDataType in_data_type_ = kBinary; - std::string in_data_type_in_ = "bin"; - int cpu_bind_mode_ = HIGHER_CPU; - // MarkPerformance - int loop_count_ = kNumDefaultLoopCount; - int num_threads_ = kNumDefaultNumThread; - bool enable_fp16_ = false; - int warm_up_loop_count_ = kNumDefaultWarmUpLoopCount; - // MarkAccuracy - std::string benchmark_data_file_; - std::string benchmark_data_type_ = "FLOAT"; - float accuracy_threshold_ = kNumDefaultAccuracyThreshold; - // Resize - std::string resize_dims_in_; - std::vector> resize_dims_; - - std::string device_ = "CPU"; - bool time_profiling_ = false; - bool perf_profiling_ = false; - std::string perf_event_ = "CYCLE"; - bool dump_profiling_ = false; -}; - -class Benchmark { - public: - explicit Benchmark(Flag *flag) : flags_(flag) {} - - virtual ~Benchmark(); - - int Init(); - int RunBenchmark(); - - private: - // call GenerateInputData or ReadInputFile to init inputTensors - int LoadInput(); - - // call GenerateRandomData to fill inputTensors - int GenerateInputData(); - - int GenerateRandomData(size_t size, void *data, TypeId data_type); - - int ReadInputFile(); - - int ReadCalibData(); - - int ReadTensorData(std::ifstream &in_file_stream, const std::string &tensor_name, const std::vector &dims); - - int CompareOutput(); - - tensor::MSTensor *GetTensorByNameOrShape(const std::string &node_or_tensor_name, const std::vector &dims); - - tensor::MSTensor *GetTensorByNodeShape(const std::vector &node_shape); - - int CompareStringData(const std::string &name, tensor::MSTensor *tensor); - - int CompareDataGetTotalBiasAndSize(const std::string &name, tensor::MSTensor *tensor, float *total_bias, - int *total_size); - - int InitCallbackParameter(); - - int InitTimeProfilingCallbackParameter(); - - int InitPerfProfilingCallbackParameter(); - - int InitDumpProfilingCallbackParameter(); - - int PrintResult(const std::vector &title, const std::map> &result); - - void InitContext(const std::shared_ptr &context); - -#ifdef ENABLE_ARM64 - int PrintPerfResult(const std::vector &title, - const std::map> &result); -#endif - - int PrintInputData(); - - // tensorData need to be converter first - template - float CompareData(const std::string &nodeName, const std::vector &msShape, const void *tensor_data) { - const T *msTensorData = static_cast(tensor_data); - auto iter = this->benchmark_data_.find(nodeName); - if (iter != this->benchmark_data_.end()) { - std::vector castedMSShape; - size_t shapeSize = 1; - for (int64_t dim : msShape) { - castedMSShape.push_back(size_t(dim)); - shapeSize *= dim; - } - - CheckTensor *calibTensor = iter->second; - if (calibTensor->shape != castedMSShape) { - std::cout << "Shape of mslite output("; - for (auto dim : castedMSShape) { - std::cout << dim << ","; - } - std::cout << ") and shape source model output("; - for (auto dim : calibTensor->shape) { - std::cout << dim << ","; - } - std::cout << ") are different"; - return RET_ERROR; - } - size_t errorCount = 0; - float meanError = 0; - std::cout << "Data of node " << nodeName << " : "; - for (size_t j = 0; j < shapeSize; j++) { - if (j < kNumDefaultPrintLen) { - std::cout << static_cast(msTensorData[j]) << " "; - } - - if (std::isnan(msTensorData[j]) || std::isinf(msTensorData[j])) { - std::cerr << "Output tensor has nan or inf data, compare fail" << std::endl; - return RET_ERROR; - } - - auto tolerance = kNumAbsoluteTolerance + kNumRelativeTolerance * fabs(calibTensor->data.at(j)); - auto absoluteError = std::fabs(msTensorData[j] - calibTensor->data.at(j)); - if (absoluteError > tolerance) { - if (fabs(calibTensor->data.at(j) - 0.0f) < FLT_EPSILON) { - if (absoluteError > kNumMinAbsoluteError) { - meanError += absoluteError; - errorCount++; - } else { - continue; - } - } else { - // just assume that atol = rtol - meanError += absoluteError / (fabs(calibTensor->data.at(j)) + FLT_MIN); - errorCount++; - } - } - } - std::cout << std::endl; - if (meanError > 0.0f) { - meanError /= errorCount; - } - - if (meanError <= kNumMinMeanError) { - std::cout << "Mean bias of node/tensor " << nodeName << " : 0%" << std::endl; - } else { - std::cout << "Mean bias of node/tensor " << nodeName << " : " << meanError * kNumPercentage << "%" << std::endl; - } - return meanError; - } else { - std::cout << "%s is not in Source Model output" << nodeName.c_str(); - return RET_ERROR; - } - } - - template - void FillInputData(int size, void *data, Distribution distribution) { - if (data == nullptr) { - std::cout << "data is nullptr."; - return; - } - int elements_num = size / sizeof(T); - (void)std::generate_n(static_cast(data), elements_num, - [&]() { return static_cast(distribution(random_engine_)); }); - } - - int MarkPerformance(); - - int MarkAccuracy(); - - private: - struct Flag *flags_; - session::LiteSession *session_{nullptr}; - std::vector ms_inputs_; - std::unordered_map> ms_outputs_; - std::unordered_map benchmark_data_; - std::unordered_map data_type_map_{{"FLOAT", TypeId::kNumberTypeFloat}, - {"INT8", TypeId::kNumberTypeInt8}, - {"INT32", TypeId::kNumberTypeInt32}, - {"UINT8", TypeId::kNumberTypeUInt8}}; - TypeId msCalibDataType = TypeId::kNumberTypeFloat; - - // callback parameters - uint64_t op_begin_ = 0; - int op_call_times_total_ = 0; - float op_cost_total_ = 0.0f; - std::map> op_times_by_type_; - std::map> op_times_by_name_; -#ifdef ENABLE_ARM64 - int perf_fd = 0; - int perf_fd2 = 0; - float op_cost2_total_ = 0.0f; - std::map> op_perf_by_type_; - std::map> op_perf_by_name_; -#endif - KernelCallBack before_call_back_ = nullptr; - KernelCallBack after_call_back_ = nullptr; - std::mt19937 random_engine_; -}; -int RunBenchmark(Flag *flags); -int main_benchmark(); +int main_benchmark(std::string* model_path); } // namespace mindspore::lite #endif // MINNIE_BENCHMARK_BENCHMARK_H_ diff --git a/mindspore-src/source/mindspore/lite/src/CMakeLists.txt b/mindspore-src/source/mindspore/lite/src/CMakeLists.txt index 437ac2db68fe90953fe04a32ff798b3662fc9d75..087ca6785f5c6a323cf480b8785de6093536708a 100644 --- a/mindspore-src/source/mindspore/lite/src/CMakeLists.txt +++ b/mindspore-src/source/mindspore/lite/src/CMakeLists.txt @@ -50,10 +50,10 @@ if(APPLE OR PLATFORM_ARM32 OR PLATFORM_ARM64) if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-aliasing -ffunction-sections \ -fdata-sections -ffast-math -fno-rtti -Wno-shorten-64-to-32 \ - -fno-aligned-allocation -DTARGET_OS_OSX") + -fno-aligned-allocation") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-aliasing -ffunction-sections \ -fdata-sections -ffast-math -fno-rtti -Wno-shorten-64-to-32 \ - -fno-aligned-allocation -DTARGET_OS_OSX") + -fno-aligned-allocation") if(NOT MSLITE_ENABLE_COREML) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") diff --git a/mindspore-src/source/mindspore/lite/src/common/ops/CMakeLists.txt b/mindspore-src/source/mindspore/lite/src/common/ops/CMakeLists.txt index 43790c7d4598b18fdec90c608103055738a755b9..68819148b9034ebc8bc21941e406fcd050dec908 100644 --- a/mindspore-src/source/mindspore/lite/src/common/ops/CMakeLists.txt +++ b/mindspore-src/source/mindspore/lite/src/common/ops/CMakeLists.txt @@ -3,10 +3,10 @@ include_directories(${CCSRC_DIR}/plugin/device/cpu/kernel) if(APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-aliasing -ffunction-sections \ -fdata-sections -ffast-math -fno-rtti -fno-exceptions -Wno-shorten-64-to-32 \ - -fno-aligned-allocation -DTARGET_OS_OSX") + -fno-aligned-allocation") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-aliasing -ffunction-sections \ -fdata-sections -ffast-math -fno-rtti -fno-exceptions -Wno-shorten-64-to-32 \ - -fno-aligned-allocation -DTARGET_OS_OSX") + -fno-aligned-allocation") endif() file(GLOB OPS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cc diff --git a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_delegate.mm b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_delegate.mm index 9ef45841518700837dd1515ff250dc6e1e57d8ce..30aa12a905886ceef121e4e5eba124d11e9822f3 100644 --- a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_delegate.mm +++ b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_delegate.mm @@ -185,7 +185,7 @@ CoreMLOp *CoreMLDelegateImpl::GetOP(kernel::Kernel *kernel, const schema::Primit return nullptr; } - for (int i = 0; i < kernel->size(); i++) { + for (int i = 0; i < kernel->inputs().size(); i++) { mindspore::MSTensor tensor = kernel->inputs()[i]; if (tensor.DataType() == DataType::kNumberTypeFloat16 && tensor.Data() == nullptr) { tensor.SetDataType(DataType::kNumberTypeFloat32); diff --git a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_graph.cc b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_graph.cc index ace96a729c2d4ef01d54214c89f5f209e7a8c7bd..d7860a65842c56a2479462cff5be7d5c8c904365 100644 --- a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_graph.cc +++ b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/coreml_graph.cc @@ -35,7 +35,7 @@ void CoreMLGraph::set_input(mindspore::MSTensor in_tensor, int index) { MS_ASSERT(static_cast(index) < inputs_.size()); auto origin_tensor = this->inputs_[index]; for (auto kernel : all_kernels_) { - for (size_t i = 0; i < kernel->size(); i++) { + for (size_t i = 0; i < kernel->inputs().size(); i++) { if (kernel->inputs()[i] == origin_tensor) { kernel->set_input(in_tensor, i); } diff --git a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/pass/coreml_trans_extend_pass.cc b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/pass/coreml_trans_extend_pass.cc index d16fd0ee8a23713bfdd71f23585397b22d9b9423..9e09cdcc3a6f30bd287bb4f91755a860ee60f4b1 100644 --- a/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/pass/coreml_trans_extend_pass.cc +++ b/mindspore-src/source/mindspore/lite/src/litert/delegate/coreml/pass/coreml_trans_extend_pass.cc @@ -166,10 +166,7 @@ int CoreMLTransExtendPass::InsertTransNode(CoreMLOp *op, CoreMLOp *post_op, cons auto *nc2nh_op = CoreMLPassUtils::CreateNchw2NhwcOp(nh2nc_tensors, nc2nh_tensors, nc2nh_name); trans_ops->push_back(nc2nh_op); - if(nh2nc == nullptr){ - MS_LOG(ERROR) << "nh2nc_op is nullptr."; - return RET_ERROR; - } + CoreMLPassUtils::UpdateOp(nh2nc_op, in_ops, {nc2nh_op}, {trans_in_tensor}, nh2nc_tensors); if(nc2nh_op == nullptr){ MS_LOG(ERROR) << "nc2nh_op is nullptr."; diff --git a/mindspore-src/source/third_party/patch/robin_hood_hashing/0001-fix-unused-var-warning.patch b/mindspore-src/source/third_party/patch/robin_hood_hashing/0001-fix-unused-var-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..54b7857e253be93be0cd24de67d7d82e2be05be7 --- /dev/null +++ b/mindspore-src/source/third_party/patch/robin_hood_hashing/0001-fix-unused-var-warning.patch @@ -0,0 +1,60 @@ +diff --git a/src/include/robin_hood.h b/src/include/robin_hood.h +--- a/src/include/robin_hood.h ++++ b/src/include/robin_hood.h +@@ -2541,4 +2541,56 @@ using unordered_set = detail::Table ++struct tuple_size> : std::integral_constant {}; ++ ++template ++struct tuple_element> { ++ typedef typename std::conditional::type type; ++}; ++} // namespace std ++ ++namespace robin_hood { ++template ++typename std::enable_if::type get(robin_hood::pair &p) { ++ return p.first; ++} ++ ++template ++typename std::enable_if::type get(robin_hood::pair &p) { ++ return p.second; ++} ++ ++template ++typename std::enable_if::type get(const robin_hood::pair &p) { ++ return p.first; ++} ++ ++template ++typename std::enable_if::type get(const robin_hood::pair &p) { ++ return p.second; ++} ++ ++template ++typename std::enable_if::type get(robin_hood::pair &&p) { ++ return std::move(p.first); ++} ++ ++template ++typename std::enable_if::type get(robin_hood::pair &&p) { ++ return std::move(p.second); ++} ++ ++template ++typename std::enable_if::type get(const robin_hood::pair &&p) { ++ return std::move(p.first); ++} ++ ++template ++typename std::enable_if::type get(const robin_hood::pair &&p) { ++ return std::move(p.second); ++} ++} // namespace robin_hood ++ + #endif diff --git a/mindspore-src/source/third_party/patch/robin_hood_hashing/0002-fix-string-isflat-symbol.patch b/mindspore-src/source/third_party/patch/robin_hood_hashing/0002-fix-string-isflat-symbol.patch new file mode 100644 index 0000000000000000000000000000000000000000..45341d7d74259cc8eba4f2486efdf6188a064e12 --- /dev/null +++ b/mindspore-src/source/third_party/patch/robin_hood_hashing/0002-fix-string-isflat-symbol.patch @@ -0,0 +1,22 @@ +diff --git a/src/include/robin_hood.h b/src/include/robin_hood.h +--- a/src/include/robin_hood.h ++++ b/src/include/robin_hood.h +@@ -206,7 +206,7 @@ static Counts& counts() { + + // workaround missing "is_trivially_copyable" in g++ < 5.0 + // See https://stackoverflow.com/a/31798726/48181 +-#if defined(__GNUC__) && __GNUC__ < 5 ++#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) + # define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) __has_trivial_copy(__VA_ARGS__) + #else + # define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable<__VA_ARGS__>::value +@@ -2519,7 +2519,8 @@ + using unordered_map = + detail::Table) <= sizeof(size_t) * 6 && + std::is_nothrow_move_constructible>::value && +- std::is_nothrow_move_assignable>::value, ++ std::is_nothrow_move_assignable>::value && ++ !std::is_same::value, + MaxLoadFactor100, Key, T, Hash, KeyEqual>; + + // set