310 ocr suport dynamic hw
This commit is contained in:
parent
c0332b4fc7
commit
9f1c444178
|
@ -352,7 +352,7 @@ class MS_API Ascend310DeviceInfo : public DeviceInfoContext {
|
|||
|
||||
/// \brief Set the dynamic image size of model inputs.
|
||||
///
|
||||
/// \param[in] image size e.g. "66,66;88,88".
|
||||
/// \param[in] image size hw e.g. "66,88;32,64" means h1:66,w1:88; h2:32,w2:64.
|
||||
inline void SetDynamicImageSize(const std::string &dynamic_image_size);
|
||||
|
||||
/// \brief Get dynamic image size of model inputs.
|
||||
|
@ -444,9 +444,7 @@ void Ascend310DeviceInfo::SetDynamicImageSize(const std::string &dynamic_image_s
|
|||
SetDynamicImageSize(StringToChar(dynamic_image_size));
|
||||
}
|
||||
|
||||
std::string Ascend310DeviceInfo::GetDynamicImageSize() const {
|
||||
return CharToString(GetDynamicImageSizeChar());
|
||||
}
|
||||
std::string Ascend310DeviceInfo::GetDynamicImageSize() const { return CharToString(GetDynamicImageSizeChar()); }
|
||||
|
||||
void Ascend310DeviceInfo::SetPrecisionMode(const std::string &precision_mode) {
|
||||
SetPrecisionMode(StringToChar(precision_mode));
|
||||
|
|
|
@ -207,9 +207,9 @@ STATUS ModelProcess::CreateDataBuffer(void **data_mem_buffer, size_t buffer_size
|
|||
aclError ret;
|
||||
auto free_data_buffer = [this](void *dataMemBuffer) {
|
||||
if (!is_run_on_device_) {
|
||||
aclrtFree(dataMemBuffer);
|
||||
(void)aclrtFree(dataMemBuffer);
|
||||
} else {
|
||||
aclrtFreeHost(dataMemBuffer);
|
||||
(void)aclrtFreeHost(dataMemBuffer);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -213,11 +213,19 @@ STATUS AclPassImpl::DeparseGraph(const FuncGraphPtr &func_graph, const FuncGraph
|
|||
return lite::RET_OK;
|
||||
}
|
||||
|
||||
bool AclPassImpl::IsDynamicInput() {
|
||||
return !acl_model_option_cfg_.dynamic_image_size.empty() || !acl_model_option_cfg_.dynamic_batch_size.empty();
|
||||
}
|
||||
|
||||
STATUS AclPassImpl::CommonPass(const FuncGraphPtr &func_graph) {
|
||||
if (!lite::RunOptimizerPass(func_graph, {kRemoveRedundantOpPass})) {
|
||||
MS_LOG(ERROR) << "Remove redundant op pass failed.";
|
||||
return lite::RET_ERROR;
|
||||
}
|
||||
if (IsDynamicInput()) {
|
||||
MS_LOG(INFO) << "Dynamic input no need to run const fold pass.";
|
||||
return lite::RET_OK;
|
||||
}
|
||||
if (!lite::RunOptimizerPass(func_graph, {kConstFoldPass})) {
|
||||
MS_LOG(ERROR) << "Const fold pass failed.";
|
||||
return lite::RET_ERROR;
|
||||
|
|
|
@ -65,6 +65,7 @@ class AclPassImpl {
|
|||
void SetAclModelInitOptions(const std::shared_ptr<Ascend310DeviceInfo> &ascend310_info);
|
||||
void SetAclModelBuildOptions(const std::shared_ptr<Ascend310DeviceInfo> &ascend310_info);
|
||||
std::string AdjustCnodeName(const PrimitivePtr &prim);
|
||||
bool IsDynamicInput();
|
||||
|
||||
std::string device_type_;
|
||||
FmkType fmk_type_;
|
||||
|
|
Loading…
Reference in New Issue