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

GraphBuilder - verify node name is not reserved method of nn.module #1204

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions model_compression_toolkit/core/pytorch/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
IN_FEATURES = 'in_features'
OUT_FEATURES = 'out_features'

# # Reserved layer names
RESERVED_NAME_TO = 'to'
RESERVED_NAME_SUFFIX = 'node'

# torch devices
CUDA = 'cuda'
CPU = 'cpu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from model_compression_toolkit.core.common.graph.edge import Edge
from model_compression_toolkit.core.common.graph.functional_node import FunctionalNode
from model_compression_toolkit.core.pytorch.constants import OUTPUT, PLACEHOLDER, TENSOR_META, CALL_FUNCTION, TYPE, \
CALL_METHOD, BIAS, FUNCTIONAL_OP, OP_CALL_KWARGS, OP_CALL_ARGS, INPUTS_AS_LIST, TENSOR_INPUT_ALLOCS, GET_ATTR
CALL_METHOD, BIAS, FUNCTIONAL_OP, OP_CALL_KWARGS, OP_CALL_ARGS, INPUTS_AS_LIST, TENSOR_INPUT_ALLOCS, GET_ATTR, \
RESERVED_NAME_TO, RESERVED_NAME_SUFFIX
from model_compression_toolkit.core.pytorch.reader.node_holders import DummyPlaceHolder
from model_compression_toolkit.logger import Logger

Expand Down Expand Up @@ -284,6 +285,9 @@ def nodes_builder(model: GraphModule,
graph_node_type = BaseNode
kwargs = {}

if node.name == RESERVED_NAME_TO:
node.name = node.name + RESERVED_NAME_SUFFIX

graph_node = graph_node_type(name=node.name,
framework_attr=framework_attr,
input_shape=input_shape,
Expand Down
Loading