Skip to content

Commit 1b32eb6

Browse files
committed
Add inputs and outputs for BenchmarkConfig
Signed-off-by: Cheng, Penghui <[email protected]>
1 parent 06fd5c9 commit 1b32eb6

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

neural_compressor/conf/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,10 @@ def map_pyconfig_to_cfg(self, pythonic_config):
13711371
'tuning.tensorboard': pythonic_config.options.tensorboard,
13721372
})
13731373
if pythonic_config.benchmark is not None:
1374+
if pythonic_config.benchmark.inputs != []:
1375+
mapping.update({'model.inputs': pythonic_config.benchmark.inputs})
1376+
if pythonic_config.benchmark.outputs != []:
1377+
mapping.update({'model.outputs': pythonic_config.benchmark.outputs})
13741378
mapping.update({
13751379
'evaluation.performance.warmup': pythonic_config.benchmark.warmup,
13761380
'evaluation.performance.iteration': pythonic_config.benchmark.iteration,

neural_compressor/config.py

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,42 @@ def tensorboard(self, tensorboard):
136136

137137

138138
class BenchmarkConfig:
139-
def __init__(self, warmup=5, iteration=-1, cores_per_instance=None, num_of_instance=None,
140-
inter_num_of_threads=None, intra_num_of_threads=None):
139+
def __init__(self,
140+
inputs=[],
141+
outputs=[],
142+
warmup=5,
143+
iteration=-1,
144+
cores_per_instance=None,
145+
num_of_instance=None,
146+
inter_num_of_threads=None,
147+
intra_num_of_threads=None):
148+
self._inputs = inputs
149+
self._outputs = outputs
141150
self._warmup = warmup
142151
self._iteration = iteration
143152
self._cores_per_instance = cores_per_instance
144153
self._num_of_instance = num_of_instance
145154
self._inter_num_of_threads = inter_num_of_threads
146155
self._intra_num_of_threads = intra_num_of_threads
147156

157+
@property
158+
def outputs(self):
159+
return self._outputs
160+
161+
@outputs.setter
162+
def outputs(self, outputs):
163+
if check_value('outputs', outputs, str):
164+
self._outputs = outputs
165+
166+
@property
167+
def inputs(self):
168+
return self._inputs
169+
170+
@inputs.setter
171+
def inputs(self, inputs):
172+
if check_value('inputs', inputs, str):
173+
self._inputs = inputs
174+
148175
@property
149176
def warmup(self):
150177
return self._warmup
@@ -789,16 +816,16 @@ def dynamic_axes(self, dynamic_axes):
789816

790817

791818
class Torch2ONNXConfig(ExportConfig):
792-
def __init__(
793-
self,
794-
dtype="int8",
795-
opset_version=14,
796-
quant_format="QDQ",
797-
example_inputs=None,
798-
input_names=None,
799-
output_names=None,
800-
dynamic_axes=None,
801-
**kwargs,
819+
def __init__(
820+
self,
821+
dtype="int8",
822+
opset_version=14,
823+
quant_format="QDQ",
824+
example_inputs=None,
825+
input_names=None,
826+
output_names=None,
827+
dynamic_axes=None,
828+
**kwargs,
802829
):
803830
super().__init__(
804831
dtype=dtype,
@@ -813,16 +840,16 @@ def __init__(
813840

814841

815842
class TF2ONNXConfig(ExportConfig):
816-
def __init__(
817-
self,
818-
dtype="int8",
819-
opset_version=14,
820-
quant_format="QDQ",
821-
example_inputs=None,
822-
input_names=None,
823-
output_names=None,
824-
dynamic_axes=None,
825-
**kwargs,
843+
def __init__(
844+
self,
845+
dtype="int8",
846+
opset_version=14,
847+
quant_format="QDQ",
848+
example_inputs=None,
849+
input_names=None,
850+
output_names=None,
851+
dynamic_axes=None,
852+
**kwargs,
826853
):
827854
super().__init__(
828855
dtype=dtype,

0 commit comments

Comments
 (0)