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

Function extend_with_zeros

ciphercore-base/src/ops/utils.rs:125–137  ·  view source on GitHub ↗

Adds several zero rows to the end or beginning of the array

(g: &Graph, x: Node, num_zero_rows: u64, in_front: bool)

Source from the content-addressed store, hash-verified

123
124// Adds several zero rows to the end or beginning of the array
125pub fn extend_with_zeros(g: &Graph, x: Node, num_zero_rows: u64, in_front: bool) -> Result<Node> {
126 let t = x.get_type()?;
127 let st = t.get_scalar_type();
128 let shape = t.get_shape();
129 let last_axis = shape.len() - 1;
130 let mut zeros_shape = shape[0..last_axis].to_vec();
131 zeros_shape.push(num_zero_rows);
132 let zero_rows = g.zeros(array_type(zeros_shape, st))?;
133 if in_front {
134 return g.concatenate(vec![zero_rows, x], last_axis as u64);
135 }
136 g.concatenate(vec![x, zero_rows], last_axis as u64)
137}
138
139pub fn constant(g: &Graph, v: TypedValue) -> Result<Node> {
140 g.constant(v.t, v.value)

Callers 2

instantiateMethod · 0.85
instantiateMethod · 0.85

Calls 7

get_shapeMethod · 0.80
zerosMethod · 0.80
concatenateMethod · 0.80
array_typeFunction · 0.50
get_typeMethod · 0.45
get_scalar_typeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected