MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / get_slice_shape

Function get_slice_shape

ciphercore-base/src/slices.rs:7–20  ·  view source on GitHub ↗
(shape: ArrayShape, slice: Slice)

Source from the content-addressed store, hash-verified

5use std::iter::repeat;
6
7pub(super) fn get_slice_shape(shape: ArrayShape, slice: Slice) -> Result<ArrayShape> {
8 let clean_slice = get_clean_slice(shape.clone(), slice)?;
9 let mut result_shape = vec![];
10 for i in 0..shape.len() {
11 if i < clean_slice.len() {
12 if let Some(s) = get_slice_shape_1d(shape[i], clean_slice[i].clone())? {
13 result_shape.push(s);
14 }
15 } else {
16 result_shape.push(shape[i]);
17 }
18 }
19 Ok(result_shape)
20}
21
22/// Assumes that `slice` is a correct slice, in particular that
23/// `get_slice_shape(shape, slice)` does not return an error.

Callers 1

process_nodeMethod · 0.85

Calls 4

get_clean_sliceFunction · 0.85
get_slice_shape_1dFunction · 0.85
cloneMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected