Skip to content

How to convert the values in dynamic Snode into numpy? to_numpy() will get the full array #8588

Closed Answered by Jianghanxiao
Jianghanxiao asked this question in Q&A
Discussion options

You must be logged in to vote

I find the below code may be the most efficient and proper way

@ti.kernel
def extract_collisions(self, buffer: ti.types.ndarray(ti.i32, ndim=1)):
    print(self.collisions.length())
    for i in range(self.collisions.length()):
        buffer[i] = self.collisions[i]

def get_collisions(self, collision_len):
    collisions_torch = torch.zeros(collision_len, dtype=torch.int32, device="cuda")
    self.extract_collisions(collisions_torch)
    return collisions_torch

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jianghanxiao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant