1
+ # https://github.com/pytorch/pytorch/issues/136642
2
+ import torch
3
+ import torch .nn as nn
4
+ import typing
5
+
6
+
7
+ class NetMRE (nn .Module ):
8
+ def forward (self , x : typing .List [torch .Tensor ]):
9
+ shapes : typing .List [typing .Tuple [int , int ]] = []
10
+ for xi in x :
11
+ shapes .append (xi .shape [2 :])
12
+
13
+ shapes = torch .as_tensor (shapes , dtype = torch .long )
14
+ return [
15
+ xx [
16
+ 0 ,
17
+ : (shapes [ix , 0 ] // 2 ) : (shapes [ix , 1 ] // 4 ),
18
+ : (shapes [ix , 1 ] // 2 ) : (shapes [ix , 1 ] // 4 ),
19
+ ]
20
+ for ix , xx in enumerate (x )
21
+ ]
22
+
23
+
24
+ x = [
25
+ torch .rand (1 , 3 , 64 , 64 ),
26
+ torch .rand (1 , 3 , 32 , 32 ),
27
+ ]
28
+
29
+ torch ._subclasses .fake_tensor .CONSTANT_NUMEL_LIMIT = 8
30
+ exported_program : torch .export .ExportedProgram = torch .export .export (NetMRE (), (x ,))
31
+ print (exported_program )
32
+
33
+ # Traceback (most recent call last):
34
+ # File "/home/dgcnz/development/amsterdam/edge/scripts/mre/pt2e_const_index.py", line 29, in <module>
35
+ # exported_program: torch.export.ExportedProgram = torch.export.export(NetMRE(), (x,))
36
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/__init__.py", line 366, in export
37
+ # return _export(
38
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 1014, in wrapper
39
+ # raise e
40
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 987, in wrapper
41
+ # ep = fn(*args, **kwargs)
42
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/exported_program.py", line 116, in wrapper
43
+ # return fn(*args, **kwargs)
44
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 1964, in _export
45
+ # export_artifact = export_func( # type: ignore[operator]
46
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 1235, in _strict_export
47
+ # return _strict_export_lower_to_aten_ir(
48
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 1263, in _strict_export_lower_to_aten_ir
49
+ # gm_torch_level = _export_to_torch_ir(
50
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/export/_trace.py", line 565, in _export_to_torch_ir
51
+ # gm_torch_level, _ = torch._dynamo.export(
52
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1462, in inner
53
+ # result_traced = opt_f(*args, **kwargs)
54
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
55
+ # return self._call_impl(*args, **kwargs)
56
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
57
+ # return forward_call(*args, **kwargs)
58
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 487, in _fn
59
+ # return fn(*args, **kwargs)
60
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
61
+ # return self._call_impl(*args, **kwargs)
62
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
63
+ # return forward_call(*args, **kwargs)
64
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1364, in __call__
65
+ # return self._torchdynamo_orig_callable(
66
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 544, in __call__
67
+ # return _compile(
68
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 964, in _compile
69
+ # guarded_code = compile_inner(code, one_graph, hooks, transform)
70
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 695, in compile_inner
71
+ # return _compile_inner(code, one_graph, hooks, transform)
72
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_utils_internal.py", line 87, in wrapper_function
73
+ # return function(*args, **kwargs)
74
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 728, in _compile_inner
75
+ # out_code = transform_code_object(code, transform)
76
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1337, in transform_code_object
77
+ # transformations(instructions, code_options)
78
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 229, in _fn
79
+ # return fn(*args, **kwargs)
80
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 657, in transform
81
+ # tracer.run()
82
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2888, in run
83
+ # super().run()
84
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1095, in run
85
+ # while self.step():
86
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1007, in step
87
+ # self.dispatch_table[inst.opcode](self, inst)
88
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 615, in wrapper
89
+ # return inner_fn(self, inst)
90
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1714, in CALL_FUNCTION
91
+ # self.call_function(fn, args, {})
92
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 942, in call_function
93
+ # self.push(fn.call_function(self, args, kwargs)) # type: ignore[arg-type]
94
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 111, in call_function
95
+ # return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
96
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 948, in inline_user_function_return
97
+ # return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
98
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3103, in inline_call
99
+ # return cls.inline_call_(parent, func, args, kwargs)
100
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 3231, in inline_call_
101
+ # tracer.run()
102
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1095, in run
103
+ # while self.step():
104
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1007, in step
105
+ # self.dispatch_table[inst.opcode](self, inst)
106
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1931, in BUILD_SLICE
107
+ # self.push(SliceVariable(items))
108
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/variables/lists.py", line 792, in __init__
109
+ # unimplemented("Dynamic slicing on data-dependent value is not supported")
110
+ # File "/home/dgcnz/.conda/envs/cu124/lib/python3.10/site-packages/torch/_dynamo/exc.py", line 304, in unimplemented
111
+ # raise Unsupported(msg, case_name=case_name)
112
+ # torch._dynamo.exc.Unsupported: Dynamic slicing on data-dependent value is not supported
113
+ #
114
+ # from user code:
115
+ # File "/home/dgcnz/development/amsterdam/edge/scripts/mre/pt2e_const_index.py", line 13, in forward
116
+ # return [
117
+ # File "/home/dgcnz/development/amsterdam/edge/scripts/mre/pt2e_const_index.py", line 16, in <listcomp>
118
+ # : (shapes[ix, 0] // 2) : (shapes[ix, 1] // 4),
119
+ #
120
+ # Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
0 commit comments