Repository navigation
Open
Labels
codegen/llvmLLVM code generation compiler backend
Description
Testcase:
func.func @test_exp2_f16() -> () {
%input = util.unfoldable_constant dense<[-1.0]> : tensor<1xf16>
%result_empty = tensor.empty() : tensor<1xf16>
%result = linalg.generic {indexing_maps = [
affine_map<(d0) -> (d0)>,
affine_map<(d0) -> (d0)>
], iterator_types = ["parallel"]}
ins(%input : tensor<1xf16>) outs(%result_empty : tensor<1xf16>) {
^bb0(%in: f16, %out: f16):
%x = math.erfc %in : f16
linalg.yield %x : f16
} -> tensor<1xf16>
check.expect_almost_eq_const(%result, dense<[0.5]> : tensor<1xf16>) : tensor<1xf16>
return
}Repro:
iree-compile --iree-hal-target-device=llvm-cpu --iree-llvmcpu-target-cpu=generic ~/a.mlir -o ~/a.vmfb
Result:
// -----// IR Dump Before ConvertToLLVMPass (iree-convert-to-llvm) //----- //
module {
func.func @_test_exp2_f16_dispatch_0_elementwise() {
%c0 = arith.constant 0 : index
%0 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(0) alignment(64) offset(%c0) flags("ReadOnly|Indirect") : memref<f16>
memref.assume_alignment %0, 64 : memref<f16>
%1 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(1) alignment(64) offset(%c0) flags(Indirect) : memref<f16>
memref.assume_alignment %1, 64 : memref<f16>
%2 = memref.load %0[] : memref<f16>
%3 = math.erfc %2 : f16
memref.store %3, %1[] : memref<f16>
return
}
}
/home/benjacob/a.mlir:10:10: error: failed to legalize operation 'math.erfc' that was explicitly marked illegal
%x = math.erfc %in : f16
Metadata
Metadata
Assignees
Labels
codegen/llvmLLVM code generation compiler backend
Activity
ScottTodd commentedon Mar 5, 2025
Dunno about the f16 part of that, but could try adding erf to https://github.com/iree-org/iree/tree/main/runtime/src/iree/builtins/musl (pulling from https://github.com/powderluv/musl/blob/main/src/math/erf.c) or one of the related files
bjacob commentedon Mar 5, 2025
Note this issue is about
erfc, noterf.erfcis a recent addition to the math dialect.Also there is no
erfc.cfile under https://github.com/powderluv/musl/tree/main/src/mathScottTodd commentedon Mar 5, 2025
double erfc(double x): https://github.com/powderluv/musl/blob/3f701faace7addc75d16dea8a6cd769fa5b3f260/src/math/erf.c#L244C1-L244C22E2E tests for math ops. (#20169)
[AMDGPU] Test more math ops on ROCm: `erfc`, `log10`, `trunc` (#20225)
E2E tests for math ops. (#20169)
[AMDGPU] Test more math ops on ROCm: `erfc`, `log10`, `trunc` (#20225)