Skip to content

Instantly share code, notes, and snippets.

@nihalpasham
Last active September 28, 2024 02:00
Show Gist options
  • Save nihalpasham/6e4c0edf5b1a0b199c05c186a5a75b2d to your computer and use it in GitHub Desktop.
Save nihalpasham/6e4c0edf5b1a0b199c05c186a5a75b2d to your computer and use it in GitHub Desktop.
CubeCL IR for the gelu_example
KernelDefinition { inputs: [Binding { location: Storage, visibility: Read, item: Item { elem: Float(F32), vectorization: Some(1)
}, size: None
}
], outputs: [Binding { location: Storage, visibility: ReadWrite, item: Item { elem: Float(F32), vectorization: Some(1)
}, size: None
}
], named: [("info", Binding { location: Storage, visibility: Read, item: Item { elem: UInt, vectorization: None
}, size: None
})
], cube_dim: CubeDim { x: 4, y: 1, z: 1
}, body: Scope { depth: 0, operations: [Metadata(Length { var: GlobalInputArray { id: 0, item: Item { elem: Float(F32), vectorization: Some(1)
}
}, out: Local { id: 0, item: Item { elem: UInt, vectorization: None
}, depth: 0
}
}), Operator(Lower(BinaryOperator { lhs: AbsolutePos, rhs: Local { id: 0, item: Item { elem: UInt, vectorization: None
}, depth: 0
}, out: Local { id: 1, item: Item { elem: Bool, vectorization: None
}, depth: 0
}
})), Branch(If(If { cond: Local { id: 1, item: Item { elem: Bool, vectorization: None
}, depth: 0
}, scope: Scope { depth: 1, operations: [Operator(Index(BinaryOperator { lhs: GlobalInputArray { id: 0, item: Item { elem: Float(F32), vectorization: Some(1)
}
}, rhs: AbsolutePos, out: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(Div(BinaryOperator { lhs: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, rhs: ConstantScalar(Float(1.4142135381698608, F32)), out: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(Add(BinaryOperator { lhs: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, rhs: ConstantScalar(Float(1.0, F32)), out: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(Erf(UnaryOperator { input: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, out: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(Mul(BinaryOperator { lhs: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, rhs: Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, out: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(Div(BinaryOperator { lhs: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, rhs: ConstantScalar(Float(2.0, F32)), out: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
})), Operator(IndexAssign(BinaryOperator { lhs: AbsolutePos, rhs: Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, out: GlobalOutputArray { id: 0, item: Item { elem: Float(F32), vectorization: Some(1)
}
}
}))
], locals: [], matrices: [], slices: [], shared_memories: [], local_arrays: [], reads_global: [], index_offset_with_output_layout_position: [], writes_global: [], reads_scalar: [], layout_ref: Some(GlobalOutputArray { id: 0, item: Item { elem: Float(F32), vectorization: Some(1)
}
}), undeclared: 0
}
}))
], locals: [Local { id: 0, item: Item { elem: UInt, vectorization: None
}, depth: 0
}, Local { id: 1, item: Item { elem: Bool, vectorization: None
}, depth: 0
}, Local { id: 2, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}, Local { id: 3, item: Item { elem: Float(F32), vectorization: Some(1)
}, depth: 0
}
], matrices: [], slices: [], shared_memories: [], local_arrays: [], reads_global: [], index_offset_with_output_layout_position: [], writes_global: [], reads_scalar: [], layout_ref: Some(GlobalOutputArray { id: 0, item: Item { elem: Float(F32), vectorization: Some(1)
}
}), undeclared: 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment