[JIT] Fix compilation unit reference link in constant object upon load (#65784)

Summary:
Follow up to https://github.com/pytorch/pytorch/pull/65442, make sure objects inserted into the graph from load do not holding owning reference.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/65784

Reviewed By: suo

Differential Revision: D31251033

Pulled By: eellison

fbshipit-source-id: 59efe19ce6f70744383de4eebf0f89f79f3eb03a
This commit is contained in:
Elias Ellison
2021-09-30 09:31:02 -07:00
committed by Facebook GitHub Bot
parent 8130157504
commit 928a4bbafb
4 changed files with 61 additions and 5 deletions

View File

@ -525,6 +525,11 @@ void initJITBindings(PyObject* module) {
[](std::shared_ptr<Graph>& g) { return ConstantPropagation(g); },
py::arg("graph"))
.def("_jit_pass_erase_shape_information", EraseShapeInformation)
.def(
"_jit_object_is_non_holding",
[](Node& n) {
return toIValue(n.output())->toObject()->is_weak_compilation_ref();
})
.def(
"_jit_erase_non_input_shape_information",
[](std::shared_ptr<Graph>& g) {