Skip to content

Commit e0f0ae8

Browse files
authored
refactor: Remove unused variables and arguments in model generation scripts (#8720)
1 parent 79877d7 commit e0f0ae8

22 files changed

Lines changed: 238 additions & 439 deletions

qa/L0_infer/infer_test.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2018-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2018-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -157,19 +157,13 @@ def _infer_exact_helper(
157157
input_dtype,
158158
output0_dtype,
159159
output1_dtype,
160-
(input_size,),
161-
(input_size,),
162-
(input_size,),
163160
):
164161
ensemble_prefix.append(prefix)
165162

166163
if not CPU_ONLY and tu.validate_for_trt_model(
167164
input_dtype,
168165
output0_dtype,
169166
output1_dtype,
170-
(input_size, 1, 1),
171-
(input_size, 1, 1),
172-
(input_size, 1, 1),
173167
):
174168
for prefix in ensemble_prefix:
175169
if "plan" in BACKENDS:
@@ -204,9 +198,6 @@ def _infer_exact_helper(
204198
input_dtype,
205199
output0_dtype,
206200
output1_dtype,
207-
(input_size,),
208-
(input_size,),
209-
(input_size,),
210201
):
211202
for prefix in ensemble_prefix:
212203
if "onnx" in BACKENDS:

qa/L0_infer_reshape/infer_reshape_test.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -50,9 +50,7 @@ def _full_reshape(self, dtype, input_shapes, output_shapes=None, no_batch=True):
5050
output_shapes = input_shapes
5151

5252
# For validation assume any shape can be used...
53-
if tu.validate_for_onnx_model(
54-
dtype, dtype, dtype, input_shapes[0], input_shapes[0], input_shapes[0]
55-
):
53+
if tu.validate_for_onnx_model(dtype, dtype, dtype):
5654
# model that supports batching
5755
for bs in (1, 8):
5856
full_shapes = [
@@ -155,9 +153,6 @@ def _full_reshape(self, dtype, input_shapes, output_shapes=None, no_batch=True):
155153
dtype,
156154
dtype,
157155
dtype,
158-
input_shapes[0],
159-
input_shapes[0],
160-
input_shapes[0],
161156
):
162157
# model that supports batching
163158
for bs in (1, 8):
@@ -203,9 +198,7 @@ def _trt_reshape(self, dtype, input_shapes, output_shapes=None, no_batch=True):
203198
if output_shapes is None:
204199
output_shapes = input_shapes
205200

206-
if tu.validate_for_trt_model(
207-
dtype, dtype, dtype, input_shapes[0], input_shapes[0], input_shapes[0]
208-
):
201+
if tu.validate_for_trt_model(dtype, dtype, dtype):
209202
# model that supports batching
210203
for bs in (1, 8):
211204
full_shapes = [

qa/L0_infer_variable/infer_variable_test.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -140,19 +140,13 @@ def _infer_exact_helper(
140140
input_dtype,
141141
output0_dtype,
142142
output1_dtype,
143-
input_shape,
144-
input_shape,
145-
input_shape,
146143
):
147144
ensemble_prefix.append(prefix)
148145

149146
if tu.validate_for_trt_model(
150147
input_dtype,
151148
output0_dtype,
152149
output1_dtype,
153-
input_shape,
154-
output0_shape,
155-
output1_shape,
156150
):
157151
for prefix in ensemble_prefix:
158152
if input_dtype == np.int8:
@@ -186,9 +180,6 @@ def _infer_exact_helper(
186180
input_dtype,
187181
output0_dtype,
188182
output1_dtype,
189-
input_shape,
190-
output0_shape,
191-
output1_shape,
192183
):
193184
# No basic ensemble models are created against custom models [TODO]
194185
_infer_exact_helper(

qa/L0_infer_zero/infer_zero_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -93,9 +93,7 @@ def _full_zero(self, dtype, shapes):
9393
)
9494

9595
for name in ["simple_zero", "sequence_zero", "fan_zero"]:
96-
if tu.validate_for_ensemble_model(
97-
name, dtype, dtype, dtype, shapes[0], shapes[0], shapes[0]
98-
):
96+
if tu.validate_for_ensemble_model(name, dtype, dtype, dtype):
9997
# model that supports batching
10098
for bs in (1, 8):
10199
batch_shapes = [

qa/L0_storage_swiftstack/infer_test.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2021-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -87,9 +87,6 @@ def _infer_exact_helper(
8787
input_dtype,
8888
output0_dtype,
8989
output1_dtype,
90-
(input_size, 1, 1),
91-
(input_size, 1, 1),
92-
(input_size, 1, 1),
9390
):
9491
if input_dtype == np.int8:
9592
_infer_exact_helper(
@@ -122,9 +119,6 @@ def _infer_exact_helper(
122119
input_dtype,
123120
output0_dtype,
124121
output1_dtype,
125-
(input_size,),
126-
(input_size,),
127-
(input_size,),
128122
):
129123
_infer_exact_helper(
130124
self,

qa/common/gen_ensemble_model_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -761,7 +761,7 @@ def create_ensemble_modelfile(
761761

762762
try:
763763
os.makedirs(model_version_dir)
764-
except OSError as ex:
764+
except OSError:
765765
pass # ignore existing dir
766766

767767

@@ -834,7 +834,7 @@ def create_ensemble_modelconfig(
834834

835835
try:
836836
os.makedirs(config_dir)
837-
except OSError as ex:
837+
except OSError:
838838
pass # ignore existing dir
839839

840840
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -867,7 +867,7 @@ def create_identity_ensemble_modelfile(
867867

868868
try:
869869
os.makedirs(model_version_dir)
870-
except OSError as ex:
870+
except OSError:
871871
pass # ignore existing dir
872872

873873

@@ -915,7 +915,7 @@ def create_identity_ensemble_modelconfig(
915915

916916
try:
917917
os.makedirs(config_dir)
918-
except OSError as ex:
918+
except OSError:
919919
pass # ignore existing dir
920920

921921
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -937,7 +937,7 @@ def create_sequence_ensemble_modelfile(
937937

938938
try:
939939
os.makedirs(model_version_dir)
940-
except OSError as ex:
940+
except OSError:
941941
pass # ignore existing dir
942942

943943

@@ -979,7 +979,7 @@ def create_sequence_ensemble_modelconfig(
979979

980980
try:
981981
os.makedirs(config_dir)
982-
except OSError as ex:
982+
except OSError:
983983
pass # ignore existing dir
984984

985985
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -1015,7 +1015,7 @@ def create_nop_modelconfig(
10151015

10161016
try:
10171017
os.makedirs(config_dir)
1018-
except OSError as ex:
1018+
except OSError:
10191019
pass # ignore existing dir
10201020

10211021
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -1059,7 +1059,7 @@ def create_nop_tunnel_modelconfig(models_dir, tensor_shape, tensor_dtype):
10591059

10601060
try:
10611061
os.makedirs(config_dir)
1062-
except OSError as ex:
1062+
except OSError:
10631063
pass # ignore existing dir
10641064

10651065
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -1084,7 +1084,7 @@ def create_nop_tunnel_modelconfig(models_dir, tensor_shape, tensor_dtype):
10841084

10851085
try:
10861086
os.makedirs(config_dir)
1087-
except OSError as ex:
1087+
except OSError:
10881088
pass # ignore existing dir
10891089

10901090
with open(config_dir + "/config.pbtxt", "w") as cfile:

qa/common/gen_qa_custom_ops_models.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# Copyright 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -68,13 +68,13 @@ def forward(self, input0, input1):
6868

6969
try:
7070
os.makedirs(model_version_dir)
71-
except OSError as ex:
71+
except OSError:
7272
pass # ignore existing dir
7373

7474
traced.save(model_version_dir + "/model.pt")
7575

7676

77-
def create_moduloop_modelconfig(models_dir, model_version):
77+
def create_moduloop_modelconfig(models_dir):
7878
model_name = "libtorch_modulo"
7979
config_dir = models_dir + "/" + model_name
8080
config = """
@@ -106,7 +106,7 @@ def create_moduloop_modelconfig(models_dir, model_version):
106106

107107
try:
108108
os.makedirs(config_dir)
109-
except OSError as ex:
109+
except OSError:
110110
pass # ignore existing dir
111111

112112
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -132,13 +132,13 @@ def forward(self, input, boxes):
132132

133133
try:
134134
os.makedirs(model_version_dir)
135-
except OSError as ex:
135+
except OSError:
136136
pass # ignore existing dir
137137

138138
scripted.save(model_version_dir + "/model.pt")
139139

140140

141-
def create_visionop_modelconfig(models_dir, model_version):
141+
def create_visionop_modelconfig(models_dir):
142142
model_name = "libtorch_visionop"
143143
config_dir = models_dir + "/" + model_name
144144
config = """
@@ -170,7 +170,7 @@ def create_visionop_modelconfig(models_dir, model_version):
170170

171171
try:
172172
os.makedirs(config_dir)
173-
except OSError as ex:
173+
except OSError:
174174
pass # ignore existing dir
175175

176176
with open(config_dir + "/config.pbtxt", "w") as cfile:
@@ -181,15 +181,15 @@ def create_modulo_op_models(models_dir):
181181
model_version = 1
182182

183183
if FLAGS.libtorch:
184-
create_moduloop_modelconfig(models_dir, model_version)
184+
create_moduloop_modelconfig(models_dir)
185185
create_moduloop_modelfile(models_dir, model_version)
186186

187187

188188
def create_vision_op_models(models_dir):
189189
model_version = 1
190190

191191
if FLAGS.libtorch:
192-
create_visionop_modelconfig(models_dir, model_version)
192+
create_visionop_modelconfig(models_dir)
193193
create_visionop_modelfile(models_dir, model_version)
194194

195195

0 commit comments

Comments
 (0)