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 cast a int* to FloatC? #64

Closed
andyyankai opened this issue Mar 18, 2020 · 2 comments
Closed

How to cast a int* to FloatC? #64

andyyankai opened this issue Mar 18, 2020 · 2 comments

Comments

@andyyankai
Copy link

For example, if I have an int* like an int array
How can I cast that int array into a FloatC/FloatD, which is a cuda_array in enoki efficiently? I don't think it is a good idea to scatter_add each element in that int array to enoki cuda_array.
Thanks

@Speierers
Copy link
Member

I believe you can do something like this:

using IntC = enoki::CUDAArray<int>;
using FloatC = enoki::CUDAArray<float>;

size_t size = ...; // Size of my array
int* data = ...; // Points to an array of len == size
IntC data_gpu = IntC::copy(data, size);

// Then cast it to Float values
FloatC data_gpu_float = FloatC(data_gpu);

Is this what you are looking for?

@andyyankai
Copy link
Author

Yes, the copy() is really helpful. Thanks!

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