• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEVICE_RESOURCE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DEVICE_RESOURCE_H_
19 
20 #include <memory>
21 #include "include/api/context.h"
22 #include "include/api/status.h"
23 #include "include/api/types.h"
24 #include "minddata/dataset/core/device_tensor.h"
25 #include "minddata/dataset/core/tensor.h"
26 
27 namespace mindspore {
28 namespace dataset {
29 
30 class DeviceResource {
31  public:
32   DeviceResource() = default;
33 
34   virtual ~DeviceResource() = default;
35 
36   virtual Status InitResource(uint32_t device_id);
37 
38   virtual Status FinalizeResource();
39 
40   virtual Status Sink(const mindspore::MSTensor &host_input, std::shared_ptr<DeviceTensor> *device_input);
41 
42   virtual Status Pop(const std::shared_ptr<DeviceTensor> &device_output, std::shared_ptr<Tensor> *host_output);
43 
44   virtual std::shared_ptr<void> GetInstance();
45 
46   virtual Status DeviceDataRelease();
47 
48   virtual void *GetContext();
49 
50   virtual void *GetStream();
51 };
52 
53 }  // namespace dataset
54 }  // namespace mindspore
55 #endif  // MINDSPORE_DEVICE_RESOURCE_H
56