Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline

[mlir][tosa] Create a profile validation pass for TOSA dialect

Authored by tatwaichong on Nov 2 2022, 11:46 AM.



Add a separate validation pass to check if TOSA operations match with
the specification against given requirement. Perform profile type
checking as the initial feature in the pass.

This is an optional pass that can be enabled via command line. e.g.
$mlir-opt --tosa-validate="profile=bi" for validating against the
base inference profile.

TOSA defines a variety of operator behavior and requirements in the
specification. It would be helpful to have a separate validation pass
to keep TOSA operation input match with TOSA specification for given
criteria, and also diminish the burden of dialect validation during

TOSA supports three profiles of which two are for inference purposes.
The main inference profile supports both integer and floating-point
data types, but the base inference profile only supports integers.
In this initial PR, validate the operations against a given profile
of TOSA, so that validation would fail if a floating point tensor is
present when the base inference profile is selected. Afterward, others
checking will be added to the pass if needed. e.g. control flow
operators and custom operators validation.

The pass is expected to be able to run on any point of TOSA dialect
conversion/transformation pipeline, and not depend on a particular
pass run ahead. So that it is can be used to validate the initial tosa
operations just converted from other dialects, the intermediate form,
or the final tosa operations output.

Change-Id: Ib58349c873c783056e89d2ab3b3312b8d2c61863

Diff Detail

Event Timeline

tatwaichong created this revision.Nov 2 2022, 11:46 AM
tatwaichong requested review of this revision.Nov 2 2022, 11:46 AM
rsuderman added inline comments.Nov 2 2022, 5:19 PM

You should be able to define the enum in tablegen for the pass.

Define the enum in tablegen for the pass, and use a walk on the operation instead.

tatwaichong marked an inline comment as done.Nov 8 2022, 10:55 PM

Thanks. Good to know the enum can be defined in Tblgen. Also change to use walk function as suggested.

fix compilation error.

fix: include header in the wrong place.

fix clang format error

rsuderman added inline comments.Nov 14 2022, 12:32 PM
56 ↗(On Diff #474855)

Why is this included in TosaToSCF? This seems independent of the SCF pass.

tatwaichong added inline comments.Nov 14 2022, 3:10 PM
56 ↗(On Diff #474855)

This question has been asked internally. My thought was to land this pass on the passes named with "Tosa" as use cases. Let's remove this pass from the SCF pass as these dialects aren't relevant.

Remove this pass from the SCF pass as these dialects is independent of each other.

rsuderman accepted this revision.Nov 14 2022, 5:29 PM
This revision is now accepted and ready to land.Nov 14 2022, 5:29 PM
This revision was landed with ongoing or failed builds.Nov 14 2022, 5:43 PM
This revision was automatically updated to reflect the committed changes.