Explicit control orders of related static (un)scoped variables

in torch:

  • dispatcher(libtorch)
  • python_registrations(libtorch_python)

manage registered kernel functions, like PythonKernelHolder, which contains SafePyObject that holds :

  • self_interpreter(libtorch_python)
  • noop_vtable(libtorch)

for python-aware lifetime management of PyObject. However, above 4 global/static scoped/unscoped variables will be destructed after the program exits with implicit orders, and:

  • libtorch_python links libtorch.
  • dispatcher and python_registrations depend self_interpreter/noop_vtable.

For now, implicit orders are normal after PR in DEBUG mode. Should we be explicit about their dependeies? like:

  • meyer’s singleton of get scoped static noop_vtable .
  • In dispatcher/python_registrations, explicit call get_noop_vtable ().

I would recommend creating an issue on GitHub to discuss it with the code owners directly.