ShapeOperationsExample
Example demonstrating shape manipulation operations in StableHLO conversion.
This example shows how to:
Create a graph with various shape operations
Convert reshape, flatten, squeeze, and unsqueeze operations to StableHLO
Handle dynamic shape transformations
Functions
Convert a graph to StableHLO MLIR using the extended converter
Create a graph demonstrating flatten operation for neural networks: input (1,32,28,28) -> flatten (1,25088) typical CNN to FC transition
Create a graph demonstrating common shape transformations: input (2,3,4,5) -> reshape (2,3,20) -> flatten (2,60) -> unsqueeze (2,1,60) -> squeeze (2,60)
Create a simpler graph showing just reshape operation: input (4,6) -> reshape (2,12)
Run the complete shape transformation example
Run the neural network flatten example
Run the simple reshape example