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

How to automatically set the backends? #9

Closed
jxgu1016 opened this issue Jun 7, 2018 · 2 comments
Closed

How to automatically set the backends? #9

jxgu1016 opened this issue Jun 7, 2018 · 2 comments

Comments

@jxgu1016
Copy link

jxgu1016 commented Jun 7, 2018

Is there any way to automatically set the backends (cpu or gpu)?
To merge the two Function into one and it will choose the proper backend according to what device we are using.

@jxgu1016 jxgu1016 closed this as completed Jun 7, 2018
@jxgu1016 jxgu1016 reopened this Jun 7, 2018
@jxgu1016
Copy link
Author

jxgu1016 commented Jun 7, 2018

Also, can we merge the two setup.py together and make them share the same package name?
Sorry to close this issue mistakenly ...

@goldsborough
Copy link
Contributor

You can merge the two Functions and write:

if tensor.is_cuda():
  # call CUDA code
else:
  # call C++ code

inside your PyTorch Function, or you can move it into C++ and write:

if (tensor.is_cuda()) {
  // call CUDA code
} else {
  // call C++ code
}

There's nothing to stop you from merging the setup.pys, no. I won't do it for this example because things are supposed to be isolated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants