TorchSharp icon indicating copy to clipboard operation
TorchSharp copied to clipboard

Ranges implementation

Open Sprinzl opened this issue 4 months ago • 3 comments

Hello, Hope this not an error with my code... So I really like to use ranges. Lets assume tensor of 3 dimensions. I can do x[some tensor] .... I can do x[x<=2] .... I can do x[..int,..,..] ..... What I cannot do is x[..,some tensor,..] ... where some tensor are indices or booleans. Is where any way to implement this. Would be really cool because this often appears in pythonic code...

Thanks

Sprinzl avatar Mar 09 '24 13:03 Sprinzl

Implicit casting could be a cool feature, for now you can work around it by doing:

var indexed = x[..,TensorIndex.Tensor(some_tensor),..];

shaltielshmid avatar Mar 09 '24 21:03 shaltielshmid

@shaltielshmid So are we facing any problems when implementing the implicit cast (since nobody did it before)?

yueyinqiu avatar Apr 26 '24 12:04 yueyinqiu

I haven't gotten up to it yet, but feel free to go ahead :)

shaltielshmid avatar Apr 26 '24 12:04 shaltielshmid