Skip to content
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

Optimize tensor getitem. #5433

Merged
merged 10 commits into from
Jul 12, 2021
Merged

Optimize tensor getitem. #5433

merged 10 commits into from
Jul 12, 2021

Conversation

hjchen2
Copy link
Contributor

@hjchen2 hjchen2 commented Jul 8, 2021

No description provided.

@hjchen2 hjchen2 requested review from daquexian and VertexC and removed request for daquexian July 8, 2021 12:00
@hjchen2 hjchen2 force-pushed the dev_optimize_tensor_getitem branch from a4a90e7 to bb9b330 Compare July 8, 2021 12:05
@hjchen2 hjchen2 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot July 9, 2021 02:17
@oneflow-ci-bot oneflow-ci-bot removed their request for review July 9, 2021 03:40
@hjchen2 hjchen2 requested review from wyg1997 and lixinqi July 9, 2021 07:53
}();
std::shared_ptr<one::Tensor> result;
if (is_identity) {
result = x;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样做的原因是什么呢,PyTorch 里 id(x) == id(x[:]) 是 False。如果是想模拟 PyTorch slicing 返回 view 的行为,是不是现在什么都不用做,等到支持了 view 之后这里的行为就自动和 pytorch 一致了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是为了做性能优化,但确实可能会给用户造成混淆。我改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identity的时候改成copy一把,性能应该会更高一些

@hjchen2 hjchen2 force-pushed the dev_optimize_tensor_getitem branch from 48c8d36 to 4c4714a Compare July 12, 2021 03:34
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot July 12, 2021 06:41
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot July 12, 2021 07:08
@oneflow-ci-bot oneflow-ci-bot merged commit 18e5c9e into master Jul 12, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the dev_optimize_tensor_getitem branch July 12, 2021 08:25
@hjchen2 hjchen2 restored the dev_optimize_tensor_getitem branch August 11, 2021 14:29
@chengtbf chengtbf deleted the dev_optimize_tensor_getitem branch September 8, 2021 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants