/** * Copyright 2019 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MINDSPORE_CCSRC_PARALLEL_TENSOR_LAYOUT_ARRANGEMENT_H_ #define MINDSPORE_CCSRC_PARALLEL_TENSOR_LAYOUT_ARRANGEMENT_H_ #include #include #include #include #include #include #include "parallel/status.h" #include "parallel/tensor_layout/array.h" namespace mindspore { namespace parallel { class Arrangement : public Array { public: Arrangement() : size_(1) {} ~Arrangement() override = default; Status Init(const std::vector &array) override; int32_t size() const { return size_; } std::vector GetFrontElementByValue(int32_t value) const; std::shared_ptr> GetExpandShapeList(const Arrangement &expand_shape) const; std::vector ComputeReverseAccumulateSumInReverseOrder() const; std::shared_ptr GetExpandedShapeByExpandListReserveLeft( const std::vector &expand_list) const; std::shared_ptr GetExpandedShapeByExpandListRemoveLeft( const std::vector &expand_list) const; std::shared_ptr, Arrangement>> GetExpandShapeListPair( const Arrangement &expand_shape) const; std::shared_ptr GetUnifiedShape(const Arrangement &in2) const; std::vector GetSqueezeIdx() const; Arrangement GetSqueezeArrangement() const; private: bool IsValidArrangement(); void ComputeSize(); int32_t size_; }; } // namespace parallel } // namespace mindspore #endif // MINDSPORE_CCSRC_PARALLEL_TENSOR_LAYOUT_ARRANGEMENT_H_