Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -13
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/case.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/gen_example.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/logging.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/assume_constant_result.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/autograd_function.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/class_method.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_class_method.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nested_function.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nonlocal_variables.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_closed_over_variable.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_operands.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_predicate.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_size_example.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_value_example.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/decorator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dictionary.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_assert.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_constructor.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_if_guard.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_map.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_round.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_slicing.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_view.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/fn_with_kwargs.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_contains.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_unpack.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/model_attr_mutation.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/nested_function.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/null_context_manager.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/optional_input.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/pytree_flatten.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/scalar_output.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/specialized_attribute.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/static_for_loop.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/static_if.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/tensor_setattr.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/type_reflection_method.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/unsupported_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/user_input_mutation.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_if_guard.py +19 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_map.py +19 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_round.py +21 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_slicing.py +15 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_view.py +17 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/fn_with_kwargs.py +30 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/list_contains.py +17 -0
- tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/list_unpack.py +21 -0
.gitattributes
CHANGED
|
@@ -4458,16 +4458,4 @@ tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_cpu.so filter=
|
|
| 4458 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_cuda.so filter=lfs diff=lfs merge=lfs -text
|
| 4459 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_cuda_linalg.so filter=lfs diff=lfs merge=lfs -text
|
| 4460 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_python.so filter=lfs diff=lfs merge=lfs -text
|
| 4461 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/__pycache__/
|
| 4462 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/__pycache__/_meta_registrations.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4463 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/__pycache__/_tensor_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4464 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/__pycache__/_torch_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4465 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/__pycache__/overrides.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4466 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_decomp/__pycache__/decompositions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4467 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/symbolic_convert.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4468 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/utils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4469 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/guards.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4470 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/output_graph.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4471 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/trace_rules.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4472 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4473 |
-
tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/higher_order_ops.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 4458 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_cuda.so filter=lfs diff=lfs merge=lfs -text
|
| 4459 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_cuda_linalg.so filter=lfs diff=lfs merge=lfs -text
|
| 4460 |
tool_server/.venv/lib/python3.12/site-packages/torch/lib/libtorch_python.so filter=lfs diff=lfs merge=lfs -text
|
| 4461 |
+
tool_server/.venv/lib/python3.12/site-packages/torch/_export/serde/__pycache__/serialize.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (186 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/case.cpython-312.pyc
ADDED
|
Binary file (7.49 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/gen_example.cpython-312.pyc
ADDED
|
Binary file (1.21 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/__pycache__/logging.cpython-312.pyc
ADDED
|
Binary file (1.67 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (3.3 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/assume_constant_result.cpython-312.pyc
ADDED
|
Binary file (1.37 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/autograd_function.cpython-312.pyc
ADDED
|
Binary file (1.58 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/class_method.cpython-312.pyc
ADDED
|
Binary file (1.58 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_class_method.cpython-312.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nested_function.cpython-312.pyc
ADDED
|
Binary file (2.44 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nonlocal_variables.cpython-312.pyc
ADDED
|
Binary file (2.69 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_closed_over_variable.cpython-312.pyc
ADDED
|
Binary file (1.42 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_operands.cpython-312.pyc
ADDED
|
Binary file (1.78 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_predicate.cpython-312.pyc
ADDED
|
Binary file (1.64 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_size_example.cpython-312.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_value_example.cpython-312.pyc
ADDED
|
Binary file (1.47 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/decorator.cpython-312.pyc
ADDED
|
Binary file (1.32 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dictionary.cpython-312.pyc
ADDED
|
Binary file (998 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_assert.cpython-312.pyc
ADDED
|
Binary file (1.05 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_constructor.cpython-312.pyc
ADDED
|
Binary file (1.05 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_if_guard.cpython-312.pyc
ADDED
|
Binary file (1.21 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_map.cpython-312.pyc
ADDED
|
Binary file (1.18 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_round.cpython-312.pyc
ADDED
|
Binary file (1.24 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_slicing.cpython-312.pyc
ADDED
|
Binary file (1.06 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_view.cpython-312.pyc
ADDED
|
Binary file (1.12 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/fn_with_kwargs.cpython-312.pyc
ADDED
|
Binary file (1.47 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_contains.cpython-312.pyc
ADDED
|
Binary file (1.12 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_unpack.cpython-312.pyc
ADDED
|
Binary file (1.26 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/model_attr_mutation.cpython-312.pyc
ADDED
|
Binary file (1.82 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/nested_function.cpython-312.pyc
ADDED
|
Binary file (1.21 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/null_context_manager.cpython-312.pyc
ADDED
|
Binary file (1.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/optional_input.cpython-312.pyc
ADDED
|
Binary file (1.07 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/pytree_flatten.cpython-312.pyc
ADDED
|
Binary file (1.05 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/scalar_output.cpython-312.pyc
ADDED
|
Binary file (1.35 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/specialized_attribute.cpython-312.pyc
ADDED
|
Binary file (1.52 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/static_for_loop.cpython-312.pyc
ADDED
|
Binary file (992 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/static_if.cpython-312.pyc
ADDED
|
Binary file (1.04 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/tensor_setattr.cpython-312.pyc
ADDED
|
Binary file (971 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/type_reflection_method.cpython-312.pyc
ADDED
|
Binary file (1.33 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/unsupported_operator.cpython-312.pyc
ADDED
|
Binary file (1.13 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/user_input_mutation.cpython-312.pyc
ADDED
|
Binary file (923 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_if_guard.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class DynamicShapeIfGuard(torch.nn.Module):
|
| 5 |
+
"""
|
| 6 |
+
`if` statement with backed dynamic shape predicate will be specialized into
|
| 7 |
+
one particular branch and generate a guard. However, export will fail if the
|
| 8 |
+
the dimension is marked as dynamic shape from higher level API.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
def forward(self, x):
|
| 12 |
+
if x.shape[0] == 3:
|
| 13 |
+
return x.cos()
|
| 14 |
+
|
| 15 |
+
return x.sin()
|
| 16 |
+
|
| 17 |
+
example_args = (torch.randn(3, 2, 2),)
|
| 18 |
+
tags = {"torch.dynamic-shape", "python.control-flow"}
|
| 19 |
+
model = DynamicShapeIfGuard()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_map.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
from functorch.experimental.control_flow import map
|
| 5 |
+
|
| 6 |
+
class DynamicShapeMap(torch.nn.Module):
|
| 7 |
+
"""
|
| 8 |
+
functorch map() maps a function over the first tensor dimension.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
def forward(self, xs, y):
|
| 12 |
+
def body(x, y):
|
| 13 |
+
return x + y
|
| 14 |
+
|
| 15 |
+
return map(body, xs, y)
|
| 16 |
+
|
| 17 |
+
example_args = (torch.randn(3, 2), torch.randn(2))
|
| 18 |
+
tags = {"torch.dynamic-shape", "torch.map"}
|
| 19 |
+
model = DynamicShapeMap()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_round.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
from torch._export.db.case import SupportLevel
|
| 5 |
+
from torch.export import Dim
|
| 6 |
+
|
| 7 |
+
class DynamicShapeRound(torch.nn.Module):
|
| 8 |
+
"""
|
| 9 |
+
Calling round on dynamic shapes is not supported.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
def forward(self, x):
|
| 13 |
+
return x[: round(x.shape[0] / 2)]
|
| 14 |
+
|
| 15 |
+
x = torch.randn(3, 2)
|
| 16 |
+
dim0_x = Dim("dim0_x")
|
| 17 |
+
example_args = (x,)
|
| 18 |
+
tags = {"torch.dynamic-shape", "python.builtin"}
|
| 19 |
+
support_level = SupportLevel.NOT_SUPPORTED_YET
|
| 20 |
+
dynamic_shapes = {"x": {0: dim0_x}}
|
| 21 |
+
model = DynamicShapeRound()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_slicing.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class DynamicShapeSlicing(torch.nn.Module):
|
| 5 |
+
"""
|
| 6 |
+
Slices with dynamic shape arguments should be captured into the graph
|
| 7 |
+
rather than being baked in.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
def forward(self, x):
|
| 11 |
+
return x[: x.shape[0] - 2, x.shape[1] - 1 :: 2]
|
| 12 |
+
|
| 13 |
+
example_args = (torch.randn(3, 2),)
|
| 14 |
+
tags = {"torch.dynamic-shape"}
|
| 15 |
+
model = DynamicShapeSlicing()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/dynamic_shape_view.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class DynamicShapeView(torch.nn.Module):
|
| 5 |
+
"""
|
| 6 |
+
Dynamic shapes should be propagated to view arguments instead of being
|
| 7 |
+
baked into the exported graph.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
def forward(self, x):
|
| 11 |
+
new_x_shape = x.size()[:-1] + (2, 5)
|
| 12 |
+
x = x.view(*new_x_shape)
|
| 13 |
+
return x.permute(0, 2, 1)
|
| 14 |
+
|
| 15 |
+
example_args = (torch.randn(10, 10),)
|
| 16 |
+
tags = {"torch.dynamic-shape"}
|
| 17 |
+
model = DynamicShapeView()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/fn_with_kwargs.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class FnWithKwargs(torch.nn.Module):
|
| 5 |
+
"""
|
| 6 |
+
Keyword arguments are not supported at the moment.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
def forward(self, pos0, tuple0, *myargs, mykw0, **mykwargs):
|
| 10 |
+
out = pos0
|
| 11 |
+
for arg in tuple0:
|
| 12 |
+
out = out * arg
|
| 13 |
+
for arg in myargs:
|
| 14 |
+
out = out * arg
|
| 15 |
+
out = out * mykw0
|
| 16 |
+
out = out * mykwargs["input0"] * mykwargs["input1"]
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
example_args = (
|
| 20 |
+
torch.randn(4),
|
| 21 |
+
(torch.randn(4), torch.randn(4)),
|
| 22 |
+
*[torch.randn(4), torch.randn(4)]
|
| 23 |
+
)
|
| 24 |
+
example_kwargs = {
|
| 25 |
+
"mykw0": torch.randn(4),
|
| 26 |
+
"input0": torch.randn(4),
|
| 27 |
+
"input1": torch.randn(4),
|
| 28 |
+
}
|
| 29 |
+
tags = {"python.data-structure"}
|
| 30 |
+
model = FnWithKwargs()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/list_contains.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
class ListContains(torch.nn.Module):
|
| 5 |
+
"""
|
| 6 |
+
List containment relation can be checked on a dynamic shape or constants.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
def forward(self, x):
|
| 10 |
+
assert x.size(-1) in [6, 2]
|
| 11 |
+
assert x.size(0) not in [4, 5, 6]
|
| 12 |
+
assert "monkey" not in ["cow", "pig"]
|
| 13 |
+
return x + x
|
| 14 |
+
|
| 15 |
+
example_args = (torch.randn(3, 2),)
|
| 16 |
+
tags = {"torch.dynamic-shape", "python.data-structure", "python.assert"}
|
| 17 |
+
model = ListContains()
|
tool_server/.venv/lib/python3.12/site-packages/torch/_export/db/examples/list_unpack.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
class ListUnpack(torch.nn.Module):
|
| 6 |
+
"""
|
| 7 |
+
Lists are treated as static construct, therefore unpacking should be
|
| 8 |
+
erased after tracing.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
def forward(self, args: list[torch.Tensor]):
|
| 12 |
+
"""
|
| 13 |
+
Lists are treated as static construct, therefore unpacking should be
|
| 14 |
+
erased after tracing.
|
| 15 |
+
"""
|
| 16 |
+
x, *y = args
|
| 17 |
+
return x + y[0]
|
| 18 |
+
|
| 19 |
+
example_args = ([torch.randn(3, 2), torch.tensor(4), torch.tensor(5)],)
|
| 20 |
+
tags = {"python.control-flow", "python.data-structure"}
|
| 21 |
+
model = ListUnpack()
|