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
132 lines
6.0 KiB
MLIR
132 lines
6.0 KiB
MLIR
// RUN: mlir-opt -split-input-file -convert-complex-to-spirv %s | FileCheck %s
|
|
|
|
func.func @create_complex(%real: f32, %imag: f32) -> complex<f32> {
|
|
%0 = complex.create %real, %imag : complex<f32>
|
|
return %0 : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @create_complex
|
|
// CHECK-SAME: (%[[RE:.+]]: f32, %[[IM:.+]]: f32)
|
|
// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[RE]], %[[IM]] : (f32, f32) -> vector<2xf32>
|
|
// CHECK: %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[CC]] : vector<2xf32> to complex<f32>
|
|
// CHECK: return %[[CAST]] : complex<f32>
|
|
|
|
|
|
// -----
|
|
|
|
func.func @real_number(%arg: complex<f32>) -> f32 {
|
|
%real = complex.re %arg : complex<f32>
|
|
return %real : f32
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @real_number
|
|
// CHECK-SAME: %[[ARG:.+]]: complex<f32>
|
|
// CHECK: %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG]] : complex<f32> to vector<2xf32>
|
|
// CHECK: %[[RE:.+]] = spirv.CompositeExtract %[[CAST]][0 : i32] : vector<2xf32>
|
|
// CHECK: return %[[RE]] : f32
|
|
|
|
// -----
|
|
|
|
func.func @imaginary_number(%arg: complex<f32>) -> f32 {
|
|
%imaginary = complex.im %arg : complex<f32>
|
|
return %imaginary: f32
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @imaginary_number
|
|
// CHECK-SAME: %[[ARG:.+]]: complex<f32>
|
|
// CHECK: %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG]] : complex<f32> to vector<2xf32>
|
|
// CHECK: %[[IM:.+]] = spirv.CompositeExtract %[[CAST]][1 : i32] : vector<2xf32>
|
|
// CHECK: return %[[IM]] : f32
|
|
|
|
// -----
|
|
|
|
func.func @complex_const() -> complex<f32> {
|
|
%cst = complex.constant [0x7FC00000 : f32, 0.000000e+00 : f32] : complex<f32>
|
|
return %cst : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @complex_const()
|
|
// CHECK: spirv.Constant dense<[0x7FC00000, 0.000000e+00]> : vector<2xf32>
|
|
|
|
// -----
|
|
|
|
func.func @complex_add(%lhs: complex<f32>, %rhs: complex<f32>) -> complex<f32> {
|
|
%0 = complex.add %lhs, %rhs : complex<f32>
|
|
return %0 : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @complex_add
|
|
// CHECK-SAME: (%[[LHS:.+]]: complex<f32>, %[[RHS:.+]]: complex<f32>)
|
|
// CHECK-DAG: %[[LV:.+]] = builtin.unrealized_conversion_cast %[[LHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK-DAG: %[[RV:.+]] = builtin.unrealized_conversion_cast %[[RHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK: %[[LRE:.+]] = spirv.CompositeExtract %[[LV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[LIM:.+]] = spirv.CompositeExtract %[[LV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[RRE:.+]] = spirv.CompositeExtract %[[RV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[RIM:.+]] = spirv.CompositeExtract %[[RV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[RE:.+]] = spirv.FAdd %[[LRE]], %[[RRE]] : f32
|
|
// CHECK: %[[IM:.+]] = spirv.FAdd %[[LIM]], %[[RIM]] : f32
|
|
// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[RE]], %[[IM]] : (f32, f32) -> vector<2xf32>
|
|
|
|
// -----
|
|
|
|
func.func @complex_sub(%lhs: complex<f32>, %rhs: complex<f32>) -> complex<f32> {
|
|
%0 = complex.sub %lhs, %rhs : complex<f32>
|
|
return %0 : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @complex_sub
|
|
// CHECK: spirv.FSub
|
|
// CHECK: spirv.FSub
|
|
// CHECK: spirv.CompositeConstruct
|
|
|
|
// -----
|
|
|
|
func.func @complex_mul(%lhs: complex<f32>, %rhs: complex<f32>) -> complex<f32> {
|
|
%0 = complex.mul %lhs, %rhs : complex<f32>
|
|
return %0 : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @complex_mul
|
|
// CHECK-SAME: (%[[LHS:.+]]: complex<f32>, %[[RHS:.+]]: complex<f32>)
|
|
// CHECK-DAG: %[[LV:.+]] = builtin.unrealized_conversion_cast %[[LHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK-DAG: %[[RV:.+]] = builtin.unrealized_conversion_cast %[[RHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK: %[[A:.+]] = spirv.CompositeExtract %[[LV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[B:.+]] = spirv.CompositeExtract %[[LV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[C:.+]] = spirv.CompositeExtract %[[RV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[D:.+]] = spirv.CompositeExtract %[[RV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[AC:.+]] = spirv.FMul %[[A]], %[[C]] : f32
|
|
// CHECK: %[[BD:.+]] = spirv.FMul %[[B]], %[[D]] : f32
|
|
// CHECK: %[[AD:.+]] = spirv.FMul %[[A]], %[[D]] : f32
|
|
// CHECK: %[[BC:.+]] = spirv.FMul %[[B]], %[[C]] : f32
|
|
// CHECK: %[[RE:.+]] = spirv.FSub %[[AC]], %[[BD]] : f32
|
|
// CHECK: %[[IM:.+]] = spirv.FAdd %[[AD]], %[[BC]] : f32
|
|
// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[RE]], %[[IM]] : (f32, f32) -> vector<2xf32>
|
|
|
|
// -----
|
|
|
|
func.func @complex_div(%lhs: complex<f32>, %rhs: complex<f32>) -> complex<f32> {
|
|
%0 = complex.div %lhs, %rhs : complex<f32>
|
|
return %0 : complex<f32>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @complex_div
|
|
// CHECK-SAME: (%[[LHS:.+]]: complex<f32>, %[[RHS:.+]]: complex<f32>)
|
|
// CHECK-DAG: %[[LV:.+]] = builtin.unrealized_conversion_cast %[[LHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK-DAG: %[[RV:.+]] = builtin.unrealized_conversion_cast %[[RHS]] : complex<f32> to vector<2xf32>
|
|
// CHECK: %[[A:.+]] = spirv.CompositeExtract %[[LV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[B:.+]] = spirv.CompositeExtract %[[LV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[C:.+]] = spirv.CompositeExtract %[[RV]][0 : i32] : vector<2xf32>
|
|
// CHECK: %[[D:.+]] = spirv.CompositeExtract %[[RV]][1 : i32] : vector<2xf32>
|
|
// CHECK: %[[AC:.+]] = spirv.FMul %[[A]], %[[C]] : f32
|
|
// CHECK: %[[BD:.+]] = spirv.FMul %[[B]], %[[D]] : f32
|
|
// CHECK: %[[BC:.+]] = spirv.FMul %[[B]], %[[C]] : f32
|
|
// CHECK: %[[AD:.+]] = spirv.FMul %[[A]], %[[D]] : f32
|
|
// CHECK: %[[CC2:.+]] = spirv.FMul %[[C]], %[[C]] : f32
|
|
// CHECK: %[[DD:.+]] = spirv.FMul %[[D]], %[[D]] : f32
|
|
// CHECK: %[[DENOM:.+]] = spirv.FAdd %[[CC2]], %[[DD]] : f32
|
|
// CHECK: %[[NRE:.+]] = spirv.FAdd %[[AC]], %[[BD]] : f32
|
|
// CHECK: %[[NIM:.+]] = spirv.FSub %[[BC]], %[[AD]] : f32
|
|
// CHECK: %[[RE:.+]] = spirv.FDiv %[[NRE]], %[[DENOM]] : f32
|
|
// CHECK: %[[IM:.+]] = spirv.FDiv %[[NIM]], %[[DENOM]] : f32
|
|
// CHECK: %[[CC:.+]] = spirv.CompositeConstruct %[[RE]], %[[IM]] : (f32, f32) -> vector<2xf32>
|