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 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 <string> 21 #include <vector> 22 #include <memory> 23 24 #include "minddata/dataset/core/tensor.h" 25 #include "minddata/dataset/kernels/tensor_op.h" 26 27 namespace mindspore { 28 namespace dataset { 29 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 explicit ConcatenateOp(int8_t axis, std::shared_ptr<Tensor> prepend, std::shared_ptr<Tensor> append) 37 : axis_(axis), prepend_(prepend), append_(append) {} 38 39 ~ConcatenateOp() override = default; 40 41 /// Print method to see which tensor Op this is. 42 /// @param std::ostream &out - output stream object. 43 44 /// Compute method allowing multiple tensors as inputs 45 /// @param TensorRow &input - input tensor rows 46 /// @param TensorRow *output - output tensor rows 47 Status Compute(const TensorRow &input, TensorRow *output) override; 48 49 /// Compute tensor output shape 50 /// @param std::vector<TensorShape> &inputs - vector of input tensor shapes 51 /// @param std::vector<TensorShape< &outputs - vector of output tensor shapes 52 Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override; 53 54 /// Number of inputs the tensor operation accepts NumInput()55 uint32_t NumInput() override { return 0; } 56 Name()57 std::string Name() const override { return kConcatenateOp; } 58 59 private: 60 int8_t axis_; 61 std::shared_ptr<Tensor> prepend_; 62 std::shared_ptr<Tensor> append_; 63 }; 64 } // namespace dataset 65 } // namespace mindspore 66 67 #endif // MINDSPORE_CONCATENATE_OP_H 68