-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move pybind/python api to cpython [part2] #8315
Conversation
Code got formatted by CI. Please request CI again if you still want to have this PR merged. If the PR is from a forked repo, please download the patch files from the GitHub Actions web page and apply them locally. |
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/8315/ |
Speed stats:
|
auto shape = PyTensor_Unpack(self)->shape(); | ||
if (idx_obj == NULL || idx_obj == Py_None) return TensorSize_NewFromShape(*shape); | ||
int64_t idx = PyLong_AsLongLong(idx_obj); | ||
CHECK_OR_THROW(idx >= -shape->NumAxes() && idx < shape->NumAxes()) |
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.
shape->NumAxes()
用了很多次,建议提取出来避免重复调用
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.
已改
…-Inc/oneflow into move_tensor_api_to_cpython_part2
Tensor.int = _int | ||
Tensor.long = _long | ||
Tensor.float = _float | ||
Tensor.double = _double |
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.
同时也要把这里不用的接口也删一下,比如_double、_float这些
本PR完成了:
PyTensorObject_add
为PyTensorObject_nb_add
,防止其与Tensor.add
对应的PyTensorObject_add
冲突。这部分API的搬运思路如下:
concat_self
,用来把Tensor self和args拼接起来,以便生成的函数接口调用DIRECT_PASS_FUNC
来创建函数,统一调用functional_api.yaml.pybind.h
里面的接口Tensor.int/float
等转dtype的函数,用宏DATATYPE_FUNC
创建(虽然只有四个),不调用functional_api.yaml.pybind.h
里面的接口其他:
这个部分迁移的api如下: