Skip to content

Generic abstraction for prologue/epilogue elementwise unary operator fusion onto GEMV/GEMM #193

Description

@andrej

We're currently hard-coding which unary operators ("activation functions") may be applied/fused onto a GEMV on to a core:

if self.epilogue not in ("none", "gelu"):
raise ValueError(
f"unknown epilogue {self.epilogue!r} (expected 'none' or 'gelu')"
)

A nicer "Kernel" abstraction that encodes (i) the function name (extern C), (ii) the argument specification expected (MLIR func.func signature), (iii) how to compile and link it in would be good at some point in the future. If we have to list every single activation function in every GEMV and GEMM kernel as a custom prologue/epilogue, it will get old quick.

We could probably reuse ChanneledUnaryOperator for this. Extract the kernel and its calling convention out of the ChanneledUnaryOperator. A single prologue=ChanneledUnaryOperator(...) would enode all the information needed -- no listing of all functions inside GEMV.

cc @atassis

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions