Adds several zero rows to the end or beginning of the array
(g: &Graph, x: Node, num_zero_rows: u64, in_front: bool)
| 123 | |
| 124 | // Adds several zero rows to the end or beginning of the array |
| 125 | pub 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 | |
| 139 | pub fn constant(g: &Graph, v: TypedValue) -> Result<Node> { |
| 140 | g.constant(v.t, v.value) |
no test coverage detected