• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 DATASET_ENGINE_DATASETOPS_MAP_OP_MAP_JOB_H_
17 #define DATASET_ENGINE_DATASETOPS_MAP_OP_MAP_JOB_H_
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "minddata/dataset/core/tensor.h"
23 #include "minddata/dataset/core/tensor_row.h"
24 #include "minddata/dataset/kernels/tensor_op.h"
25 #include "minddata/dataset/util/status.h"
26 
27 namespace mindspore {
28 namespace dataset {
29 class MapJob {
30  public:
31   // Constructor
MapJob(std::vector<std::shared_ptr<TensorOp>> operations)32   explicit MapJob(std::vector<std::shared_ptr<TensorOp>> operations) : ops_(operations) {}
33 
34   // Constructor
35   MapJob() = default;
36 
37   // Destructor
38   ~MapJob() = default;
39 
AddOperation(std::shared_ptr<TensorOp> operation)40   Status AddOperation(std::shared_ptr<TensorOp> operation) {
41     ops_.push_back(operation);
42     return Status::OK();
43   }
44 
45   // A pure virtual run function to execute a particular map job
46   virtual Status Run(std::vector<TensorRow> in, std::vector<TensorRow> *out) = 0;
47 
48  protected:
49   std::vector<std::shared_ptr<TensorOp>> ops_;
50 };
51 
52 }  // namespace dataset
53 }  // namespace mindspore
54 
55 #endif  // DATASET_ENGINE_DATASETOPS_MAP_OP_MAP_JOB_H_
56