tico 0.1.0.dev250411__py3-none-any.whl → 0.1.0.dev250414__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
@@ -22,7 +22,7 @@ from tico.config import CompileConfigV1, get_default_config
22
22
  from tico.utils.convert import convert, convert_from_exported_program, convert_from_pt2
23
23
 
24
24
  # THIS LINE IS AUTOMATICALLY GENERATED BY setup.py
25
- __version__ = '0.1.0.dev250411'
25
+ __version__ = '0.1.0.dev250414'
26
26
 
27
27
 
28
28
  if Version(torch.__version__) < Version("2.5.0"):
@@ -0,0 +1,297 @@
1
+ Metadata-Version: 2.1
2
+ Name: tico
3
+ Version: 0.1.0.dev250414
4
+ Summary: Convert exported Torch module to circle
5
+ Home-page: UNKNOWN
6
+ License: UNKNOWN
7
+ Platform: UNKNOWN
8
+ Requires-Python: >=3.10.0
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: cffi
12
+ Requires-Dist: circle-schema
13
+ Requires-Dist: packaging
14
+ Requires-Dist: pyyaml
15
+ Requires-Dist: torch
16
+
17
+ # TICO
18
+
19
+ _TICO_ (Torch IR to Circle [ONE](https://github.com/Samsung/ONE)) is a python library for converting
20
+ Pytorch modules into a circle model that is a lightweight and efficient representation in ONE
21
+ designed for optimized on-device neural network inference.
22
+
23
+ ## Table of Contents
24
+
25
+ ### For Users
26
+
27
+ - [Installation](#installation)
28
+ - [Getting Started](#getting-started)
29
+ - [From torch module](#from-torch-module)
30
+ - [From .pt2](#from-pt2)
31
+ - [Running circle models directly in Python](#running-circle-models-directly-in-python)
32
+
33
+ ### For Developers
34
+
35
+ - [Testing & Code Formatting](#testing--code-formatting)
36
+ - [Testing](#testing)
37
+ - [Code Formatting](#code-formatting)
38
+
39
+ ## For Users
40
+
41
+ ### Installation
42
+
43
+ 0. Prerequisites
44
+
45
+ - Python 3.10
46
+ - [one-compiler nightly](https://github.com/Samsung/TICO/issues/2)
47
+ - This project depends on [ONE](https://github.com/Samsung/ONE) Compiler, and it uses
48
+ nightly features that are not yet available in the official release. Until one-compiler 1.30.0
49
+ is released, you must use a prebuilt nighlty version of ONE Compiler.
50
+
51
+ We highly recommend to use a virtual env, e.g., conda.
52
+
53
+ 1. Clone this repo
54
+
55
+ 2. Build python package
56
+
57
+ ```bash
58
+ ./ccex build
59
+ ```
60
+
61
+ This will generate `build` and `dist` directories in the root directory.
62
+
63
+ 3. Install generated package
64
+
65
+ ```bash
66
+ ./ccex install
67
+ ```
68
+
69
+ **Available options**
70
+ - `--dist` To install the package from .whl (without this option, _TICO_ is installed in an editable mode)
71
+ - `--torch_ver <torch version>` To install a specific torch version (default: 2.6).
72
+ - Available <torch version>: 2.5, 2.6, nightly
73
+
74
+ 4. Now you can convert a torch module to a `.circle`.
75
+
76
+ ### Getting started
77
+
78
+ This tutorial explains how you can use _TICO_ to generate a circle model from a torch module.
79
+
80
+ Let's assume we have a torch module.
81
+
82
+ ```python
83
+ import tico
84
+ import torch
85
+
86
+ class AddModule(torch.nn.Module):
87
+ def __init__(self):
88
+ super().__init__()
89
+
90
+ def forward(self, x, y):
91
+ return x + y
92
+ ```
93
+
94
+ **NOTE**
95
+ _TICO_ internally uses [torch.export](https://pytorch.org/docs/stable/export.html#torch-export).
96
+ Therefore, the torch module must be 'export'able. Please see
97
+ [this document](https://pytorch.org/docs/stable/export.html#limitations-of-torch-export)
98
+ if you have any trouble to export.
99
+
100
+ #### From torch module
101
+
102
+ You can convert a torch module to a circle model with these steps.
103
+
104
+ ```python
105
+ torch_module = AddModule()
106
+ example_inputs = (torch.ones(4), torch.ones(4))
107
+
108
+ circle_model = tico.convert(torch_module, example_inputs)
109
+ circle_model.save('add.circle')
110
+ ```
111
+
112
+ **Compile with configuration**
113
+
114
+ ```python
115
+ from test.modules.op.add import AddWithCausalMaskFolded
116
+
117
+ torch_module = AddWithCausalMaskFolded()
118
+ example_inputs = torch_module.get_example_inputs()
119
+
120
+ config = tico.CompileConfigV1()
121
+ config.legalize_causal_mask_value = True
122
+ circle_model = tico.convert(torch_module, example_inputs, config = config)
123
+ circle_model.save('add_causal_mask_m120.circle')
124
+ ```
125
+
126
+ With `legalize_causal_mask_value` option on, causal mask value is converted from
127
+ -inf to -120, creating a more quantization-friendly circle model with the cost of
128
+ slight accuracy drop.
129
+
130
+ #### From .pt2
131
+
132
+ The torch module can be exported and saved as `.pt2` file (from PyTorch 2.1).
133
+
134
+ ```python
135
+ module = AddModule()
136
+ example_inputs = (torch.ones(4), torch.ones(4))
137
+
138
+ exported_program = torch.export.export(module, example_inputs)
139
+ torch.export.save(exported_program, 'add.pt2')
140
+ ```
141
+
142
+ There are two ways to convert `.pt2` file: python api, command line tool.
143
+
144
+ - Python API
145
+
146
+ ```python
147
+ circle_model = tico.convert_from_pt2('add.pt2')
148
+ circle_model.save('add.circle')
149
+ ```
150
+
151
+ - Command Line Tool
152
+
153
+ ```bash
154
+ pt2-to-circle -i add.pt2 -o add.circle
155
+ ```
156
+
157
+ - Command Line Tool with configuration
158
+
159
+ ```bash
160
+ pt2-to-circle -i add.pt2 -o add.circle -c config.yaml
161
+ ```
162
+
163
+ ```yaml
164
+ # config.yaml
165
+
166
+ version: '1.0' # You must specify the config version.
167
+ legalize_causal_mask_value: True
168
+ ```
169
+
170
+ #### Running circle models directly in Python
171
+
172
+ After circle export, you can run the model directly in Python.
173
+
174
+ Note that you should install one-compiler package first.
175
+
176
+ The output types are numpy.ndarray.
177
+
178
+ ```python
179
+ torch_module = AddModule()
180
+ example_inputs = (torch.ones(4), torch.ones(4))
181
+
182
+ circle_model = tico.convert(torch_module, example_inputs)
183
+ circle_model(*example_inputs)
184
+ # numpy.ndarray([2., 2., 2., 2.], dtype=float32)
185
+ ```
186
+
187
+ ## For Developers
188
+
189
+ ### Testing & Code Formatting
190
+
191
+ Run below commands to configure testing or formatting environment.
192
+
193
+ Refer to the dedicated section to have more fine-grained control.
194
+
195
+ ```bash
196
+ $ ./ccex configure # to set up testing & formatting environment
197
+ $ ./ccex configure format # to set up only formatting environment
198
+ $ ./ccex configure test # to set up only testing environment
199
+ ```
200
+
201
+ **Available options**
202
+ - `--torch_ver <torch version>` To install a specific torch family package(ex. torchvision) version (default: 2.6)
203
+ - Available <torch version>: '2.5', '2.6', 'nightly'
204
+
205
+ ```bash
206
+ $ ./ccex configure # to set up testing & formatting environment with stable2.6.x version
207
+ $ ./ccex configure test # to set up only testing environment with stable 2.6.x version
208
+ $ ./ccex configure test --torch_ver 2.5 # to set up only testing environment with stable 2.5.x version
209
+ $ ./ccex configure test --torch_ver nightly # to set up only testing environment with nightly version
210
+ ```
211
+
212
+ ### Testing
213
+
214
+ #### Test congifure
215
+
216
+ Run below commands to install requirements for testing.
217
+
218
+ **NOTE** `TICO` will be installed in an editable mode.
219
+
220
+ ```bash
221
+ ./ccex configure test
222
+
223
+ # without editable install
224
+ ./ccex configure test --dist
225
+ ```
226
+
227
+ #### Test All
228
+
229
+ Run below commands to run the all unit tests.
230
+
231
+ **NOTE** Unit tests don't include model test.
232
+
233
+ ```bash
234
+ ./ccex test
235
+ # OR
236
+ ./ccex test run-all-tests
237
+ ```
238
+
239
+ #### Test Subset
240
+
241
+ To run subset of `test.modules.*`,
242
+ Run `./ccex test -k <keyword>`
243
+
244
+
245
+ For example, to run tests in specific sub-directory (op, net, ..)
246
+ ```bash
247
+ # To run tests in specific sub-directory (op/, net/ ..)
248
+ ./ccex test -k op
249
+ ./ccex test -k net
250
+
251
+ # To run tests in one file (single/op/add, single/op/sub, ...)
252
+ ./ccex test -k add
253
+ ./ccex test -k sub
254
+
255
+ # To run SimpleAdd test in test/modules/single/op/add.py
256
+ ./ccex test -k SimpleAdd
257
+ ```
258
+
259
+ To see the full debug log, add `-v` or `TICO_LOG=4`.
260
+
261
+ ```bash
262
+ TICO_LOG=4 ./ccex test -k add
263
+ # OR
264
+ ./ccex test -v -k add
265
+ ```
266
+
267
+ #### Test Model
268
+
269
+ If you want to test them locally, you can do so by navigating to each model directory,
270
+ installing the dependencies listed in its `requirements.txt`, and running the tests one by one.
271
+ ```bash
272
+ $ pip install -r test/modules/model/<model_name>/requirements.txt
273
+ # Run test for a single model
274
+ $ ./ccex test -m <model_name>
275
+ ```
276
+
277
+ For example, to run a single model
278
+ ```
279
+ ./ccex test -m InceptionV3
280
+ ```
281
+
282
+ ### Code Formatting
283
+
284
+ #### Format configure
285
+
286
+ Run below commands to install requirements for formatting.
287
+
288
+ ```bash
289
+ ./ccex configure format
290
+ ```
291
+
292
+ #### Format run
293
+
294
+ ```bash
295
+ ./ccex format
296
+ ```
297
+
@@ -1,4 +1,4 @@
1
- tico/__init__.py,sha256=3ox6RnlXIaWboX14JLH-rtpN5tkKhFYvkxQ9RjZwaYo,1181
1
+ tico/__init__.py,sha256=drwOk40YiN-xglot_aW8vG4uxq2GWx4F853Gxd6Jdv0,1181
2
2
  tico/pt2_to_circle.py,sha256=PPmFNw20jw2Z2VyM3ln9pX__jTzBOAZiv0gT5a-p-Y8,2666
3
3
  tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
4
4
  tico/config/base.py,sha256=anwOiJFkUxUi7Cef573JgQcjk6S-FSi6O_TLjYASW-g,1244
@@ -188,9 +188,9 @@ tico/utils/register_custom_op.py,sha256=FbMcrg8o5vKWC_aoVxL2GrIcR14KFi1yKG0mFGqX
188
188
  tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
189
189
  tico/utils/utils.py,sha256=pybDU1LoNhjEplANig11lboX9yzYRkvFCSmyYth_2Do,10359
190
190
  tico/utils/validate_args_kwargs.py,sha256=DXW7W5x-6pQR43_q4EFoeWE5pn1Nm7gNsrzaO5avm4k,24724
191
- tico-0.1.0.dev250411.dist-info/LICENSE,sha256=dAq6L2M49W6wEPmkyVtYxE3Omm3oInXPd6qw5mQX6wY,12644
192
- tico-0.1.0.dev250411.dist-info/METADATA,sha256=0QMEluiyKjjlcPwY-ONXF-zpMHPUUz65amgjaay7A8A,336
193
- tico-0.1.0.dev250411.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
194
- tico-0.1.0.dev250411.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
195
- tico-0.1.0.dev250411.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
196
- tico-0.1.0.dev250411.dist-info/RECORD,,
191
+ tico-0.1.0.dev250414.dist-info/LICENSE,sha256=dAq6L2M49W6wEPmkyVtYxE3Omm3oInXPd6qw5mQX6wY,12644
192
+ tico-0.1.0.dev250414.dist-info/METADATA,sha256=NxIJgt_iKq8KOz07g5VLVRyCv7Q9UQXJYML-EWcQYoY,7353
193
+ tico-0.1.0.dev250414.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
194
+ tico-0.1.0.dev250414.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
195
+ tico-0.1.0.dev250414.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
196
+ tico-0.1.0.dev250414.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: tico
3
- Version: 0.1.0.dev250411
4
- Summary: Convert exported Torch module to circle
5
- Home-page: UNKNOWN
6
- License: UNKNOWN
7
- Platform: UNKNOWN
8
- Requires-Python: >=3.10.0
9
- License-File: LICENSE
10
- Requires-Dist: cffi
11
- Requires-Dist: circle-schema
12
- Requires-Dist: packaging
13
- Requires-Dist: pyyaml
14
- Requires-Dist: torch
15
-
16
- UNKNOWN
17
-