Created
March 25, 2022 05:53
-
-
Save daniil-lyakhov/4059e6dd2aa40336b6413ac0eac183d5 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