• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-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_BACKEND_KERNEL_COMPILER_GPU_DATA_DATASET_ITERATOR_GPU_KERNEL_H_
18 #define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_GPU_DATA_DATASET_ITERATOR_GPU_KERNEL_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include "backend/kernel_compiler/gpu/data/dataset_profiling.h"
24 #include "backend/kernel_compiler/gpu/gpu_kernel.h"
25 #include "backend/kernel_compiler/gpu/gpu_kernel_factory.h"
26 
27 namespace mindspore {
28 namespace kernel {
29 class DatasetIteratorKernel : public GpuKernel {
30  public:
31   DatasetIteratorKernel();
32   ~DatasetIteratorKernel();
33 
34   const std::vector<size_t> &GetInputSizeList() const override;
35   const std::vector<size_t> &GetOutputSizeList() const override;
36   const std::vector<size_t> &GetWorkspaceSizeList() const override;
37   bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
38               const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
39   bool Init(const CNodePtr &kernel_node) override;
40   void ReleaseResource() override;
41 
42  protected:
43   void InitSizeLists() override;
44 
45  private:
46   bool ReadDevice(void **addr, size_t *len);
47   std::string queue_name_;
48   unsigned int handle_;
49   size_t total_bytes_;
50   bool profiling_enable_;
51   std::shared_ptr<GetNextProfiling> profiling_op_;
52 
53   std::vector<size_t> input_size_list_;
54   std::vector<size_t> output_size_list_;
55   std::vector<size_t> workspace_size_list_;
56 };
57 
58 MS_REG_GPU_KERNEL(GetNext, DatasetIteratorKernel)
59 }  // namespace kernel
60 }  // namespace mindspore
61 
62 #endif  // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_GPU_DATA_DATASET_ITERATOR_GPU_KERNEL_H_
63