Skip to content

Commit

Permalink
Add chlo dialect to auto input conversion pipeline (iree-org#15474)
Browse files Browse the repository at this point in the history
`chlo` operations should be checked for with the `stablehlo` part of the
auto input conversion pipeline.
  • Loading branch information
rsuderman authored Nov 7, 2023
1 parent 82dc975 commit 2fda954
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ static void populateHloFeatures(Operation *op, InputFeatures &features) {
}
}

static void populateFeatures(Operation *op, const Dialect *stablehloDialect,
static void populateFeatures(Operation *op, const Dialect *chloDialect,
const Dialect *stablehloDialect,
const Dialect *tosaDialect,
InputFeatures &features) {
Dialect *d = op->getDialect();
if (d == stablehloDialect) {
if (d == stablehloDialect || d == chloDialect) {
features.hasStableHLO = true;
return populateHloFeatures(op, features);
}
Expand All @@ -101,14 +102,15 @@ void AutoInputConversionPipelinePass::runOnOperation() {
MLIRContext *ctxt = &getContext();

InputFeatures features;
const Dialect *chloDialect = ctxt->getLoadedDialect("chlo");
const Dialect *stablehloDialect = ctxt->getLoadedDialect("stablehlo");
const Dialect *tosaDialect = ctxt->getLoadedDialect("tosa");
if (!stablehloDialect && !tosaDialect) {
if (!chloDialect && !stablehloDialect && !tosaDialect) {
return;
}

auto res = module.walk([&](Operation *op) {
populateFeatures(op, stablehloDialect, tosaDialect, features);
populateFeatures(op, chloDialect, stablehloDialect, tosaDialect, features);
if (features.hasStableHLO && features.hasTOSA) {
module.emitError("not yet implemented mixture of *HLO and TOSA");
return WalkResult::interrupt();
Expand Down

0 comments on commit 2fda954

Please sign in to comment.