Skip to content

Commit 01d8d85

Browse files
andyanwangpytorchmergebot
authored andcommitted
[MTIAGraph][Pytorch][2.1/n] Add API to destroy graph C++ instance (pytorch#166806)
I missed this API for MTIAGraph in D84457757(pytorch#165963) Differential Revision: [D86026706](https://our.internmc.facebook.com/intern/diff/D86026706/) Pull Request resolved: pytorch#166806 Approved by: https://github.com/albanD ghstack dependencies: pytorch#166805
1 parent b8855e7 commit 01d8d85

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

aten/src/ATen/detail/MTIAHooksInterface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ struct TORCH_API MTIAHooksInterface : AcceleratorHooksInterface {
156156
return -1;
157157
}
158158

159+
virtual void mtiagraphDestroy(int64_t handle) const {
160+
FAIL_MTIAHOOKS_FUNC(__func__);
161+
}
162+
159163
virtual void mtiagraphCaptureBegin(int64_t handle, MempoolId_t pool) const {
160164
FAIL_MTIAHOOKS_FUNC(__func__);
161165
}

torch/csrc/mtia/Module.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ struct _MTIAGraph {
1919

2020
_MTIAGraph(bool keep_graph = false)
2121
: handle_(at::detail::getMTIAHooks().mtiagraphCreate(keep_graph)) {}
22-
~_MTIAGraph() = default;
22+
23+
~_MTIAGraph() {
24+
at::detail::getMTIAHooks().mtiagraphDestroy(handle_);
25+
}
2326

2427
void capture_begin(at::MempoolId_t pool) {
2528
at::detail::getMTIAHooks().mtiagraphCaptureBegin(handle_, pool);

0 commit comments

Comments
 (0)