From 6f7e768cee18faca699bd9c33a4303ca07ce2157 Mon Sep 17 00:00:00 2001 From: carryyu <569782149@qq.com> Date: Wed, 19 Oct 2022 16:58:41 +0800 Subject: [PATCH] test=infer-coverage fix A10 test_fc_elementwise_layernorm_fuse_pass (#46651) --- ...test_fc_elementwise_layernorm_fuse_pass.py | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_fc_elementwise_layernorm_fuse_pass.py b/python/paddle/fluid/tests/unittests/ir/inference/test_fc_elementwise_layernorm_fuse_pass.py index 3bd6fabfd1..23b84df574 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_fc_elementwise_layernorm_fuse_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_fc_elementwise_layernorm_fuse_pass.py @@ -20,6 +20,19 @@ import unittest import hypothesis.strategies as st +class FcElementLayernormFusePassDataGen: + + def __init__(self, min_v, max_v, shape, dtype): + self.min_v = min_v + self.max_v = max_v + self.shape = shape + self.dtype = dtype + + def __call__(self): + return np.random.normal(self.min_v, self.max_v, + self.shape).astype(self.dtype) + + class TestFCElementwiseLayerNormFusePass(PassAutoScanTest): """ x_var w(persistable) bias_var(persistable) @@ -116,11 +129,18 @@ class TestFCElementwiseLayerNormFusePass(PassAutoScanTest): program_config = ProgramConfig( ops=ops, weights={ - "fc_w": TensorConfig(shape=w_shape), - "fc_bias": TensorConfig(shape=fc_bias_shape), - "add_bias": TensorConfig(shape=add_bias_shape), - "scale": TensorConfig(shape=layer_norm_shape), - "layer_norm_bias": TensorConfig(shape=layer_norm_shape), + "fc_w": + TensorConfig(shape=w_shape), + "fc_bias": + TensorConfig(shape=fc_bias_shape), + "add_bias": + TensorConfig(shape=add_bias_shape), + "scale": + TensorConfig(shape=layer_norm_shape, + data_gen=FcElementLayernormFusePassDataGen( + 0.0, 0.5, layer_norm_shape, np.float32)), + "layer_norm_bias": + TensorConfig(shape=layer_norm_shape), }, inputs={ "fc_x": TensorConfig(shape=x_shape), -- GitLab