@@ -652,6 +652,18 @@ def ROCDL_DPPUpdateOp : ROCDL_IntrOp<"update.dpp", [], [0],
652652 }];
653653}
654654
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+
655667//===---------------------------------------------------------------------===//
656668// 16-bit float intrinsics
657669//===---------------------------------------------------------------------===//
@@ -667,6 +679,164 @@ def ROCDL_CvtPkRtz:
667679 }];
668680}
669681
682+ def ROCDL_CvtScalePkFp8F16 :
683+ ROCDL_IntrOp<"cvt.scalef32.pk.fp8.f16", [], [], [Pure], 1>,
684+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2F16Type: $src, F32: $scale, I1:$wordSel)> {
685+ let summary = "Scale and convert f16 to packed fp8";
686+ let description = [{
687+ Scale `src` by the exponent in `scale` then convert to packed fp8.
688+ Store the result in low/high word based on $wordSel, preserving the other word.
689+ }];
690+ let assemblyFormat = [{
691+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
692+ }];
693+ }
694+
695+ def ROCDL_CvtScalePkFp8Bf16 :
696+ ROCDL_IntrOp<"cvt.scalef32.pk.fp8.bf16", [], [], [Pure], 1>,
697+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2BF16Type: $src, F32: $scale, I1:$wordSel)> {
698+ let summary = "Scale and convert packed bf16 to packed fp8";
699+ let description = [{
700+ Scale `src` by the exponent in `scale` then convert to packed fp8.
701+ Store the result in low/high word based on $wordSel, preserving the other word.
702+ }];
703+ let assemblyFormat = [{
704+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
705+ }];
706+ }
707+
708+
709+ def ROCDL_CvtScalePkBf8F16 :
710+ ROCDL_IntrOp<"cvt.scalef32.pk.bf8.f16", [], [], [Pure], 1>,
711+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2F16Type: $src, F32: $scale, I1:$wordSel)> {
712+ let summary = "Scale and convert f16 to packed bf8";
713+ let description = [{
714+ Scale `src` by the exponent in `scale` then convert to packed bf8.
715+ Store the result in low/high word based on $wordSel, preserving the other word.
716+ }];
717+ let assemblyFormat = [{
718+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
719+ }];
720+ }
721+
722+
723+ def ROCDL_CvtScalePkBf8Bf16 :
724+ ROCDL_IntrOp<"cvt.scalef32.pk.bf8.bf16", [], [], [Pure], 1>,
725+ Arguments<(ins ROCDL_V2I16Type: $old, ROCDL_V2BF16Type: $src, F32: $scale, I1:$wordSel)> {
726+ let summary = "Scale and convert bf16 to packed bf8";
727+ let description = [{
728+ Scale `src` by the exponent in `scale` then convert to packed bf8.
729+ Store the result in low/high word based on $wordSel, preserving the other word.
730+ }];
731+ let assemblyFormat = [{
732+ attr-dict $src `,` $scale `->` $old `[` $wordSel `]` `:` type($res)
733+ }];
734+ }
735+
736+ def ROCDL_CvtScaleSrFp8F16 :
737+ ROCDL_IntrOp<"cvt.scalef32.sr.fp8.f16", [], [], [Pure], 1>,
738+ Arguments<(ins I32:$old, F16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
739+ let summary = "Scale and convert f16 to packed fp8 using stochastic rounding";
740+ let description = [{
741+ Scale `src` by the exponent in `scale` then convert to packed p8 with stochastic rounding
742+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
743+
744+ }];
745+ let assemblyFormat = [{
746+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
747+ }];
748+ }
749+
750+ def ROCDL_CvtScaleSrBf8F16 :
751+ ROCDL_IntrOp<"cvt.scalef32.sr.bf8.f16", [], [], [Pure], 1>,
752+ Arguments<(ins I32:$old, F16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
753+ let summary = "Scale and convert f16 to packed bf8 using stochastic rounding";
754+ let description = [{
755+ Scale `src` by the exponent in `scale` then convert to packed bf8 with stochastic rounding
756+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
757+
758+ }];
759+ let assemblyFormat = [{
760+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
761+ }];
762+ }
763+
764+ def ROCDL_CvtScaleSrFp8Bf16 :
765+ ROCDL_IntrOp<"cvt.scalef32.sr.fp8.bf16", [], [], [Pure], 1>,
766+ Arguments<(ins I32:$old, BF16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
767+ let summary = "Scale and convert packed bf16 to packed fp8 using stochastic rounding";
768+ let description = [{
769+ Scale `src` by the exponent in `scale` then convert to packed fp8 with stochastic rounding
770+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
771+
772+ }];
773+ let assemblyFormat = [{
774+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
775+ }];
776+ }
777+
778+ def ROCDL_CvtScaleSrBf8Bf16:
779+ ROCDL_IntrOp<"cvt.scalef32.sr.bf8.bf16", [], [], [Pure], 1>,
780+ Arguments<(ins I32:$old, BF16:$src, I32:$seed, F32: $scale, I32:$byteSel)> {
781+ let summary = "Scale and convert bf16 to packed fp8 using stochastic rounding";
782+ let description = [{
783+ Scale `src` by the exponent in `scale` then convert to packed p8 with stochastic rounding
784+ using seed data in `seed`. store into the `byteSel`th byte of `old`, preserving the others.
785+
786+ }];
787+ let assemblyFormat = [{
788+ attr-dict $src `,` $seed `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
789+ }];
790+ }
791+
792+ def ROCDL_CvtScalePkF16Fp8 :
793+ ROCDL_IntrOp<"cvt.scalef32.pk.f16.fp8", [], [], [Pure], 1>,
794+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
795+ let summary = "Scale and convert fp8 to packed f16";
796+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
797+ then convert to packed f16.
798+ }];
799+ let assemblyFormat = [{
800+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
801+ }];
802+ }
803+
804+ def ROCDL_CvtScalePkF16Bf8 :
805+ ROCDL_IntrOp<"cvt.scalef32.pk.f16.bf8", [], [], [Pure], 1>,
806+ Arguments<(ins I32:$src, F32: $scale, I1:$wordSel)> {
807+ let summary = "Scale and convert bf8 to packed f16";
808+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
809+ then convert to packed f16.
810+ }];
811+ let assemblyFormat = [{
812+ attr-dict $src `[` $wordSel `]` `,` $scale `:` type($res)
813+ }];
814+ }
815+
816+ def ROCDL_CvtScaleF16Fp8 :
817+ ROCDL_IntrOp<"cvt.scalef32.f16.fp8", [], [], [Pure], 1>,
818+ Arguments<(ins ROCDL_V2F16Type:$old, I32:$src, F32: $scale, I32:$byteSel, I1:$wordSel)> {
819+ let summary = "Scale and convert fp8 to f16";
820+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
821+ then convert to f16 store into the `byteSel`th byte of `old`, preserving the others.
822+ }];
823+ let assemblyFormat = [{
824+ attr-dict $src `[` $wordSel `]` `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
825+ }];
826+ }
827+
828+ def ROCDL_CvtScaleF16Bf8 :
829+ ROCDL_IntrOp<"cvt.scalef32.f16.bf8", [], [], [Pure], 1>,
830+ Arguments<(ins ROCDL_V2F16Type:$old, I32:$src, F32: $scale, I32:$byteSel, I1:$wordSel)> {
831+ let summary = "Scale and convert fp8 to f16";
832+ let description = [{ Scale `src` based on $wordSel by the exponent in `scale`
833+ then convert to f16 store into the `byteSel`th byte of `old`, preserving the others.
834+ }];
835+ let assemblyFormat = [{
836+ attr-dict $src `[` $wordSel `]` `,` $scale `->` $old `[` $byteSel `]` `:` type($res)
837+ }];
838+ }
839+
670840//===---------------------------------------------------------------------===//
671841// 32-bit float intrinsics
672842//===---------------------------------------------------------------------===//
@@ -697,10 +867,6 @@ def ROCDL_CvtScalePkF32Bf8 :
697867//===---------------------------------------------------------------------===//
698868// 8-bit float scale intrinsics
699869//===---------------------------------------------------------------------===//
700- def ROCDL_V2I16Type : FixedVectorOfLengthAndType<[2], [I16]>,
701- BuildableType<"::mlir::VectorType::get("
702- "{2},$_builder.getI16Type())">;
703-
704870def ROCDL_CvtScaleF32PkFp8F32:
705871 ROCDL_IntrOp<"cvt.scalef32.pk.fp8.f32", [], [], [Pure], 1>,
706872 Arguments<(ins ROCDL_V2I16Type:$old, F32:$srcA, F32:$srcB, F32:$scale, I1:$wordSel)> {
0 commit comments