137 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// -----4 5// CHECK-LABEL: @convert_f32x2_to_f8x2_e4m36llvm.func @convert_f32x2_to_f8x2_e4m3(%srcA : f32, %srcB : f32) {7 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.e4m3x2.rn(float %{{.*}}, float %{{.*}})8 %res1 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E4M3FN)9 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.e4m3x2.rn.relu(float %{{.*}}, float %{{.*}})10 %res2 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {relu = true, rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E4M3FN)11 llvm.return12}13 14// CHECK-LABEL: @convert_f32x2_to_f8x2_e5m215llvm.func @convert_f32x2_to_f8x2_e5m2(%srcA : f32, %srcB : f32) {16 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.e5m2x2.rn(float %{{.*}}, float %{{.*}})17 %res1 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E5M2)18 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.e5m2x2.rn.relu(float %{{.*}}, float %{{.*}})19 %res2 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {relu = true, rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E5M2)20 llvm.return21}22 23// CHECK-LABEL: @convert_f32x2_to_f8x2_ue8m024llvm.func @convert_f32x2_to_f8x2_ue8m0(%srcA : f32, %srcB : f32) {25 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.ue8m0x2.rz(float %{{.*}}, float %{{.*}})26 %res1 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rz>} : i16 (f8E8M0FNU)27 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.ue8m0x2.rp(float %{{.*}}, float %{{.*}})28 %res2 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rp>} : i16 (f8E8M0FNU)29 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.ue8m0x2.rz.satfinite(float %{{.*}}, float %{{.*}})30 %res3 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rz>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E8M0FNU)31 // CHECK: %{{.*}} = call i16 @llvm.nvvm.ff.to.ue8m0x2.rp.satfinite(float %{{.*}}, float %{{.*}})32 %res4 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rp>, sat = #nvvm.sat_mode<satfinite>} : i16 (f8E8M0FNU)33 llvm.return34}35 36// CHECK-LABEL: @convert_f32x2_to_f8x2_vector_return37llvm.func @convert_f32x2_to_f8x2_vector_return(%srcA : f32, %srcB : f32) {38 // CHECK: %[[res1:.*]] = call i16 @llvm.nvvm.ff.to.e4m3x2.rn(float %{{.*}}, float %{{.*}})39 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res1]] to <2 x i8>40 %res1 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : vector<2xi8> (f8E4M3FN)41 // CHECK: %[[res2:.*]] = call i16 @llvm.nvvm.ff.to.e4m3x2.rn.relu(float %{{.*}}, float %{{.*}})42 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res2]] to <2 x i8>43 %res2 = nvvm.convert.f32x2.to.f8x2 %srcA, %srcB {relu = true, rnd = #nvvm.fp_rnd_mode<rn>, sat = #nvvm.sat_mode<satfinite>} : vector<2xi8> (f8E4M3FN)44 llvm.return45}46 47// -----48 49// CHECK-LABEL: @convert_f16x2_to_f8x2_e4m350llvm.func @convert_f16x2_to_f8x2_e4m3(%src : vector<2xf16>) {51 // CHECK: %{{.*}} = call i16 @llvm.nvvm.f16x2.to.e4m3x2.rn(<2 x half> %{{.*}})52 %res1 = nvvm.convert.f16x2.to.f8x2 %src : vector<2xf16> -> i16 (f8E4M3FN)53 // CHECK: %{{.*}} = call i16 @llvm.nvvm.f16x2.to.e4m3x2.rn.relu(<2 x half> %{{.*}})54 %res2 = nvvm.convert.f16x2.to.f8x2 %src {relu = true} : vector<2xf16> -> i16 (f8E4M3FN)55 llvm.return56}57 58// CHECK-LABEL: @convert_f16x2_to_f8x2_e5m259llvm.func @convert_f16x2_to_f8x2_e5m2(%src : vector<2xf16>) {60 // CHECK: %{{.*}} = call i16 @llvm.nvvm.f16x2.to.e5m2x2.rn(<2 x half> %{{.*}})61 %res1 = nvvm.convert.f16x2.to.f8x2 %src : vector<2xf16> -> i16 (f8E5M2)62 // CHECK: %{{.*}} = call i16 @llvm.nvvm.f16x2.to.e5m2x2.rn.relu(<2 x half> %{{.*}})63 %res2 = nvvm.convert.f16x2.to.f8x2 %src {relu = true} : vector<2xf16> -> i16 (f8E5M2)64 llvm.return65}66 67// CHECK-LABEL: @convert_f16x2_to_f8x2_vector_return68llvm.func @convert_f16x2_to_f8x2_vector_return(%src : vector<2xf16>) {69 // CHECK: %[[res1:.*]] = call i16 @llvm.nvvm.f16x2.to.e4m3x2.rn(<2 x half> %{{.*}})70 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res1]] to <2 x i8>71 %res1 = nvvm.convert.f16x2.to.f8x2 %src : vector<2xf16> -> vector<2xi8> (f8E4M3FN)72 // CHECK: %[[res2:.*]] = call i16 @llvm.nvvm.f16x2.to.e5m2x2.rn(<2 x half> %{{.*}})73 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res2]] to <2 x i8>74 %res2 = nvvm.convert.f16x2.to.f8x2 %src : vector<2xf16> -> vector<2xi8> (f8E5M2)75 llvm.return76}77 78// -----79 80// CHECK-LABEL: @convert_bf16x2_to_f8x2_ue8m081llvm.func @convert_bf16x2_to_f8x2_ue8m0(%src : vector<2xbf16>) {82 // CHECK: %{{.*}} = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz(<2 x bfloat> %{{.*}})83 %res1 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rz>} : vector<2xbf16> -> i16 (f8E8M0FNU)84 // CHECK: %{{.*}} = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp(<2 x bfloat> %{{.*}})85 %res2 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rp>} : vector<2xbf16> -> i16 (f8E8M0FNU)86 // CHECK: %{{.*}} = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz.satfinite(<2 x bfloat> %{{.*}})87 %res3 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rz>, sat = #nvvm.sat_mode<satfinite>} : vector<2xbf16> -> i16 (f8E8M0FNU)88 // CHECK: %{{.*}} = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp.satfinite(<2 x bfloat> %{{.*}})89 %res4 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rp>, sat = #nvvm.sat_mode<satfinite>} : vector<2xbf16> -> i16 (f8E8M0FNU)90 llvm.return91}92 93// CHECK-LABEL: @convert_bf16x2_to_f8x2_vector_return94llvm.func @convert_bf16x2_to_f8x2_vector_return(%src : vector<2xbf16>) {95 // CHECK: %[[res1:.*]] = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz(<2 x bfloat> %{{.*}})96 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res1]] to <2 x i8>97 %res1 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rz>} : vector<2xbf16> -> vector<2xi8> (f8E8M0FNU)98 // CHECK: %[[res2:.*]] = call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp.satfinite(<2 x bfloat> %{{.*}})99 // CHECK-NEXT: %{{.*}} = bitcast i16 %[[res2]] to <2 x i8>100 %res2 = nvvm.convert.bf16x2.to.f8x2 %src {rnd = #nvvm.fp_rnd_mode<rp>, sat = #nvvm.sat_mode<satfinite>} : vector<2xbf16> -> vector<2xi8> (f8E8M0FNU)101 llvm.return102}103 104// -----105 106// CHECK-LABEL: @convert_f8x2_to_f16x2107llvm.func @convert_f8x2_to_f16x2_e4m3(%src : vector<2xi8>) {108 // CHECK: %[[res1:.*]] = bitcast <2 x i8> %{{.*}} to i16109 // CHECK-NEXT: %{{.*}} = call <2 x half> @llvm.nvvm.e4m3x2.to.f16x2.rn(i16 %[[res1]])110 %res1 = nvvm.convert.f8x2.to.f16x2 %src : vector<2xi8> (f8E4M3FN)-> vector<2xf16>111 // CHECK: %[[res2:.*]] = bitcast <2 x i8> %{{.*}} to i16112 // CHECK-NEXT: %{{.*}} = call <2 x half> @llvm.nvvm.e4m3x2.to.f16x2.rn.relu(i16 %[[res2]])113 %res2 = nvvm.convert.f8x2.to.f16x2 %src {relu = true} : vector<2xi8> (f8E4M3FN)-> vector<2xf16>114 llvm.return115}116 117// CHECK-LABEL: @convert_f8x2_to_f16x2_e5m2118llvm.func @convert_f8x2_to_f16x2_e5m2(%src : vector<2xi8>) {119 // CHECK: %[[res1:.*]] = bitcast <2 x i8> %{{.*}} to i16120 // CHECK-NEXT: %{{.*}} = call <2 x half> @llvm.nvvm.e5m2x2.to.f16x2.rn(i16 %[[res1]])121 %res1 = nvvm.convert.f8x2.to.f16x2 %src : vector<2xi8> (f8E5M2)-> vector<2xf16>122 // CHECK: %[[res2:.*]] = bitcast <2 x i8> %{{.*}} to i16123 // CHECK-NEXT: %{{.*}} = call <2 x half> @llvm.nvvm.e5m2x2.to.f16x2.rn.relu(i16 %[[res2]])124 %res2 = nvvm.convert.f8x2.to.f16x2 %src {relu = true} : vector<2xi8> (f8E5M2)-> vector<2xf16>125 llvm.return126}127 128// -----129 130// CHECK-LABEL: @convert_f8x2_to_bf16x2_ue8m0131llvm.func @convert_f8x2_to_bf16x2_ue8m0(%src : vector<2xi8>) {132 // CHECK: %[[res1:.*]] = bitcast <2 x i8> %{{.*}} to i16133 // CHECK-NEXT: %{{.*}} = call <2 x bfloat> @llvm.nvvm.ue8m0x2.to.bf16x2(i16 %[[res1]])134 %res1 = nvvm.convert.f8x2.to.bf16x2 %src : vector<2xi8> (f8E8M0FNU)-> vector<2xbf16>135 llvm.return136}137