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

[Relay] Modify create_executor to pass params #8418

Merged
merged 2 commits into from
Jul 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion python/tvm/relay/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def _graph_wrapper(*args, **kwargs):
return _graph_wrapper


def create_executor(kind="debug", mod=None, device=None, target="llvm"):
def create_executor(kind="debug", mod=None, device=None, target="llvm", params=None):
"""Factory function to create an executor.

Example
Expand Down Expand Up @@ -544,6 +544,10 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm"):
target : :py:class:`tvm.Target`
The corresponding context

params : dict of str to NDArray
Input parameters to the graph that do not change
during inference time.

Returns
-------
executor : :py:class:`~tvm.relay.backend.interpreter.Executor`
Expand All @@ -555,6 +559,9 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm"):
else:
device = _nd.device(str(target), 0)

if params is not None:
mod = IRModule.from_expr(bind_params_by_name(mod["main"], params))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to consider what if the mod does not contain a "main" function, or the mod contains multiple functions(subgraphs), each with a different params dict?

Copy link
Contributor

@YuchenJin YuchenJin Jul 13, 2021

Choose a reason for hiding this comment

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

I think it's fine to throw an error if cannot find "main" in the Module, so ignore this comment. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and it is passing all the CI stages.


if isinstance(target, str):
target = Target(target)
if kind == "debug":
Expand Down