This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] Add TOSA f64 type support for cast op
ClosedPublic

Authored by AmosLewis on Jan 25 2023, 9:03 PM.

Diff Detail

Event Timeline

AmosLewis created this revision.Jan 25 2023, 9:03 PM
AmosLewis requested review of this revision.Jan 25 2023, 9:03 PM
AmosLewis retitled this revision from [mlir][TOSA] Add TOSA f64 type support to [mlir][tosa] Add TOSA f64 type support.Jan 25 2023, 9:14 PM
AmosLewis added reviewers: NatashaKnk, rsuderman.

The TOSA specification doesn't support F64, so I think we should be careful in how we expand the data types in the dialect. Adding it has implications for TOSA consumers.

At a minimum, code should be added to the tosa-validate pass that warns backends that attempt to align with the TOSA specification that non-compliant data types are present. The pass exists, it should be simple to report errors if FP64 operands are detected for any profile, as fp64 doesn't exist in a profile.

I'd also recommend that we proceed more incrementally with fp64. Rather than changing Tosa_Float, which changes almost all of the operators, create a new type, which is Tosa_Float + fp64, and use that only where needed. So if we only need fp64 for the CAST operator, the new type only gets used there. This would allow consumers of TOSA dialect to understand where f64 is needed, and would help reason about how fp64 would get added to the specification.

If any consumers of TOSA dialect have thoughts on F64 support, whether they want to avoid it, or are already capable of consuming it, it would be good to hear, even outside of this specific review.

AmosLewis updated this revision to Diff 494431.Feb 2 2023, 2:32 PM

[mlir][tosa] Add TOSA f64 type support for cast op

AmosLewis retitled this revision from [mlir][tosa] Add TOSA f64 type support to [mlir][tosa] Add TOSA f64 type support for cast op.
AmosLewis edited the summary of this revision. (Show Details)

Can you add a simple check to TosaValidation::runOnOperation that goes into the existing for loop and checks for float64 type, and does a signalPassFailure there? You don't need to check profileType, as f64 isn't in the spec. This pass is for implementations to use to check against the spec, so dialect specific changes that aren't in the spec should be flagged when it is run.

AmosLewis updated this revision to Diff 494489.Feb 2 2023, 6:36 PM

Add TosaValidation float64 type check and signalPassFailure

Can you add a simple check to TosaValidation::runOnOperation that goes into the existing for loop and checks for float64 type, and does a signalPassFailure there? You don't need to check profileType, as f64 isn't in the spec. This pass is for implementations to use to check against the spec, so dialect specific changes that aren't in the spec should be flagged when it is run.

I am not familiar with this part of the code, could you check if adding is correct? Or any way to check if I am adding it correctly?

if (getElementTypeOrSelf(operand).isF64()) {
  return signalPassFailure();
}
eric-k256 accepted this revision.Feb 2 2023, 10:33 PM

Thanks. Looks good to me now.

This revision is now accepted and ready to land.Feb 2 2023, 10:33 PM

Thanks. Looks good to me now.

How long will it take for this patch to land?

I don't have commit privileges. @rsuderman or @NatashaKnk, can you take a look?

I'll help in a bit

This revision was automatically updated to reflect the committed changes.