wkcn commented on a change in pull request #16778: custom op full_like URL: https://github.com/apache/incubator-mxnet/pull/16778#discussion_r345014417
########## File path: python/mxnet/numpy_op_fallback.py ########## @@ -49,6 +49,73 @@ def _register_helper(prop_cls): return _register_helper +@use_np # enforce np shape and array semantics for all the methods in this class +class FullLike(operator.CustomOp): + """Fallback to NumPy full_like operator.""" + def __init__(self, fill_value, dtype, order, subok, shape): + super(FullLike, self).__init__() + self._fill_value = fill_value + self._dtype = dtype + self._order = order + self._subok = subok + self._shape = shape + + def forward(self, is_train, req, in_data, out_data, aux): + np_version = np.version.version + if np_version == '1.17.0': + out = np.full_like(in_data[0].asnumpy(), self._fill_value, dtype=self._dtype, order=self._order, Review comment: It will be faster to use `mx.nd.full(shape, fill_value)` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services