Browse Source

!13839 [MS][LITE][Develop]add GetOutputsByNodeName

From: @lx0095
Reviewed-by: @zhang_xue_tong
Signed-off-by:
pull/13839/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
7647c06bfc
3 changed files with 9 additions and 2 deletions
  1. +5
    -0
      include/api/model.h
  2. +2
    -2
      mindspore/lite/src/cxx_api/tensor/tensor_impl.cc
  3. +2
    -0
      mindspore/lite/src/cxx_api/tensor/tensor_impl.h

+ 5
- 0
include/api/model.h View File

@@ -49,6 +49,7 @@ class MS_API Model {
std::vector<MSTensor> GetOutputs(); std::vector<MSTensor> GetOutputs();
inline std::vector<std::string> GetOutputTensorNames(); inline std::vector<std::string> GetOutputTensorNames();
inline MSTensor GetOutputByTensorName(const std::string &tensor_name); inline MSTensor GetOutputByTensorName(const std::string &tensor_name);
inline std::vector<MSTensor> GetOutputsByNodeName(const std::string &tensor_name);


static bool CheckModelSupport(enum DeviceType device_type, ModelType model_type); static bool CheckModelSupport(enum DeviceType device_type, ModelType model_type);


@@ -71,5 +72,9 @@ std::vector<std::string> Model::GetOutputTensorNames() { return VectorCharToStri
MSTensor Model::GetOutputByTensorName(const std::string &tensor_name) { MSTensor Model::GetOutputByTensorName(const std::string &tensor_name) {
return GetOutputByTensorName(StringToChar(tensor_name)); return GetOutputByTensorName(StringToChar(tensor_name));
} }

std::vector<MSTensor> Model::GetOutputsByNodeName(const std::string &tensor_name) {
return GetOutputsByNodeName(StringToChar(tensor_name));
}
} // namespace mindspore } // namespace mindspore
#endif // MINDSPORE_INCLUDE_API_MODEL_H #endif // MINDSPORE_INCLUDE_API_MODEL_H

+ 2
- 2
mindspore/lite/src/cxx_api/tensor/tensor_impl.cc View File

@@ -45,12 +45,12 @@ MSTensor::Impl *MSTensor::Impl::CreateTensorImpl(const std::string &name, enum D
MS_LOG(ERROR) << "Failed to allocate lite tensor."; MS_LOG(ERROR) << "Failed to allocate lite tensor.";
return nullptr; return nullptr;
} }
auto impl = new (std::nothrow) Impl();
auto impl = new (std::nothrow) Impl(lite_tensor);
if (impl == nullptr) { if (impl == nullptr) {
MS_LOG(ERROR) << "Failed to allocate tensor impl."; MS_LOG(ERROR) << "Failed to allocate tensor impl.";
return nullptr; return nullptr;
} }
impl->set_lite_tensor(lite_tensor);
impl->set_from_session(false);
return impl; return impl;
} }




+ 2
- 0
mindspore/lite/src/cxx_api/tensor/tensor_impl.h View File

@@ -149,6 +149,8 @@ class MSTensor::Impl {


void set_own_data(bool own_data) { own_data_ = own_data; } void set_own_data(bool own_data) { own_data_ = own_data; }


void set_from_session(bool from_session) { from_session_ = from_session; }

private: private:
tensor::MSTensor *lite_tensor_ = nullptr; tensor::MSTensor *lite_tensor_ = nullptr;
std::string tensor_name_ = ""; std::string tensor_name_ = "";


Loading…
Cancel
Save