julianolorenzato
How to create a matrix where each cell contain a index pair?
I want to create a tensor of size m * m * 2, that simulate a square matrix where each cell contain your indexes in a pair. Something like that:
f32[3][3][2]
[
[
[0, 0],
[0, 1],
[0, 2]
],
[
[1, 0],
[1, 1],
[1, 2]
],
[
[2, 0],
[2, 1],
[2, 2]
]
]
I used many Nx functions (iota, broadcast, concatenate, stack, tile, reshape) trying to achieve this result, but the closest tensor I got was the following:
f32[2][3][3]
[
[
[0, 0, 0],
[1, 1, 1],
[2, 2, 2]
],
[
[0, 1, 2],
[0, 1, 2],
[0, 1, 2]
]
]
Any suggestion? Thanks
Most Liked
Eiji
I guess it’s similar to implementing NIF. We need to ask ourselves how often and big data we want to transfer between CPU and GPU calculations. <1ms loss is nothing if it’s not multiplied many, many times.Square matrix for small values called just once shouldn’t be even noticeable. You could create async tasks in a loop, but I’m not sure if for such small data it’s even worth. Maybe in generic_matrix/2 version it could make sense to pattern-match checking if size is bigger than let’s say 100 and if so we could work asynchronously.








