tico 0.1.0.dev250708__py3-none-any.whl → 0.1.0.dev250710__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tico/__init__.py +1 -1
- tico/passes/legalize_causal_mask_value.py +9 -8
- tico/serialize/operators/op_round.py +53 -0
- tico/utils/convert.py +6 -1
- tico/utils/validate_args_kwargs.py +10 -0
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/METADATA +1 -1
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/RECORD +11 -10
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/LICENSE +0 -0
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/WHEEL +0 -0
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/entry_points.txt +0 -0
- {tico-0.1.0.dev250708.dist-info → tico-0.1.0.dev250710.dist-info}/top_level.txt +0 -0
tico/__init__.py
CHANGED
@@ -21,7 +21,7 @@ from tico.config import CompileConfigV1, get_default_config
|
|
21
21
|
from tico.utils.convert import convert, convert_from_exported_program, convert_from_pt2
|
22
22
|
|
23
23
|
# THIS LINE IS AUTOMATICALLY GENERATED BY setup.py
|
24
|
-
__version__ = "0.1.0.
|
24
|
+
__version__ = "0.1.0.dev250710"
|
25
25
|
|
26
26
|
MINIMUM_SUPPORTED_VERSION = "2.5.0"
|
27
27
|
SECURE_TORCH_VERSION = "2.6.0"
|
@@ -17,6 +17,7 @@ from typing import TYPE_CHECKING
|
|
17
17
|
if TYPE_CHECKING:
|
18
18
|
import torch.fx
|
19
19
|
import torch
|
20
|
+
from torch._export.utils import is_lifted_tensor_constant
|
20
21
|
from torch.export import ExportedProgram
|
21
22
|
|
22
23
|
from tico.passes import ops
|
@@ -52,6 +53,7 @@ class LegalizeCausalMaskValue(PassBase):
|
|
52
53
|
graph_module = exported_program.graph_module
|
53
54
|
graph = graph_module.graph
|
54
55
|
modified = False
|
56
|
+
|
55
57
|
for node in graph.nodes:
|
56
58
|
if not is_target_node(node, ops.aten.add):
|
57
59
|
continue
|
@@ -60,21 +62,19 @@ class LegalizeCausalMaskValue(PassBase):
|
|
60
62
|
input = args.input
|
61
63
|
other = args.other
|
62
64
|
|
63
|
-
if (
|
64
|
-
|
65
|
-
and input.name
|
66
|
-
in exported_program.graph_signature.lifted_tensor_constants
|
65
|
+
if isinstance(input, torch.fx.Node) and is_lifted_tensor_constant(
|
66
|
+
exported_program, input
|
67
67
|
):
|
68
68
|
mask_node = input
|
69
|
-
elif (
|
70
|
-
|
71
|
-
and other.name
|
72
|
-
in exported_program.graph_signature.lifted_tensor_constants
|
69
|
+
elif isinstance(other, torch.fx.Node) and is_lifted_tensor_constant(
|
70
|
+
exported_program, other
|
73
71
|
):
|
74
72
|
mask_node = other
|
75
73
|
else:
|
76
74
|
continue
|
77
75
|
|
76
|
+
assert isinstance(mask_node, torch.fx.Node)
|
77
|
+
|
78
78
|
mask_node_name = (
|
79
79
|
exported_program.graph_signature.inputs_to_lifted_tensor_constants[
|
80
80
|
mask_node.name
|
@@ -90,6 +90,7 @@ class LegalizeCausalMaskValue(PassBase):
|
|
90
90
|
if torch.all(
|
91
91
|
torch.logical_or(mask_data == 0, mask_data < fp32_minus_inf_rounded)
|
92
92
|
):
|
93
|
+
# Replace the value from -inf to -120
|
93
94
|
exported_program.constants[mask_node_name] = torch.where(
|
94
95
|
mask_data < fp32_minus_inf_rounded,
|
95
96
|
torch.tensor(new_mask, dtype=mask_data.dtype),
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
from typing import Dict, List, TYPE_CHECKING
|
16
|
+
|
17
|
+
if TYPE_CHECKING:
|
18
|
+
import torch._ops
|
19
|
+
import torch.fx
|
20
|
+
import torch
|
21
|
+
from circle_schema import circle
|
22
|
+
|
23
|
+
from tico.serialize.circle_graph import CircleSubgraph
|
24
|
+
from tico.serialize.operators.hashable_opcode import OpCode
|
25
|
+
from tico.serialize.operators.node_visitor import NodeVisitor, register_node_visitor
|
26
|
+
from tico.serialize.operators.utils import create_builtin_operator, get_op_index
|
27
|
+
from tico.utils.validate_args_kwargs import RoundArgs
|
28
|
+
|
29
|
+
|
30
|
+
@register_node_visitor
|
31
|
+
class RoundVisitor(NodeVisitor):
|
32
|
+
target: List[torch._ops.OpOverload] = [torch.ops.aten.round.default]
|
33
|
+
|
34
|
+
def __init__(self, op_codes: Dict[OpCode, int], graph: CircleSubgraph):
|
35
|
+
super().__init__(op_codes, graph)
|
36
|
+
|
37
|
+
def define_node(
|
38
|
+
self,
|
39
|
+
node: torch.fx.Node,
|
40
|
+
) -> circle.Operator.OperatorT:
|
41
|
+
op_index = get_op_index(
|
42
|
+
circle.BuiltinOperator.BuiltinOperator.ROUND, self._op_codes
|
43
|
+
)
|
44
|
+
|
45
|
+
args = RoundArgs(*node.args, **node.kwargs) # type: ignore[arg-type]
|
46
|
+
input = args.input
|
47
|
+
|
48
|
+
inputs = [input]
|
49
|
+
outputs = [node]
|
50
|
+
|
51
|
+
operator = create_builtin_operator(self.graph, op_index, inputs, outputs)
|
52
|
+
|
53
|
+
return operator
|
tico/utils/convert.py
CHANGED
@@ -182,8 +182,13 @@ def check_training_ops(exported_program: ExportedProgram):
|
|
182
182
|
|
183
183
|
def convert_exported_module_to_circle(
|
184
184
|
exported_program: ExportedProgram,
|
185
|
-
config: CompileConfigBase =
|
185
|
+
config: Optional[CompileConfigBase] = None,
|
186
186
|
) -> bytes:
|
187
|
+
if not config:
|
188
|
+
config = get_default_config()
|
189
|
+
|
190
|
+
assert isinstance(config, CompileConfigBase)
|
191
|
+
|
187
192
|
logger = logging.getLogger(__name__)
|
188
193
|
logger.debug("Input ExportedProgram (must be core aten)")
|
189
194
|
logger.debug(exported_program)
|
@@ -933,6 +933,16 @@ class ResizeNearestNeighborArgs:
|
|
933
933
|
size: List[int]
|
934
934
|
|
935
935
|
|
936
|
+
@enforce_type
|
937
|
+
@dataclass
|
938
|
+
class RoundArgs:
|
939
|
+
"""
|
940
|
+
round(Tensor self) -> Tensor
|
941
|
+
"""
|
942
|
+
|
943
|
+
input: torch.fx.Node
|
944
|
+
|
945
|
+
|
936
946
|
@enforce_type
|
937
947
|
@dataclass
|
938
948
|
class RsqrtArgs:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tico/__init__.py,sha256=
|
1
|
+
tico/__init__.py,sha256=JX2TYbqasSNy-orrm1WTXfJiq3BmszrlWsgAHAt-6aI,1743
|
2
2
|
tico/pt2_to_circle.py,sha256=gu3MD4Iqc0zMZcCZ2IT8oGbyj21CTSbT3Rgd9s2B_9A,2767
|
3
3
|
tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
|
4
4
|
tico/config/base.py,sha256=anwOiJFkUxUi7Cef573JgQcjk6S-FSi6O_TLjYASW-g,1244
|
@@ -78,7 +78,7 @@ tico/passes/extract_dtype_kwargs.py,sha256=ObpsaFlrTPYQw2hJ7UsC5CocyAtBkT_bMtzkM
|
|
78
78
|
tico/passes/fill_meta_val.py,sha256=Xbam6Aq90ZfWItZw1dgLIwH_q8RCiU5JodKNqkj-ink,1797
|
79
79
|
tico/passes/fuse_leading_unsqueeze_reshape.py,sha256=88jwTP35yRyXOk9xdO6YW2OEfdKAws3KFRT16WQz0RI,4291
|
80
80
|
tico/passes/fuse_redundant_reshape_to_mean.py,sha256=GhJS1ZKB6Ns4AhwcW3uUQ6q-0N-AzlD32B2EwusUJHg,3761
|
81
|
-
tico/passes/legalize_causal_mask_value.py,sha256=
|
81
|
+
tico/passes/legalize_causal_mask_value.py,sha256=0nfUKGd7XSe9Hg5TAi4dUi6Nn6-JRTWCwhULR5AEgqs,4079
|
82
82
|
tico/passes/legalize_predefined_layout_operators.py,sha256=MNx7L2dAlsxSazb-F7c0onPqHleI17zAc7AzQAa9aJ4,18934
|
83
83
|
tico/passes/lower_pow2_to_mul.py,sha256=nfJXa9ZTZMiLg6ownSyvkM4KF2z9tZW34Q3CCWI_vmQ,2402
|
84
84
|
tico/passes/lower_to_resize_nearest_neighbor.py,sha256=N6F56Of8Aiv-KIiYLHnh33WX72W60ZVQSBEYWHdYqNQ,9005
|
@@ -161,6 +161,7 @@ tico/serialize/operators/op_relu6.py,sha256=ZWqEolfAKjOdUC1ZCg0iuu4dBhkJRxVYR2tU
|
|
161
161
|
tico/serialize/operators/op_repeat.py,sha256=0wTv1Mg7kg0eHz0CT6atyVAli4T4h5rYXq5opY6op20,4235
|
162
162
|
tico/serialize/operators/op_reshape.py,sha256=0_bJwimiGAHaKkfwfhxUw9Gebt5tnecGaEVoKhEvV0Q,2550
|
163
163
|
tico/serialize/operators/op_resize_nearest_neighbor.py,sha256=dXaAnZ5M_ko_tH-HolxNpHFXkDUQ8x45myskojP5XZE,2771
|
164
|
+
tico/serialize/operators/op_round.py,sha256=pe6w_TB4xGLu0iPv4Qo0a0fIkY9DgCgXk5127TWt8pE,1837
|
164
165
|
tico/serialize/operators/op_rsqrt.py,sha256=yl2vd8InjhLPbE0vHIrEera6DVXlY9dLgO7yZZCH3RI,1837
|
165
166
|
tico/serialize/operators/op_scalar_tensor.py,sha256=vDWxi4hXwyDJJhvfMR_QrBInw_No3WeU_M4gtfZqmbo,1928
|
166
167
|
tico/serialize/operators/op_select_copy.py,sha256=GPLN7QZmwSlA4WRbjfU6pLer3KVWzgaYsZPJXw_vv9g,2305
|
@@ -181,7 +182,7 @@ tico/serialize/operators/op_view.py,sha256=5EMww-ve17Vm9XPuV03Tn7vJsjpU2J8U4d_FO
|
|
181
182
|
tico/serialize/operators/op_where.py,sha256=doE81GSwygrPBm3JIfN9w7kKXxeIYKxgk0eoY22QIcg,2845
|
182
183
|
tico/serialize/operators/utils.py,sha256=lXGpEJW1h8U_-gfc6EWjvvSiq3yJ9P-v1v3EMRT_pSk,2954
|
183
184
|
tico/utils/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
184
|
-
tico/utils/convert.py,sha256=
|
185
|
+
tico/utils/convert.py,sha256=11Ps0i4-3Fmcts_PZO5Eo8rRL7FcLV33eHz_G97MnCg,12865
|
185
186
|
tico/utils/define.py,sha256=Ypgp7YffM4pgPl4Zh6TmogSn1OxGBMRw_e09qYGflZk,1467
|
186
187
|
tico/utils/diff_graph.py,sha256=_eDGGPDPYQD4b--MXX0DLoVgSt_wLfNPt47UlolLLR4,5272
|
187
188
|
tico/utils/errors.py,sha256=f3csJjgbXG9W1aHhqEcou008Aor19W57X8oT5Hx8w1M,954
|
@@ -195,14 +196,14 @@ tico/utils/register_custom_op.py,sha256=3-Yl6iYmx1qQA2igNHt4hYhQhQMkdPb7gF50LIY8
|
|
195
196
|
tico/utils/serialize.py,sha256=AQXMBOLu-Kg2Rn-qbqsAtHndjZAZIavlKA0QFgJREHM,1420
|
196
197
|
tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
|
197
198
|
tico/utils/utils.py,sha256=fnbZ2RLH6-J-wqb32O4qsR1ce4BJU0wYNrk84QXa6_E,13158
|
198
|
-
tico/utils/validate_args_kwargs.py,sha256=
|
199
|
+
tico/utils/validate_args_kwargs.py,sha256=3dXkNll9E9eZq-p0HjYaV4YltQESqdEHBU34k-tIg1k,26733
|
199
200
|
tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
200
201
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
201
202
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
202
203
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
203
|
-
tico-0.1.0.
|
204
|
-
tico-0.1.0.
|
205
|
-
tico-0.1.0.
|
206
|
-
tico-0.1.0.
|
207
|
-
tico-0.1.0.
|
208
|
-
tico-0.1.0.
|
204
|
+
tico-0.1.0.dev250710.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
205
|
+
tico-0.1.0.dev250710.dist-info/METADATA,sha256=Qf2fCMvuXn6zEMGfY37nTMPf4OHkgIAJcZgK9jIJpGU,8430
|
206
|
+
tico-0.1.0.dev250710.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
207
|
+
tico-0.1.0.dev250710.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
|
208
|
+
tico-0.1.0.dev250710.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
209
|
+
tico-0.1.0.dev250710.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|