-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
Hey @JiangZhaoh , Thanks for submitting the PR
CI supported jobs: [unix-cpu, website, windows-cpu, windows-gpu, edge, centos-cpu, sanity, unix-gpu, clang, centos-gpu, miscellaneous] Note: |
9faab79
to
e7f0f36
Compare
@mxnet-bot run ci [windows-cpu] |
Jenkins CI successfully triggered : [windows-cpu] |
@mxnet-bot run ci [unix-gpu] |
Jenkins CI successfully triggered : [unix-gpu] |
@mxnet-bot run ci [unix-cpu] |
Jenkins CI successfully triggered : [unix-cpu] |
@mxnet-bot run ci [unix-gpu] |
Jenkins CI successfully triggered : [unix-gpu] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sxjscience could you also take a look?
src/api/operator/numpy/np_init_op.cc
Outdated
@@ -216,7 +217,7 @@ MXNET_REGISTER_API("_npi.arange") | |||
param.repeat = 1; | |||
param.infer_range = false; | |||
if (args[3].type_code() == kNull) { | |||
param.dtype = mshadow::kFloat32; | |||
param.dtype = mxnet::common::GetDefaultDtype(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that in numpy, the default dtype of arange is int64.
import numpy as np
print(np.arange(10).dtype)
import mxnet as mx
mx.npx.set_np()
print(mx.np.arange(10).dtype)
Output:
int64
float32
Thus, we should change the dtype to be consistent with the official numpy. What do you think @yzhliu @leezu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that in numpy, the default dtype of arange is int64.
import numpy as np print(np.arange(10).dtype) import mxnet as mx mx.npx.set_np() print(mx.np.arange(10).dtype)Output:
int64 float32
Thus, we should change the dtype to be consistent with the official numpy. What do you think @yzhliu @leezu
I think maybe we could consider the most common use cases to decide which return result to choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, arange is usually used for constructing the index. Sometimes, the user may use np.arange(0, 1000*1000*1000, 10000)
and we will lose precision if we use float32. In addition, pytorch uses int64.
import torch as th
print(th.arange(10).dtype)
# torch.int64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example @sxjscience listed looks reasonable to me. I guess we should do int64 then.
otherwise good to me. |
@mxnet-bot run ci [centos-cpu, miscellaneous, unix-cpu] |
Jenkins CI successfully triggered : [unix-cpu, centos-cpu, miscellaneous] |
@mxnet-bot run ci [centos-cpu] |
Jenkins CI successfully triggered : [centos-cpu] |
Thanks @JiangZhaoh @sxjscience |
* apply apache#17283 * fix issue apache#18060 * fix error * remove redundant code * fix CI error * replace Flase to False * add 'dtype=False' to set_np() * fix doc * default 'arange' default np dtype as int64
Description
#17283 cause an issue #18193. So I depart dtype flag from npx.set_np() in this pull request.
And also try to fix #18060 .
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments