Replies: 1 comment 5 replies
-
Hi @cadop, Thanks for opening this issue and apologies for not getting back to you earlier! This is just to let you know that we're currently working on addressing some of these issues, either through improving our FAQ or improving or error messages. I'll also try answering your questions now. It's not possible to assign to Warp arrays outside of kernel functions because Warp arrays can represent either CPU or GPU data. In the case of CPU data, that'd be straightforward to support in Python however, if the data is living on the GPU, then this would require launching a CUDA kernel for each item assignment, which wouldn't be efficient. Instead, we recommend to either initialise a Warp array with another array (Python list, NumPy array, ...) that already describes the desired dataset, or to use a kernel to set the data afterwards. And, as you already found out, Warp also provides native Python functions to help setting an array with a given value, but that also works on slices, for example: In the following snippet, you are assigning an entire vector onto a single vector component. What are you expecting the result to be? vec2Data = wp.vec2(666.0,666.0)
vec2Data[0] = vec2Data
####### >>> TypeError: incompatible types, vec2f instance instead of c_float instance As for here, the error message is extremely confusing and we're working on improving that now, but what's happening is that you are trying to access a global array twoD_floats = wp.full((row_cnt, 2), 9999999.0, dtype=float, device='cpu') # would be nice to have inf
@wp.kernel
def simple_kernel():
# Modify twoD_floats in kernel
twoD_floats[0,0] = 1.0
####### >>> 'array' object has no attribute 'type' Finally, in regards to supporting infinity, you can already use Python's I hope this helps. Please let us know if you have any other questions, thank you! |
Beta Was this translation helpful? Give feedback.
-
I have been trying to make a 'cheatsheet' for referencing some of the basic utilities in warp that I can't find in the getting started/basics documentation.
One common issue I have run into is how to index and then assign values to arrays, especially for global scope.
Below is an example script with some commented out code and the corresponding errors below it.
I think this is made up of;
Beta Was this translation helpful? Give feedback.
All reactions