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

Mxnet parser prelu support #96

Merged
merged 2 commits into from
Mar 7, 2018
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
11 changes: 8 additions & 3 deletions mmdnn/conversion/mxnet/mxnet_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,22 +809,27 @@ def rename_Embedding(self, source_node):
self.set_output_shape(source_node, IR_node)


# IR only support elu from {'elu', 'leaky', 'prelu', 'rrelu'}
# IR only support elu and prelu from {'elu', 'leaky', 'prelu', 'rrelu'}
def rename_LeakyReLU(self, source_node):
# judge whether meaningful
assert "attr"
# attr
layer_attr = self._get_layer_attr(source_node)

if "act_type" in layer_attr:
if not layer_attr["act_type"] == "elu":
if not layer_attr["act_type"] == "elu" and not layer_attr["act_type"] == "prelu":
print("Warning: Activation Type %s is not supported yet." % layer_attr["act_type"])
# return

IR_node = self.IR_graph.node.add()

# name, op
self._copy_and_reop(source_node, IR_node, "Elu")
if layer_attr['act_type'] == 'prelu':
self._copy_and_reop(source_node, IR_node, "PRelu")
# gamma
self.set_weight(source_node.name, "gamma", self.weight_data.get(source_node.name + "_gamma").asnumpy())
else: # All other cases set to 'Elu'
self._copy_and_reop(source_node, IR_node, "Elu")

# input edge
self.convert_inedge(source_node, IR_node)
Expand Down