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

[QST] How to pass a cute::Tensor as parameter to a device function? #1363

Closed
ZhangZhiPku opened this issue Feb 27, 2024 · 4 comments
Closed
Labels
question Question

Comments

@ZhangZhiPku
Copy link

ZhangZhiPku commented Feb 27, 2024

I am writing a device function like:

__device__ void func(cute::Tensor tensor){...}

I want to call it like:

auto A = cute::make_tensor(...);
func(A);

However I got an error says: argument list for class template "cute::Tensor" is missing.
How can I pass a tensor as parameter to a function?

@ZhangZhiPku
Copy link
Author

ZhangZhiPku commented Feb 27, 2024

Besides, I rewrite this function to:

__device__ void func(float* tensor){...}

And call it like:

auto A = cute::make_tensor(...);
func(A.data());

There is another error says: no instance of function template "func" matches the argument list, argument types are cute::gmem_ptr<float *> rather than float .
How can I get the data pointer float
from a tensor?

@thakkarV
Copy link
Collaborator

thakkarV commented Feb 27, 2024

Tensor is a template type. The error you see "argument list for class template "cute::Tensor" is missing." is telling you what is wrong/missing. The signature of your device function will be something like this:

template <class Engine, class Layout>
auto
__device__
func(cute::Tensor<Engine, Layout> tensor) {
  // blah
}

@mnicely
Copy link
Collaborator

mnicely commented Feb 28, 2024

@ZhangZhiPku let us know if that works and we can close this issue

@ZhangZhiPku
Copy link
Author

It works fine, thank you!

@mnicely mnicely closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question
Projects
None yet
Development

No branches or pull requests

3 participants