pub struct ShapeGraph { /* private fields */ }Expand description
Shape graph for inference and optimization
Implementations§
Source§impl ShapeGraph
impl ShapeGraph
Sourcepub fn reshape(&mut self, input: NodeId, target_shape: Vec<usize>) -> NodeId
pub fn reshape(&mut self, input: NodeId, target_shape: Vec<usize>) -> NodeId
Add a reshape operation
Sourcepub fn transpose(&mut self, input: NodeId, axes: Vec<usize>) -> NodeId
pub fn transpose(&mut self, input: NodeId, axes: Vec<usize>) -> NodeId
Add a transpose operation
Sourcepub fn broadcast(&mut self, input: NodeId, target_shape: Vec<usize>) -> NodeId
pub fn broadcast(&mut self, input: NodeId, target_shape: Vec<usize>) -> NodeId
Add a broadcast operation
Sourcepub fn concatenate(
&mut self,
input1: NodeId,
input2: NodeId,
axis: usize,
) -> NodeId
pub fn concatenate( &mut self, input1: NodeId, input2: NodeId, axis: usize, ) -> NodeId
Add a concatenate operation
Sourcepub fn stack(&mut self, input1: NodeId, input2: NodeId, axis: usize) -> NodeId
pub fn stack(&mut self, input1: NodeId, input2: NodeId, axis: usize) -> NodeId
Add a stack operation
Sourcepub fn squeeze(&mut self, input: NodeId, axes: Option<Vec<usize>>) -> NodeId
pub fn squeeze(&mut self, input: NodeId, axes: Option<Vec<usize>>) -> NodeId
Add a squeeze operation
Sourcepub fn unsqueeze(&mut self, input: NodeId, axes: Vec<usize>) -> NodeId
pub fn unsqueeze(&mut self, input: NodeId, axes: Vec<usize>) -> NodeId
Add an unsqueeze operation
Sourcepub fn flatten(
&mut self,
input: NodeId,
start_dim: usize,
end_dim: usize,
) -> NodeId
pub fn flatten( &mut self, input: NodeId, start_dim: usize, end_dim: usize, ) -> NodeId
Add a flatten operation
Sourcepub fn infer_shape(&mut self, node_id: NodeId) -> InferenceResult<Vec<usize>>
pub fn infer_shape(&mut self, node_id: NodeId) -> InferenceResult<Vec<usize>>
Infer the shape for a node
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the inference cache
Sourcepub fn topological_sort(&self) -> InferenceResult<Vec<NodeId>>
pub fn topological_sort(&self) -> InferenceResult<Vec<NodeId>>
Get all nodes in topological order
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count the number of nodes in the graph
Trait Implementations§
Source§impl Clone for ShapeGraph
impl Clone for ShapeGraph
Source§fn clone(&self) -> ShapeGraph
fn clone(&self) -> ShapeGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShapeGraph
impl Debug for ShapeGraph
Auto Trait Implementations§
impl Freeze for ShapeGraph
impl RefUnwindSafe for ShapeGraph
impl Send for ShapeGraph
impl Sync for ShapeGraph
impl Unpin for ShapeGraph
impl UnsafeUnpin for ShapeGraph
impl UnwindSafe for ShapeGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more