Skip to content

Conversation

@amd-eochoalo
Copy link
Contributor

@amd-eochoalo amd-eochoalo commented Nov 14, 2025

Depends on #167369

Copy link
Contributor

@krzysz00 krzysz00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a few nits

if (is_fp8 && firstScaleLane == 1 && firstScaleByte == 2 && is_block_16) {
return 0b1101;
}
if (is_fp8 && firstScaleLane == 1 && firstScaleByte == 3 && !is_block_16) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to make this a bit less of an exhaustive enumeration of the cases?

ScaledExtPacked816Op op, ScaledExtPacked816OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {

int firstScaleLane = op.getFirstScaleLane();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is int the right type here? Probably int64_t for index and int32_t otherwise.

} else if (isa<Float6E3M2FNType>(srcElemType) && destElemType.isF16()) {
rewriter.replaceOpWithNewOp<ROCDL::CvtPkScalePk16F16Bf6Op>(
op, op.getResult().getType(), castedSource, castedScale, scaleSel);
} else if (isa<Float6E2M3FNType>(srcElemType) && destElemType.isBF16()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could pull a page out of the MFMA book and have a general create that is relying on an OperationName, so that we don't have to repeat the ::create part N different times.

Comment on lines +1618 to +1621
// When lowering amdgpu.scaled_ext_packed816 to
// rocdl.cvt.scale.pk*.f*.f* operations, the
// attributes blockSize, sourceType, firstScaleLane and firstScaleByte
// are merged into a single attribute scaleSel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reflow this comment


llvm_unreachable("invalid combination of firstScaleLane, firstScaleByte, "
"blockSize and type.");
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No return after unreachable

Comment on lines +1690 to +1692
ConversionPatternRewriter &rewriter) const {

int firstScaleLane = op.getFirstScaleLane();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ConversionPatternRewriter &rewriter) const {
int firstScaleLane = op.getFirstScaleLane();
ConversionPatternRewriter &rewriter) const {
int firstScaleLane = op.getFirstScaleLane();

nit: superfluous empty line

Type packedType;
if (isa<Float4E2M1FNType>(srcElemType)) {
packedType = i32;
packedType = getTypeConverter()->convertType(packedType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the most general case, type conversion can fail -- are we checking this anywhere?

Value castedSource =
LLVM::BitcastOp::create(rewriter, loc, packedType, source);

if (isa<Float4E2M1FNType>(srcElemType) && destElemType.isF16()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can define type aliases for these, e.g.: using fp4 = Float4E2M1FNType to make the code more concise.

return failure();
}

return success();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reachable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants