1 /** 2 * Copyright 2021 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 17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_ASCEND_RESOURCE_H_ 18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_ASCEND_RESOURCE_H_ 19 20 #include <memory> 21 #include <string> 22 #include "acl/acl.h" 23 #include "minddata/dataset/core/device_resource.h" 24 #include "minddata/dataset/core/device_tensor.h" 25 #include "minddata/dataset/core/tensor.h" 26 #include "minddata/dataset/kernels/image/dvpp/utils/CommonDataType.h" 27 #include "minddata/dataset/kernels/image/dvpp/utils/ErrorCode.h" 28 #include "minddata/dataset/kernels/image/dvpp/utils/MDAclProcess.h" 29 #include "minddata/dataset/kernels/image/dvpp/utils/ResourceManager.h" 30 31 namespace mindspore { 32 namespace dataset { 33 34 class AscendResource : public DeviceResource { 35 public: 36 AscendResource() = default; 37 ~AscendResource() = default; 38 39 Status InitResource(uint32_t device_id) override; 40 41 Status FinalizeResource() override; 42 43 Status Sink(const mindspore::MSTensor &host_input, std::shared_ptr<DeviceTensor> *device_input) override; 44 45 Status Pop(const std::shared_ptr<DeviceTensor> &device_output, std::shared_ptr<Tensor> *host_output) override; 46 47 std::shared_ptr<void> GetInstance() override; 48 49 Status DeviceDataRelease() override; 50 51 void *GetContext() override; 52 53 void *GetStream() override; 54 55 private: 56 std::shared_ptr<MDAclProcess> processor_; 57 std::shared_ptr<ResourceManager> ascend_resource_; 58 }; 59 60 } // namespace dataset 61 } // namespace mindspore 62 63 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_ASCEND_RESOURCE_H_ 64