Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
removed contrib op registration
Browse files Browse the repository at this point in the history
re-registered ops from mx.nd.op to mx.nd
  • Loading branch information
Sam Skalicky committed Aug 20, 2019
1 parent f568e3d commit 8e12588
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions python/mxnet/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""Library management API of mxnet."""
from __future__ import absolute_import
import ctypes
import sys
import os
from .base import _LIB, check_call, MXNetError, _init_op_module
from .ndarray.register import _make_ndarray_function
Expand Down Expand Up @@ -53,3 +54,17 @@ def load(path):
#regenerate operators
_init_op_module('mxnet', 'ndarray', _make_ndarray_function)
_init_op_module('mxnet', 'symbol', _make_symbol_function)

#re-register mx.nd.op into mx.nd
mx_nd = sys.modules["mxnet.ndarray"]
mx_nd_op = sys.modules["mxnet.ndarray.op"]
for op in dir(mx_nd_op):
func = getattr(mx_nd_op,op)
setattr(mx_nd,op,func)

#re-register mx.sym.op into mx.sym
mx_sym = sys.modules["mxnet.symbol"]
mx_sym_op = sys.modules["mxnet.symbol.op"]
for op in dir(mx_sym_op):
func = getattr(mx_sym_op,op)
setattr(mx_sym,op,func)
3 changes: 2 additions & 1 deletion src/c_api/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ int MXLoadLib(const char *path) {
};

//re-register op in MXNet using lambda converter functions
std::string contrib_name("_contrib_");
//std::string contrib_name("_contrib_");
std::string contrib_name("");
contrib_name += name;
nnvm::Op &regOp = dmlc::Registry<nnvm::Op>::Get()->__REGISTER_OR_GET__(contrib_name.c_str());
regOp.set_attr<FCompute>("FCompute<cpu>",fcomp_conv);
Expand Down

0 comments on commit 8e12588

Please sign in to comment.