tico 0.1.0.dev250709__py3-none-any.whl → 0.1.0.dev250713__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 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.dev250709"
24
+ __version__ = "0.1.0.dev250713"
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
- isinstance(input, torch.fx.Node)
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
- isinstance(other, torch.fx.Node)
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),
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 = get_default_config(),
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tico
3
- Version: 0.1.0.dev250709
3
+ Version: 0.1.0.dev250713
4
4
  Summary: Convert exported Torch module to circle
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -1,4 +1,4 @@
1
- tico/__init__.py,sha256=uUyBqMHPDHaFA-Jf9XrT1UKDQ1UbQTvgqju8rx5nxQg,1743
1
+ tico/__init__.py,sha256=LDO-ry5VXGAZCkBH5Tb-m5CIIBwYSY1NqxdYJ6EtezQ,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=xKdFwwMaSFCSQpSk8xISOAqFpZ1jIhgbBIqf7KTSGuk,4017
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
@@ -182,7 +182,7 @@ tico/serialize/operators/op_view.py,sha256=5EMww-ve17Vm9XPuV03Tn7vJsjpU2J8U4d_FO
182
182
  tico/serialize/operators/op_where.py,sha256=doE81GSwygrPBm3JIfN9w7kKXxeIYKxgk0eoY22QIcg,2845
183
183
  tico/serialize/operators/utils.py,sha256=lXGpEJW1h8U_-gfc6EWjvvSiq3yJ9P-v1v3EMRT_pSk,2954
184
184
  tico/utils/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
185
- tico/utils/convert.py,sha256=5C8Z2ia2XN4k3XgtJrFZYJSEejoeMllyr8YW6gwu9mw,12763
185
+ tico/utils/convert.py,sha256=11Ps0i4-3Fmcts_PZO5Eo8rRL7FcLV33eHz_G97MnCg,12865
186
186
  tico/utils/define.py,sha256=Ypgp7YffM4pgPl4Zh6TmogSn1OxGBMRw_e09qYGflZk,1467
187
187
  tico/utils/diff_graph.py,sha256=_eDGGPDPYQD4b--MXX0DLoVgSt_wLfNPt47UlolLLR4,5272
188
188
  tico/utils/errors.py,sha256=f3csJjgbXG9W1aHhqEcou008Aor19W57X8oT5Hx8w1M,954
@@ -201,9 +201,9 @@ tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
201
201
  tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
202
202
  tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
203
203
  tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
204
- tico-0.1.0.dev250709.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
205
- tico-0.1.0.dev250709.dist-info/METADATA,sha256=zpUu_UaIWzup7BHIowx8BPnplKbnS6lJoHCYfvs_t_c,8430
206
- tico-0.1.0.dev250709.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
207
- tico-0.1.0.dev250709.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
208
- tico-0.1.0.dev250709.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
209
- tico-0.1.0.dev250709.dist-info/RECORD,,
204
+ tico-0.1.0.dev250713.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
205
+ tico-0.1.0.dev250713.dist-info/METADATA,sha256=FhV3CCFUbKieEpdRVt0MvAOV6sOVV-h3aKPBsrQttHY,8430
206
+ tico-0.1.0.dev250713.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
207
+ tico-0.1.0.dev250713.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
208
+ tico-0.1.0.dev250713.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
209
+ tico-0.1.0.dev250713.dist-info/RECORD,,