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 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ACL_PLUGIN_H_ 17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ACL_PLUGIN_H_ 18 19 #include <memory> 20 #include <string> 21 22 #include "minddata/dataset/core/device_tensor.h" 23 #if !defined(BUILD_LITE) && defined(ENABLE_D) 24 #include "minddata/dataset/core/device_tensor_ascend910b.h" 25 #endif 26 #include "minddata/dataset/core/tensor.h" 27 #include "minddata/dataset/include/dataset/constants.h" 28 #include "minddata/dataset/kernels/image/dvpp/utils/resouce_info.h" 29 #include "utils/dlopen_macro.h" 30 31 class DvppCommon; 32 struct DvppDataInfo; 33 34 PLUGIN_METHOD(CreateDvppVideo, void *, void *, uint8_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, 35 const std::string &); 36 PLUGIN_METHOD(InitDvppVideo, int, void *); 37 PLUGIN_METHOD(CloseDvppVideo, int, void *); 38 PLUGIN_METHOD(DvppVideoDumpFrame, int, void *); 39 40 PLUGIN_METHOD(InitResource, int, ResourceInfo &); 41 PLUGIN_METHOD(GetContext, void *, int); 42 PLUGIN_METHOD(Release, void); 43 44 PLUGIN_METHOD(CreateAclProcessWithResize, void *, uint32_t, uint32_t, uint32_t, uint32_t, void *, bool, void *, 45 const std::shared_ptr<DvppCommon> &); 46 PLUGIN_METHOD(CreateAclProcessWithPara, void *, uint32_t, uint32_t, void *, bool, void *, 47 const std::shared_ptr<DvppCommon> &); 48 PLUGIN_METHOD(CreateAclProcess, void *, void *, bool, void *, const std::shared_ptr<DvppCommon> &); 49 PLUGIN_METHOD(DestroyAclProcess, void, void *); 50 PLUGIN_METHOD(ReleaseAclProcess, int, void *); 51 PLUGIN_METHOD(InitAclProcess, int, void *); 52 PLUGIN_METHOD(GetContextFromAclProcess, void *, void *); 53 PLUGIN_METHOD(GetStreamFromAclProcess, void *, void *); 54 PLUGIN_METHOD(JPEG_DRC_WITH_DATA, int, void *, const RawData &); 55 PLUGIN_METHOD(JPEG_DR_WITH_DATA, int, void *, const RawData &); 56 PLUGIN_METHOD(JPEG_D_WITH_DATA, int, void *, const RawData &); 57 PLUGIN_METHOD(JPEG_R_WITH_DATA, int, void *, const DvppDataInfo &); 58 PLUGIN_METHOD(JPEG_C_WITH_DATA, int, void *, const DvppDataInfo &); 59 PLUGIN_METHOD(PNG_D_WITH_DATA, int, void *, const RawData &); 60 PLUGIN_METHOD(JPEG_DRC, int, void *); 61 PLUGIN_METHOD(JPEG_DR, int, void *); 62 PLUGIN_METHOD(JPEG_D, int, void *); 63 PLUGIN_METHOD(JPEG_R, int, void *, const std::string &); 64 PLUGIN_METHOD(JPEG_C, int, void *, const std::string &); 65 PLUGIN_METHOD(PNG_D, int, void *); 66 PLUGIN_METHOD(GetMemoryData, void *, void *); 67 PLUGIN_METHOD(GetCropedDeviceData, DvppDataInfo *, void *); 68 PLUGIN_METHOD(GetResizedDeviceData, DvppDataInfo *, void *); 69 PLUGIN_METHOD(GetDecodeDeviceData, DvppDataInfo *, void *); 70 PLUGIN_METHOD(H2D_Sink, int, void *, const std::shared_ptr<mindspore::dataset::Tensor> &, 71 std::shared_ptr<mindspore::dataset::DeviceTensor> &); 72 PLUGIN_METHOD(D2H_Pop, int, void *, const std::shared_ptr<mindspore::dataset::DeviceTensor> &, 73 std::shared_ptr<mindspore::dataset::Tensor> &); 74 PLUGIN_METHOD(DeviceMemoryRelease, int, void *); 75 PLUGIN_METHOD(SetResizeParas, int, void *, uint32_t, uint32_t); 76 PLUGIN_METHOD(SetCropParas, int, void *, uint32_t, uint32_t); 77 78 ORIGIN_METHOD(aclrtMallocHost, int, void **, size_t); 79 PLUGIN_METHOD(aclrtMemcpy, int, void *, size_t, const void *, size_t, int); 80 ORIGIN_METHOD(aclrtFreeHost, int, void *); 81 82 #if !defined(BUILD_LITE) && defined(ENABLE_D) 83 // Ascend910B 84 PLUGIN_METHOD(DvppAdjustBrightness, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 85 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float); 86 87 PLUGIN_METHOD(DvppAdjustContrast, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 88 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float); 89 90 PLUGIN_METHOD(DvppAdjustHue, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 91 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float); 92 93 PLUGIN_METHOD(DvppAdjustSaturation, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 94 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float); 95 96 PLUGIN_METHOD(DvppAdjustSharpness, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 97 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float); 98 99 PLUGIN_METHOD(DvppAffine, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 100 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<float> &, uint32_t, 101 uint32_t, const std::vector<float> &); 102 103 PLUGIN_METHOD(DvppAutoContrast, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 104 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<float> &, 105 const std::vector<uint32_t> &); 106 107 PLUGIN_METHOD(DvppConvertColor, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 108 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, mindspore::dataset::ConvertMode); 109 110 PLUGIN_METHOD(DvppCrop, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 111 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, uint32_t, uint32_t, uint32_t, uint32_t); 112 113 PLUGIN_METHOD(DvppDecode, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 114 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *); 115 116 PLUGIN_METHOD(DvppEqualize, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 117 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *); 118 119 PLUGIN_METHOD(DvppErase, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 120 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, uint32_t, uint32_t, uint32_t, uint32_t, 121 const std::vector<float> &); 122 123 PLUGIN_METHOD(DvppGaussianBlur, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 124 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<int64_t> &, 125 const std::vector<float> &, uint32_t); 126 127 PLUGIN_METHOD(DvppHorizontalFlip, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 128 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *); 129 130 PLUGIN_METHOD(DvppInvert, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 131 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *); 132 133 PLUGIN_METHOD(DvppNormalize, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 134 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, std::vector<float>, std::vector<float>, 135 bool); 136 137 PLUGIN_METHOD(DvppPad, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 138 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<int64_t> &, uint32_t, 139 const std::vector<float> &); 140 141 PLUGIN_METHOD(DvppPerspective, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 142 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<std::vector<int32_t>> &, 143 const std::vector<std::vector<int32_t>> &, mindspore::dataset::InterpolationMode); 144 145 PLUGIN_METHOD(DvppPosterize, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 146 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, uint8_t); 147 148 PLUGIN_METHOD(DvppResize, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 149 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, int32_t, int32_t, double, double, 150 mindspore::dataset::InterpolationMode); 151 152 PLUGIN_METHOD(DvppResizedCrop, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 153 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, int32_t, int32_t, int32_t, int32_t, 154 int32_t, int32_t, mindspore::dataset::InterpolationMode); 155 156 PLUGIN_METHOD(DvppRotate, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 157 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, float, 158 mindspore::dataset::InterpolationMode, bool, const std::vector<float> &, const std::vector<float> &); 159 160 PLUGIN_METHOD(DvppSolarize, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 161 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *, const std::vector<float> &); 162 163 PLUGIN_METHOD(DvppVerticalFlip, int, const std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> &, 164 std::shared_ptr<mindspore::dataset::DeviceTensorAscend910B> *); 165 // acl 166 PLUGIN_METHOD(GetSocName, int, std::string *); 167 168 PLUGIN_METHOD(CreateAclTensor, int, const int64_t *, uint64_t, mindspore::TypeId, const int64_t *, int64_t, 169 const int64_t *, uint64_t, void *, bool, void **); 170 171 PLUGIN_METHOD(DestroyTensor, int, void *); 172 173 PLUGIN_METHOD(DestroyFloatArray, int, void *); 174 175 PLUGIN_METHOD(DestroyIntArray, int, void *); 176 #endif 177 178 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_DVPP_UTILS_ACL_PLUGIN_H_ 179