Skip to content

Commit

Permalink
Support mean in NNVM to Relay converter. (apache#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiaoquan authored and wweic committed Mar 9, 2019
1 parent 9b39048 commit 5fdaffd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nnvm/python/nnvm/to_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ def _dropout(children, attrs, odtype='float32'):
rate = attrs.get_float('rate', 0.5)
return op.nn.dropout(children[0], rate)

def _mean(children, attrs, odtype='float32'):
axis = None
try:
axis = [attrs.get_int('axis', None)]
except ValueError:
axis = axis or attrs.get_int_tuple('axis', None)
keepdims = attrs.get_bool('keepdims')

return op.mean(children[0], axis, keepdims)


NNVM_OP_2_RELAY_OP = {
'flatten': _nn_batch_flatten,
Expand All @@ -388,6 +398,7 @@ def _dropout(children, attrs, odtype='float32'):
'reshape': _reshape,
'transpose': _transpose,
'dropout': _dropout,
'mean': _mean,
# Addition
'__add_scalar__': _add,
'broadcast_add': _add,
Expand Down

0 comments on commit 5fdaffd

Please sign in to comment.