huggingface / huggingface/candle
Improving the versatility of Tensor::slice_assign
- Dominant language
- Rust
- Stars
- 21k
- Forks
- 1.8k
- Avg merge
- 16h 42m
- Merged PRs (30d)
- 25
Description
Currently, `Tensor::slice_assign` only accepts homogenous range types. This can be a limitation and can be a slight inconvenience/confusion point. I have opened #2223, which allows for heterogeneous range types in `Tensor::slice_assign`. For example, the following is possible after #2223:
```rust
let dev = Device::Cpu;
let tensor = Tensor::arange(0u32, 4 * 5, &dev)?.reshape((4, 5))?;
let src = Tensor::arange(100u32, (2 * 3) + 100, &dev)?.reshape((3, 2))?;
let out = tensor.slice_assign(&[&(..=2), &(1..3)], &src)?;
assert_eq!(
out.to_vec2::()?,
&[
[0, 100, 101, 3, 4],
[5, 102, 103, 8, 9],
[10, 104, 105, 13, 14],
[15, 16, 17, 18, 19]
]
);
Ok(())
```
Thank you for considering this change!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.