Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_awaits/__pycache__/__init__.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_dispatch/__pycache__/__init__.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_dispatch/__pycache__/python.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/__init__.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/config.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/converter.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/error.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/non_strict_utils.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/pass_base.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/tools.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/utils.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/verifier.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/wrappers.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__init__.py +5 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/__init__.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/case.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/gen_example.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/logging.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/case.py +175 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__init__.py +61 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/__init__.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/assume_constant_result.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/autograd_function.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/class_method.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_class_method.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nested_function.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nonlocal_variables.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_closed_over_variable.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_operands.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_predicate.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_size_example.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_value_example.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/decorator.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dictionary.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_assert.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_constructor.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_if_guard.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_map.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_round.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_slicing.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_view.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/fn_with_kwargs.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_contains.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_unpack.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/model_attr_mutation.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/nested_function.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/null_context_manager.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/optional_input.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/pytree_flatten.cpython-312.pyc +0 -0
- URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/scalar_output.cpython-312.pyc +0 -0
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_awaits/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (2.27 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_dispatch/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (207 Bytes). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_dispatch/__pycache__/python.cpython-312.pyc
ADDED
|
Binary file (11.6 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (8.71 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/config.cpython-312.pyc
ADDED
|
Binary file (1.19 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/converter.cpython-312.pyc
ADDED
|
Binary file (78.2 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/error.cpython-312.pyc
ADDED
|
Binary file (2.41 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/non_strict_utils.cpython-312.pyc
ADDED
|
Binary file (47.7 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/pass_base.cpython-312.pyc
ADDED
|
Binary file (25.9 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/tools.cpython-312.pyc
ADDED
|
Binary file (6.15 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (73 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/verifier.cpython-312.pyc
ADDED
|
Binary file (27.2 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/__pycache__/wrappers.cpython-312.pyc
ADDED
|
Binary file (16.3 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (208 Bytes). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/case.cpython-312.pyc
ADDED
|
Binary file (7.51 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/gen_example.cpython-312.pyc
ADDED
|
Binary file (1.23 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/__pycache__/logging.cpython-312.pyc
ADDED
|
Binary file (1.69 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/case.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import inspect
|
| 3 |
+
import re
|
| 4 |
+
import string
|
| 5 |
+
from dataclasses import dataclass, field
|
| 6 |
+
from enum import Enum
|
| 7 |
+
from typing import Any, Optional
|
| 8 |
+
from types import ModuleType
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
_TAGS: dict[str, dict[str, Any]] = {
|
| 13 |
+
"torch": {
|
| 14 |
+
"cond": {},
|
| 15 |
+
"dynamic-shape": {},
|
| 16 |
+
"escape-hatch": {},
|
| 17 |
+
"map": {},
|
| 18 |
+
"dynamic-value": {},
|
| 19 |
+
"operator": {},
|
| 20 |
+
"mutation": {},
|
| 21 |
+
},
|
| 22 |
+
"python": {
|
| 23 |
+
"assert": {},
|
| 24 |
+
"builtin": {},
|
| 25 |
+
"closure": {},
|
| 26 |
+
"context-manager": {},
|
| 27 |
+
"control-flow": {},
|
| 28 |
+
"data-structure": {},
|
| 29 |
+
"standard-library": {},
|
| 30 |
+
"object-model": {},
|
| 31 |
+
},
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class SupportLevel(Enum):
|
| 36 |
+
"""
|
| 37 |
+
Indicates at what stage the feature
|
| 38 |
+
used in the example is handled in export.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
SUPPORTED = 1
|
| 42 |
+
NOT_SUPPORTED_YET = 0
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
ArgsType = tuple[Any, ...]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def check_inputs_type(args, kwargs):
|
| 49 |
+
if not isinstance(args, tuple):
|
| 50 |
+
raise ValueError(
|
| 51 |
+
f"Expecting args type to be a tuple, got: {type(args)}"
|
| 52 |
+
)
|
| 53 |
+
if not isinstance(kwargs, dict):
|
| 54 |
+
raise ValueError(
|
| 55 |
+
f"Expecting kwargs type to be a dict, got: {type(kwargs)}"
|
| 56 |
+
)
|
| 57 |
+
for key in kwargs:
|
| 58 |
+
if not isinstance(key, str):
|
| 59 |
+
raise ValueError(
|
| 60 |
+
f"Expecting kwargs keys to be a string, got: {type(key)}"
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
def _validate_tag(tag: str):
|
| 64 |
+
parts = tag.split(".")
|
| 65 |
+
t = _TAGS
|
| 66 |
+
for part in parts:
|
| 67 |
+
assert set(part) <= set(
|
| 68 |
+
string.ascii_lowercase + "-"
|
| 69 |
+
), f"Tag contains invalid characters: {part}"
|
| 70 |
+
if part in t:
|
| 71 |
+
t = t[part]
|
| 72 |
+
else:
|
| 73 |
+
raise ValueError(f"Tag {tag} is not found in registered tags.")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@dataclass(frozen=True)
|
| 77 |
+
class ExportCase:
|
| 78 |
+
example_args: ArgsType
|
| 79 |
+
description: str # A description of the use case.
|
| 80 |
+
model: torch.nn.Module
|
| 81 |
+
name: str
|
| 82 |
+
example_kwargs: dict[str, Any] = field(default_factory=dict)
|
| 83 |
+
extra_args: Optional[ArgsType] = None # For testing graph generalization.
|
| 84 |
+
# Tags associated with the use case. (e.g dynamic-shape, escape-hatch)
|
| 85 |
+
tags: set[str] = field(default_factory=set)
|
| 86 |
+
support_level: SupportLevel = SupportLevel.SUPPORTED
|
| 87 |
+
dynamic_shapes: Optional[dict[str, Any]] = None
|
| 88 |
+
|
| 89 |
+
def __post_init__(self):
|
| 90 |
+
check_inputs_type(self.example_args, self.example_kwargs)
|
| 91 |
+
if self.extra_args is not None:
|
| 92 |
+
check_inputs_type(self.extra_args, {})
|
| 93 |
+
|
| 94 |
+
for tag in self.tags:
|
| 95 |
+
_validate_tag(tag)
|
| 96 |
+
|
| 97 |
+
if not isinstance(self.description, str) or len(self.description) == 0:
|
| 98 |
+
raise ValueError(f'Invalid description: "{self.description}"')
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
_EXAMPLE_CASES: dict[str, ExportCase] = {}
|
| 102 |
+
_MODULES: set[ModuleType] = set()
|
| 103 |
+
_EXAMPLE_CONFLICT_CASES: dict[str, list[ExportCase]] = {}
|
| 104 |
+
_EXAMPLE_REWRITE_CASES: dict[str, list[ExportCase]] = {}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def register_db_case(case: ExportCase) -> None:
|
| 108 |
+
"""
|
| 109 |
+
Registers a user provided ExportCase into example bank.
|
| 110 |
+
"""
|
| 111 |
+
if case.name in _EXAMPLE_CASES:
|
| 112 |
+
if case.name not in _EXAMPLE_CONFLICT_CASES:
|
| 113 |
+
_EXAMPLE_CONFLICT_CASES[case.name] = [_EXAMPLE_CASES[case.name]]
|
| 114 |
+
_EXAMPLE_CONFLICT_CASES[case.name].append(case)
|
| 115 |
+
return
|
| 116 |
+
|
| 117 |
+
_EXAMPLE_CASES[case.name] = case
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def to_snake_case(name):
|
| 121 |
+
name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
|
| 122 |
+
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def _make_export_case(m, name, configs):
|
| 126 |
+
if not isinstance(m, torch.nn.Module):
|
| 127 |
+
raise TypeError("Export case class should be a torch.nn.Module.")
|
| 128 |
+
|
| 129 |
+
if "description" not in configs:
|
| 130 |
+
# Fallback to docstring if description is missing.
|
| 131 |
+
assert (
|
| 132 |
+
m.__doc__ is not None
|
| 133 |
+
), f"Could not find description or docstring for export case: {m}"
|
| 134 |
+
configs = {**configs, "description": m.__doc__}
|
| 135 |
+
# pyrefly: ignore [bad-argument-type]
|
| 136 |
+
return ExportCase(**{**configs, "model": m, "name": name})
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def export_case(**kwargs):
|
| 140 |
+
"""
|
| 141 |
+
Decorator for registering a user provided case into example bank.
|
| 142 |
+
"""
|
| 143 |
+
|
| 144 |
+
def wrapper(m):
|
| 145 |
+
configs = kwargs
|
| 146 |
+
module = inspect.getmodule(m)
|
| 147 |
+
if module in _MODULES:
|
| 148 |
+
raise RuntimeError("export_case should only be used once per example file.")
|
| 149 |
+
|
| 150 |
+
assert module is not None
|
| 151 |
+
_MODULES.add(module)
|
| 152 |
+
module_name = module.__name__.split(".")[-1]
|
| 153 |
+
case = _make_export_case(m, module_name, configs)
|
| 154 |
+
register_db_case(case)
|
| 155 |
+
return case
|
| 156 |
+
|
| 157 |
+
return wrapper
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def export_rewrite_case(**kwargs):
|
| 161 |
+
def wrapper(m):
|
| 162 |
+
configs = kwargs
|
| 163 |
+
|
| 164 |
+
parent = configs.pop("parent")
|
| 165 |
+
assert isinstance(parent, ExportCase)
|
| 166 |
+
key = parent.name
|
| 167 |
+
if key not in _EXAMPLE_REWRITE_CASES:
|
| 168 |
+
_EXAMPLE_REWRITE_CASES[key] = []
|
| 169 |
+
|
| 170 |
+
configs["example_args"] = parent.example_args
|
| 171 |
+
case = _make_export_case(m, to_snake_case(m.__name__), configs)
|
| 172 |
+
_EXAMPLE_REWRITE_CASES[key].append(case)
|
| 173 |
+
return case
|
| 174 |
+
|
| 175 |
+
return wrapper
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__init__.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
import dataclasses
|
| 3 |
+
import glob
|
| 4 |
+
import inspect
|
| 5 |
+
from os.path import basename, dirname, isfile, join
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
from torch._export.db.case import (
|
| 9 |
+
_EXAMPLE_CASES,
|
| 10 |
+
_EXAMPLE_CONFLICT_CASES,
|
| 11 |
+
_EXAMPLE_REWRITE_CASES,
|
| 12 |
+
SupportLevel,
|
| 13 |
+
export_case,
|
| 14 |
+
ExportCase,
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _collect_examples():
|
| 19 |
+
case_names = glob.glob(join(dirname(__file__), "*.py"))
|
| 20 |
+
case_names = [
|
| 21 |
+
basename(f)[:-3] for f in case_names if isfile(f) and not f.endswith("__init__.py")
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
case_fields = {f.name for f in dataclasses.fields(ExportCase)}
|
| 25 |
+
for case_name in case_names:
|
| 26 |
+
case = __import__(case_name, globals(), locals(), [], 1)
|
| 27 |
+
variables = [name for name in dir(case) if name in case_fields]
|
| 28 |
+
export_case(**{v: getattr(case, v) for v in variables})(case.model)
|
| 29 |
+
|
| 30 |
+
_collect_examples()
|
| 31 |
+
|
| 32 |
+
def all_examples():
|
| 33 |
+
return _EXAMPLE_CASES
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
if len(_EXAMPLE_CONFLICT_CASES) > 0:
|
| 37 |
+
|
| 38 |
+
def get_name(case):
|
| 39 |
+
model = case.model
|
| 40 |
+
if isinstance(model, torch.nn.Module):
|
| 41 |
+
model = type(model)
|
| 42 |
+
return model.__name__
|
| 43 |
+
|
| 44 |
+
msg = "Error on conflict export case name.\n"
|
| 45 |
+
for case_name, cases in _EXAMPLE_CONFLICT_CASES.items():
|
| 46 |
+
msg += f"Case name {case_name} is associated with multiple cases:\n "
|
| 47 |
+
msg += f"[{','.join(map(get_name, cases))}]\n"
|
| 48 |
+
|
| 49 |
+
raise RuntimeError(msg)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def filter_examples_by_support_level(support_level: SupportLevel):
|
| 53 |
+
return {
|
| 54 |
+
key: val
|
| 55 |
+
for key, val in all_examples().items()
|
| 56 |
+
if val.support_level == support_level
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def get_rewrite_cases(case):
|
| 61 |
+
return _EXAMPLE_REWRITE_CASES.get(case.name, [])
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (3.32 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/assume_constant_result.cpython-312.pyc
ADDED
|
Binary file (1.39 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/autograd_function.cpython-312.pyc
ADDED
|
Binary file (1.61 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/class_method.cpython-312.pyc
ADDED
|
Binary file (1.6 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_class_method.cpython-312.pyc
ADDED
|
Binary file (2.74 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nested_function.cpython-312.pyc
ADDED
|
Binary file (2.46 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_branch_nonlocal_variables.cpython-312.pyc
ADDED
|
Binary file (2.72 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_closed_over_variable.cpython-312.pyc
ADDED
|
Binary file (1.44 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_operands.cpython-312.pyc
ADDED
|
Binary file (1.8 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/cond_predicate.cpython-312.pyc
ADDED
|
Binary file (1.66 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_size_example.cpython-312.pyc
ADDED
|
Binary file (1.25 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/constrain_as_value_example.cpython-312.pyc
ADDED
|
Binary file (1.37 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/decorator.cpython-312.pyc
ADDED
|
Binary file (1.34 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dictionary.cpython-312.pyc
ADDED
|
Binary file (1.02 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_assert.cpython-312.pyc
ADDED
|
Binary file (1.07 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_constructor.cpython-312.pyc
ADDED
|
Binary file (1.07 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_if_guard.cpython-312.pyc
ADDED
|
Binary file (1.23 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_map.cpython-312.pyc
ADDED
|
Binary file (1.2 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_round.cpython-312.pyc
ADDED
|
Binary file (1.26 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_slicing.cpython-312.pyc
ADDED
|
Binary file (1.08 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/dynamic_shape_view.cpython-312.pyc
ADDED
|
Binary file (1.14 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/fn_with_kwargs.cpython-312.pyc
ADDED
|
Binary file (1.49 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_contains.cpython-312.pyc
ADDED
|
Binary file (1.15 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/list_unpack.cpython-312.pyc
ADDED
|
Binary file (1.28 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/model_attr_mutation.cpython-312.pyc
ADDED
|
Binary file (1.77 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/nested_function.cpython-312.pyc
ADDED
|
Binary file (1.23 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/null_context_manager.cpython-312.pyc
ADDED
|
Binary file (1.22 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/optional_input.cpython-312.pyc
ADDED
|
Binary file (1.09 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/pytree_flatten.cpython-312.pyc
ADDED
|
Binary file (1.07 kB). View file
|
|
|
URSA/.venv_ursa/lib/python3.12/site-packages/torch/_export/db/examples/__pycache__/scalar_output.cpython-312.pyc
ADDED
|
Binary file (1.37 kB). View file
|
|
|