Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6c183a8e
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
6c183a8e
编写于
11月 11, 2021
作者:
W
Wilber
提交者:
GitHub
11月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update ut (#37089)
上级
32c3e61b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
93 deletion
+61
-93
python/paddle/fluid/tests/unittests/ir/inference/auto_scan_test.py
...ddle/fluid/tests/unittests/ir/inference/auto_scan_test.py
+3
-3
python/paddle/fluid/tests/unittests/ir/inference/test_emb_eltwise_layernorm_fuse_pass.py
...ests/ir/inference/test_emb_eltwise_layernorm_fuse_pass.py
+50
-73
python/paddle/fluid/tests/unittests/ir/inference/test_mkldnn_prelu_op.py
...luid/tests/unittests/ir/inference/test_mkldnn_prelu_op.py
+8
-17
未找到文件。
python/paddle/fluid/tests/unittests/ir/inference/auto_scan_test.py
浏览文件 @
6c183a8e
...
@@ -260,7 +260,7 @@ class MkldnnAutoScanTest(AutoScanTest):
...
@@ -260,7 +260,7 @@ class MkldnnAutoScanTest(AutoScanTest):
self
.
assertTrue
(
status
)
self
.
assertTrue
(
status
)
def
inference_config_str
(
self
,
config
)
->
bool
:
def
inference_config_str
(
self
,
config
)
->
str
:
dic
=
{}
dic
=
{}
enable_mkldnn
=
config
.
mkldnn_enabled
()
enable_mkldnn
=
config
.
mkldnn_enabled
()
dic
[
'use_mkldnn'
]
=
enable_mkldnn
dic
[
'use_mkldnn'
]
=
enable_mkldnn
...
@@ -372,7 +372,7 @@ class PassAutoScanTest(AutoScanTest):
...
@@ -372,7 +372,7 @@ class PassAutoScanTest(AutoScanTest):
status
=
self
.
check_op_version
()
and
status
status
=
self
.
check_op_version
()
and
status
self
.
assertTrue
(
status
)
self
.
assertTrue
(
status
)
def
inference_config_str
(
self
,
config
)
->
bool
:
def
inference_config_str
(
self
,
config
)
->
str
:
dic
=
{}
dic
=
{}
enable_mkldnn
=
config
.
mkldnn_enabled
()
enable_mkldnn
=
config
.
mkldnn_enabled
()
dic
[
'use_mkldnn'
]
=
enable_mkldnn
dic
[
'use_mkldnn'
]
=
enable_mkldnn
...
@@ -491,7 +491,7 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -491,7 +491,7 @@ class TrtLayerAutoScanTest(AutoScanTest):
'paddle_op_num is {}, but got {}!'
.
format
(
'paddle_op_num is {}, but got {}!'
.
format
(
paddle_op_size
,
paddle_op_num
))
paddle_op_size
,
paddle_op_num
))
def
inference_config_str
(
self
,
config
:
paddle_infer
.
Config
):
def
inference_config_str
(
self
,
config
:
paddle_infer
.
Config
)
->
str
:
dic
=
{}
dic
=
{}
enable_trt
=
config
.
tensorrt_engine_enabled
()
enable_trt
=
config
.
tensorrt_engine_enabled
()
trt_precison
=
config
.
tensorrt_precision_mode
()
trt_precison
=
config
.
tensorrt_precision_mode
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_emb_eltwise_layernorm_fuse_pass.py
浏览文件 @
6c183a8e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
from
auto_scan_test
import
PassAutoScanTest
,
SkipReasons
from
auto_scan_test
import
PassAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
,
OpConfig
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -116,94 +116,71 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
...
@@ -116,94 +116,71 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
'weight_size'
:
kwargs
[
'weight_size'
]
'weight_size'
:
kwargs
[
'weight_size'
]
}]
}]
ops_config
=
[{
emb_op1
=
OpConfig
(
"op_type"
:
attrs
[
0
][
'op_type'
],
type
=
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
inputs
=
{
"Ids"
:
[
"input_data1"
],
"Ids"
:
[
"input_data1"
],
"W"
:
[
"embedding_weight1"
]},
"W"
:
[
"embedding_weight1"
]
outputs
=
{
"Out"
:
[
"embedding_output1"
]},
},
attrs
=
{
"op_outputs"
:
{
"Out"
:
[
"embedding_output1"
]
},
"op_attrs"
:
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
}
})
},
{
emb_op2
=
OpConfig
(
"op_type"
:
attrs
[
0
][
'op_type'
],
type
=
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
inputs
=
{
"Ids"
:
[
"input_data2"
],
"Ids"
:
[
"input_data2"
],
"W"
:
[
"embedding_weight2"
]},
"W"
:
[
"embedding_weight2"
]
outputs
=
{
"Out"
:
[
"embedding_output2"
]},
},
attrs
=
{
"op_outputs"
:
{
"Out"
:
[
"embedding_output2"
]
},
"op_attrs"
:
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
},
})
},
{
emb_op3
=
OpConfig
(
"op_type"
:
attrs
[
0
][
'op_type'
],
type
=
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
inputs
=
{
"Ids"
:
[
"input_data3"
],
"Ids"
:
[
"input_data3"
],
"W"
:
[
"embedding_weight3"
]},
"W"
:
[
"embedding_weight3"
]
outputs
=
{
"Out"
:
[
"embedding_output3"
]},
},
attrs
=
{
"op_outputs"
:
{
"Out"
:
[
"embedding_output3"
]
},
"op_attrs"
:
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
},
})
},
{
add_op1
=
OpConfig
(
"op_type"
:
"elementwise_add"
,
type
=
'elementwise_add'
,
"op_inputs"
:
{
inputs
=
{
"X"
:
[
"embedding_output2"
],
"X"
:
[
emb_op2
.
outputs
[
"Out"
][
0
]],
"Y"
:
[
"embedding_output3"
]
"Y"
:
[
emb_op3
.
outputs
[
"Out"
][
0
]],
},
"op_outputs"
:
{
"Out"
:
[
"elementwise_add_output1"
]
},
"op_attrs"
:
{
"axis"
:
attrs
[
1
][
'axis'
],
}
},
{
"op_type"
:
"elementwise_add"
,
"op_inputs"
:
{
"X"
:
[
"elementwise_add_output1"
],
"Y"
:
[
"embedding_output1"
]
},
},
"op_outputs"
:
{
outputs
=
{
"Out"
:
[
"elementwise_add_output1"
]},
"Out"
:
[
"elementwise_add_output2"
]
attrs
=
{
"axis"
:
attrs
[
1
][
'axis'
]})
add_op2
=
OpConfig
(
type
=
'elementwise_add'
,
inputs
=
{
"X"
:
[
add_op1
.
outputs
[
"Out"
][
0
]],
"Y"
:
[
emb_op1
.
outputs
[
"Out"
][
0
]],
},
},
"op_attrs"
:
{
outputs
=
{
"Out"
:
[
"elementwise_add_output2"
]},
"axis"
:
attrs
[
1
][
'axis'
],
attrs
=
{
"axis"
:
attrs
[
1
][
'axis'
]})
}
layer_norm_op
=
OpConfig
(
},
{
type
=
'layer_norm'
,
"op_type"
:
"layer_norm"
,
inputs
=
{
"op_inputs"
:
{
"X"
:
[
add_op2
.
outputs
[
"Out"
][
0
]],
"X"
:
[
"elementwise_add_output2"
],
"Bias"
:
[
"layer_norm_bias"
],
"Bias"
:
[
"layer_norm_bias"
],
"Scale"
:
[
"layer_norm_scale"
]
"Scale"
:
[
"layer_norm_scale"
]
},
},
"op_outputs"
:
{
outputs
=
{
"Y"
:
[
"layer_norm_output1"
],
"Y"
:
[
"layer_norm_output1"
],
"Mean"
:
[
"layer_norm_output2"
],
"Mean"
:
[
"layer_norm_output2"
],
"Variance"
:
[
"layer_norm_output3"
]
"Variance"
:
[
"layer_norm_output3"
]
},
},
"op_attrs"
:
{
attrs
=
{
'begin_norm_axis'
:
attrs
[
2
][
'begin_norm_axis'
],
'begin_norm_axis'
:
attrs
[
2
][
'begin_norm_axis'
],
'epsilon'
:
attrs
[
2
][
'epsilon'
],
'epsilon'
:
attrs
[
2
][
'epsilon'
]
}
})
}]
ops
=
self
.
generate_op_config
(
ops_config
)
program_config
=
ProgramConfig
(
program_config
=
ProgramConfig
(
ops
=
ops
,
ops
=
[
emb_op1
,
emb_op2
,
emb_op3
,
add_op1
,
add_op2
,
layer_norm_op
]
,
weights
=
{
weights
=
{
"embedding_weight1"
:
"embedding_weight1"
:
TensorConfig
(
data_gen
=
partial
(
generate_weight1
,
attrs
[
3
])),
TensorConfig
(
data_gen
=
partial
(
generate_weight1
,
attrs
[
3
])),
...
@@ -242,7 +219,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
...
@@ -242,7 +219,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
precision_mode
=
paddle_infer
.
PrecisionType
.
Float32
,
precision_mode
=
paddle_infer
.
PrecisionType
.
Float32
,
use_static
=
False
,
use_static
=
False
,
use_calib_mode
=
False
)
use_calib_mode
=
False
)
yield
config
,
(
10
,
3
),
(
1e-5
,
1e-5
)
yield
config
,
(
10
,
5
),
(
1e-5
,
1e-5
)
# trt dynamic_shape
# trt dynamic_shape
config
=
self
.
create_trt_inference_config
()
config
=
self
.
create_trt_inference_config
()
config
.
enable_tensorrt_engine
(
config
.
enable_tensorrt_engine
(
...
@@ -280,7 +257,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
...
@@ -280,7 +257,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
"input_data2"
:
[
2
,
128
],
"input_data2"
:
[
2
,
128
],
"input_data3"
:
[
2
,
128
]
"input_data3"
:
[
2
,
128
]
})
})
yield
config
,
(
10
,
3
),
(
1e-5
,
1e-5
)
yield
config
,
(
10
,
5
),
(
1e-5
,
1e-5
)
def
add_skip_pass_case
(
self
):
def
add_skip_pass_case
(
self
):
def
teller1
(
program_config
,
predictor_config
):
def
teller1
(
program_config
,
predictor_config
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_mkldnn_prelu_op.py
浏览文件 @
6c183a8e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# limitations under the License.
# limitations under the License.
from
auto_scan_test
import
MkldnnAutoScanTest
,
SkipReasons
from
auto_scan_test
import
MkldnnAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
,
OpConfig
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -52,24 +52,15 @@ class TestMkldnnPreluOp(MkldnnAutoScanTest):
...
@@ -52,24 +52,15 @@ class TestMkldnnPreluOp(MkldnnAutoScanTest):
return
np
.
zeros
((
1
)).
astype
(
np
.
float32
)
return
np
.
zeros
((
1
)).
astype
(
np
.
float32
)
return
np
.
random
.
random
(
kwargs
[
'in_shape'
]).
astype
(
np
.
float32
)
return
np
.
random
.
random
(
kwargs
[
'in_shape'
]).
astype
(
np
.
float32
)
ops_config
=
[{
prelu_op
=
OpConfig
(
"op_type"
:
"prelu"
,
type
=
"prelu"
,
"op_inputs"
:
{
inputs
=
{
"X"
:
[
"input_data"
],
"X"
:
[
"input_data"
],
"Alpha"
:
[
"alpha_weight"
]},
"Alpha"
:
[
"alpha_weight"
]
outputs
=
{
"Out"
:
[
"output_data"
]},
},
attrs
=
{
"mode"
:
kwargs
[
'mode'
]})
"op_outputs"
:
{
"Out"
:
[
"output_data"
]
},
"op_attrs"
:
{
"mode"
:
kwargs
[
'mode'
]
}
}]
ops
=
self
.
generate_op_config
(
ops_config
)
program_config
=
ProgramConfig
(
program_config
=
ProgramConfig
(
ops
=
ops
,
ops
=
[
prelu_op
]
,
weights
=
{
weights
=
{
"alpha_weight"
:
"alpha_weight"
:
TensorConfig
(
data_gen
=
partial
(
generate_alpha
,
*
args
,
**
kwargs
))
TensorConfig
(
data_gen
=
partial
(
generate_alpha
,
*
args
,
**
kwargs
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录