i(..) indexing sugar (partial).

- Only range, and select (no tensor_select)
- No negative indexing
This commit is contained in:
Nicolas Patry
2023-07-10 17:34:04 +02:00
parent 221b1aff65
commit ef0375d8bc
3 changed files with 249 additions and 1 deletions

View File

@ -444,6 +444,7 @@ impl Tensor {
len,
})?
}
println!("Narrow {start:?} - {} - {len} - {dims:?}", dims[dim]);
if start == 0 && dims[dim] == len {
Ok(self.clone())
} else {
@ -452,10 +453,11 @@ impl Tensor {
} else {
None
};
let layout = self.layout().narrow(dim, start, len)?;
let tensor_ = Tensor_ {
id: TensorId::new(),
storage: self.storage.clone(),
layout: self.layout().narrow(dim, start, len)?,
layout,
op,
is_variable: false,
};