pytorch/torch/csrc/jit/python
David Berard b3cf36cb7c Implement deepcopy / clone for SymNode, NestedIntSymNode (#121361)
**Motivation**: There's a Meta-internal use case that deepcopies a bunch of metadata, which includes shapes. When we try to use NestedTensor with this tool, it errors out when we try to deepcopy the metadata, because SymNodes cannot be deepcopied. The change here is to add an implementation of `__deepcopy__`.

**Implementation**:
1. `__deepcopy__` on SymNode calls clone()
2. Implement `clone()` in NestedIntSymNode, which previously didn't have this implemented

**Potential Issues**:
Right now, this works.

But, regarding (2): Eventually we'll have some mapping between the NestedSymIntNode and its corresponding offsets/lengths tensor (cc @soulitzer who is working on this). How should this work with `__deepcopy__`? Should the offsets/lengths tensor also be cloned, or should the new symint reference the same offsets as the old symint?

On one hand, we already have this issue with NestedIntSymNodeImpl::mul(): mul() creates a new NestedIntSymNodeImpl. On the other hand, `__deepcopy__` might imply different semantics.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/121361
Approved by: https://github.com/soulitzer
2024-04-26 04:18:29 +00:00
..
init.cpp Implement deepcopy / clone for SymNode, NestedIntSymNode (#121361) 2024-04-26 04:18:29 +00:00
init.h
module_python.h
pybind_utils.cpp Add pending_fresh_unbacked_symbols, populate unbacked_bindings for Dynamo (#124290) 2024-04-24 09:11:34 +00:00
pybind_utils.h Support torchbind op dispatch in python (#123367) 2024-04-19 17:17:27 +00:00
pybind.h
python_arg_flatten.cpp
python_arg_flatten.h
python_custom_class.cpp
python_custom_class.h
python_dict.cpp
python_dict.h
python_interpreter.cpp
python_ir.cpp [2/N] Replace std::tie with structural binding (#119879) 2024-02-15 02:56:34 +00:00
python_ir.h
python_ivalue.h
python_list.cpp
python_list.h
python_sugared_value.cpp [2/N] Replace std::tie with structural binding (#119879) 2024-02-15 02:56:34 +00:00
python_sugared_value.h
python_tracer.cpp
python_tracer.h
python_tree_views.cpp [2/N] Replace std::tie with structural binding (#119879) 2024-02-15 02:56:34 +00:00
python_tree_views.h
script_init.cpp [2/N] Replace std::tie with structural binding (#119879) 2024-02-15 02:56:34 +00:00
script_init.h
update_graph_executor_opt.cpp
update_graph_executor_opt.h
utf8_decoding_ignore.cpp
utf8_decoding_ignore.h