// Copyright (c) 2023 CINN Authors. All Rights Reserved. // // 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. #pragma once #include #include #include #include #include "paddle/cinn/adt/adt.h" #include "paddle/cinn/adt/dim_expr.h" #include "paddle/cinn/adt/equation_variable.h" #include "paddle/cinn/adt/tags.h" #include "paddle/cinn/common/equation_graph_topo_walker.h" namespace cinn::adt { template struct Identity; // Identity (tOut Iterator) (tIn Iterator) template <> struct Identity, tIn> : public Tuple, tIn> { using Tuple, tIn>::Tuple; }; // Identity (tOut Index) (tIn Index) template <> struct Identity, tIn> : public Tuple, tIn> { using Tuple, tIn>::Tuple; }; template struct IndexDot; // IndexDot [DimExpr] (tOut Index) (tIn [Iterator]) template <> struct IndexDot, tOut, tIn>> : public Tuple, tOut, tIn>> { using Tuple, tOut, tIn>>::Tuple; }; template struct IndexUnDot; // IndexUnDot [DimExpr] (tOut [Iterator]) (tIn Index) template <> struct IndexUnDot, tOut>, tIn> : public Tuple, tOut>, tIn> { using Tuple, tOut>, tIn>::Tuple; }; // OpArgIndexes = (tIn [Index], tOut [Index]) template struct OpArgIndexes final : public Tuple>, tOut>> { using Tuple>, tOut>>::Tuple; }; template struct InMsg2OutMsg; // InMsg2OutMsg (tOut FakeOpPlaceHolder) (tOut (tOutMsg OpArgIndexes)) // (tIn (tInMsg OpArgIndexes)) template <> struct InMsg2OutMsg, tOut>>, tIn>> : public Tuple, tOut>>, tIn>> { using Tuple, tOut>>, tIn>>::Tuple; }; template struct ConstantFunction; template <> struct ConstantFunction, tIn> final : public Tuple, tIn, DimExpr> { using Tuple, tIn, DimExpr>::Tuple; }; template struct GetBroadcastedIterator; template <> struct GetBroadcastedIterator, tIn> : public Tuple, tIn> { using Tuple, tIn>::Tuple; }; // clang-format off DEFINE_ADT_UNION(Equation, Identity, tIn>, Identity, tIn>, GetBroadcastedIterator, tIn>, IndexDot, tOut, tIn>>, IndexUnDot, tOut>, tIn>, InMsg2OutMsg, tOut>>, tIn>>, ConstantFunction, tIn>); // clang-format on // Function = Equation using Function = Equation; using Equations = List; using GraphView = EquationGraphTopoWalker; std::string GetFunctionTypeName(const Function& function); const void* GetFunctionDataPtr(const Function& function); } // namespace cinn::adt