frozen_graphs_to_plans.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
  2. # Full license terms provided in LICENSE.md file.
  3. import sys
  4. sys.path.append('third_party/models/')
  5. sys.path.append('third_party/models/research')
  6. sys.path.append('third_party/models/research/slim')
  7. import uff
  8. from model_meta import NETS, FROZEN_GRAPHS_DIR, CHECKPOINT_DIR, PLAN_DIR
  9. from convert_plan import frozenToPlan
  10. import os
  11. if __name__ == '__main__':
  12. if not os.path.exists('data/plans'):
  13. os.makedirs('data/plans')
  14. for net_name, net_meta in NETS.items():
  15. if 'exclude' in net_meta.keys() and net_meta['exclude'] is True:
  16. continue
  17. print("Convertings %s to PLAN" % net_name)
  18. frozenToPlan(net_meta['frozen_graph_filename'],
  19. net_meta['plan_filename'],
  20. net_meta['input_name'],
  21. net_meta['input_height'],
  22. net_meta['input_width'],
  23. net_meta['output_names'][0],
  24. 1, # batch size
  25. 1 << 20, # workspace size
  26. 'half' # data type
  27. )