Skip to content

Commit

Permalink
add opset and better print
Browse files Browse the repository at this point in the history
  • Loading branch information
inisis committed Nov 9, 2023
1 parent e0126f7 commit b4d5d17
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions onnxslim/core/slim.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def init_logging(self, log_level):

ort.set_default_logger_severity(3)

def get_opset(self, model):
try:
for importer in model.opset_import:
if importer.domain == "" or importer.domain == "ai.onnx":
return importer.version

return None
except:
return None

def input_shape_modification(self, input_shapes):
if not input_shapes:
return
Expand Down Expand Up @@ -176,18 +186,25 @@ def convert_data_format(self, dtype):
def summary(self):
self.slimmed_info = self.summarize(self.model)
final_op_info = []
final_op_info.append(["Model Name", self.model_name])
final_op_info.append(
[
"Model Name",
self.model_name,
"Op Set: " + str(self.get_opset(self.model)),
]
)
final_op_info.append([SEPARATING_LINE])

final_op_info.append(["Model Info", "Original Model", "Slimmed Model"])
final_op_info.append([SEPARATING_LINE, SEPARATING_LINE, SEPARATING_LINE])

all_inputs = list(self.float_info["op_input_info"].keys())

for inputs in all_inputs:
float_shape = self.float_info["op_input_info"].get(inputs, None)
slimmed_shape = self.slimmed_info["op_input_info"].get(inputs, None)
final_op_info.append(["IN: " + inputs, float_shape, slimmed_shape])

final_op_info.append([SEPARATING_LINE, SEPARATING_LINE, SEPARATING_LINE])

all_outputs = list(self.float_info["op_output_info"].keys())

for outputs in all_outputs:
Expand Down

0 comments on commit b4d5d17

Please sign in to comment.