Skip to content

Commit d7c948d

Browse files
committed
address comments & close submesh properly
1 parent fe091fd commit d7c948d

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

pjrt_implementation/inc/api/client_instance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class ModuleBuilder;
4747
class GlobalClientInstanceSingleton {
4848
public:
4949
static ClientInstance *getClientInstance();
50-
static PJRT_Error *init_client();
51-
static void destroy_client();
50+
static PJRT_Error *initClient();
51+
static void destroyClient();
5252

5353
private:
5454
GlobalClientInstanceSingleton(std::unique_ptr<ClientInstance> client_instance)

pjrt_implementation/src/api/client_instance.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
namespace tt::pjrt {
3939

40-
PJRT_Error *GlobalClientInstanceSingleton::init_client() {
40+
PJRT_Error *GlobalClientInstanceSingleton::initClient() {
4141
std::unique_ptr<ClientInstance> client = std::make_unique<ClientInstance>();
4242
PJRT_Error *error = client->initialize();
4343
if (error) {
@@ -50,7 +50,7 @@ PJRT_Error *GlobalClientInstanceSingleton::init_client() {
5050
return nullptr;
5151
}
5252

53-
void GlobalClientInstanceSingleton::destroy_client() {
53+
void GlobalClientInstanceSingleton::destroyClient() {
5454
GlobalClientInstanceSingleton &singleton_instance = getInstance();
5555
if (singleton_instance.is_initialized()) {
5656
singleton_instance.m_client_instance.reset();
@@ -89,9 +89,7 @@ ClientInstance::ClientInstance()
8989
ClientInstance::~ClientInstance() {
9090
DLOG_F(LOG_DEBUG, "ClientInstance::~ClientInstance");
9191

92-
if (m_optimizer_submesh.has_value()) {
93-
tt::runtime::releaseSubMeshDevice(*m_optimizer_submesh);
94-
}
92+
closeOptimizerSubmesh();
9593

9694
if (m_parent_mesh.has_value()) {
9795
tt::runtime::closeMeshDevice(*m_parent_mesh);
@@ -525,7 +523,7 @@ PJRT_Error *onClientCreate(PJRT_Client_Create_Args *args) {
525523
args->create_options[i].name);
526524
}
527525

528-
PJRT_Error *error = GlobalClientInstanceSingleton::init_client();
526+
PJRT_Error *error = GlobalClientInstanceSingleton::initClient();
529527

530528
if (error) {
531529
DLOG_F(ERROR, "Failed to initialize PJRT client instance");
@@ -547,7 +545,7 @@ PJRT_Error *onClientDestroy(PJRT_Client_Destroy_Args *args) {
547545
ClientInstance *global_client_instance =
548546
GlobalClientInstanceSingleton::getClientInstance();
549547
assert(client_instance == global_client_instance);
550-
GlobalClientInstanceSingleton::destroy_client();
548+
GlobalClientInstanceSingleton::destroyClient();
551549
return nullptr;
552550
}
553551

pjrt_implementation/src/api/module_builder/module_builder.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,13 @@ tt_pjrt_status ModuleBuilder::convertFromTTIRToTTNN(
860860

861861
enableVerboseIRPrinting(ttir_to_ttnn_pm);
862862

863+
// Run the pass manager.
864+
mlir::LogicalResult mlir_result = ttir_to_ttnn_pm.run(mlir_module.get());
865+
863866
// Close the optimizer submesh now that the compilation is complete.
864867
client_instance->closeOptimizerSubmesh();
865868

866-
// Run the pass manager.
867-
if (mlir::failed(ttir_to_ttnn_pm.run(mlir_module.get()))) {
869+
if (mlir::failed(mlir_result)) {
868870
DLOG_F(ERROR, "Failed to convert from TTIR to TTNN module");
869871
return tt_pjrt_status::kInternal;
870872
}

0 commit comments

Comments
 (0)