Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6c183a8e
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
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):
self
.
assertTrue
(
status
)
def
inference_config_str
(
self
,
config
)
->
bool
:
def
inference_config_str
(
self
,
config
)
->
str
:
dic
=
{}
enable_mkldnn
=
config
.
mkldnn_enabled
()
dic
[
'use_mkldnn'
]
=
enable_mkldnn
...
...
@@ -372,7 +372,7 @@ class PassAutoScanTest(AutoScanTest):
status
=
self
.
check_op_version
()
and
status
self
.
assertTrue
(
status
)
def
inference_config_str
(
self
,
config
)
->
bool
:
def
inference_config_str
(
self
,
config
)
->
str
:
dic
=
{}
enable_mkldnn
=
config
.
mkldnn_enabled
()
dic
[
'use_mkldnn'
]
=
enable_mkldnn
...
...
@@ -491,7 +491,7 @@ class TrtLayerAutoScanTest(AutoScanTest):
'paddle_op_num is {}, but got {}!'
.
format
(
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
=
{}
enable_trt
=
config
.
tensorrt_engine_enabled
()
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 @@
# limitations under the License.
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
paddle.inference
as
paddle_infer
from
functools
import
partial
...
...
@@ -116,94 +116,71 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
'weight_size'
:
kwargs
[
'weight_size'
]
}]
ops_config
=
[{
"op_type"
:
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
"Ids"
:
[
"input_data1"
],
"W"
:
[
"embedding_weight1"
]
},
"op_outputs"
:
{
"Out"
:
[
"embedding_output1"
]
},
"op_attrs"
:
{
emb_op1
=
OpConfig
(
type
=
attrs
[
0
][
'op_type'
],
inputs
=
{
"Ids"
:
[
"input_data1"
],
"W"
:
[
"embedding_weight1"
]},
outputs
=
{
"Out"
:
[
"embedding_output1"
]},
attrs
=
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
}
},
{
"op_type"
:
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
"Ids"
:
[
"input_data2"
],
"W"
:
[
"embedding_weight2"
]
},
"op_outputs"
:
{
"Out"
:
[
"embedding_output2"
]
},
"op_attrs"
:
{
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
})
emb_op2
=
OpConfig
(
type
=
attrs
[
0
][
'op_type'
],
inputs
=
{
"Ids"
:
[
"input_data2"
],
"W"
:
[
"embedding_weight2"
]},
outputs
=
{
"Out"
:
[
"embedding_output2"
]},
attrs
=
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
},
},
{
"op_type"
:
attrs
[
0
][
'op_type'
],
"op_inputs"
:
{
"Ids"
:
[
"input_data3"
],
"W"
:
[
"embedding_weight3"
]
},
"op_outputs"
:
{
"Out"
:
[
"embedding_output3"
]
},
"op_attrs"
:
{
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
})
emb_op3
=
OpConfig
(
type
=
attrs
[
0
][
'op_type'
],
inputs
=
{
"Ids"
:
[
"input_data3"
],
"W"
:
[
"embedding_weight3"
]},
outputs
=
{
"Out"
:
[
"embedding_output3"
]},
attrs
=
{
'is_sparse'
:
attrs
[
0
][
'is_sparse'
],
'is_distributed'
:
attrs
[
0
][
'is_distributed'
],
'padding_idx'
:
attrs
[
0
][
'padding_idx'
],
},
},
{
"op_type"
:
"elementwise_add"
,
"op_inputs"
:
{
"X"
:
[
"embedding_output2"
],
"Y"
:
[
"embedding_output3"
]
},
"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"
]
'padding_idx'
:
attrs
[
0
][
'padding_idx'
]
})
add_op1
=
OpConfig
(
type
=
'elementwise_add'
,
inputs
=
{
"X"
:
[
emb_op2
.
outputs
[
"Out"
][
0
]],
"Y"
:
[
emb_op3
.
outputs
[
"Out"
][
0
]],
},
"op_outputs"
:
{
"Out"
:
[
"elementwise_add_output2"
]
outputs
=
{
"Out"
:
[
"elementwise_add_output1"
]},
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"
:
{
"axis"
:
attrs
[
1
][
'axis'
],
}
},
{
"op_type"
:
"layer_norm"
,
"op_inputs"
:
{
"X"
:
[
"elementwise_add_output2"
],
outputs
=
{
"Out"
:
[
"elementwise_add_output2"
]},
attrs
=
{
"axis"
:
attrs
[
1
][
'axis'
]})
layer_norm_op
=
OpConfig
(
type
=
'layer_norm'
,
inputs
=
{
"X"
:
[
add_op2
.
outputs
[
"Out"
][
0
]],
"Bias"
:
[
"layer_norm_bias"
],
"Scale"
:
[
"layer_norm_scale"
]
},
"op_outputs"
:
{
outputs
=
{
"Y"
:
[
"layer_norm_output1"
],
"Mean"
:
[
"layer_norm_output2"
],
"Variance"
:
[
"layer_norm_output3"
]
},
"op_attrs"
:
{
attrs
=
{
'begin_norm_axis'
:
attrs
[
2
][
'begin_norm_axis'
],
'epsilon'
:
attrs
[
2
][
'epsilon'
],
}
}]
ops
=
self
.
generate_op_config
(
ops_config
)
'epsilon'
:
attrs
[
2
][
'epsilon'
]
})
program_config
=
ProgramConfig
(
ops
=
ops
,
ops
=
[
emb_op1
,
emb_op2
,
emb_op3
,
add_op1
,
add_op2
,
layer_norm_op
]
,
weights
=
{
"embedding_weight1"
:
TensorConfig
(
data_gen
=
partial
(
generate_weight1
,
attrs
[
3
])),
...
...
@@ -242,7 +219,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
precision_mode
=
paddle_infer
.
PrecisionType
.
Float32
,
use_static
=
False
,
use_calib_mode
=
False
)
yield
config
,
(
10
,
3
),
(
1e-5
,
1e-5
)
yield
config
,
(
10
,
5
),
(
1e-5
,
1e-5
)
# trt dynamic_shape
config
=
self
.
create_trt_inference_config
()
config
.
enable_tensorrt_engine
(
...
...
@@ -280,7 +257,7 @@ class TestEmbeddingEltwiseLayerNormFusePass(PassAutoScanTest):
"input_data2"
:
[
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
teller1
(
program_config
,
predictor_config
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_mkldnn_prelu_op.py
浏览文件 @
6c183a8e
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
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
paddle.inference
as
paddle_infer
from
functools
import
partial
...
...
@@ -52,24 +52,15 @@ class TestMkldnnPreluOp(MkldnnAutoScanTest):
return
np
.
zeros
((
1
)).
astype
(
np
.
float32
)
return
np
.
random
.
random
(
kwargs
[
'in_shape'
]).
astype
(
np
.
float32
)
ops_config
=
[{
"op_type"
:
"prelu"
,
"op_inputs"
:
{
"X"
:
[
"input_data"
],
"Alpha"
:
[
"alpha_weight"
]
},
"op_outputs"
:
{
"Out"
:
[
"output_data"
]
},
"op_attrs"
:
{
"mode"
:
kwargs
[
'mode'
]
}
}]
ops
=
self
.
generate_op_config
(
ops_config
)
prelu_op
=
OpConfig
(
type
=
"prelu"
,
inputs
=
{
"X"
:
[
"input_data"
],
"Alpha"
:
[
"alpha_weight"
]},
outputs
=
{
"Out"
:
[
"output_data"
]},
attrs
=
{
"mode"
:
kwargs
[
'mode'
]})
program_config
=
ProgramConfig
(
ops
=
ops
,
ops
=
[
prelu_op
]
,
weights
=
{
"alpha_weight"
:
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录