未验证 提交 4149cabe 编写于 作者: 王明冬 提交者: GitHub

add type constrait for DenseTensor (#39967)

上级 d17961ed
...@@ -40,6 +40,12 @@ def DenseTensor : Infrt_Type<"DenseTensor"> { ...@@ -40,6 +40,12 @@ def DenseTensor : Infrt_Type<"DenseTensor"> {
); );
} }
// Type Constrait for concrete DenseTensor type.
class DenseTensor<string target, string precision, string layout> :
Type<CPred<"$_self == ::infrt::DenseTensorType::get($_self.getContext(), ::infrt::TargetType::"#target#",::infrt::PrecisionType::"#precision#",::infrt::LayoutType::"#layout#")">,
"!infrt.DenseTensor<"#target#","#precision#","#layout#">",
"::infrt::DenseTensorType">;
// Base class for infrt dialect attributes. // Base class for infrt dialect attributes.
class Infrt_Attr<string name, list<Trait> traits = [], class Infrt_Attr<string name, list<Trait> traits = [],
string baseCppClass = "::mlir::Attribute"> string baseCppClass = "::mlir::Attribute">
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "paddle/infrt/dialect/infrt/infrt_dialect.h" #include "paddle/infrt/dialect/infrt/infrt_dialect.h"
#include "paddle/infrt/dialect/infrt_base.h" #include "paddle/infrt/dialect/infrt_base.h"
#include "paddle/infrt/dialect/pd_ops.h" #include "paddle/infrt/dialect/pd_ops.h"
#include "paddle/infrt/dialect/phi/infrt_phi_tensor.h" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h"
#include "paddle/infrt/dialect/phi/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h"
#include "paddle/infrt/dialect/tensor_shape.h" #include "paddle/infrt/dialect/tensor_shape.h"
namespace infrt { namespace infrt {
......
...@@ -2,16 +2,7 @@ if (NOT INFRT_WITH_PHI) ...@@ -2,16 +2,7 @@ if (NOT INFRT_WITH_PHI)
return() return()
endif() endif()
#mlir_tablegen_on(infrt_phi_base DIALECT phi) add_subdirectory(ir)
add_mlir_dialect(infrt_phi_base phi)
add_mlir_dialect(infrt_phi_tensor phi_dt)
add_mlir_dialect(infrt_phi_kernel phi_kernel)
#mlir_tablegen_on(infrt_phi_tensor)
gather_srcs(infrt_src SRCS
phi_base.cc infrt_phi_tensor.cc
infrt_phi_tensor.cc)
add_subdirectory(pass) add_subdirectory(pass)
add_executable(phi-exec phi_exec.cc) add_executable(phi-exec phi_exec.cc)
......
#mlir_tablegen_on(infrt_phi_base DIALECT phi)
add_mlir_dialect(infrt_phi_base phi)
add_mlir_dialect(infrt_phi_tensor phi_dt)
add_mlir_dialect(infrt_phi_kernel phi_kernel)
#mlir_tablegen_on(infrt_phi_tensor)
gather_srcs(infrt_src SRCS
phi_base.cc
infrt_phi_tensor.cc)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/OpBase.td" include "mlir/IR/OpBase.td"
include "paddle/infrt/dialect/infrt_base.td" include "paddle/infrt/dialect/infrt_base.td"
include "paddle/infrt/dialect/phi/infrt_phi_base.td" include "paddle/infrt/dialect/phi/ir/infrt_phi_base.td"
def PHI_KernelDialect : Dialect { def PHI_KernelDialect : Dialect {
let name = "phi_kernel"; let name = "phi_kernel";
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "paddle/infrt/dialect/phi/infrt_phi_tensor.h" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h"
#include <mlir/IR/BuiltinTypes.h> #include <mlir/IR/BuiltinTypes.h>
#include "paddle/infrt/dialect/phi/infrt_phi_tensorDialect.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensorDialect.cpp.inc"
#include "paddle/infrt/dialect/phi/infrt_phi_tensorTypes.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensorTypes.cpp.inc"
namespace infrt { namespace infrt {
namespace phi { namespace phi {
...@@ -25,7 +25,7 @@ namespace phi { ...@@ -25,7 +25,7 @@ namespace phi {
void PHIDenseTensorDialect::initialize() { void PHIDenseTensorDialect::initialize() {
#define GET_OP_LIST #define GET_OP_LIST
addOperations< addOperations<
#include "paddle/infrt/dialect/phi/infrt_phi_tensor.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.cpp.inc"
>(); >();
} }
...@@ -33,4 +33,4 @@ void PHIDenseTensorDialect::initialize() { ...@@ -33,4 +33,4 @@ void PHIDenseTensorDialect::initialize() {
} // namespace infrt } // namespace infrt
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "paddle/infrt/dialect/phi/infrt_phi_tensor.cpp.inc" // NOLINT #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.cpp.inc" // NOLINT
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
#include <mlir/Interfaces/LoopLikeInterface.h> #include <mlir/Interfaces/LoopLikeInterface.h>
#include <mlir/Interfaces/SideEffectInterfaces.h> #include <mlir/Interfaces/SideEffectInterfaces.h>
#include "paddle/infrt/dialect/phi/infrt_phi_tensorDialect.h.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensorDialect.h.inc"
#include "paddle/infrt/dialect/phi/infrt_phi_tensorTypes.h.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensorTypes.h.inc"
#include "paddle/infrt/dialect/dense_tensor.h" #include "paddle/infrt/dialect/dense_tensor.h"
#include "paddle/infrt/dialect/phi/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h"
// NOLINT // NOLINT
#define GET_OP_CLASSES #define GET_OP_CLASSES
#include "paddle/infrt/dialect/phi/infrt_phi_tensor.h.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h.inc"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#else #else
#define PHI_TENSOR #define PHI_TENSOR
include "paddle/infrt/dialect/phi/infrt_phi_base.td" include "paddle/infrt/dialect/phi/ir/infrt_phi_base.td"
include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/OpBase.td" include "mlir/IR/OpBase.td"
include "paddle/infrt/dialect/infrt_base.td" include "paddle/infrt/dialect/infrt_base.td"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "paddle/infrt/dialect/phi/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h"
#include <mlir/IR/Builders.h> #include <mlir/IR/Builders.h>
#include <mlir/IR/Dialect.h> #include <mlir/IR/Dialect.h>
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include <mlir/IR/TypeUtilities.h> #include <mlir/IR/TypeUtilities.h>
#include <mlir/IR/Types.h> #include <mlir/IR/Types.h>
#include "paddle/infrt/common/global.h" #include "paddle/infrt/common/global.h"
#include "paddle/infrt/dialect/phi/infrt_phi_base.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_base.cpp.inc"
#include "paddle/infrt/dialect/phi/infrt_phi_baseDialect.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.cpp.inc"
namespace infrt { namespace infrt {
namespace phi { namespace phi {
...@@ -51,11 +51,11 @@ void PHIDialect::printType(::mlir::Type type, ...@@ -51,11 +51,11 @@ void PHIDialect::printType(::mlir::Type type,
void PHIDialect::initialize() { void PHIDialect::initialize() {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "paddle/infrt/dialect/phi/infrt_phi_base.cpp.inc" // NOLINT #include "paddle/infrt/dialect/phi/ir/infrt_phi_base.cpp.inc" // NOLINT
>(); >();
addTypes< addTypes<
#define GET_TYPEDEF_LIST #define GET_TYPEDEF_LIST
#include "paddle/infrt/dialect/phi/infrt_phi_baseTypes.cpp.inc" // NOLINT #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseTypes.cpp.inc" // NOLINT
>(); >();
} }
...@@ -81,4 +81,4 @@ mlir::Type PHIDialect::parseType(mlir::DialectAsmParser& parser) const { ...@@ -81,4 +81,4 @@ mlir::Type PHIDialect::parseType(mlir::DialectAsmParser& parser) const {
} // namespace infrt } // namespace infrt
#define GET_TYPEDEF_CLASSES #define GET_TYPEDEF_CLASSES
#include "paddle/infrt/dialect/phi/infrt_phi_baseTypes.cpp.inc" // NOLINT #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseTypes.cpp.inc" // NOLINT
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
#include <string> #include <string>
#include "paddle/infrt/dialect/phi/infrt_phi_base.h.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.h.inc"
#include "paddle/infrt/dialect/phi/infrt_phi_baseDialect.h.inc"
#define GET_TYPEDEF_CLASSES #define GET_TYPEDEF_CLASSES
#include "paddle/infrt/dialect/phi/infrt_phi_baseTypes.h.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseTypes.h.inc"
#define GET_OP_CLASSES
#include "paddle/infrt/dialect/phi/ir/infrt_phi_base.h.inc"
namespace mlir { namespace mlir {
namespace OpTrait { namespace OpTrait {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册