Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions projects/eudsl-python-extras/mlir/extras/runtime/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,19 +2146,24 @@ def convert_math_to_spirv(self):
def convert_math_to_xevm(
self, convert_arith: bool = None, convert_to_ocl: bool = None
):
"""Convert (fast) math operations to native XeVM/SPIRV equivalents
"""Convert math operations to their XeVM/SPIRV OpenCL equivalents

This pass converts supported math ops marked with the `afn` fastmath flag
to function calls for OpenCL `native_` math intrinsics: These intrinsics
are typically mapped directly to native device instructions, often resulting
in better performance. However, the precision/error of these intrinsics
are implementation-defined, and thus math ops are only converted when they
have the `afn` fastmath flag enabled. However, if the `convertToOCL` flag is
set then all supported math ops would be lowered to OpenCL math intrinsics.
This pass lowers supported math ops to OpenCL math intrinsic calls. The
fastmath flag on each op picks which intrinsic is used:

* Ops marked `afn` or `fast` become calls to OpenCL `native_` intrinsics.
Both work because `fast` is a group flag that expands to every fastmath
bit, `afn` included. These intrinsics are typically mapped directly to
native device instructions, often resulting in better performance. Their
precision/error is implementation-defined, so `afn` is what opts in.
Other flags on their own (`nnan`, `ninf`, ...) do not.
* Every other op becomes a call to the precise OpenCL intrinsic from the
`__spirv_ocl_` extended instruction set. Set the `convertToOCL` flag to
`false` to leave these ops alone instead.

Args:
convert_arith: Convert supported Arith ops (e.g. arith.divf) as well.
convert_to_ocl: Convert supported Math ops to OCL intrinsics.
convert_to_ocl: Convert Math ops without `afn` fastmath to precise OCL intrinsics.
"""
self.add_pass(
"convert-math-to-xevm",
Expand Down
23 changes: 14 additions & 9 deletions projects/mlir-python-mcp/mlir_python_mcp/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,19 +2146,24 @@ def convert_math_to_spirv(self):
def convert_math_to_xevm(
self, convert_arith: bool = None, convert_to_ocl: bool = None
):
"""Convert (fast) math operations to native XeVM/SPIRV equivalents
"""Convert math operations to their XeVM/SPIRV OpenCL equivalents

This pass converts supported math ops marked with the `afn` fastmath flag
to function calls for OpenCL `native_` math intrinsics: These intrinsics
are typically mapped directly to native device instructions, often resulting
in better performance. However, the precision/error of these intrinsics
are implementation-defined, and thus math ops are only converted when they
have the `afn` fastmath flag enabled. However, if the `convertToOCL` flag is
set then all supported math ops would be lowered to OpenCL math intrinsics.
This pass lowers supported math ops to OpenCL math intrinsic calls. The
fastmath flag on each op picks which intrinsic is used:

* Ops marked `afn` or `fast` become calls to OpenCL `native_` intrinsics.
Both work because `fast` is a group flag that expands to every fastmath
bit, `afn` included. These intrinsics are typically mapped directly to
native device instructions, often resulting in better performance. Their
precision/error is implementation-defined, so `afn` is what opts in.
Other flags on their own (`nnan`, `ninf`, ...) do not.
* Every other op becomes a call to the precise OpenCL intrinsic from the
`__spirv_ocl_` extended instruction set. Set the `convertToOCL` flag to
`false` to leave these ops alone instead.

Args:
convert_arith: Convert supported Arith ops (e.g. arith.divf) as well.
convert_to_ocl: Convert supported Math ops to OCL intrinsics.
convert_to_ocl: Convert Math ops without `afn` fastmath to precise OCL intrinsics.
"""
self.add_pass(
"convert-math-to-xevm",
Expand Down
2 changes: 1 addition & 1 deletion third_party/llvm-project
Submodule llvm-project updated 900 files
Loading