• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-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 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_DATA_CONCATENATE_OP_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_DATA_CONCATENATE_OP_H_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "minddata/dataset/core/tensor.h"
26 #include "minddata/dataset/kernels/tensor_op.h"
27 
28 namespace mindspore {
29 namespace dataset {
30 class ConcatenateOp : public TensorOp {
31  public:
32   /// Constructor to ConcatenateOp.
33   /// @param int8_t axis - axis to concatenate tensors along.
34   /// @param std::shared_ptr<Tensor> prepend - prepend tensor.
35   /// @param std::shared_ptr<Tensor> append -append tensor.
ConcatenateOp(int8_t axis,std::shared_ptr<Tensor> prepend,std::shared_ptr<Tensor> append)36   ConcatenateOp(int8_t axis, std::shared_ptr<Tensor> prepend, std::shared_ptr<Tensor> append)
37       : axis_(axis), prepend_(std::move(prepend)), append_(std::move(append)) {}
38 
39   ~ConcatenateOp() override = default;
40 
41   /// Compute method allowing multiple tensors as inputs
42   /// @param TensorRow &input - input tensor rows
43   /// @param TensorRow *output - output tensor rows
44   Status Compute(const TensorRow &input, TensorRow *output) override;
45 
46   /// Compute tensor output shape
47   /// @param std::vector<TensorShape> &inputs - vector of input tensor shapes
48   /// @param std::vector<TensorShape< &outputs - vector of output tensor shapes
49   Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
50 
51   /// Number of inputs the tensor operation accepts
NumInput()52   uint32_t NumInput() override { return 0; }
53 
Name()54   std::string Name() const override { return kConcatenateOp; }
55 
56  private:
57   int8_t axis_;
58   std::shared_ptr<Tensor> prepend_;
59   std::shared_ptr<Tensor> append_;
60 };
61 }  // namespace dataset
62 }  // namespace mindspore
63 #endif  // MINDSPORE_CONCATENATE_OP_H
64