Skip to content

Commit 82b9f19

Browse files
authored
【Paddle Tensor】Fix bugs related to converting unit tests about collect shape (#71305)
* fix scale * fix codestyle * fix argsort * fix elementwise * fix reduce * fix codestyle * fix collect_shape * fix codestyle * add split test * add time * fix codestyle * fix conv2d * fix codestyle * delete conv2d * delete conv2d * update * last fix * fix timeout * Update CMakeLists.txt
1 parent 9dd9191 commit 82b9f19

6 files changed

+600
-574
lines changed

test/ir/inference/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ if(WITH_GPU AND TENSORRT_FOUND)
175175
PROPERTIES TIMEOUT 1000)
176176
set_tests_properties(test_trt_convert_pool2d PROPERTIES TIMEOUT 600)
177177
set_tests_properties(test_trt_convert_slice PROPERTIES TIMEOUT 600)
178+
set_tests_properties(test_trt_convert_scale PROPERTIES TIMEOUT 600)
179+
set_tests_properties(test_trt_convert_elementwise PROPERTIES TIMEOUT 600)
180+
set_tests_properties(test_trt_convert_reduce PROPERTIES TIMEOUT 600)
181+
set_tests_properties(test_trt_convert_compare_and_logical PROPERTIES TIMEOUT
182+
600)
178183

179184
if(NOT WIN32)
180185

test/ir/inference/test_trt_convert_argsort.py

+47-45
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool:
3030
def sample_program_configs(self):
3131
def generate_input1():
3232
if self.dims == 4:
33-
return np.random.random([1, 3, 3, 4000]).astype(np.float32)
33+
return np.random.random([1, 3, 3, 3840]).astype(np.float32)
3434
elif self.dims == 3:
3535
return np.random.random([1, 3, 24]).astype(np.int32)
3636
elif self.dims == 2:
@@ -69,50 +69,52 @@ def generate_input1():
6969
)
7070
yield program_config
7171

72+
def generate_dynamic_shape(self):
73+
if self.dims == 4:
74+
self.dynamic_shape.min_input_shape = {
75+
"input_data": [1, 3, 3, 3840],
76+
}
77+
self.dynamic_shape.max_input_shape = {
78+
"input_data": [9, 3, 3, 3840],
79+
}
80+
self.dynamic_shape.opt_input_shape = {
81+
"input_data": [6, 3, 3, 3840],
82+
}
83+
elif self.dims == 3:
84+
self.dynamic_shape.min_input_shape = {
85+
"input_data": [1, 3, 24],
86+
}
87+
self.dynamic_shape.max_input_shape = {
88+
"input_data": [9, 3, 24],
89+
}
90+
self.dynamic_shape.opt_input_shape = {
91+
"input_data": [6, 3, 24],
92+
}
93+
elif self.dims == 2:
94+
self.dynamic_shape.min_input_shape = {
95+
"input_data": [1, 24],
96+
}
97+
self.dynamic_shape.max_input_shape = {
98+
"input_data": [9, 24],
99+
}
100+
self.dynamic_shape.opt_input_shape = {
101+
"input_data": [6, 24],
102+
}
103+
else:
104+
self.dynamic_shape.min_input_shape = {
105+
"input_data": [24],
106+
}
107+
self.dynamic_shape.max_input_shape = {
108+
"input_data": [24],
109+
}
110+
self.dynamic_shape.opt_input_shape = {
111+
"input_data": [24],
112+
}
113+
return self.dynamic_shape
114+
72115
def sample_predictor_configs(
73-
self, program_config
116+
self, program_config, run_pir=False
74117
) -> tuple[paddle_infer.Config, list[int], float]:
75-
def generate_dynamic_shape(attrs):
76-
if self.dims == 4:
77-
self.dynamic_shape.min_input_shape = {
78-
"input_data": [1, 3, 3, 4000],
79-
}
80-
self.dynamic_shape.max_input_shape = {
81-
"input_data": [9, 3, 3, 4000],
82-
}
83-
self.dynamic_shape.opt_input_shape = {
84-
"input_data": [6, 3, 3, 4000],
85-
}
86-
elif self.dims == 3:
87-
self.dynamic_shape.min_input_shape = {
88-
"input_data": [1, 3, 24],
89-
}
90-
self.dynamic_shape.max_input_shape = {
91-
"input_data": [9, 3, 24],
92-
}
93-
self.dynamic_shape.opt_input_shape = {
94-
"input_data": [6, 3, 24],
95-
}
96-
elif self.dims == 2:
97-
self.dynamic_shape.min_input_shape = {
98-
"input_data": [1, 24],
99-
}
100-
self.dynamic_shape.max_input_shape = {
101-
"input_data": [9, 24],
102-
}
103-
self.dynamic_shape.opt_input_shape = {
104-
"input_data": [6, 24],
105-
}
106-
else:
107-
self.dynamic_shape.min_input_shape = {
108-
"input_data": [24],
109-
}
110-
self.dynamic_shape.max_input_shape = {
111-
"input_data": [25],
112-
}
113-
self.dynamic_shape.opt_input_shape = {
114-
"input_data": [24],
115-
}
116118

117119
def clear_dynamic_shape():
118120
self.dynamic_shape.max_input_shape = {}
@@ -124,14 +126,14 @@ def clear_dynamic_shape():
124126
]
125127
self.trt_param.workspace_size = 1073741824
126128
# for dynamic_shape
127-
generate_dynamic_shape(attrs)
129+
self.generate_dynamic_shape()
128130
self.trt_param.precision = paddle_infer.PrecisionType.Float32
129131
yield self.create_inference_config(), (1, 3), 1e-5
130132
self.trt_param.precision = paddle_infer.PrecisionType.Half
131133
yield self.create_inference_config(), (1, 3), 1e-3
132134

133135
def test(self):
134-
self.run_test()
136+
self.run_test(run_pir=True)
135137

136138

137139
if __name__ == "__main__":

0 commit comments

Comments
 (0)