@@ -652,6 +652,20 @@ def ROCDL_DPPUpdateOp : ROCDL_IntrOp<"update.dpp", [], [0],
652
652
}];
653
653
}
654
654
655
+ def ROCDL_V2I16Type : FixedVectorOfLengthAndType<[2], [I16]>,
656
+ BuildableType<"::mlir::VectorType::get("
657
+ "{2},$_builder.getI16Type())">;
658
+
659
+ def ROCDL_V2F16Type : FixedVectorOfLengthAndType<[2], [F16]>,
660
+ BuildableType<"::mlir::VectorType::get("
661
+ "{2},$_builder.getF16Type())">;
662
+
663
+ def ROCDL_V2BF16Type : FixedVectorOfLengthAndType<[2], [BF16]>,
664
+ BuildableType<"::mlir::VectorType::get("
665
+ "{2},$_builder.getBF16Type())">;
666
+
667
+ // TODO: The word and byte selectors are immarg in LLVM
668
+ // update to be attributes in MLIR
655
669
//===---------------------------------------------------------------------===//
656
670
// 16-bit float intrinsics
657
671
//===---------------------------------------------------------------------===//
@@ -667,10 +681,168 @@ def ROCDL_CvtPkRtz:
667
681
}];
668
682
}
669
683
684
+ def ROCDL_CvtScaleF32PkFp8F16 :
685
+ ROCDL_IntrOp<"cvt.scalef32.pk.fp8.f16", [], [], [Pure], 1>,
686
+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2F16Type: $src, F32: $scale, I1:$wordSel)> {
687
+ let summary = "Scale and convert f16 to packed fp8";
688
+ let description = [{
689
+ Scale `src` by the exponent in `scale` then convert to packed fp8.
690
+ Store the result in low/high word based on $wordSel, preserving the other word.
691
+ }];
692
+ let assemblyFormat = [{
693
+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
694
+ }];
695
+ }
696
+
697
+ def ROCDL_CvtScaleF32PkFp8Bf16 :
698
+ ROCDL_IntrOp<"cvt.scalef32.pk.fp8.bf16", [], [], [Pure], 1>,
699
+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2BF16Type: $src, F32: $scale, I1:$wordSel)> {
700
+ let summary = "Scale and convert packed bf16 to packed fp8";
701
+ let description = [{
702
+ Scale `src` by the exponent in `scale` then convert to packed fp8.
703
+ Store the result in low/high word based on $wordSel, preserving the other word.
704
+ }];
705
+ let assemblyFormat = [{
706
+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
707
+ }];
708
+ }
709
+
710
+
711
+ def ROCDL_CvtScaleF32PkBf8F16 :
712
+ ROCDL_IntrOp<"cvt.scalef32.pk.bf8.f16", [], [], [Pure], 1>,
713
+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2F16Type: $src, F32: $scale, I1:$wordSel)> {
714
+ let summary = "Scale and convert f16 to packed bf8";
715
+ let description = [{
716
+ Scale `src` by the exponent in `scale` then convert to packed bf8.
717
+ Store the result in low/high word based on $wordSel, preserving the other word.
718
+ }];
719
+ let assemblyFormat = [{
720
+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
721
+ }];
722
+ }
723
+
724
+
725
+ def ROCDL_CvtScaleF32PkBf8Bf16 :
726
+ ROCDL_IntrOp<"cvt.scalef32.pk.bf8.bf16", [], [], [Pure], 1>,
727
+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2BF16Type: $src, F32: $scale, I1:$wordSel)> {
728
+ let summary = "Scale and convert bf16 to packed bf8";
729
+ let description = [{
730
+ Scale `src` by the exponent in `scale` then convert to packed bf8.
731
+ Store the result in low/high word based on $wordSel, preserving the other word.
732
+ }];
733
+ let assemblyFormat = [{
734
+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
735
+ }];
736
+ }
737
+
738
+ def ROCDL_CvtScaleF32SrFp8F16 :
739
+ ROCDL_IntrOp<"cvt.scalef32.sr.fp8.f16", [], [], [Pure], 1>,
740
+ Arguments<(ins I32:$old, F16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
741
+ let summary = "Scale and convert f16 to packed fp8 using stochastic rounding";
742
+ let description = [{
743
+ Scale `src` by the exponent in `scale` then convert to packed p8 with stochastic rounding
744
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
745
+
746
+ }];
747
+ let assemblyFormat = [{
748
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
749
+ }];
750
+ }
751
+
752
+ def ROCDL_CvtScaleF32SrBf8F16 :
753
+ ROCDL_IntrOp<"cvt.scalef32.sr.bf8.f16", [], [], [Pure], 1>,
754
+ Arguments<(ins I32:$old, F16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
755
+ let summary = "Scale and convert f16 to packed bf8 using stochastic rounding";
756
+ let description = [{
757
+ Scale `src` by the exponent in `scale` then convert to packed bf8 with stochastic rounding
758
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
759
+
760
+ }];
761
+ let assemblyFormat = [{
762
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
763
+ }];
764
+ }
765
+
766
+ def ROCDL_CvtScaleF32SrFp8Bf16 :
767
+ ROCDL_IntrOp<"cvt.scalef32.sr.fp8.bf16", [], [], [Pure], 1>,
768
+ Arguments<(ins I32:$old, BF16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
769
+ let summary = "Scale and convert packed bf16 to packed fp8 using stochastic rounding";
770
+ let description = [{
771
+ Scale `src` by the exponent in `scale` then convert to packed fp8 with stochastic rounding
772
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
773
+
774
+ }];
775
+ let assemblyFormat = [{
776
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
777
+ }];
778
+ }
779
+
780
+ def ROCDL_CvtScaleF32SrBf8Bf16:
781
+ ROCDL_IntrOp<"cvt.scalef32.sr.bf8.bf16", [], [], [Pure], 1>,
782
+ Arguments<(ins I32:$old, BF16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
783
+ let summary = "Scale and convert bf16 to packed fp8 using stochastic rounding";
784
+ let description = [{
785
+ Scale `src` by the exponent in `scale` then convert to packed p8 with stochastic rounding
786
+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
787
+
788
+ }];
789
+ let assemblyFormat = [{
790
+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
791
+ }];
792
+ }
793
+
794
+ def ROCDL_CvtScaleF32PkF16Fp8 :
795
+ ROCDL_IntrOp<"cvt.scalef32.pk.f16.fp8", [], [], [Pure], 1>,
796
+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
797
+ let summary = "Scale and convert fp8 to packed f16";
798
+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
799
+ then convert to packed f16.
800
+ }];
801
+ let assemblyFormat = [{
802
+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
803
+ }];
804
+ }
805
+
806
+ def ROCDL_CvtScaleF32PkF16Bf8 :
807
+ ROCDL_IntrOp<"cvt.scalef32.pk.f16.bf8", [], [], [Pure], 1>,
808
+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
809
+ let summary = "Scale and convert bf8 to packed f16";
810
+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
811
+ then convert to packed f16.
812
+ }];
813
+ let assemblyFormat = [{
814
+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
815
+ }];
816
+ }
817
+
818
+ def ROCDL_CvtScaleF16Fp8 :
819
+ ROCDL_IntrOp<"cvt.scalef32.f16.fp8", [], [], [Pure], 1>,
820
+ Arguments<(ins ROCDL_V2F16Type:$old, I32:$src, F32: $scale, I32:$byteSel, I1:$wordSel)> {
821
+ let summary = "Scale and convert fp8 to f16";
822
+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
823
+ then convert to f16 store into the `byteSel`th byte of `old`, preserving the others.
824
+ }];
825
+ let assemblyFormat = [{
826
+ attr-dict $src `[` $wordSel `]` `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
827
+ }];
828
+ }
829
+
830
+ def ROCDL_CvtScaleF16Bf8 :
831
+ ROCDL_IntrOp<"cvt.scalef32.f16.bf8", [], [], [Pure], 1>,
832
+ Arguments<(ins ROCDL_V2F16Type:$old, I32:$src, F32: $scale, I32:$byteSel, I1:$wordSel)> {
833
+ let summary = "Scale and convert fp8 to f16";
834
+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
835
+ then convert to f16 store into the `byteSel`th byte of `old`, preserving the others.
836
+ }];
837
+ let assemblyFormat = [{
838
+ attr-dict $src `[` $wordSel `]` `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
839
+ }];
840
+ }
841
+
670
842
//===---------------------------------------------------------------------===//
671
843
// 32-bit float intrinsics
672
844
//===---------------------------------------------------------------------===//
673
- def ROCDL_CvtScalePkF32Fp8 :
845
+ def ROCDL_CvtScale32PkF32Fp8 :
674
846
ROCDL_IntrOp<"cvt.scalef32.pk.f32.fp8", [], [], [Pure], 1>,
675
847
Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
676
848
let summary = "Scale and convert packed fp8 to packed f32";
@@ -682,7 +854,7 @@ def ROCDL_CvtScalePkF32Fp8 :
682
854
attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
683
855
}];
684
856
}
685
- def ROCDL_CvtScalePkF32Bf8 :
857
+ def ROCDL_CvtScale32PkF32Bf8 :
686
858
ROCDL_IntrOp<"cvt.scalef32.pk.f32.bf8", [], [], [Pure], 1>,
687
859
Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
688
860
let summary = "Scale and convert packed bf8 to packed f32";
@@ -697,10 +869,6 @@ def ROCDL_CvtScalePkF32Bf8 :
697
869
//===---------------------------------------------------------------------===//
698
870
// 8-bit float scale intrinsics
699
871
//===---------------------------------------------------------------------===//
700
- def ROCDL_V2I16Type : FixedVectorOfLengthAndType<[2], [I16]>,
701
- BuildableType<"::mlir::VectorType::get("
702
- "{2},$_builder.getI16Type())">;
703
-
704
872
def ROCDL_CvtScaleF32PkFp8F32:
705
873
ROCDL_IntrOp<"cvt.scalef32.pk.fp8.f32", [], [], [Pure], 1>,
706
874
Arguments<(ins ROCDL_V2I16Type:$old, F32:$srcA, F32:$srcB, F32:$scale, I1:$wordSel)> {
0 commit comments