File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,6 +70,15 @@ static auto TORCHTRT_UNUSED TRTEngineTSRegistrtion =
7070 .def(" __str__" , &TRTEngine::to_str)
7171 .def(" __repr__" , &TRTEngine::to_str)
7272 .def(" __obj_flatten__" , &TRTEngine::__obj_flatten__)
73+ // Reporting "real" below puts the engine itself into torch's fake tensor
74+ // dispatch cache key, and that cache compares keys with ==. Without this the
75+ // second lookup raises "'__eq__' is not implemented", which breaks any
76+ // re-export of a compiled module. Two handles to one engine are one engine.
77+ .def(
78+ " __eq__" ,
79+ [](const c10::intrusive_ptr<TRTEngine>& self, const c10::intrusive_ptr<TRTEngine>& other) -> bool {
80+ return self.get () == other.get ();
81+ })
7382 // Reporting "real" makes torch's tracing_with_real skip fakification and hand
7483 // the engine itself to the meta kernel, which reads only
7584 // get_serialized_metadata() -- nothing executes or mutates it. Otherwise each
You can’t perform that action at this time.
0 commit comments