Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
4aed099d
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4aed099d
编写于
12月 23, 2021
作者:
王
王明冬
提交者:
GitHub
12月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[infrt] unify the paddle dialect operation name. test=develop (#38354)
上级
4e4d58b3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
64 addition
and
40 deletion
+64
-40
paddle/infrt/dialect/mlir_loader.cc
paddle/infrt/dialect/mlir_loader.cc
+2
-2
paddle/infrt/dialect/mlir_tests/paddle_ops.mlir
paddle/infrt/dialect/mlir_tests/paddle_ops.mlir
+3
-3
paddle/infrt/dialect/mlir_tests/rewrite.mlir
paddle/infrt/dialect/mlir_tests/rewrite.mlir
+16
-16
paddle/infrt/dialect/mlir_tests/rewrite_conv_bn.mlir
paddle/infrt/dialect/mlir_tests/rewrite_conv_bn.mlir
+7
-7
paddle/infrt/dialect/mlir_tests/trt_ops.mlir
paddle/infrt/dialect/mlir_tests/trt_ops.mlir
+24
-0
paddle/infrt/dialect/pd_ops.td
paddle/infrt/dialect/pd_ops.td
+11
-11
paddle/infrt/dialect/print_ir.cc
paddle/infrt/dialect/print_ir.cc
+1
-1
未找到文件。
paddle/infrt/dialect/mlir_loader.cc
浏览文件 @
4aed099d
...
...
@@ -34,7 +34,7 @@ namespace infrt::dialect {
mlir
::
OwningModuleRef
LoadMlirSource
(
mlir
::
MLIRContext
*
context
,
const
std
::
string
&
mlir_source
)
{
context
->
allowUnregisteredDialects
();
//
context->allowUnregisteredDialects();
RegisterCinnDialects
(
context
->
getDialectRegistry
());
context
->
getDialectRegistry
().
insert
<
mlir
::
StandardOpsDialect
>
();
...
...
@@ -54,7 +54,7 @@ mlir::OwningModuleRef LoadMlirSource(mlir::MLIRContext* context,
mlir
::
OwningModuleRef
LoadMlirFile
(
const
std
::
string
&
file_name
,
mlir
::
MLIRContext
*
context
)
{
context
->
allowUnregisteredDialects
();
//
context->allowUnregisteredDialects();
RegisterCinnDialects
(
context
->
getDialectRegistry
());
context
->
getDialectRegistry
().
insert
<
mlir
::
StandardOpsDialect
>
();
...
...
paddle/infrt/dialect/mlir_tests/paddle_ops.mlir
浏览文件 @
4aed099d
func @ops() {
%a = pd.
F
eed() : tensor<?xf32>
%b = pd.
F
eed() : tensor<?xf32>
%a = pd.
f
eed() : tensor<?xf32>
%b = pd.
f
eed() : tensor<?xf32>
%c = "pd.
M
atmul"(%a, %b) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%c = "pd.
m
atmul"(%a, %b) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
infrt.return
}
paddle/infrt/dialect/mlir_tests/rewrite.mlir
浏览文件 @
4aed099d
// CHECK-LABEL: @main
func @main() -> tensor<?xf32> {
%a = "pd.
F
eed"() : () -> tensor<?xf32>
%b = "pd.
F
eed"() : () -> tensor<?xf32>
%bias = "pd.
F
eed"() : () -> tensor<?xf32>
%a = "pd.
f
eed"() : () -> tensor<?xf32>
%b = "pd.
f
eed"() : () -> tensor<?xf32>
%bias = "pd.
f
eed"() : () -> tensor<?xf32>
%b1 = "pd.
F
eed"() : () -> tensor<?xf32>
%b2 = "pd.
F
eed"() : () -> tensor<?xf32>
%bias1 = "pd.
F
eed"() : () -> tensor<?xf32>
%bias2 = "pd.
F
eed"() : () -> tensor<?xf32>
%b1 = "pd.
f
eed"() : () -> tensor<?xf32>
%b2 = "pd.
f
eed"() : () -> tensor<?xf32>
%bias1 = "pd.
f
eed"() : () -> tensor<?xf32>
%bias2 = "pd.
f
eed"() : () -> tensor<?xf32>
%c = "pd.
M
atmul"(%a, %b) {transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d = "pd.
ElementwiseA
dd"(%c, %bias) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e = "pd.
R
elu6"(%d) {} : (tensor<?xf32>) -> tensor<?xf32>
%c = "pd.
m
atmul"(%a, %b) {transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d = "pd.
elementwise_a
dd"(%c, %bias) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e = "pd.
r
elu6"(%d) {} : (tensor<?xf32>) -> tensor<?xf32>
%c1 = "pd.
M
atmul"(%e, %b1) {transpose_x=false, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d1 = "pd.
ElementwiseA
dd"(%c1, %bias1) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e1 = "pd.
R
elu"(%d1) {} : (tensor<?xf32>) -> tensor<?xf32>
%c1 = "pd.
m
atmul"(%e, %b1) {transpose_x=false, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d1 = "pd.
elementwise_a
dd"(%c1, %bias1) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e1 = "pd.
r
elu"(%d1) {} : (tensor<?xf32>) -> tensor<?xf32>
%c2 = "pd.
M
atmul"(%e1, %b2) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d2 = "pd.
ElementwiseA
dd"(%c2, %bias2) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e2 = "pd.
R
elu"(%d2) {} : (tensor<?xf32>) -> tensor<?xf32>
%c2 = "pd.
m
atmul"(%e1, %b2) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d2 = "pd.
elementwise_a
dd"(%c2, %bias2) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e2 = "pd.
r
elu"(%d2) {} : (tensor<?xf32>) -> tensor<?xf32>
infrt.return %e2 : tensor<?xf32>
}
\ No newline at end of file
paddle/infrt/dialect/mlir_tests/rewrite_conv_bn.mlir
浏览文件 @
4aed099d
// CHECK-LABEL: @main
func @main() -> tensor<?xf32> {
%a = "pd.
F
eed"() : () -> tensor<?x3x256x256xf32>
%filter = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<3x64x3x3xf32>} : () -> tensor<3x64x3x3xf32>
%bias = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%a = "pd.
f
eed"() : () -> tensor<?x3x256x256xf32>
%filter = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<3x64x3x3xf32>} : () -> tensor<3x64x3x3xf32>
%bias = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%scale = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%bias2 = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%mean = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%var = "pd.
C
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%scale = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%bias2 = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%mean = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%var = "pd.
c
onstant"(){value = dense<1.000000e+00> : tensor<64xf32>} : () -> tensor<64xf32>
%c = "pd.conv2d"(%a, %filter, %bias) {} : (tensor<?x3x256x256xf32>, tensor<3x64x3x3xf32>, tensor<64xf32>) -> tensor<?x3x256x256xf32>
%d = "pd.batch_norm"(%c, %scale, %bias2, %mean, %var) {} : (tensor<?x3x256x256xf32>, tensor<64xf32>, tensor<64xf32>, tensor<64xf32>, tensor<64xf32>) -> tensor<?x3x256x256xf32>
...
...
paddle/infrt/dialect/mlir_tests/trt_ops.mlir
0 → 100644
浏览文件 @
4aed099d
// CHECK-LABEL: @main
func @main() -> tensor<?xf32> {
%a = "pd.feed"() : () -> tensor<?xf32>
%b = "pd.feed"() : () -> tensor<?xf32>
%bias = "pd.feed"() : () -> tensor<?xf32>
%c = "pd.feed"() : () -> tensor<?xf32>
%b1 = "pd.feed"() : () -> tensor<?xf32>
%b2 = "pd.feed"() : () -> tensor<?xf32>
%bias1 = "pd.feed"() : () -> tensor<?xf32>
%bias2 = "pd.feed"() : () -> tensor<?xf32>
%d = "pd.elementwise_add"(%c, %bias) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e = "pd.relu6"(%d) {} : (tensor<?xf32>) -> tensor<?xf32>
%c1 = "pd.matmul"(%e, %b1) {transpose_x=false, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d1 = "pd.elementwise_add"(%c1, %bias1) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e1 = "pd.relu"(%d1) {} : (tensor<?xf32>) -> tensor<?xf32>
%c2 = "pd.matmul"(%e1, %b2) {transpose_x=true, transpose_y=false} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%d2 = "pd.elementwise_add"(%c2, %bias2) {axis=1:i32} : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
%e2 = "pd.relu"(%d2) {} : (tensor<?xf32>) -> tensor<?xf32>
"pd.fetch"(%e2) :(tensor<?xf32>)->()
}
paddle/infrt/dialect/pd_ops.td
浏览文件 @
4aed099d
...
...
@@ -41,7 +41,7 @@ def PD_GraphOp : PD_Op<"graph", [SingleBlockImplicitTerminator<"FetchOp">]> {
let results = (outs Variadic<PD_Tensor>:$outputs);
}
def PD_ConstantOp : PD_Op<"
C
onstant", [NoSideEffect, ConstantLike, DeclareOpInterfaceMethods<InferTypeOpInterface>, AllTypesMatch<["value", "output"]>]> {
def PD_ConstantOp : PD_Op<"
c
onstant", [NoSideEffect, ConstantLike, DeclareOpInterfaceMethods<InferTypeOpInterface>, AllTypesMatch<["value", "output"]>]> {
let summary = "constant Op";
let description = [{}];
...
...
@@ -54,7 +54,7 @@ def PD_ConstantOp : PD_Op<"Constant", [NoSideEffect, ConstantLike, DeclareOpInte
];
}
def PD_AbsOp : PD_Op<"
A
bs", [NoSideEffect, SameOperandsAndResultType]> {
def PD_AbsOp : PD_Op<"
a
bs", [NoSideEffect, SameOperandsAndResultType]> {
let summary = "Computes the absolute value of a tensor";
let description = [{
...
...
@@ -74,7 +74,7 @@ def PD_SqrtOp : PD_Op<"sqrt", [NoSideEffect, SameOperandsAndResultType]> {
let results = (outs PD_Tensor:$y);
}
def PD_ReluOp : PD_Op<"
R
elu", [NoSideEffect, SameOperandsAndResultType]> {
def PD_ReluOp : PD_Op<"
r
elu", [NoSideEffect, SameOperandsAndResultType]> {
let summary = "Computes the Relu of a tensor";
let description = [{
...
...
@@ -85,7 +85,7 @@ def PD_ReluOp : PD_Op<"Relu", [NoSideEffect, SameOperandsAndResultType]> {
let hasCanonicalizer = 1;
}
def PD_Relu6Op : PD_Op<"
R
elu6", [NoSideEffect, SameOperandsAndResultType]> {
def PD_Relu6Op : PD_Op<"
r
elu6", [NoSideEffect, SameOperandsAndResultType]> {
let summary = "Computes the Relu6 of a tensor";
let description = [{
...
...
@@ -95,7 +95,7 @@ def PD_Relu6Op : PD_Op<"Relu6", [NoSideEffect, SameOperandsAndResultType]> {
let results = (outs PD_Tensor:$y);
}
def PD_ElementwiseAdd : PD_Op<"
ElementwiseA
dd", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
def PD_ElementwiseAdd : PD_Op<"
elementwise_a
dd", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
let summary = "ElementwiseAdd Op";
let description = [{
}];
...
...
@@ -106,7 +106,7 @@ def PD_ElementwiseAdd : PD_Op<"ElementwiseAdd", [NoSideEffect, Commutative, Decl
let hasFolder = 1;
}
def PD_ElementwiseSub : PD_Op<"
ElementwiseS
ub", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
def PD_ElementwiseSub : PD_Op<"
elementwise_s
ub", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
let summary = "ElementwiseSub Op";
let description = [{
}];
...
...
@@ -115,7 +115,7 @@ def PD_ElementwiseSub : PD_Op<"ElementwiseSub", [NoSideEffect, DeclareOpInterfac
let results = (outs PD_Tensor:$out);
}
def PD_ElementwiseMul : PD_Op<"
ElementwiseM
ul", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
def PD_ElementwiseMul : PD_Op<"
elementwise_m
ul", [NoSideEffect, Commutative, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
let summary = "ElementwiseMul Op";
let description = [{
}];
...
...
@@ -124,7 +124,7 @@ def PD_ElementwiseMul : PD_Op<"ElementwiseMul", [NoSideEffect, Commutative, Decl
let results = (outs PD_Tensor:$out);
}
def PD_ElementwiseDiv : PD_Op<"
ElementwiseD
iv", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
def PD_ElementwiseDiv : PD_Op<"
elementwise_d
iv", [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
let summary = "ElementwiseDiv Op";
let description = [{
}];
...
...
@@ -133,7 +133,7 @@ def PD_ElementwiseDiv : PD_Op<"ElementwiseDiv", [NoSideEffect, DeclareOpInterfac
let results = (outs PD_Tensor:$out);
}
def PD_MatmulOp : PD_Op<"
M
atmul", [NoSideEffect]> {
def PD_MatmulOp : PD_Op<"
m
atmul", [NoSideEffect]> {
let summary = "Computes the matrix mulplication result of two tensors";
let description = [{
}];
...
...
@@ -181,7 +181,7 @@ def PD_BatchNormOp : PD_Op<"batch_norm", [NoSideEffect]> {
let hasCanonicalizer = 1;
}
def PD_FusedFC : PD_Op<"
FC
", [NoSideEffect]> {
def PD_FusedFC : PD_Op<"
fc
", [NoSideEffect]> {
let summary = "Computes the Fully Connected result of two tensors";
let description = [{
}];
...
...
@@ -190,7 +190,7 @@ def PD_FusedFC : PD_Op<"FC", [NoSideEffect]> {
let results = (outs PD_Tensor:$out);
}
def PD_FusedRepeatedFCRelu : PD_Op<"
RepeatedFCR
elu", [SameVariadicOperandSize, NoSideEffect]> {
def PD_FusedRepeatedFCRelu : PD_Op<"
fusion_repeated_fc_r
elu", [SameVariadicOperandSize, NoSideEffect]> {
let summary = "";
let description = [{ }];
...
...
paddle/infrt/dialect/print_ir.cc
浏览文件 @
4aed099d
...
...
@@ -115,7 +115,7 @@ int main(int argc, char **argv) {
cl
::
ParseCommandLineOptions
(
argc
,
argv
,
"mlir demo"
);
mlir
::
MLIRContext
*
context
=
infrt
::
Global
::
getMLIRContext
();
context
->
allowUnregisteredDialects
();
//
context->allowUnregisteredDialects();
auto
&
registry
=
context
->
getDialectRegistry
();
infrt
::
RegisterCinnDialects
(
registry
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录