Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NNVM][FRONTEND] Tensorflow frontend support #1188

Merged
merged 17 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions nnvm/python/nnvm/compiler/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ def build(graph, target=None, shape=None, dtype="float32",
# Apply optimization
with target:
graph = optimize(graph, shape, dtype, layout)

# Clear extra params without nodes.
_remove_noref_params(params, graph)

# Precompute prune
if params and cfg.pass_enabled("PrecomputePrune"):
graph, params = precompute_prune(graph, params)
Expand All @@ -296,6 +300,24 @@ def build(graph, target=None, shape=None, dtype="float32",
params.update(init_var)
return graph, libmod, params

def _remove_noref_params(params, graph):
""" Helper to clear non referenced params

Parameters
----------
graph : Graph
The input graph

params: dict of str to ndarray
The parameter dictionary
"""
arg_list = graph.symbol.list_input_names()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

efficiency: build a set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


if params:
param_keys = list(params.keys())
for key in param_keys:
if key not in arg_list:
params.pop(key)

def _run_graph(graph, params):
"""Helper utility to build and run and get outputs, only use cpu mode.
Expand Down
1 change: 1 addition & 0 deletions nnvm/python/nnvm/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .coreml import from_coreml
from .keras import from_keras
from .darknet import from_darknet
from .tensorflow import from_tensorflow