|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | from auto_scan_test import PassAutoScanTest, SkipReasons |
16 | | -from program_config import TensorConfig, ProgramConfig |
| 16 | +from program_config import TensorConfig, ProgramConfig, OpConfig |
17 | 17 | import numpy as np |
18 | 18 | import paddle.inference as paddle_infer |
19 | 19 | from functools import partial |
@@ -116,94 +116,71 @@ def generate_weight2(attrs): |
116 | 116 | 'weight_size': kwargs['weight_size'] |
117 | 117 | }] |
118 | 118 |
|
119 | | - ops_config = [{ |
120 | | - "op_type": attrs[0]['op_type'], |
121 | | - "op_inputs": { |
122 | | - "Ids": ["input_data1"], |
123 | | - "W": ["embedding_weight1"] |
124 | | - }, |
125 | | - "op_outputs": { |
126 | | - "Out": ["embedding_output1"] |
127 | | - }, |
128 | | - "op_attrs": { |
| 119 | + emb_op1 = OpConfig( |
| 120 | + type=attrs[0]['op_type'], |
| 121 | + inputs={"Ids": ["input_data1"], |
| 122 | + "W": ["embedding_weight1"]}, |
| 123 | + outputs={"Out": ["embedding_output1"]}, |
| 124 | + attrs={ |
129 | 125 | 'is_sparse': attrs[0]['is_sparse'], |
130 | 126 | 'is_distributed': attrs[0]['is_distributed'], |
131 | | - 'padding_idx': attrs[0]['padding_idx'], |
132 | | - } |
133 | | - }, { |
134 | | - "op_type": attrs[0]['op_type'], |
135 | | - "op_inputs": { |
136 | | - "Ids": ["input_data2"], |
137 | | - "W": ["embedding_weight2"] |
138 | | - }, |
139 | | - "op_outputs": { |
140 | | - "Out": ["embedding_output2"] |
141 | | - }, |
142 | | - "op_attrs": { |
| 127 | + 'padding_idx': attrs[0]['padding_idx'] |
| 128 | + }) |
| 129 | + emb_op2 = OpConfig( |
| 130 | + type=attrs[0]['op_type'], |
| 131 | + inputs={"Ids": ["input_data2"], |
| 132 | + "W": ["embedding_weight2"]}, |
| 133 | + outputs={"Out": ["embedding_output2"]}, |
| 134 | + attrs={ |
143 | 135 | 'is_sparse': attrs[0]['is_sparse'], |
144 | 136 | 'is_distributed': attrs[0]['is_distributed'], |
145 | | - 'padding_idx': attrs[0]['padding_idx'], |
146 | | - }, |
147 | | - }, { |
148 | | - "op_type": attrs[0]['op_type'], |
149 | | - "op_inputs": { |
150 | | - "Ids": ["input_data3"], |
151 | | - "W": ["embedding_weight3"] |
152 | | - }, |
153 | | - "op_outputs": { |
154 | | - "Out": ["embedding_output3"] |
155 | | - }, |
156 | | - "op_attrs": { |
| 137 | + 'padding_idx': attrs[0]['padding_idx'] |
| 138 | + }) |
| 139 | + emb_op3 = OpConfig( |
| 140 | + type=attrs[0]['op_type'], |
| 141 | + inputs={"Ids": ["input_data3"], |
| 142 | + "W": ["embedding_weight3"]}, |
| 143 | + outputs={"Out": ["embedding_output3"]}, |
| 144 | + attrs={ |
157 | 145 | 'is_sparse': attrs[0]['is_sparse'], |
158 | 146 | 'is_distributed': attrs[0]['is_distributed'], |
159 | | - 'padding_idx': attrs[0]['padding_idx'], |
160 | | - }, |
161 | | - }, { |
162 | | - "op_type": "elementwise_add", |
163 | | - "op_inputs": { |
164 | | - "X": ["embedding_output2"], |
165 | | - "Y": ["embedding_output3"] |
166 | | - }, |
167 | | - "op_outputs": { |
168 | | - "Out": ["elementwise_add_output1"] |
169 | | - }, |
170 | | - "op_attrs": { |
171 | | - "axis": attrs[1]['axis'], |
172 | | - } |
173 | | - }, { |
174 | | - "op_type": "elementwise_add", |
175 | | - "op_inputs": { |
176 | | - "X": ["elementwise_add_output1"], |
177 | | - "Y": ["embedding_output1"] |
| 147 | + 'padding_idx': attrs[0]['padding_idx'] |
| 148 | + }) |
| 149 | + add_op1 = OpConfig( |
| 150 | + type='elementwise_add', |
| 151 | + inputs={ |
| 152 | + "X": [emb_op2.outputs["Out"][0]], |
| 153 | + "Y": [emb_op3.outputs["Out"][0]], |
178 | 154 | }, |
179 | | - "op_outputs": { |
180 | | - "Out": ["elementwise_add_output2"] |
| 155 | + outputs={"Out": ["elementwise_add_output1"]}, |
| 156 | + attrs={"axis": attrs[1]['axis']}) |
| 157 | + add_op2 = OpConfig( |
| 158 | + type='elementwise_add', |
| 159 | + inputs={ |
| 160 | + "X": [add_op1.outputs["Out"][0]], |
| 161 | + "Y": [emb_op1.outputs["Out"][0]], |
181 | 162 | }, |
182 | | - "op_attrs": { |
183 | | - "axis": attrs[1]['axis'], |
184 | | - } |
185 | | - }, { |
186 | | - "op_type": "layer_norm", |
187 | | - "op_inputs": { |
188 | | - "X": ["elementwise_add_output2"], |
| 163 | + outputs={"Out": ["elementwise_add_output2"]}, |
| 164 | + attrs={"axis": attrs[1]['axis']}) |
| 165 | + layer_norm_op = OpConfig( |
| 166 | + type='layer_norm', |
| 167 | + inputs={ |
| 168 | + "X": [add_op2.outputs["Out"][0]], |
189 | 169 | "Bias": ["layer_norm_bias"], |
190 | 170 | "Scale": ["layer_norm_scale"] |
191 | 171 | }, |
192 | | - "op_outputs": { |
| 172 | + outputs={ |
193 | 173 | "Y": ["layer_norm_output1"], |
194 | 174 | "Mean": ["layer_norm_output2"], |
195 | 175 | "Variance": ["layer_norm_output3"] |
196 | 176 | }, |
197 | | - "op_attrs": { |
| 177 | + attrs={ |
198 | 178 | 'begin_norm_axis': attrs[2]['begin_norm_axis'], |
199 | | - 'epsilon': attrs[2]['epsilon'], |
200 | | - } |
201 | | - }] |
202 | | - |
203 | | - ops = self.generate_op_config(ops_config) |
| 179 | + 'epsilon': attrs[2]['epsilon'] |
| 180 | + }) |
204 | 181 |
|
205 | 182 | program_config = ProgramConfig( |
206 | | - ops=ops, |
| 183 | + ops=[emb_op1, emb_op2, emb_op3, add_op1, add_op2, layer_norm_op], |
207 | 184 | weights={ |
208 | 185 | "embedding_weight1": |
209 | 186 | TensorConfig(data_gen=partial(generate_weight1, attrs[3])), |
@@ -242,7 +219,7 @@ def sample_predictor_configs(self, program_config): |
242 | 219 | precision_mode=paddle_infer.PrecisionType.Float32, |
243 | 220 | use_static=False, |
244 | 221 | use_calib_mode=False) |
245 | | - yield config, (10, 3), (1e-5, 1e-5) |
| 222 | + yield config, (10, 5), (1e-5, 1e-5) |
246 | 223 | # trt dynamic_shape |
247 | 224 | config = self.create_trt_inference_config() |
248 | 225 | config.enable_tensorrt_engine( |
@@ -280,7 +257,7 @@ def sample_predictor_configs(self, program_config): |
280 | 257 | "input_data2": [2, 128], |
281 | 258 | "input_data3": [2, 128] |
282 | 259 | }) |
283 | | - yield config, (10, 3), (1e-5, 1e-5) |
| 260 | + yield config, (10, 5), (1e-5, 1e-5) |
284 | 261 |
|
285 | 262 | def add_skip_pass_case(self): |
286 | 263 | def teller1(program_config, predictor_config): |
|
0 commit comments