Forked from daniil-lyakhov/inspect_ov_ir_weights.py
Created
February 15, 2023 20:05
-
-
Save vuiseng9/bbbdb097b4a4d3a12e75e081b8384d21 to your computer and use it in GitHub Desktop.
Way to inspect OpenVino IR model weights (openvino==2022.1.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Openvino==2022.1.0 | |
import sys | |
from openvino.runtime import Core | |
DELIMITER = ' | ' | |
if len(sys.argv) < 3: | |
print("Please provide path to model xml file as a first arg and" | |
" path to output text file to dump model constants.") | |
exit() | |
ie = Core() | |
model = ie.read_model(model=sys.argv[1]) | |
with open(sys.argv[2], 'w') as out: | |
for op in model.get_ordered_ops(): | |
if 'constant' in str(op.get_type_info()).lower(): | |
out.write(op.get_name() + DELIMITER + str(op.get_output_shape(0)) +\ | |
DELIMITER + str(op.get_vector()) + '\n') | |
print('Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment