Files
TheRock/compiler/amd-llvm/mlir/test/Dialect/EmitC/math/ops.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

49 lines
2.0 KiB
MLIR

// RUN: mlir-opt %s -math-expand-ops=ops=rsqrt -convert-math-to-emitc \
// RUN: -convert-arith-to-emitc | FileCheck %s
/// This file checks the conversion of math ops whose EmitC lowering requires
/// expansion across multiple dialects, s.a. arith.
/// The FileCheck coverage is intentionally minimal, since the full MathToEmitC
/// lowering is already covered in
/// `test/Conversion/MathToEmitC/math-to-emitc.mlir`, their expansion in
/// `test/Dialect/Math/expand-math.mlir`, but not the combination of the two.
/// Vector cases excluded: `math.rsqrt` expands through `arith.constant` to
/// materialize the numerator `1.0`, and ArithToEmitC does not convert
/// `VectorType` to an EmitC type.
/// Tensor cases excluded: `math.rsqrt` expands through `arith.divf`, and the
/// resulting `emitc.div` does not accept tensor operands.
// CHECK-LABEL: func.func @rsqrt32
// CHECK-SAME: %[[SRC:.*]]: f32) -> f32
func.func @rsqrt32(%float: f32) -> (f32) {
// CHECK-NOT: math.sqrt
// CHECK: %[[CONST:.*]] = "emitc.constant"() <{value = 1.000000e+00 : f32}>
// CHECK: %[[SQRT:.*]] = emitc.call_opaque "sqrtf"(%[[SRC]])
// CHECK: %[[DIV:.*]] = emitc.div %[[CONST]], %[[SQRT]]
%float_result = math.rsqrt %float : f32
// CHECK: return %[[DIV]] : f32
return %float_result : f32
}
// CHECK-LABEL: func.func @rsqrt64
// CHECK-SAME: %[[SRC:.*]]: f64) -> f64
func.func @rsqrt64(%float: f64) -> (f64) {
// CHECK-NOT: math.sqrt
// CHECK: %[[CONST:.*]] = "emitc.constant"() <{value = 1.000000e+00 : f64}>
// CHECK: %[[SQRT:.*]] = emitc.call_opaque "sqrt"(%[[SRC]])
// CHECK: %[[DIV:.*]] = emitc.div %[[CONST]], %[[SQRT]]
%float_result = math.rsqrt %float : f64
// CHECK: return %[[DIV]] : f64
return %float_result : f64
}
/// `math.sqrt` is only lowered for f32/f64.
// CHECK-LABEL: func.func @negative_rsqrt16
func.func @negative_rsqrt16(%float: f16) -> (f16) {
// CHECK: math.sqrt
%float_result = math.rsqrt %float : f16
return %float_result : f16
}