-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SPIR-V] Add support for the SPIR-V extension SPV_INTEL_tensor_float32_conversion #150090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MrSidims
merged 6 commits into
llvm:main
from
YixingZhang007:add_SPV_INTEL_tensor_float32_conversion
Aug 1, 2025
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3749aa6
draft implementation for supporting SPV_INTEL_tensor_float32_conversion
YixingZhang007 b90fd0c
add tests, finalize the implementation and code cleanup
YixingZhang007 6135f14
fix clang format
YixingZhang007 8528c2f
fix the CI test failure
YixingZhang007 5b4b793
move the mlir part to a new PR
YixingZhang007 608c8fa
solve the grammar mistake
YixingZhang007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
.../test/CodeGen/SPIRV/extensions/SPV_INTEL_tensor_float32_conversion/tf32-conv-negative1.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_tensor_float32_conversion %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
| ; CHECK-ERROR: result and argument must have the same number of components | ||
|
|
||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
| target triple = "spir64-unknown-unknown" | ||
|
|
||
| define spir_func void @test(<8 x float> %in) { | ||
| %res = tail call spir_func float @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float> %in) | ||
| ret void | ||
| } | ||
|
|
||
| declare spir_func float @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float>) |
12 changes: 12 additions & 0 deletions
12
.../test/CodeGen/SPIRV/extensions/SPV_INTEL_tensor_float32_conversion/tf32-conv-negative2.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_tensor_float32_conversion %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
| ; CHECK-ERROR: result and argument must have the same number of components | ||
|
|
||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
| target triple = "spir64-unknown-unknown" | ||
|
|
||
| define spir_func void @test(<8 x float> %in) { | ||
| %res = tail call spir_func <4 x float> @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float> %in) | ||
| ret void | ||
| } | ||
|
|
||
| declare spir_func <4 x float> @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float>) |
62 changes: 62 additions & 0 deletions
62
llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_tensor_float32_conversion/tf32-conv.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_tensor_float32_conversion %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_tensor_float32_conversion %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
| ; CHECK-ERROR: the builtin requires the following SPIR-V extension: SPV_INTEL_tensor_float32_conversion | ||
|
|
||
| ; CHECK: OpCapability TensorFloat32RoundingINTEL | ||
| ; CHECK: OpExtension "SPV_INTEL_tensor_float32_conversion" | ||
|
|
||
| ; CHECK-DAG: %[[VoidTy:.*]] = OpTypeVoid | ||
| ; CHECK-DAG: %[[FP32Ty:.*]] = OpTypeFloat 32 | ||
| ; CHECK-DAG: %[[VecFloat2:.*]] = OpTypeVector %[[FP32Ty]] 2 | ||
| ; CHECK-DAG: %[[VecFloat3:.*]] = OpTypeVector %[[FP32Ty]] 3 | ||
| ; CHECK-DAG: %[[VecFloat4:.*]] = OpTypeVector %[[FP32Ty]] 4 | ||
| ; CHECK-DAG: %[[VecFloat8:.*]] = OpTypeVector %[[FP32Ty]] 8 | ||
| ; CHECK-DAG: %[[VecFloat16:.*]] = OpTypeVector %[[FP32Ty]] 16 | ||
| ; CHECK-DAG: %[[FloatConstId:.*]] = OpConstant %[[FP32Ty]] 1.5 | ||
|
|
||
| ; CHECK: OpFunction %[[VoidTy]] | ||
| ; CHECK: %[[FP32ValId:.*]] = OpFunctionParameter %[[FP32Ty]] | ||
| ; CHECK: %[[FP32v8ValId:.*]] = OpFunctionParameter %[[VecFloat8]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[FP32Ty]] %[[FP32ValId]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat8]] %[[FP32v8ValId]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[FP32Ty]] %[[FloatConstId]] | ||
|
|
||
| ; CHECK: OpRoundFToTF32INTEL %[[FP32Ty]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat2]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat3]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat4]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat8]] | ||
| ; CHECK: OpRoundFToTF32INTEL %[[VecFloat16]] | ||
|
|
||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
| target triple = "spir64-unknown-unknown" | ||
|
|
||
| define spir_func void @test(float %a, <8 x float> %in) { | ||
| %res1 = tail call spir_func float @_Z25__spirv_RoundFToTF32INTELf(float %a) | ||
| %res2 = tail call spir_func <8 x float> @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float> %in) | ||
| %res3 = tail call spir_func float @_Z25__spirv_RoundFToTF32INTELf(float 1.500000e+00) | ||
| ret void | ||
| } | ||
|
|
||
| declare spir_func float @_Z25__spirv_RoundFToTF32INTELf(float) | ||
| declare spir_func <8 x float> @_Z25__spirv_RoundFToTF32INTELDv8_f(<8 x float>) | ||
|
|
||
| define dso_local spir_kernel void @test_ocl(float %a) { | ||
| entry: | ||
| %res4 = call spir_func float @_Z35intel_round_as_tensor_float32_floatt(float 0.000000e+00) | ||
| %res5 = call spir_func <2 x float> @_Z37intel_round_as_tensor_float322_float2Dv2_t(<2 x float> zeroinitializer) | ||
| %res6 = call spir_func <3 x float> @_Z37intel_round_as_tensor_float323_float3Dv3_t(<3 x float> zeroinitializer) | ||
| %res7 = call spir_func <4 x float> @_Z37intel_round_as_tensor_float324_float4Dv4_t(<4 x float> zeroinitializer) | ||
| %res8 = call spir_func <8 x float> @_Z37intel_round_as_tensor_float328_float8Dv8_t(<8 x float> zeroinitializer) | ||
| %res9 = call spir_func <16 x float> @_Z39intel_round_as_tensor_float3216_float16Dv16_t(<16 x float> zeroinitializer) | ||
| ret void | ||
| } | ||
|
|
||
| declare spir_func float @_Z35intel_round_as_tensor_float32_floatt(float) | ||
| declare spir_func <2 x float> @_Z37intel_round_as_tensor_float322_float2Dv2_t(<2 x float>) | ||
| declare spir_func <3 x float> @_Z37intel_round_as_tensor_float323_float3Dv3_t(<3 x float>) | ||
| declare spir_func <4 x float> @_Z37intel_round_as_tensor_float324_float4Dv4_t(<4 x float>) | ||
| declare spir_func <8 x float> @_Z37intel_round_as_tensor_float328_float8Dv8_t(<8 x float>) | ||
| declare spir_func <16 x float> @_Z39intel_round_as_tensor_float3216_float16Dv16_t(<16 x float>) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.