@@ -736,6 +736,93 @@ def ROCDL_CvtPkRtz:
736
736
}];
737
737
}
738
738
739
+ //===---------------------------------------------------------------------===//
740
+ // 32-bit float intrinsics
741
+ //===---------------------------------------------------------------------===//
742
+ def ROCDL_CvtScalePkF32Fp8 :
743
+ ROCDL_IntrOp<"cvt.scalef32.pk.f32.fp8", [], [], [Pure], 1>,
744
+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
745
+ let summary = "Scale and convert packed fp8 to packed f32";
746
+ let description = [{
747
+ Scale `src` by the exponent in `scale` then convert to packed fp32.
748
+ Store the result in low/high word based on $wordSel, preserving the other word.
749
+ }];
750
+ let assemblyFormat = [{
751
+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
752
+ }];
753
+ }
754
+ def ROCDL_CvtScalePkF32Bf8 :
755
+ ROCDL_IntrOp<"cvt.scalef32.pk.f32.bf8", [], [], [Pure], 1>,
756
+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
757
+ let summary = "Scale and convert packed bf8 to packed f32";
758
+ let description = [{
759
+ Scale `src` by the exponent in `scale` then convert to packed fp32.
760
+ Store the result in low/high word based on $wordSel, preserving the other word.
761
+ }];
762
+ let assemblyFormat = [{
763
+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
764
+ }];
765
+ }
766
+ //===---------------------------------------------------------------------===//
767
+ // 8-bit float scale intrinsics
768
+ //===---------------------------------------------------------------------===//
769
+ def ROCDL_V2I16Type : FixedVectorOfLengthAndType<[2], [I16]>,
770
+ BuildableType<"::mlir::VectorType::get("
771
+ "{2},$_builder.getI16Type())">;
772
+
773
+ def ROCDL_CvtScaleF32PkFp8F32:
774
+ ROCDL_IntrOp<"cvt.scalef32.pk.fp8.f32", [], [], [Pure], 1>,
775
+ Arguments<(ins ROCDL_V2I16Type:$old, F32:$srcA, F32:$srcB, F32:$scale, I1:$wordSel)> {
776
+ let summary = "Scale and convert two f32's to packed fp8";
777
+ let description = [{
778
+ Scale `srcA` and `srcB` by the exponent in `scale` then convert to packed fp8
779
+ and store into the low/high word of `old`, preserving the other word.
780
+ }];
781
+ let assemblyFormat = [{
782
+ attr-dict $srcA `,` $srcB `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
783
+ }];
784
+ }
785
+
786
+ def ROCDL_CvtScaleF32PkBf8F32:
787
+ ROCDL_IntrOp<"cvt.scalef32.pk.bf8.f32", [], [], [Pure], 1>,
788
+ Arguments<(ins ROCDL_V2I16Type:$old, F32:$srcA, F32:$srcB, F32: $scale, I1:$wordSel)> {
789
+ let summary = "Scale and convert two f32's to packed bf8";
790
+ let description = [{
791
+ Scale `srcA` and `srcB` by the exponent in `scale` then convert to packed bf8
792
+ and store into the low/high word of `old`, preserving the other word.
793
+ }];
794
+ let assemblyFormat = [{
795
+ attr-dict $srcA `,` $srcB `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
796
+ }];
797
+ }
798
+
799
+ def ROCDL_CvtScaleF32SrFp8F32:
800
+ ROCDL_IntrOp<"cvt.scalef32.sr.fp8.f32", [], [], [Pure], 1>,
801
+ Arguments<(ins I32:$old, F32:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
802
+ let summary = "Scale and convert f32 to fp8 using stochastic rounding";
803
+ let description = [{
804
+ Scale `src` by the exponent in `scale` then convert to fp8 with stochastic rounding
805
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
806
+ }];
807
+ let assemblyFormat = [{
808
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
809
+ }];
810
+ }
811
+
812
+
813
+ def ROCDL_CvtScaleF32SrBf8F32:
814
+ ROCDL_IntrOp<"cvt.scalef32.sr.bf8.f32", [], [], [Pure], 1>,
815
+ Arguments<(ins I32:$old, F32:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
816
+ let summary = "Scale and convert f32 to bf8 using stochastic rounding";
817
+ let description = [{
818
+ Scale `src` by the exponent in `scale` then convert to bf8 with stochastic rounding
819
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
820
+ }];
821
+ let assemblyFormat = [{
822
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
823
+ }];
824
+ }
825
+
739
826
//===---------------------------------------------------------------------===//
740
827
// 8-bit float intrinsics
741
828
//===---------------------------------------------------------------------===//
@@ -751,6 +838,20 @@ def ROCDL_CvtF32Bf8Op :
751
838
}];
752
839
}
753
840
841
+ def ROCDL_CvtScaleF32Bf8Op :
842
+ ROCDL_IntrOp<"cvt.scalef32.f32.bf8", [], [], [Pure], 1>,
843
+ Arguments<(ins I32:$src, F32: $scale, I32:$byteSel)> {
844
+ let summary = "Scale and convert bf8 to f32";
845
+ let description = [{
846
+ Scale `src` by the exponent in `scale` then convert 8-bit bf8 value
847
+ from the `byteSel`th bit of `src` to fp32.
848
+ }];
849
+ let assemblyFormat = [{
850
+ attr-dict $src `[` $byteSel `]` `,` $scale `:` type($res)
851
+ }];
852
+ }
853
+
854
+
754
855
def ROCDL_CvtF32Fp8Op :
755
856
ROCDL_IntrOp<"cvt.f32.fp8", [], [], [Pure], 1>,
756
857
Arguments<(ins I32:$srcA, I32:$byteSel)> {
@@ -763,6 +864,22 @@ def ROCDL_CvtF32Fp8Op :
763
864
}];
764
865
}
765
866
867
+
868
+ def ROCDL_CvtScaleF32Fp8Op :
869
+ ROCDL_IntrOp<"cvt.scalef32.f32.fp8", [], [], [Pure], 1>,
870
+ Arguments<(ins I32:$src, F32: $scale, I32:$byteSel)> {
871
+ let summary = "Scale and convert fp8 to f32";
872
+ let description = [{
873
+ Scale `src` by the exponent in `scale` then convert 8-bit fp8 value
874
+ from the `byteSel`th bit of `src` to fp32.
875
+
876
+ }];
877
+ let assemblyFormat = [{
878
+ attr-dict $src `[` $byteSel `]` `,` $scale `:` type($res)
879
+ }];
880
+ }
881
+
882
+
766
883
def ROCDL_CvtPkBf8F32Op :
767
884
ROCDL_IntrOp<"cvt.pk.bf8.f32", [], [], [Pure], 1>,
768
885
Arguments<(ins F32:$srcA, F32:$srcB, I32:$old, I1:$wordSel)> {
0 commit comments