diff --git a/mindspore/lite/minddata/CMakeLists.txt b/mindspore/lite/minddata/CMakeLists.txt index d13cd94764..4e7843d18d 100644 --- a/mindspore/lite/minddata/CMakeLists.txt +++ b/mindspore/lite/minddata/CMakeLists.txt @@ -110,6 +110,7 @@ if(BUILD_MINDDATA STREQUAL "full") ${TOP_DIR}/mindspore/lite/src/cxx_api/types.cc ${TOP_DIR}/mindspore/lite/src/cxx_api/tensor/tensor_impl.cc ${TOP_DIR}/mindspore/lite/src/tensor.cc + ${TOP_DIR}/mindspore/lite/src/ms_tensor.cc ${TOP_DIR}/mindspore/lite/src/common/string_util.cc ${CORE_DIR}/utils/status.cc ${MINDDATA_DIR}/api/datasets.cc diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 1601fbcc27..4b8f60fd16 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -54,6 +54,7 @@ set(LITE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/thread_pool.c ${CMAKE_CURRENT_SOURCE_DIR}/runtime/infer_manager.cc ${CMAKE_CURRENT_SOURCE_DIR}/tensor.cc + ${CMAKE_CURRENT_SOURCE_DIR}/ms_tensor.cc ${CMAKE_CURRENT_SOURCE_DIR}/tensorlist.cc ${CMAKE_CURRENT_SOURCE_DIR}/executor.cc ${CMAKE_CURRENT_SOURCE_DIR}/inner_context.cc diff --git a/mindspore/lite/src/common/loader_util.cc b/mindspore/lite/src/common/loader_util.cc index 07e7038c37..582723ef3c 100644 --- a/mindspore/lite/src/common/loader_util.cc +++ b/mindspore/lite/src/common/loader_util.cc @@ -24,18 +24,18 @@ namespace mindspore { namespace lite { -int SoLoader::Open(const char *SoPath, int mode) { - if ((strlen(SoPath)) >= PATH_MAX) { +int SoLoader::Open(const char *so_path, int mode) { + if ((strlen(so_path)) >= PATH_MAX) { MS_LOG(ERROR) << "path is too long"; return RET_ERROR; } char resolved_path[PATH_MAX]; - auto resolve_res = realpath(SoPath, resolved_path); + auto resolve_res = realpath(so_path, resolved_path); if (resolve_res == nullptr) { - MS_LOG(ERROR) << "PATH NOT EXITS"; + MS_LOG(ERROR) << "path not exist"; return RET_ERROR; } - handler_ = dlopen(SoPath, mode); + handler_ = dlopen(so_path, mode); if (handler_ == nullptr) { MS_LOG(ERROR) << "open path failed"; return RET_ERROR; @@ -43,7 +43,7 @@ int SoLoader::Open(const char *SoPath, int mode) { return RET_OK; } -void *SoLoader::GetFunc(const char *FuncName) { return dlsym(handler_, FuncName); } +void *SoLoader::GetFunc(const char *func_name) { return dlsym(handler_, func_name); } int SoLoader::Close() { auto close_res = dlclose(handler_); diff --git a/mindspore/lite/src/common/loader_util.h b/mindspore/lite/src/common/loader_util.h index c784f2b07f..2c01424d41 100644 --- a/mindspore/lite/src/common/loader_util.h +++ b/mindspore/lite/src/common/loader_util.h @@ -25,8 +25,8 @@ namespace lite { class SoLoader { public: - int Open(const char *SoPath, int mode = RTLD_LAZY); - void *GetFunc(const char *FuncName); + int Open(const char *so_path, int mode = RTLD_LAZY); + void *GetFunc(const char *func_name); int Close(); private: diff --git a/mindspore/lite/src/ms_tensor.cc b/mindspore/lite/src/ms_tensor.cc new file mode 100644 index 0000000000..b84029e992 --- /dev/null +++ b/mindspore/lite/src/ms_tensor.cc @@ -0,0 +1,38 @@ +/** + * 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/ms_tensor.h" +#include "src/tensor.h" + +namespace mindspore { +namespace tensor { + +tensor::MSTensor *tensor::MSTensor::CreateTensor(const std::string &name, TypeId type, const std::vector &shape, + const void *data, size_t data_len) { + auto tensor = new (std::nothrow) lite::Tensor(); + if (tensor == nullptr) { + MS_LOG(ERROR) << "Failed to allocate tensor."; + return nullptr; + } + tensor->set_data(const_cast(data)); + tensor->set_shape(shape); + tensor->set_tensor_name(name); + tensor->set_data_type(type); + return tensor; +} + +} // namespace tensor +} // namespace mindspore diff --git a/mindspore/lite/src/tensor.cc b/mindspore/lite/src/tensor.cc index c9f7ce85cc..047da46e8e 100644 --- a/mindspore/lite/src/tensor.cc +++ b/mindspore/lite/src/tensor.cc @@ -375,18 +375,4 @@ std::vector TensorVectorCast(const std::vector &sr } // namespace lite -tensor::MSTensor *tensor::MSTensor::CreateTensor(const std::string &name, TypeId type, const std::vector &shape, - const void *data, size_t data_len) { - auto tensor = new (std::nothrow) lite::Tensor(); - if (tensor == nullptr) { - MS_LOG(ERROR) << "Failed to allocate tensor."; - return nullptr; - } - tensor->set_data(const_cast(data)); - tensor->set_shape(shape); - tensor->set_tensor_name(name); - tensor->set_data_type(type); - return tensor; -} - } // namespace mindspore diff --git a/mindspore/lite/test/CMakeLists.txt b/mindspore/lite/test/CMakeLists.txt index b898e98502..87286fffdc 100644 --- a/mindspore/lite/test/CMakeLists.txt +++ b/mindspore/lite/test/CMakeLists.txt @@ -137,6 +137,7 @@ set(TEST_LITE_SRC ${LITE_DIR}/src/runtime/parallel_executor.cc ${LITE_DIR}/src/runtime/infer_manager.cc ${LITE_DIR}/src/tensor.cc + ${LITE_DIR}/src/ms_tensor.cc ${LITE_DIR}/src/tensorlist.cc ${LITE_DIR}/src/executor.cc ${LITE_DIR}/src/inner_context.cc diff --git a/mindspore/lite/tools/converter/CMakeLists.txt b/mindspore/lite/tools/converter/CMakeLists.txt index 9851c0ed55..9e37b2a2b6 100644 --- a/mindspore/lite/tools/converter/CMakeLists.txt +++ b/mindspore/lite/tools/converter/CMakeLists.txt @@ -104,6 +104,7 @@ set(LITE_SRC ${SRC_DIR}/runtime/infer_manager.cc ${SRC_DIR}/inner_context.cc ${SRC_DIR}/tensor.cc + ${SRC_DIR}/ms_tensor.cc ${SRC_DIR}/tensorlist.cc ${SRC_DIR}/kernel_registry.cc ${SRC_DIR}/lite_kernel.cc