Skip to content

Commit dd41cf6

Browse files
authored
[Torch] Add aten._scaled_mm_v2 op support and FX import plumbing (#4587)
Adds Torch dialect support and FX importer plumbing for MXFP4 aten._scaled_mm_v2.
1 parent 626f533 commit dd41cf6

9 files changed

Lines changed: 1994 additions & 0 deletions

File tree

include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6654,6 +6654,41 @@ def Torch_Aten_ScaledMmOp : Torch_Op<"aten._scaled_mm", [
66546654
let hasVerifier = 1;
66556655
}
66566656

6657+
def Torch_Aten_ScaledMmV2Op : Torch_Op<"aten._scaled_mm_v2", [
6658+
AllowsTypeRefinement,
6659+
HasValueSemantics,
6660+
ReadOnly
6661+
]> {
6662+
let summary = "Generated op for `aten::_scaled_mm_v2 : (Tensor, Tensor, Tensor[], int[], int[], Tensor[], int[], int[], Tensor?, int?, int[], bool) -> (Tensor)`";
6663+
let arguments = (ins
6664+
AnyTorchTensorType:$self,
6665+
AnyTorchTensorType:$mat2,
6666+
AnyTorchListOfTensorType:$scale_a,
6667+
AnyTorchListOfTorchIntType:$recipe_a,
6668+
AnyTorchListOfTorchIntType:$swizzle_a,
6669+
AnyTorchListOfTensorType:$scale_b,
6670+
AnyTorchListOfTorchIntType:$recipe_b,
6671+
AnyTorchListOfTorchIntType:$swizzle_b,
6672+
AnyTorchOptionalTensorType:$bias,
6673+
AnyTorchOptionalIntType:$out_dtype,
6674+
AnyTorchListOfTorchIntType:$contraction_dim,
6675+
Torch_BoolType:$use_fast_accum
6676+
);
6677+
let results = (outs
6678+
AnyTorchOptionalTensorType:$result
6679+
);
6680+
let hasCustomAssemblyFormat = 1;
6681+
let extraClassDefinition = [{
6682+
ParseResult Aten_ScaledMmV2Op::parse(OpAsmParser &parser, OperationState &result) {
6683+
return parseDefaultTorchOp(parser, result, 12, 1);
6684+
}
6685+
void Aten_ScaledMmV2Op::print(OpAsmPrinter &printer) {
6686+
printDefaultTorchOp(printer, *this, 12, 1);
6687+
}
6688+
}];
6689+
let hasVerifier = 1;
6690+
}
6691+
66576692
def Torch_Aten_IntMmOp : Torch_Op<"aten._int_mm", [
66586693
AllowsTypeRefinement,
66596694
HasValueSemantics,

0 commit comments

Comments
 (0)