forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REPL + Operators + Env Refactor (apache#42)
* Start on REPL * Clean up evaluator after rebase * Add support for registering primitives Refactor Environment interface to better disambiguate between Globals and Intrinsics. Start on Python code to produce operator specific JIT compilers which will specialize an operator based on the type signature of the operator * Debugging test crashes * Fix testing error and setup primitive test case * Add a bunch of type annotations * Add more .pyi files to stub C++ written functions * Getting closer to primitive evaluation, need type information * Continue refactoring needed to call Tensor program w/ Primitives * Add Tensor values, and improve calling into eval * Add notes for tomorrow * Fix linting, prepare for early merge * Fix rebase * Fix linting * Add typed_ast to package list * Fix failing test cases * Trigger rebuild
- Loading branch information
Showing
27 changed files
with
881 additions
and
410 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# pylint: disable=no-else-return, unidiomatic-typecheck | ||
"""A global environment storing everything needed to interpret or compile a Realy program.""" | ||
from typing import Union, Dict | ||
from tvm._ffi.function import _init_api | ||
from .base import register_nnvm_node, NodeBase | ||
from .expr import GlobalId, IntrinsicId, Item | ||
|
||
_init_api("nnvm.relay.env", __name__) | ||
|
||
@register_nnvm_node | ||
class Environment(NodeBase): | ||
"""The global Relay environment containing definitions, | ||
primitives, options, and more. | ||
""" | ||
items: Dict[GlobalId, Item] | ||
|
||
def add(self, func: GlobalId) -> None: | ||
return Environment_add(self, func) | ||
|
||
def global_id(self, name: str) -> GlobalId: | ||
return Environment_global_id(self, name) | ||
|
||
def lookup(self, ident: Union[GlobalId, IntrinsicId]) -> Item: | ||
if isinstance(ident, IntrinsicId): | ||
intrin_id = self.intrinsic_id(ident) | ||
return Environment_lookup_intrinsic(self, intrin_id) | ||
else: | ||
global_id = self.global_id(ident) | ||
return Environment_lookup_global(self, global_id) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Union, Tuple, Dict | ||
from nnvm.relay.expr import GlobalId, IntrinsicId, Item | ||
|
||
class Environment(): ... | ||
|
||
def Environment_add(self: Environment, func: GlobalId) -> None: ... | ||
def Environment_global_id(self: Environment, name: str) -> GlobalId: ... | ||
def Environment_intrinsic_id(self: Environment, name: str) -> IntrinsicId: ... | ||
def Environment_lookup_global(self: Environment, id: GlobalId) -> Item: ... | ||
def Environment_lookup_intrinsic(self: Environment, id: GlobalId) -> Item: ... |
Oops, something went wrong.