Conversation
python/mxnet/numpy_op_fallback.py
Outdated
| 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, |
There was a problem hiding this comment.
It will be faster to use mx.nd.full(shape, fill_value)
|
@mxnet-label-bot add [Numpy] |
1855f98 to
9223167
Compare
| def hybrid_forward(self, F, x, *args, **kwargs): | ||
| return F.np.full_like(x, self._fill_value, self._dtype) | ||
|
|
||
| if StrictVersion(platform.python_version()) < StrictVersion('3.0.0'): |
There was a problem hiding this comment.
You can decorate the test function with this condition as the following.
@unittest.skipIf(StrictVersion(platform.python_version()) < StrictVersion('3.0.0'), "reason to skip")
def test_np_full_like():
...|
I suggest not use the customop for full_like, which is very similar to ones_like |
|
@Alicia1529, You can refer to the implementation of ones_like and zeros_like: https://github.com/apache/incubator-mxnet/blob/61c8bafdcfee129e4f7a491438a2402e6762ddd9/src/operator/numpy/np_init_op.cc#L100-L134 |
Thanks for the suggestions! In pr #16804 a c++ version of full_like is implemented. Zeros_like and ones_like are also rewritten by calling full_like with different fill_value in the front-end to fix the type inference bug in issue #16646 But I am still fixing some problems in python2 test, so it has not been merged. This pr is older and should be closed. |
|
@Alicia1529 Is it safe to close this PR? |
|
@sxjscience Yeah, thanks |
Description
Add numpy operator full_like