mirror of
https://github.com/huggingface/candle.git
synced 2025-06-18 03:28:50 +00:00
Propagate the changes on the cpu backend.
This commit is contained in:
@ -39,6 +39,17 @@ impl Layout {
|
||||
self.start_offset
|
||||
}
|
||||
|
||||
/// Returns the appropriate start and stop offset if the data is stored in a C
|
||||
/// contiguous (aka row major) way.
|
||||
pub fn contiguous_offsets(&self) -> Option<(usize, usize)> {
|
||||
if self.is_contiguous() {
|
||||
let start_o = self.start_offset;
|
||||
Some((start_o, start_o + self.shape.elem_count()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the data is stored in a C contiguous (aka row major) way.
|
||||
pub fn is_contiguous(&self) -> bool {
|
||||
self.shape.is_contiguous(&self.stride)
|
||||
|
Reference in New Issue
Block a user