Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Last active March 22, 2020 15:19
Show Gist options
  • Save dboyliao/c1a78afa23a9bc3b8c092148521ad78b to your computer and use it in GitHub Desktop.
Save dboyliao/c1a78afa23a9bc3b8c092148521ad78b to your computer and use it in GitHub Desktop.
from utensor_cgen.backend.graph_lower import TensorAllocationPlanner
from utensor_cgen.frontend.tensorflow import GraphDefParser
parser = GraphDefParser(config={})
planner = TensorAllocationPlanner(config={})
ugraph = parser.parse('tests/deep_mlp/simple_mnist.pb', output_nodes=['y_pred'])
planner.apply(ugraph)
plan = ugraph.attributes[planner.KWARGS_NAMESCOPE].plan
total_size = ugraph.attributes[planner.KWARGS_NAMESCOPE].total_size
for tensor_name, alloc in plan.items():
print(f'{tensor_name!r}', f'memory offset: {alloc.offset_start}, size: {alloc.size}')
print('total memory usage:', total_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment