Takes arrays `[a1, a2, ..., a_n]` and `[b1, b2, ..., b_n]` Returns `[a1, b1, a2, b2, ..., a_n, b_n]`
(first: Node, second: Node)
| 216 | /// |
| 217 | /// Returns `[a1, b1, a2, b2, ..., a_n, b_n]` |
| 218 | fn interleave(first: Node, second: Node) -> Result<Node> { |
| 219 | let first = expand_dims(first, &[0])?; |
| 220 | let second = expand_dims(second, &[0])?; |
| 221 | let graph = first.get_graph(); |
| 222 | let joined = graph.concatenate(vec![first, second], 0)?; |
| 223 | let mut axes: Vec<_> = (0..joined.get_type()?.get_shape().len() as u64).collect(); |
| 224 | axes.swap(0, 1); |
| 225 | let joined = joined.permute_axes(axes)?; |
| 226 | let mut shape = joined.get_type()?.get_shape(); |
| 227 | shape[0] *= 2; |
| 228 | shape.remove(1); |
| 229 | let scalar = joined.get_type()?.get_scalar_type(); |
| 230 | joined.reshape(array_type(shape, scalar)) |
| 231 | } |
| 232 | |
| 233 | /// This function generates a graph for the "segment tree" to calculate |
| 234 | /// carry bits. |
no test coverage detected