metaopt / optree

OpTree: Optimized PyTree Utilities
https://optree.readthedocs.io
Apache License 2.0
136 stars 6 forks source link

[Feature Request] Add API to unregister types in the pytree node type registry #119

Closed XuehaiPan closed 5 months ago

XuehaiPan commented 8 months ago

Required prerequisites

Motivation

There are many use cases in which users only want to register the pytree node type for temporary use. They want to remove the type registration when they exit a context. The object of the corresponding type should become leaf type again.

For example:

https://github.com/pytorch/pytorch/blob/fb91acd33b5ae8c036a1c2373f1dfe6417ebe7a8/torch/onnx/_internal/fx/dynamo_graph_extractor.py#L32-L111

Solution

No response

Alternatives

No response

Additional context

No response