• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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_FRONTEND_PARALLEL_TENSOR_LAYOUT_LAYOUT_TRANSFER_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_TENSOR_LAYOUT_LAYOUT_TRANSFER_H_
19 
20 #include <string>
21 #include "frontend/parallel/status.h"
22 #include "frontend/parallel/tensor_layout/tensor_layout.h"
23 
24 namespace mindspore {
25 namespace parallel {
26 class LayoutTransfer {
27  public:
28   LayoutTransfer() = default;
29   virtual ~LayoutTransfer() = 0;
30   std::string ToString() const;
31   Status Init(const TensorLayout &from_in, const TensorLayout &to_in);
from_in()32   TensorLayout from_in() const { return from_in_; }
to_in()33   TensorLayout to_in() const { return to_in_; }
34 
35  protected:
IsSameTensorShape()36   bool IsSameTensorShape() const { return from_in_.IsSameTensorShape(to_in_); }
IsSameDeviceArrangement()37   bool IsSameDeviceArrangement() const { return from_in_.IsSameDeviceArrangement(to_in_); }
38 
39   TensorLayout from_in_;
40   TensorLayout to_in_;
41 
42  private:
43   virtual Status CheckValidTransfer() = 0;
44 };
45 }  // namespace parallel
46 }  // namespace mindspore
47 
48 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_TENSOR_LAYOUT_LAYOUT_TRANSFER_H_
49