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

Use cpu for slice boxing if device is not cpu and cuda #8180

Merged

Conversation

clackhan
Copy link
Contributor

修改 eager slice boxing计算图,当tensor的设备类型既不是cpu又不是cuda时,将tensor 拷贝到cpu上,在cpu上做boxing,然后在结果拷回到对应的设备上。此pr为添加一种新的设备类型时,提供最基本的eager boxing 支持

Comment on lines +53 to +54
template<Maybe<one::Tensor> (*func)(const std::shared_ptr<one::Tensor>&, Symbol<PlacedNdSbp>,
Symbol<PlacedNdSbp>)>
Copy link
Contributor

Choose a reason for hiding this comment

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

这里template<typename func>就行

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里template<typename func>就行

template<typename func>的话需要Func作为变量作为输入参数,上面写法可以将一个函数指针作为特化值,二者还是有一定的区别

Copy link
Contributor

Choose a reason for hiding this comment

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

我是说template会更简单一些,不一定需要将Func作为输入参数,你可以写成template<typename Func, Func* func>,func的类型自动推导,写起来会更简单一些

@github-actions
Copy link
Contributor

View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/8180/

@clackhan clackhan merged commit 4a1a239 into master May 24, 2022
@clackhan clackhan deleted the use_cpu_for_slice_boxing_if_device_is_not_cpu_and_cuda branch May 24, 2022 04:24
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.

3 participants