use crate::op::ScatterNdReduction;
use crate::{Graph, NodeId, Op, Shape};
impl Graph {
pub fn reshape(&mut self, input: NodeId, new_shape: Vec<i64>, out_shape: Shape) -> NodeId {
self.push(Op::Reshape { new_shape }, vec![input], out_shape, None)
}
pub fn gather(&mut self, table: NodeId, indices: NodeId, axis: usize, shape: Shape) -> NodeId {
self.push(Op::Gather { axis }, vec![table, indices], shape, None)
}
pub fn scatter_nd(
&mut self,
data: NodeId,
indices: NodeId,
updates: NodeId,
reduction: ScatterNdReduction,
) -> NodeId {
let shape = self.node(data).shape.clone();
self.push(
Op::ScatterNd { reduction },
vec![data, indices, updates],
shape,
None,
)
}
pub fn scatter_elements(
&mut self,
data: NodeId,
indices: NodeId,
updates: NodeId,
axis: i32,
reduction: ScatterNdReduction,
) -> NodeId {
let shape = self.node(data).shape.clone();
self.push(
Op::ScatterElements { axis, reduction },
vec![data, indices, updates],
shape,
None,
)
}
pub fn gather_nd(
&mut self,
data: NodeId,
indices: NodeId,
batch_dims: i32,
out_shape: Shape,
) -> NodeId {
self.push(
Op::GatherNd { batch_dims },
vec![data, indices],
out_shape,
None,
)
}
pub fn gather_elements(&mut self, data: NodeId, indices: NodeId, axis: i32) -> NodeId {
let shape = self.node(indices).shape.clone();
self.push(
Op::GatherElements { axis },
vec![data, indices],
shape,
None,
)
}
pub fn concat(&mut self, inputs: Vec<NodeId>, axis: usize, shape: Shape) -> NodeId {
self.push(Op::Concat { axis }, inputs, shape, None)
}
pub fn reverse(&mut self, input: NodeId, axes: Vec<usize>) -> NodeId {
let shape = self.node(input).shape.clone();
self.push(Op::Reverse { axes }, vec![input], shape, None)
}
}