forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RELAY][FRONTEND] Initial MXNet frontend support. (apache#2163)
- Loading branch information
Showing
39 changed files
with
2,228 additions
and
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Relay frontends.""" | ||
from __future__ import absolute_import | ||
|
||
from .mxnet import from_mxnet |
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,129 @@ | ||
"""Common utilities""" | ||
from __future__ import absolute_import as _abs | ||
|
||
|
||
class RequiredAttr(object): | ||
"""Dummpy class to represent required attr""" | ||
pass | ||
|
||
|
||
class StrAttrsDict(object): | ||
"""Helper class to parse attrs stored as Dict[str, str]. | ||
Parameters | ||
---------- | ||
attrs : Dict[str, str] | ||
The attributes to be used. | ||
""" | ||
def __init__(self, attrs): | ||
self.attrs = attrs | ||
|
||
def get_float(self, key, default=RequiredAttr()): | ||
"""Get float attribute | ||
Parameters | ||
---------- | ||
key : str | ||
The attribute key | ||
default : float | ||
The default value. | ||
Returns | ||
------- | ||
value : The result | ||
""" | ||
if key in self.attrs: | ||
return float(self.attrs[key]) | ||
if isinstance(default, RequiredAttr): | ||
raise AttributeError("Required attribute {} not found.".format(key)) | ||
return default | ||
|
||
def get_int(self, key, default=RequiredAttr()): | ||
"""Get int attribute | ||
Parameters | ||
---------- | ||
key : str | ||
The attribute key | ||
default : float | ||
The default value. | ||
Returns | ||
------- | ||
value : The result | ||
""" | ||
if key in self.attrs: | ||
val = self.attrs[key] | ||
if val == "None": | ||
return None | ||
return int(val) | ||
if isinstance(default, RequiredAttr): | ||
raise AttributeError("Required attribute {} not found.".format(key)) | ||
return default | ||
|
||
def get_str(self, key, default=RequiredAttr()): | ||
"""Get str attribute | ||
Parameters | ||
---------- | ||
key : str | ||
The attribute key | ||
default : float | ||
The default value. | ||
Returns | ||
------- | ||
value : The result | ||
""" | ||
if key in self.attrs: | ||
return self.attrs[key] | ||
if isinstance(default, RequiredAttr): | ||
raise AttributeError("Required attribute {} not found.".format(key)) | ||
return default | ||
|
||
def get_int_tuple(self, key, default=RequiredAttr()): | ||
"""Get int tuple attribute | ||
Parameters | ||
---------- | ||
key : str | ||
The attribute key | ||
default : float | ||
The default value. | ||
Returns | ||
------- | ||
value : The result | ||
""" | ||
if key in self.attrs: | ||
tshape = self.attrs[key] | ||
return tuple(int(x.strip()) for x in tshape.strip('()').split(',')) | ||
if isinstance(default, RequiredAttr): | ||
raise AttributeError("Required attribute {} not found.".format(key)) | ||
return default | ||
|
||
def get_bool(self, key, default=RequiredAttr()): | ||
"""Get bool tuple attribute | ||
Parameters | ||
---------- | ||
key : str | ||
The attribute key | ||
default : float | ||
The default value. | ||
Returns | ||
------- | ||
value : The result | ||
""" | ||
if key in self.attrs: | ||
val = self.attrs[key] | ||
return val.strip().lower() in ['true', '1', 't', 'y', 'yes'] | ||
if isinstance(default, RequiredAttr): | ||
raise AttributeError("Required attribute {} not found.".format(key)) | ||
return default |
Oops, something went wrong.