• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2022-2023 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "minddata/dataset/kernels/image/dvpp/acl_adapter.h"
17 
18 #if !defined(_WIN32) && !defined(_WIN64)
19 #include <libgen.h>
20 #endif
21 
22 #include <algorithm>
23 
24 #include "utils/ms_context.h"
25 
26 namespace mindspore {
27 namespace dataset {
28 namespace {
29 #if defined(BUILD_LITE)
30 constexpr auto kAclPluginRelatedPath = "./libdvpp_utils.so";
31 #else
32 constexpr auto kAclPluginRelatedPath = "./lib/plugin/ascend/libdvpp_utils.so";
33 #endif
34 }  // namespace
GetInstance()35 AclAdapter &AclAdapter::GetInstance() {
36   static AclAdapter instance{};
37   static std::once_flag flag;
38   std::call_once(flag, []() { instance.InitPlugin(); });
39   return instance;
40 }
41 
InitPlugin()42 void AclAdapter::InitPlugin() {
43   if (plugin_handle_ != nullptr) {
44     return;
45   }
46 #if !defined(ENABLE_ACL) || defined(ENABLE_D)
47   // 310.tar.gz skip this check
48   if (MsContext::GetInstance() != nullptr && !MsContext::GetInstance()->IsAscendPluginLoaded()) {
49     return;
50   }
51 #endif
52 #if !defined(_WIN32) && !defined(_WIN64)
53   Dl_info dl_info;
54   if (dladdr(reinterpret_cast<void *>(AclAdapter::GetInstance), &dl_info) == 0) {
55     MS_LOG(INFO) << "Get dladdr error";
56     return;
57   }
58   std::string cur_so_path = dl_info.dli_fname;
59   std::string acl_plugin_path = std::string(dirname(cur_so_path.data())) + "/" + kAclPluginRelatedPath;
60 
61   plugin_handle_ = dlopen(acl_plugin_path.c_str(), RTLD_LAZY | RTLD_LOCAL);
62   if (plugin_handle_ == nullptr) {
63     MS_LOG(INFO) << "Cannot dlopen " << acl_plugin_path << ", result = " << GetDlErrorMsg()
64                  << ", it can be ignored if not running on ascend.";
65     return;
66   }
67 
68   create_dvpp_video_fun_obj_ = DlsymFuncObj(CreateDvppVideo, plugin_handle_);
69   init_dvpp_video_fun_obj_ = DlsymFuncObj(InitDvppVideo, plugin_handle_);
70   close_dvpp_video_fun_obj_ = DlsymFuncObj(CloseDvppVideo, plugin_handle_);
71   dvpp_video_dump_frame_fun_obj_ = DlsymFuncObj(DvppVideoDumpFrame, plugin_handle_);
72   init_resource_fun_obj_ = DlsymFuncObj(InitResource, plugin_handle_);
73   get_context_fun_obj_ = DlsymFuncObj(GetContext, plugin_handle_);
74   release_fun_obj_ = DlsymFuncObj(Release, plugin_handle_);
75   create_acl_process_with_resize_fun_obj_ = DlsymFuncObj(CreateAclProcessWithResize, plugin_handle_);
76   create_acl_process_with_para_fun_obj_ = DlsymFuncObj(CreateAclProcessWithPara, plugin_handle_);
77   create_acl_process_fun_obj_ = DlsymFuncObj(CreateAclProcess, plugin_handle_);
78   destroy_acl_process_fun_obj_ = DlsymFuncObj(DestroyAclProcess, plugin_handle_);
79   release_acl_process_fun_obj_ = DlsymFuncObj(ReleaseAclProcess, plugin_handle_);
80   init_acl_process_fun_obj_ = DlsymFuncObj(InitAclProcess, plugin_handle_);
81   get_context_from_acl_process_fun_obj_ = DlsymFuncObj(GetContextFromAclProcess, plugin_handle_);
82   get_stream_from_acl_process_fun_obj_ = DlsymFuncObj(GetStreamFromAclProcess, plugin_handle_);
83   jpeg_drc_with_data_fun_obj_ = DlsymFuncObj(JPEG_DRC_WITH_DATA, plugin_handle_);
84   jpeg_dr_with_data_fun_obj_ = DlsymFuncObj(JPEG_DR_WITH_DATA, plugin_handle_);
85   jpeg_d_with_data_fun_obj_ = DlsymFuncObj(JPEG_D_WITH_DATA, plugin_handle_);
86   jpeg_r_with_data_fun_obj_ = DlsymFuncObj(JPEG_R_WITH_DATA, plugin_handle_);
87   jpeg_c_with_data_fun_obj_ = DlsymFuncObj(JPEG_C_WITH_DATA, plugin_handle_);
88   png_d_with_data_fun_obj_ = DlsymFuncObj(PNG_D_WITH_DATA, plugin_handle_);
89   jpeg_drc_fun_obj_ = DlsymFuncObj(JPEG_DRC, plugin_handle_);
90   jpeg_dr_fun_obj_ = DlsymFuncObj(JPEG_DR, plugin_handle_);
91   jpeg_d_fun_obj_ = DlsymFuncObj(JPEG_D, plugin_handle_);
92   jpeg_r_fun_obj_ = DlsymFuncObj(JPEG_R, plugin_handle_);
93   jpeg_c_fun_obj_ = DlsymFuncObj(JPEG_C, plugin_handle_);
94   png_d_fun_obj_ = DlsymFuncObj(PNG_D, plugin_handle_);
95   get_memory_data_fun_obj_ = DlsymFuncObj(GetMemoryData, plugin_handle_);
96   get_croped_device_data_fun_obj_ = DlsymFuncObj(GetCropedDeviceData, plugin_handle_);
97   get_resized_device_data_fun_obj_ = DlsymFuncObj(GetResizedDeviceData, plugin_handle_);
98   get_decode_device_data_fun_obj_ = DlsymFuncObj(GetDecodeDeviceData, plugin_handle_);
99   h_2_d_sink_fun_obj_ = DlsymFuncObj(H2D_Sink, plugin_handle_);
100   d_2_h_pop_fun_obj_ = DlsymFuncObj(D2H_Pop, plugin_handle_);
101   device_memory_release_fun_obj_ = DlsymFuncObj(DeviceMemoryRelease, plugin_handle_);
102   set_resize_paras_fun_obj_ = DlsymFuncObj(SetResizeParas, plugin_handle_);
103   set_crop_paras_fun_obj_ = DlsymFuncObj(SetCropParas, plugin_handle_);
104   aclrt_malloc_host_fun_obj_ = DlsymFuncObj(aclrtMallocHost, plugin_handle_);
105   aclrt_free_host_fun_obj_ = DlsymFuncObj(aclrtFreeHost, plugin_handle_);
106   aclrt_memcpy_fun_obj_ = DlsymFuncObj(aclrtMemcpy, plugin_handle_);
107 #if !defined(BUILD_LITE) && defined(ENABLE_D)
108   // Ascend910B
109   dvpp_affine_fun_obj_ = DlsymFuncObj(DvppAffine, plugin_handle_);
110   dvpp_auto_contrast_fun_obj_ = DlsymFuncObj(DvppAutoContrast, plugin_handle_);
111   dvpp_brightness_fun_obj_ = DlsymFuncObj(DvppAdjustBrightness, plugin_handle_);
112   dvpp_contrast_fun_obj_ = DlsymFuncObj(DvppAdjustContrast, plugin_handle_);
113   dvpp_convert_color_fun_obj_ = DlsymFuncObj(DvppConvertColor, plugin_handle_);
114   dvpp_crop_fun_obj_ = DlsymFuncObj(DvppCrop, plugin_handle_);
115   dvpp_decode_fun_obj_ = DlsymFuncObj(DvppDecode, plugin_handle_);
116   dvpp_equalize_fun_obj_ = DlsymFuncObj(DvppEqualize, plugin_handle_);
117   dvpp_erase_fun_obj_ = DlsymFuncObj(DvppErase, plugin_handle_);
118   dvpp_gaussian_blur_fun_obj_ = DlsymFuncObj(DvppGaussianBlur, plugin_handle_);
119   dvpp_horizontal_flip_fun_obj_ = DlsymFuncObj(DvppHorizontalFlip, plugin_handle_);
120   dvpp_invert_fun_obj_ = DlsymFuncObj(DvppInvert, plugin_handle_);
121   dvpp_hue_fun_obj_ = DlsymFuncObj(DvppAdjustHue, plugin_handle_);
122   dvpp_normalize_fun_obj_ = DlsymFuncObj(DvppNormalize, plugin_handle_);
123   dvpp_pad_fun_obj_ = DlsymFuncObj(DvppPad, plugin_handle_);
124   dvpp_perspective_fun_obj_ = DlsymFuncObj(DvppPerspective, plugin_handle_);
125   dvpp_posterize_fun_obj_ = DlsymFuncObj(DvppPosterize, plugin_handle_);
126   dvpp_resize_fun_obj_ = DlsymFuncObj(DvppResize, plugin_handle_);
127   dvpp_resized_crop_fun_obj_ = DlsymFuncObj(DvppResizedCrop, plugin_handle_);
128   dvpp_rotate_fun_obj_ = DlsymFuncObj(DvppRotate, plugin_handle_);
129   dvpp_saturation_fun_obj_ = DlsymFuncObj(DvppAdjustSaturation, plugin_handle_);
130   dvpp_sharpness_fun_obj_ = DlsymFuncObj(DvppAdjustSharpness, plugin_handle_);
131   dvpp_solarize_fun_obj_ = DlsymFuncObj(DvppSolarize, plugin_handle_);
132   dvpp_vertical_flip_fun_obj_ = DlsymFuncObj(DvppVerticalFlip, plugin_handle_);
133 
134   // acl
135   get_soc_name_fun_obj_ = DlsymFuncObj(GetSocName, plugin_handle_);
136   create_acl_tensor_fun_obj_ = DlsymFuncObj(CreateAclTensor, plugin_handle_);
137   destroy_tensor_fun_obj_ = DlsymFuncObj(DestroyTensor, plugin_handle_);
138   destroy_float_array_fun_obj_ = DlsymFuncObj(DestroyFloatArray, plugin_handle_);
139   destroy_int_array_fun_obj_ = DlsymFuncObj(DestroyIntArray, plugin_handle_);
140 #endif
141 #endif
142 }
143 
FinalizePlugin()144 void AclAdapter::FinalizePlugin() {
145   if (plugin_handle_ == nullptr) {
146     return;
147   }
148 
149   create_dvpp_video_fun_obj_ = nullptr;
150   init_dvpp_video_fun_obj_ = nullptr;
151   close_dvpp_video_fun_obj_ = nullptr;
152   dvpp_video_dump_frame_fun_obj_ = nullptr;
153   init_resource_fun_obj_ = nullptr;
154   get_context_fun_obj_ = nullptr;
155   release_fun_obj_ = nullptr;
156   create_acl_process_with_resize_fun_obj_ = nullptr;
157   create_acl_process_with_para_fun_obj_ = nullptr;
158   create_acl_process_fun_obj_ = nullptr;
159   destroy_acl_process_fun_obj_ = nullptr;
160   release_acl_process_fun_obj_ = nullptr;
161   init_acl_process_fun_obj_ = nullptr;
162   get_context_from_acl_process_fun_obj_ = nullptr;
163   get_stream_from_acl_process_fun_obj_ = nullptr;
164   jpeg_drc_with_data_fun_obj_ = nullptr;
165   jpeg_dr_with_data_fun_obj_ = nullptr;
166   jpeg_d_with_data_fun_obj_ = nullptr;
167   jpeg_r_with_data_fun_obj_ = nullptr;
168   jpeg_c_with_data_fun_obj_ = nullptr;
169   png_d_with_data_fun_obj_ = nullptr;
170   jpeg_drc_fun_obj_ = nullptr;
171   jpeg_dr_fun_obj_ = nullptr;
172   jpeg_d_fun_obj_ = nullptr;
173   jpeg_r_fun_obj_ = nullptr;
174   jpeg_c_fun_obj_ = nullptr;
175   png_d_fun_obj_ = nullptr;
176   get_memory_data_fun_obj_ = nullptr;
177   get_croped_device_data_fun_obj_ = nullptr;
178   get_resized_device_data_fun_obj_ = nullptr;
179   get_decode_device_data_fun_obj_ = nullptr;
180   h_2_d_sink_fun_obj_ = nullptr;
181   d_2_h_pop_fun_obj_ = nullptr;
182   device_memory_release_fun_obj_ = nullptr;
183   set_resize_paras_fun_obj_ = nullptr;
184   set_crop_paras_fun_obj_ = nullptr;
185   aclrt_malloc_host_fun_obj_ = nullptr;
186   aclrt_free_host_fun_obj_ = nullptr;
187   aclrt_memcpy_fun_obj_ = nullptr;
188 #if !defined(BUILD_LITE) && defined(ENABLE_D)
189   // Ascend910B
190   dvpp_affine_fun_obj_ = nullptr;
191   dvpp_auto_contrast_fun_obj_ = nullptr;
192   dvpp_brightness_fun_obj_ = nullptr;
193   dvpp_contrast_fun_obj_ = nullptr;
194   dvpp_convert_color_fun_obj_ = nullptr;
195   dvpp_crop_fun_obj_ = nullptr;
196   dvpp_decode_fun_obj_ = nullptr;
197   dvpp_equalize_fun_obj_ = nullptr;
198   dvpp_erase_fun_obj_ = nullptr;
199   dvpp_gaussian_blur_fun_obj_ = nullptr;
200   dvpp_horizontal_flip_fun_obj_ = nullptr;
201   dvpp_invert_fun_obj_ = nullptr;
202   dvpp_hue_fun_obj_ = nullptr;
203   dvpp_normalize_fun_obj_ = nullptr;
204   dvpp_pad_fun_obj_ = nullptr;
205   dvpp_perspective_fun_obj_ = nullptr;
206   dvpp_posterize_fun_obj_ = nullptr;
207   dvpp_resize_fun_obj_ = nullptr;
208   dvpp_resized_crop_fun_obj_ = nullptr;
209   dvpp_rotate_fun_obj_ = nullptr;
210   dvpp_saturation_fun_obj_ = nullptr;
211   dvpp_sharpness_fun_obj_ = nullptr;
212   dvpp_solarize_fun_obj_ = nullptr;
213   dvpp_vertical_flip_fun_obj_ = nullptr;
214 
215   // acl
216   get_soc_name_fun_obj_ = nullptr;
217   create_acl_tensor_fun_obj_ = nullptr;
218   destroy_tensor_fun_obj_ = nullptr;
219   destroy_float_array_fun_obj_ = nullptr;
220   destroy_int_array_fun_obj_ = nullptr;
221 #endif
222 #if !defined(_WIN32) && !defined(_WIN64)
223   (void)dlclose(plugin_handle_);
224 #endif
225   plugin_handle_ = nullptr;
226 }
227 
CreateDvppVideo(void * context,uint8_t * data,uint32_t size,uint32_t width,uint32_t height,uint32_t type,uint32_t out_format,const std::string & output) const228 void *AclAdapter::CreateDvppVideo(void *context, uint8_t *data, uint32_t size, uint32_t width, uint32_t height,
229                                   uint32_t type, uint32_t out_format, const std::string &output) const {
230   if (!HasAclPlugin() || create_dvpp_video_fun_obj_ == nullptr) {
231     return nullptr;
232   }
233   return create_dvpp_video_fun_obj_(context, data, size, width, height, type, out_format, output);
234 }
235 
InitDvppVideo(void * dvpp_video) const236 AclLiteError AclAdapter::InitDvppVideo(void *dvpp_video) const {
237   if (!HasAclPlugin() || init_dvpp_video_fun_obj_ == nullptr) {
238     return ACLLITE_ERROR;
239   }
240   return init_dvpp_video_fun_obj_(dvpp_video);
241 }
242 
CloseDvppVideo(void * dvpp_video) const243 AclLiteError AclAdapter::CloseDvppVideo(void *dvpp_video) const {
244   if (!HasAclPlugin() || close_dvpp_video_fun_obj_ == nullptr) {
245     return ACLLITE_ERROR;
246   }
247   return close_dvpp_video_fun_obj_(dvpp_video);
248 }
249 
DvppVideoDumpFrame(void * dvpp_video) const250 AclLiteError AclAdapter::DvppVideoDumpFrame(void *dvpp_video) const {
251   if (!HasAclPlugin() || dvpp_video_dump_frame_fun_obj_ == nullptr) {
252     return ACLLITE_ERROR;
253   }
254   return dvpp_video_dump_frame_fun_obj_(dvpp_video);
255 }
256 
InitResource(ResourceInfo * resource_info) const257 APP_ERROR AclAdapter::InitResource(ResourceInfo *resource_info) const {
258   if (!HasAclPlugin() || init_resource_fun_obj_ == nullptr || resource_info == nullptr) {
259     return APP_ERR_ACL_FAILURE;
260   }
261   return init_resource_fun_obj_(*resource_info);
262 }
263 
GetContext(int device_id) const264 void *AclAdapter::GetContext(int device_id) const {
265   if (!HasAclPlugin() || get_context_fun_obj_ == nullptr) {
266     return nullptr;
267   }
268   return get_context_fun_obj_(device_id);
269 }
270 
Release() const271 void AclAdapter::Release() const {
272   if (!HasAclPlugin() || release_fun_obj_ == nullptr) {
273     return;
274   }
275   release_fun_obj_();
276 }
277 
CreateAclProcessWithResize(uint32_t resize_width,uint32_t resize_height,uint32_t crop_width,uint32_t crop_height,void * context,bool is_crop,void * stream,const std::shared_ptr<DvppCommon> & dvpp_common) const278 void *AclAdapter::CreateAclProcessWithResize(uint32_t resize_width, uint32_t resize_height, uint32_t crop_width,
279                                              uint32_t crop_height, void *context, bool is_crop, void *stream,
280                                              const std::shared_ptr<DvppCommon> &dvpp_common) const {
281   if (!HasAclPlugin() || create_acl_process_with_resize_fun_obj_ == nullptr) {
282     return nullptr;
283   }
284   return create_acl_process_with_resize_fun_obj_(resize_width, resize_height, crop_width, crop_height, context, is_crop,
285                                                  stream, dvpp_common);
286 }
287 
CreateAclProcessWithPara(uint32_t para_width,uint32_t para_height,void * context,bool is_crop,void * stream,const std::shared_ptr<DvppCommon> & dvpp_common) const288 void *AclAdapter::CreateAclProcessWithPara(uint32_t para_width, uint32_t para_height, void *context, bool is_crop,
289                                            void *stream, const std::shared_ptr<DvppCommon> &dvpp_common) const {
290   if (!HasAclPlugin() || create_acl_process_with_para_fun_obj_ == nullptr) {
291     return nullptr;
292   }
293   return create_acl_process_with_para_fun_obj_(para_width, para_height, context, is_crop, stream, dvpp_common);
294 }
295 
CreateAclProcess(void * context,bool is_crop,void * stream,const std::shared_ptr<DvppCommon> & dvpp_common) const296 void *AclAdapter::CreateAclProcess(void *context, bool is_crop, void *stream,
297                                    const std::shared_ptr<DvppCommon> &dvpp_common) const {
298   if (!HasAclPlugin() || create_acl_process_fun_obj_ == nullptr) {
299     return nullptr;
300   }
301   return create_acl_process_fun_obj_(context, is_crop, stream, dvpp_common);
302 }
303 
DestroyAclProcess(void * acl_process) const304 void AclAdapter::DestroyAclProcess(void *acl_process) const {
305   if (!HasAclPlugin() || destroy_acl_process_fun_obj_ == nullptr) {
306     return;
307   }
308   destroy_acl_process_fun_obj_(acl_process);
309 }
310 
ReleaseAclProcess(void * acl_process) const311 APP_ERROR AclAdapter::ReleaseAclProcess(void *acl_process) const {
312   if (!HasAclPlugin() || release_acl_process_fun_obj_ == nullptr) {
313     return APP_ERR_ACL_FAILURE;
314   }
315   return release_acl_process_fun_obj_(acl_process);
316 }
317 
InitAclProcess(void * acl_process) const318 APP_ERROR AclAdapter::InitAclProcess(void *acl_process) const {
319   if (!HasAclPlugin() || init_acl_process_fun_obj_ == nullptr) {
320     return APP_ERR_ACL_FAILURE;
321   }
322   return init_acl_process_fun_obj_(acl_process);
323 }
324 
GetContextFromAclProcess(void * acl_process) const325 void *AclAdapter::GetContextFromAclProcess(void *acl_process) const {
326   if (!HasAclPlugin() || get_context_from_acl_process_fun_obj_ == nullptr) {
327     return nullptr;
328   }
329   return get_context_from_acl_process_fun_obj_(acl_process);
330 }
331 
GetStreamFromAclProcess(void * acl_process) const332 void *AclAdapter::GetStreamFromAclProcess(void *acl_process) const {
333   if (!HasAclPlugin() || get_stream_from_acl_process_fun_obj_ == nullptr) {
334     return nullptr;
335   }
336   return get_stream_from_acl_process_fun_obj_(acl_process);
337 }
338 
JPEG_DRC_WITH_DATA(void * acl_process,const RawData & data) const339 APP_ERROR AclAdapter::JPEG_DRC_WITH_DATA(void *acl_process, const RawData &data) const {
340   if (!HasAclPlugin() || jpeg_drc_with_data_fun_obj_ == nullptr) {
341     return APP_ERR_ACL_FAILURE;
342   }
343   return jpeg_drc_with_data_fun_obj_(acl_process, data);
344 }
345 
JPEG_DR_WITH_DATA(void * acl_process,const RawData & data) const346 APP_ERROR AclAdapter::JPEG_DR_WITH_DATA(void *acl_process, const RawData &data) const {
347   if (!HasAclPlugin() || jpeg_dr_with_data_fun_obj_ == nullptr) {
348     return APP_ERR_ACL_FAILURE;
349   }
350   return jpeg_dr_with_data_fun_obj_(acl_process, data);
351 }
352 
JPEG_D_WITH_DATA(void * acl_process,const RawData & data) const353 APP_ERROR AclAdapter::JPEG_D_WITH_DATA(void *acl_process, const RawData &data) const {
354   if (!HasAclPlugin() || jpeg_d_with_data_fun_obj_ == nullptr) {
355     return APP_ERR_ACL_FAILURE;
356   }
357   return jpeg_d_with_data_fun_obj_(acl_process, data);
358 }
359 
JPEG_R_WITH_DATA(void * acl_process,const DvppDataInfo & data) const360 APP_ERROR AclAdapter::JPEG_R_WITH_DATA(void *acl_process, const DvppDataInfo &data) const {
361   if (!HasAclPlugin() || jpeg_r_with_data_fun_obj_ == nullptr) {
362     return APP_ERR_ACL_FAILURE;
363   }
364   return jpeg_r_with_data_fun_obj_(acl_process, data);
365 }
366 
JPEG_C_WITH_DATA(void * acl_process,const DvppDataInfo & data) const367 APP_ERROR AclAdapter::JPEG_C_WITH_DATA(void *acl_process, const DvppDataInfo &data) const {
368   if (!HasAclPlugin() || jpeg_c_with_data_fun_obj_ == nullptr) {
369     return APP_ERR_ACL_FAILURE;
370   }
371   return jpeg_c_with_data_fun_obj_(acl_process, data);
372 }
373 
PNG_D_WITH_DATA(void * acl_process,const RawData & data) const374 APP_ERROR AclAdapter::PNG_D_WITH_DATA(void *acl_process, const RawData &data) const {
375   if (!HasAclPlugin() || png_d_with_data_fun_obj_ == nullptr) {
376     return APP_ERR_ACL_FAILURE;
377   }
378   return png_d_with_data_fun_obj_(acl_process, data);
379 }
380 
JPEG_DRC(void * acl_process) const381 APP_ERROR AclAdapter::JPEG_DRC(void *acl_process) const {
382   if (!HasAclPlugin() || jpeg_drc_fun_obj_ == nullptr) {
383     return APP_ERR_ACL_FAILURE;
384   }
385   return jpeg_drc_fun_obj_(acl_process);
386 }
387 
JPEG_DR(void * acl_process) const388 APP_ERROR AclAdapter::JPEG_DR(void *acl_process) const {
389   if (!HasAclPlugin() || jpeg_dr_fun_obj_ == nullptr) {
390     return APP_ERR_ACL_FAILURE;
391   }
392   return jpeg_dr_fun_obj_(acl_process);
393 }
394 
JPEG_D(void * acl_process) const395 APP_ERROR AclAdapter::JPEG_D(void *acl_process) const {
396   if (!HasAclPlugin() || jpeg_d_fun_obj_ == nullptr) {
397     return APP_ERR_ACL_FAILURE;
398   }
399   return jpeg_d_fun_obj_(acl_process);
400 }
401 
JPEG_R(void * acl_process,const std::string & last_step) const402 APP_ERROR AclAdapter::JPEG_R(void *acl_process, const std::string &last_step) const {
403   if (!HasAclPlugin() || jpeg_r_fun_obj_ == nullptr) {
404     return APP_ERR_ACL_FAILURE;
405   }
406   return jpeg_r_fun_obj_(acl_process, last_step);
407 }
408 
JPEG_C(void * acl_process,const std::string & last_step) const409 APP_ERROR AclAdapter::JPEG_C(void *acl_process, const std::string &last_step) const {
410   if (!HasAclPlugin() || jpeg_c_fun_obj_ == nullptr) {
411     return APP_ERR_ACL_FAILURE;
412   }
413   return jpeg_c_fun_obj_(acl_process, last_step);
414 }
415 
PNG_D(void * acl_process) const416 APP_ERROR AclAdapter::PNG_D(void *acl_process) const {
417   if (!HasAclPlugin() || png_d_fun_obj_ == nullptr) {
418     return APP_ERR_ACL_FAILURE;
419   }
420   return png_d_fun_obj_(acl_process);
421 }
422 
GetMemoryData(void * acl_process) const423 void *AclAdapter::GetMemoryData(void *acl_process) const {
424   if (!HasAclPlugin() || get_memory_data_fun_obj_ == nullptr) {
425     return nullptr;
426   }
427   return get_memory_data_fun_obj_(acl_process);
428 }
429 
GetCropedDeviceData(void * acl_process) const430 DvppDataInfo *AclAdapter::GetCropedDeviceData(void *acl_process) const {
431   if (!HasAclPlugin() || get_croped_device_data_fun_obj_ == nullptr) {
432     return nullptr;
433   }
434   return get_croped_device_data_fun_obj_(acl_process);
435 }
436 
GetResizedDeviceData(void * acl_process) const437 DvppDataInfo *AclAdapter::GetResizedDeviceData(void *acl_process) const {
438   if (!HasAclPlugin() || get_resized_device_data_fun_obj_ == nullptr) {
439     return nullptr;
440   }
441   return get_resized_device_data_fun_obj_(acl_process);
442 }
443 
GetDecodeDeviceData(void * acl_process) const444 DvppDataInfo *AclAdapter::GetDecodeDeviceData(void *acl_process) const {
445   if (!HasAclPlugin() || get_decode_device_data_fun_obj_ == nullptr) {
446     return nullptr;
447   }
448   return get_decode_device_data_fun_obj_(acl_process);
449 }
450 
H2D_Sink(void * acl_process,const std::shared_ptr<mindspore::dataset::Tensor> & input,std::shared_ptr<mindspore::dataset::DeviceTensor> * device_input) const451 APP_ERROR AclAdapter::H2D_Sink(void *acl_process, const std::shared_ptr<mindspore::dataset::Tensor> &input,
452                                std::shared_ptr<mindspore::dataset::DeviceTensor> *device_input) const {
453   if (!HasAclPlugin() || h_2_d_sink_fun_obj_ == nullptr || device_input == nullptr) {
454     return APP_ERR_ACL_FAILURE;
455   }
456   return h_2_d_sink_fun_obj_(acl_process, input, *device_input);
457 }
458 
D2H_Pop(void * acl_process,const std::shared_ptr<mindspore::dataset::DeviceTensor> & device_output,std::shared_ptr<mindspore::dataset::Tensor> * output) const459 APP_ERROR AclAdapter::D2H_Pop(void *acl_process, const std::shared_ptr<mindspore::dataset::DeviceTensor> &device_output,
460                               std::shared_ptr<mindspore::dataset::Tensor> *output) const {
461   if (!HasAclPlugin() || d_2_h_pop_fun_obj_ == nullptr || output == nullptr) {
462     return APP_ERR_ACL_FAILURE;
463   }
464   return d_2_h_pop_fun_obj_(acl_process, device_output, *output);
465 }
466 
DeviceMemoryRelease(void * acl_process) const467 APP_ERROR AclAdapter::DeviceMemoryRelease(void *acl_process) const {
468   if (!HasAclPlugin() || device_memory_release_fun_obj_ == nullptr) {
469     return APP_ERR_ACL_FAILURE;
470   }
471   return device_memory_release_fun_obj_(acl_process);
472 }
473 
SetResizeParas(void * acl_process,uint32_t width,uint32_t height) const474 APP_ERROR AclAdapter::SetResizeParas(void *acl_process, uint32_t width, uint32_t height) const {
475   if (!HasAclPlugin() || set_resize_paras_fun_obj_ == nullptr) {
476     return APP_ERR_ACL_FAILURE;
477   }
478   return set_resize_paras_fun_obj_(acl_process, width, height);
479 }
480 
SetCropParas(void * acl_process,uint32_t width,uint32_t height) const481 APP_ERROR AclAdapter::SetCropParas(void *acl_process, uint32_t width, uint32_t height) const {
482   if (!HasAclPlugin() || set_crop_paras_fun_obj_ == nullptr) {
483     return APP_ERR_ACL_FAILURE;
484   }
485   return set_crop_paras_fun_obj_(acl_process, width, height);
486 }
487 
Memcpy(void * dst,size_t dest_max,const void * src,size_t count,int kind) const488 int AclAdapter::Memcpy(void *dst, size_t dest_max, const void *src, size_t count, int kind) const {
489   if (!HasAclPlugin() || aclrt_memcpy_fun_obj_ == nullptr) {
490     return APP_ERR_ACL_FAILURE;
491   }
492   return aclrt_memcpy_fun_obj_(dst, dest_max, src, count, kind);
493 }
494 
MallocHost(void ** host_ptr,size_t size) const495 int AclAdapter::MallocHost(void **host_ptr, size_t size) const {
496   if (!HasAclPlugin() || aclrt_malloc_host_fun_obj_ == nullptr) {
497     return APP_ERR_ACL_FAILURE;
498   }
499   return aclrt_malloc_host_fun_obj_(host_ptr, size);
500 }
501 
FreeHost(void * host_ptr) const502 int AclAdapter::FreeHost(void *host_ptr) const {
503   if (!HasAclPlugin() || aclrt_free_host_fun_obj_ == nullptr) {
504     return APP_ERR_ACL_FAILURE;
505   }
506   return aclrt_free_host_fun_obj_(host_ptr);
507 }
508 
509 #if !defined(BUILD_LITE) && defined(ENABLE_D)
510 // Ascend910B
DvppAdjustBrightness(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float factor)511 APP_ERROR AclAdapter::DvppAdjustBrightness(const std::shared_ptr<DeviceTensorAscend910B> &input,
512                                            std::shared_ptr<DeviceTensorAscend910B> *output, float factor) {
513   if (!HasAclPlugin() || dvpp_brightness_fun_obj_ == nullptr) {
514     return APP_ERR_ACL_FAILURE;
515   }
516   return dvpp_brightness_fun_obj_(input, output, factor);
517 }
518 
DvppAdjustContrast(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float factor)519 APP_ERROR AclAdapter::DvppAdjustContrast(const std::shared_ptr<DeviceTensorAscend910B> &input,
520                                          std::shared_ptr<DeviceTensorAscend910B> *output, float factor) {
521   if (!HasAclPlugin() || dvpp_contrast_fun_obj_ == nullptr) {
522     return APP_ERR_ACL_FAILURE;
523   }
524   return dvpp_contrast_fun_obj_(input, output, factor);
525 }
526 
DvppAdjustHue(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float factor)527 APP_ERROR AclAdapter::DvppAdjustHue(const std::shared_ptr<DeviceTensorAscend910B> &input,
528                                     std::shared_ptr<DeviceTensorAscend910B> *output, float factor) {
529   if (!HasAclPlugin() || dvpp_hue_fun_obj_ == nullptr) {
530     return APP_ERR_ACL_FAILURE;
531   }
532   return dvpp_hue_fun_obj_(input, output, factor);
533 }
534 
DvppAdjustSaturation(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float factor)535 APP_ERROR AclAdapter::DvppAdjustSaturation(const std::shared_ptr<DeviceTensorAscend910B> &input,
536                                            std::shared_ptr<DeviceTensorAscend910B> *output, float factor) {
537   if (!HasAclPlugin() || dvpp_saturation_fun_obj_ == nullptr) {
538     return APP_ERR_ACL_FAILURE;
539   }
540   return dvpp_saturation_fun_obj_(input, output, factor);
541 }
542 
DvppAdjustSharpness(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float factor)543 APP_ERROR AclAdapter::DvppAdjustSharpness(const std::shared_ptr<DeviceTensorAscend910B> &input,
544                                           std::shared_ptr<DeviceTensorAscend910B> *output, float factor) {
545   if (!HasAclPlugin() || dvpp_sharpness_fun_obj_ == nullptr) {
546     return APP_ERR_ACL_FAILURE;
547   }
548   return dvpp_sharpness_fun_obj_(input, output, factor);
549 }
550 
DvppAffine(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<float> & matrix,uint32_t interpolation_mode,uint32_t padding_mode,const std::vector<float> & fill)551 APP_ERROR AclAdapter::DvppAffine(const std::shared_ptr<DeviceTensorAscend910B> &input,
552                                  std::shared_ptr<DeviceTensorAscend910B> *output, const std::vector<float> &matrix,
553                                  uint32_t interpolation_mode, uint32_t padding_mode, const std::vector<float> &fill) {
554   if (!HasAclPlugin() || dvpp_affine_fun_obj_ == nullptr) {
555     return APP_ERR_ACL_FAILURE;
556   }
557   return dvpp_affine_fun_obj_(input, output, matrix, interpolation_mode, padding_mode, fill);
558 }
559 
DvppAutoContrast(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<float> & cutoff,const std::vector<uint32_t> & ignore)560 APP_ERROR AclAdapter::DvppAutoContrast(const std::shared_ptr<DeviceTensorAscend910B> &input,
561                                        std::shared_ptr<DeviceTensorAscend910B> *output,
562                                        const std::vector<float> &cutoff, const std::vector<uint32_t> &ignore) {
563   if (!HasAclPlugin() || dvpp_auto_contrast_fun_obj_ == nullptr) {
564     return APP_ERR_ACL_FAILURE;
565   }
566   return dvpp_auto_contrast_fun_obj_(input, output, cutoff, ignore);
567 }
568 
DvppConvertColor(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,ConvertMode convertMode)569 APP_ERROR AclAdapter::DvppConvertColor(const std::shared_ptr<DeviceTensorAscend910B> &input,
570                                        std::shared_ptr<DeviceTensorAscend910B> *output, ConvertMode convertMode) {
571   if (!HasAclPlugin() || dvpp_convert_color_fun_obj_ == nullptr) {
572     return APP_ERR_ACL_FAILURE;
573   }
574   return dvpp_convert_color_fun_obj_(input, output, convertMode);
575 }
576 
DvppCrop(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,uint32_t top,uint32_t left,uint32_t height,uint32_t width)577 APP_ERROR AclAdapter::DvppCrop(const std::shared_ptr<DeviceTensorAscend910B> &input,
578                                std::shared_ptr<DeviceTensorAscend910B> *output, uint32_t top, uint32_t left,
579                                uint32_t height, uint32_t width) {
580   if (!HasAclPlugin() || dvpp_crop_fun_obj_ == nullptr) {
581     return APP_ERR_ACL_FAILURE;
582   }
583   return dvpp_crop_fun_obj_(input, output, top, left, height, width);
584 }
585 
DvppDecode(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output)586 APP_ERROR AclAdapter::DvppDecode(const std::shared_ptr<DeviceTensorAscend910B> &input,
587                                  std::shared_ptr<DeviceTensorAscend910B> *output) {
588   if (!HasAclPlugin() || dvpp_decode_fun_obj_ == nullptr) {
589     return APP_ERR_ACL_FAILURE;
590   }
591   return dvpp_decode_fun_obj_(input, output);
592 }
593 
DvppEqualize(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output)594 APP_ERROR AclAdapter::DvppEqualize(const std::shared_ptr<DeviceTensorAscend910B> &input,
595                                    std::shared_ptr<DeviceTensorAscend910B> *output) {
596   if (!HasAclPlugin() || dvpp_equalize_fun_obj_ == nullptr) {
597     return APP_ERR_ACL_FAILURE;
598   }
599   return dvpp_equalize_fun_obj_(input, output);
600 }
601 
DvppErase(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,uint32_t top,uint32_t left,uint32_t height,uint32_t width,const std::vector<float> & value)602 APP_ERROR AclAdapter::DvppErase(const std::shared_ptr<DeviceTensorAscend910B> &input,
603                                 std::shared_ptr<DeviceTensorAscend910B> *output, uint32_t top, uint32_t left,
604                                 uint32_t height, uint32_t width, const std::vector<float> &value) {
605   if (!HasAclPlugin() || dvpp_erase_fun_obj_ == nullptr) {
606     return APP_ERR_ACL_FAILURE;
607   }
608   return dvpp_erase_fun_obj_(input, output, top, left, height, width, value);
609 }
610 
DvppGaussianBlur(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<int64_t> & kernel_size,const std::vector<float> & sigma,uint32_t padding_mode)611 APP_ERROR AclAdapter::DvppGaussianBlur(const std::shared_ptr<DeviceTensorAscend910B> &input,
612                                        std::shared_ptr<DeviceTensorAscend910B> *output,
613                                        const std::vector<int64_t> &kernel_size, const std::vector<float> &sigma,
614                                        uint32_t padding_mode) {
615   if (!HasAclPlugin() || dvpp_gaussian_blur_fun_obj_ == nullptr) {
616     return APP_ERR_ACL_FAILURE;
617   }
618   return dvpp_gaussian_blur_fun_obj_(input, output, kernel_size, sigma, padding_mode);
619 }
620 
DvppHorizontalFlip(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output)621 APP_ERROR AclAdapter::DvppHorizontalFlip(const std::shared_ptr<DeviceTensorAscend910B> &input,
622                                          std::shared_ptr<DeviceTensorAscend910B> *output) {
623   if (!HasAclPlugin() || dvpp_horizontal_flip_fun_obj_ == nullptr) {
624     return APP_ERR_ACL_FAILURE;
625   }
626   return dvpp_horizontal_flip_fun_obj_(input, output);
627 }
628 
DvppInvert(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output)629 APP_ERROR AclAdapter::DvppInvert(const std::shared_ptr<DeviceTensorAscend910B> &input,
630                                  std::shared_ptr<DeviceTensorAscend910B> *output) {
631   if (!HasAclPlugin() || dvpp_invert_fun_obj_ == nullptr) {
632     return APP_ERR_ACL_FAILURE;
633   }
634   return dvpp_invert_fun_obj_(input, output);
635 }
636 
DvppNormalize(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,std::vector<float> mean,std::vector<float> std,bool is_hwc)637 APP_ERROR AclAdapter::DvppNormalize(const std::shared_ptr<DeviceTensorAscend910B> &input,
638                                     std::shared_ptr<DeviceTensorAscend910B> *output, std::vector<float> mean,
639                                     std::vector<float> std, bool is_hwc) {
640   if (!HasAclPlugin() || dvpp_normalize_fun_obj_ == nullptr) {
641     return APP_ERR_ACL_FAILURE;
642   }
643   return dvpp_normalize_fun_obj_(input, output, mean, std, is_hwc);
644 }
645 
DvppPad(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<int64_t> & padding,uint32_t padding_mode,const std::vector<float> & fill)646 APP_ERROR AclAdapter::DvppPad(const std::shared_ptr<DeviceTensorAscend910B> &input,
647                               std::shared_ptr<DeviceTensorAscend910B> *output, const std::vector<int64_t> &padding,
648                               uint32_t padding_mode, const std::vector<float> &fill) {
649   if (!HasAclPlugin() || dvpp_pad_fun_obj_ == nullptr) {
650     return APP_ERR_ACL_FAILURE;
651   }
652   return dvpp_pad_fun_obj_(input, output, padding, padding_mode, fill);
653 }
654 
DvppPerspective(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<std::vector<int32_t>> & start_points,const std::vector<std::vector<int32_t>> & end_points,InterpolationMode interpolation)655 APP_ERROR AclAdapter::DvppPerspective(const std::shared_ptr<DeviceTensorAscend910B> &input,
656                                       std::shared_ptr<DeviceTensorAscend910B> *output,
657                                       const std::vector<std::vector<int32_t>> &start_points,
658                                       const std::vector<std::vector<int32_t>> &end_points,
659                                       InterpolationMode interpolation) {
660   if (!HasAclPlugin() || dvpp_perspective_fun_obj_ == nullptr) {
661     return APP_ERR_ACL_FAILURE;
662   }
663   return dvpp_perspective_fun_obj_(input, output, start_points, end_points, interpolation);
664 }
665 
DvppPosterize(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,uint8_t bits)666 APP_ERROR AclAdapter::DvppPosterize(const std::shared_ptr<DeviceTensorAscend910B> &input,
667                                     std::shared_ptr<DeviceTensorAscend910B> *output, uint8_t bits) {
668   if (!HasAclPlugin() || dvpp_posterize_fun_obj_ == nullptr) {
669     return APP_ERR_ACL_FAILURE;
670   }
671   return dvpp_posterize_fun_obj_(input, output, bits);
672 }
673 
DvppResize(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,int32_t output_height,int32_t output_width,double fx,double fy,InterpolationMode mode)674 APP_ERROR AclAdapter::DvppResize(const std::shared_ptr<DeviceTensorAscend910B> &input,
675                                  std::shared_ptr<DeviceTensorAscend910B> *output, int32_t output_height,
676                                  int32_t output_width, double fx, double fy, InterpolationMode mode) {
677   if (!HasAclPlugin() || dvpp_resize_fun_obj_ == nullptr) {
678     return APP_ERR_ACL_FAILURE;
679   }
680   return dvpp_resize_fun_obj_(input, output, output_height, output_width, fx, fy, mode);
681 }
682 
DvppResizedCrop(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,int32_t top,int32_t left,int32_t height,int32_t width,int32_t output_height,int32_t output_width,InterpolationMode interpolation)683 APP_ERROR AclAdapter::DvppResizedCrop(const std::shared_ptr<DeviceTensorAscend910B> &input,
684                                       std::shared_ptr<DeviceTensorAscend910B> *output, int32_t top, int32_t left,
685                                       int32_t height, int32_t width, int32_t output_height, int32_t output_width,
686                                       InterpolationMode interpolation) {
687   if (!HasAclPlugin() || dvpp_resized_crop_fun_obj_ == nullptr) {
688     return APP_ERR_ACL_FAILURE;
689   }
690   return dvpp_resized_crop_fun_obj_(input, output, top, left, height, width, output_height, output_width,
691                                     interpolation);
692 }
693 
DvppRotate(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,float degrees,InterpolationMode mode,bool expand,const std::vector<float> & center,const std::vector<float> & fill)694 APP_ERROR AclAdapter::DvppRotate(const std::shared_ptr<DeviceTensorAscend910B> &input,
695                                  std::shared_ptr<DeviceTensorAscend910B> *output, float degrees, InterpolationMode mode,
696                                  bool expand, const std::vector<float> &center, const std::vector<float> &fill) {
697   if (!HasAclPlugin() || dvpp_rotate_fun_obj_ == nullptr) {
698     return APP_ERR_ACL_FAILURE;
699   }
700   return dvpp_rotate_fun_obj_(input, output, degrees, mode, expand, center, fill);
701 }
702 
DvppVerticalFlip(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output)703 APP_ERROR AclAdapter::DvppVerticalFlip(const std::shared_ptr<DeviceTensorAscend910B> &input,
704                                        std::shared_ptr<DeviceTensorAscend910B> *output) {
705   if (!HasAclPlugin() || dvpp_vertical_flip_fun_obj_ == nullptr) {
706     return APP_ERR_ACL_FAILURE;
707   }
708   return dvpp_vertical_flip_fun_obj_(input, output);
709 }
710 
DvppSolarize(const std::shared_ptr<DeviceTensorAscend910B> & input,std::shared_ptr<DeviceTensorAscend910B> * output,const std::vector<float> & threshold)711 APP_ERROR AclAdapter::DvppSolarize(const std::shared_ptr<DeviceTensorAscend910B> &input,
712                                    std::shared_ptr<DeviceTensorAscend910B> *output,
713                                    const std::vector<float> &threshold) {
714   if (!HasAclPlugin() || dvpp_solarize_fun_obj_ == nullptr) {
715     return APP_ERR_ACL_FAILURE;
716   }
717   return dvpp_solarize_fun_obj_(input, output, threshold);
718 }
719 
720 // acl
GetSocName(std::string * soc_name)721 APP_ERROR AclAdapter::GetSocName(std::string *soc_name) {
722   if (!HasAclPlugin() || get_soc_name_fun_obj_ == nullptr) {
723     return APP_ERR_ACL_FAILURE;
724   }
725   return get_soc_name_fun_obj_(soc_name);
726 }
727 
CreateAclTensor(const int64_t * view_dims,uint64_t view_dims_num,mindspore::TypeId data_type,const int64_t * stride,int64_t offset,const int64_t * storage_dims,uint64_t storage_dims_num,void * tensor_data,bool is_hwc,void ** acl_tensor)728 APP_ERROR AclAdapter::CreateAclTensor(const int64_t *view_dims, uint64_t view_dims_num, mindspore::TypeId data_type,
729                                       const int64_t *stride, int64_t offset, const int64_t *storage_dims,
730                                       uint64_t storage_dims_num, void *tensor_data, bool is_hwc, void **acl_tensor) {
731   if (!HasAclPlugin() || create_acl_tensor_fun_obj_ == nullptr) {
732     return APP_ERR_ACL_FAILURE;
733   }
734   return create_acl_tensor_fun_obj_(view_dims, view_dims_num, data_type, stride, offset, storage_dims, storage_dims_num,
735                                     tensor_data, is_hwc, acl_tensor);
736 }
737 
DestroyTensor(void * tensor)738 APP_ERROR AclAdapter::DestroyTensor(void *tensor) {
739   if (!HasAclPlugin() || destroy_tensor_fun_obj_ == nullptr) {
740     return APP_ERR_ACL_FAILURE;
741   }
742   return destroy_tensor_fun_obj_(tensor);
743 }
744 
DestroyFloatArray(void * float_array)745 APP_ERROR AclAdapter::DestroyFloatArray(void *float_array) {
746   if (!HasAclPlugin() || destroy_float_array_fun_obj_ == nullptr) {
747     return APP_ERR_ACL_FAILURE;
748   }
749   return destroy_float_array_fun_obj_(float_array);
750 }
751 
DestroyIntArray(void * int_array)752 APP_ERROR AclAdapter::DestroyIntArray(void *int_array) {
753   if (!HasAclPlugin() || destroy_int_array_fun_obj_ == nullptr) {
754     return APP_ERR_ACL_FAILURE;
755   }
756   return destroy_int_array_fun_obj_(int_array);
757 }
758 #endif
759 }  // namespace dataset
760 }  // namespace mindspore
761