ShapeOperationsExample

Example demonstrating shape manipulation operations in StableHLO conversion.

This example shows how to:

  1. Create a graph with various shape operations

  2. Convert reshape, flatten, squeeze, and unsqueeze operations to StableHLO

  3. Handle dynamic shape transformations

Functions

Link copied to clipboard
fun convertToStableHlo(graph: DefaultComputeGraph, functionName: String = "shape_ops"): String

Convert a graph to StableHLO MLIR using the extended converter

Link copied to clipboard

Create a graph demonstrating flatten operation for neural networks: input (1,32,28,28) -> flatten (1,25088) typical CNN to FC transition

Link copied to clipboard

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)

Link copied to clipboard

Create a simpler graph showing just reshape operation: input (4,6) -> reshape (2,12)

Link copied to clipboard

Run the complete shape transformation example

Link copied to clipboard

Run the neural network flatten example

Link copied to clipboard

Run the simple reshape example