pytorch/torch/_dynamo
Pian Pawakapan a75248528f [export] refactor _process_dynamic_shapes (#133391)
Sorryyyyy for another refactor. This splits `_process_dynamic_shapes` into 3 parts:
1. `_combine_args` - mostly the same thing
2. `_check_dynamic_shapes`, which is responsible for raising 99% of UserErrors if the dynamic shapes spec is invalid (minus 1 UserError with DerivedDims)
3.  `_process_dynamic_shapes`, which for now, is the same thing, minus the stuff in 2.

This refactor is helpful for incoming automatic dynamic shapes work, because, we're switching to `assume_static_by_default=False`, which is what `_dynamo.export` currently does. This means any unspecified dims are allocated a symbol, in contrast to export today which keeps unspecified dims static. Historically this has been desirable - export users don't want too much dynamism. So we want to change how the spec is translated into constraints.

This means when we switch over to automatic dynamic shapes, we want to plug in something in between steps 2. and 3. which patches up the spec for `assume_static_by_default=False`, filling in static shapes for any unspecified dims, and potentially clearing out the auto-dynamic dims (since they're no-ops). We would do this in-between 2. and 3. to keep `_process_dynamic_shapes` semantically the same, since it's used with `_dynamo.export`.

We could do this without a refactor, plugging in this transform before `_process_dynamic_shapes`, but since that function's responsible for both spec checking + constraint production, moving spec checking to before we transform the specs helps guarantee we're raising errors on what the user's specified, and not an internal export bug.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/133391
Approved by: https://github.com/avikchaudhuri
2024-08-15 16:21:21 +00:00
..
backends Make debugging backends accept and ignore options kwargs from torch.compile (#132892) 2024-08-09 00:49:45 +00:00
repro [BE][Easy] enable ruff rule PIE790: unnecessary pass statement (#133200) 2024-08-15 15:50:19 +00:00
variables [BE][Easy] enable ruff rule PIE790: unnecessary pass statement (#133200) 2024-08-15 15:50:19 +00:00
__init__.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
_trace_wrapped_higher_order_op.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
bytecode_analysis.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
bytecode_transformation.py [3.13, dynamo] decompose fused load/store instructions (#130569) 2024-07-22 18:07:40 +00:00
cache_size.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
callback.py Flip default value for mypy disallow_untyped_defs [1/11] (#127838) 2024-06-08 18:16:33 +00:00
code_context.py Add None return type to init (#132335) 2024-08-01 15:26:45 +00:00
codegen.py Add basic mypy annotations to dynamo (#132415) 2024-08-04 18:43:36 +00:00
compiled_autograd.py [compiled autograd][cpp node] No recaptures from saved float scalars (#133048) 2024-08-10 11:05:44 +00:00
comptime.py Add comptime.sleep (#133362) 2024-08-14 19:32:18 +00:00
config.py [traced-graph][sparse] propagate sparsity in fx graph (#131920) 2024-08-05 15:49:53 +00:00
convert_frame.py Consolidate SymDispatchMode into ProxyTensorMode (#132674) 2024-08-08 12:02:54 +00:00
create_parameter_op.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
current_scope_id.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
debug_utils.py [BE][Easy] enable ruff rule PIE790: unnecessary pass statement (#133200) 2024-08-15 15:50:19 +00:00
decorators.py [BE][Easy] enable ruff rule PIE790: unnecessary pass statement (#133200) 2024-08-15 15:50:19 +00:00
device_interface.py Add basic mypy annotations to dynamo (#132415) 2024-08-04 18:43:36 +00:00
distributed.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
eval_frame.py [export] refactor _process_dynamic_shapes (#133391) 2024-08-15 16:21:21 +00:00
exc.py [dynamo][user_defined][stable-diffusion] Raise ObservedAttributeError on UserDefinedObject var_getattr (#132806) 2024-08-07 18:19:49 +00:00
external_utils.py Revert "Deprecate torch._utils.is_compiling() and torch._dynamo.external_utils.is_compiling() (#127690)" 2024-08-07 00:05:20 +00:00
funcname_cache.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
guards.py Populate submodules of torch._C to sys.modules recursively (#132216) 2024-08-08 10:20:25 +00:00
hooks.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
logging.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
mutation_guard.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
output_graph.py Only thunkify proxies in some situations (#132421) 2024-08-08 12:03:06 +00:00
polyfill.py [dynamo] revert map/zip iterator related changes (#132528) 2024-08-04 18:46:55 +00:00
profiler.py Add basic mypy annotations to dynamo (#132415) 2024-08-04 18:43:36 +00:00
replay_record.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
resume_execution.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
side_effects.py Improve side effects error message (#132223) 2024-07-31 17:29:26 +00:00
source.py [dynamo] Reland 132308, 132314, 132318, 132334 - Make builtin nn modules attributes static (#132539) 2024-08-03 02:08:22 +00:00
symbolic_convert.py Add missing endline in exception message (#133240) 2024-08-14 00:11:39 +00:00
tensor_version_op.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
test_case.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
test_minifier_common.py Flip default value for mypy disallow_untyped_defs [1/11] (#127838) 2024-06-08 18:16:33 +00:00
testing.py [BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ (#129767) 2024-07-31 21:18:11 +00:00
trace_rules.py [hop] makes compiled hops not share code objects (#132427) 2024-08-05 22:59:05 +00:00
types.py Populate submodules of torch._C to sys.modules recursively (#132216) 2024-08-08 10:20:25 +00:00
utils.py [Dynamo] Make torch.Size can be reconstructed by LOAD_CONST (#133342) 2024-08-13 23:18:38 +00:00