Skip to content

Commit

Permalink
Enable temporary shardy roudtrip import pass
Browse files Browse the repository at this point in the history
  • Loading branch information
wooseokTT committed Feb 25, 2025
1 parent a8769d7 commit 07b387a
Show file tree
Hide file tree
Showing 4 changed files with 502 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_dependencies(TTPJRTCommonDylibPlatform loguru)
add_library(TTPJRTCommon
"platform.cc"
"module_builder.cc"
"shardy_roundtrip_pass.cc"
"plugin_attributes.cc"
"pjrt_implementation/api_bindings.cc"
"pjrt_implementation/buffer_instance.cc"
Expand Down
17 changes: 17 additions & 0 deletions src/common/module_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include "stablehlo/dialect/Version.h"
#include "stablehlo/transforms/Passes.h"

// shardy includes
#include "common/shardy_roundtrip_pass.h"
#include "shardy/dialect/sdy/ir/register.h"

// tt-mlir includes
#define TTMLIR_ENABLE_STABLEHLO
#include "tt/runtime/runtime.h"
Expand Down Expand Up @@ -56,6 +60,7 @@ ModuleBuilder::ModuleBuilder()

mlir::tt::registerAllDialects(registry);
mlir::stablehlo::registerAllDialects(registry);
mlir::sdy::registerAllDialects(registry);

mlir::func::registerAllExtensions(registry);
mlir::tt::registerAllExtensions(registry);
Expand Down Expand Up @@ -130,6 +135,18 @@ void ModuleBuilder::convertFromVHLOToSHLO(
return;
}

// This is a temporary solution for the "roundtrip" mlir from openXLA.
// Once openXLA natively supports Shardy, we can remvoe following import
// passes.
mlir::PassManager shardy_pm(mlir_module.get()->getName());
tt::pjrt::sdy::addSdyRoundTripImportPipeline(shardy_pm);

if (mlir::failed(shardy_pm.run(mlir_module.get()))) {
DLOG_F(ERROR, "Failed to convert from Shardy roundtrip import pass module");
m_status = tt_pjrt_status::kInternal;
return;
}

DLOG_F(LOG_DEBUG, "SHLO Module:");
printModule(mlir_module);
}
Expand Down
Loading

0 comments on commit 07b387a

Please sign in to comment.