@@ -72,26 +72,22 @@ Overall Architecture
7272
7373::
7474
75- ============ +-----------------+ ===================
76- || model file || --> | frontend Parser | --> || uTensorGraph (IR) ||
77- ============ +-----------------+ ===================
78- |
79- +-------------------------------+ |
80- | graph transformer | |
81- | (legalization & optimization) | <------/
82- +-------------------------------+
83- |
84- v
85- ===========================
86- || uTensorGraph ||
87- || (legalized and optimized) ||
88- ===========================
89- |
90- +--------------------------+ |
91- | backend (code generator) | <----/
75+ ============ +-----------------+ ============================
76+ || model file || --> | frontend Parser | --> || uTensorGraph (IR, generic) ||
77+ ============ +-----------------+ ============================
78+ |
79+ v
80+ +---------------------+
81+ ======================= | graph transformer |
82+ || uTensorGraph || <-- | (optimization) |
83+ || (generic, optimized) || +---------------------+
84+ =======================
85+ |
86+ +--------------------------+ |
87+ | backend (code generator) | <--/
9288 +--------------------------+
9389 |
94- `---> (target files, ex: model.cpp, model.hpp, weights.idx)
90+ `---> (target files, ex: model.cpp, model.hpp, weights.idx, ...etc )
9591
9692Basic Usage
9793===========
@@ -114,7 +110,8 @@ Convert Model File to C/C++ Code
114110.. code-block :: console
115111
116112 $ utensor-cli convert <model.pb> \
117- --output-nodes=<node_name>[,<node_name>,...]
113+ --output-nodes=<node name>[,<node name>,...] \
114+ [--config=config.toml]
118115
119116 Convert given pb file into cpp/hpp files.
120117
@@ -123,6 +120,8 @@ nodes you want to output, seperated by comma for multiple values.
123120
124121In graph theory terminology, they are ``leaf `` nodes of your graph.
125122
123+ Use ``--config `` to pass a configuration file to the cli, you can use ``generate-config `` command to generate one (see below).
124+
126125example
127126~~~~~~~
128127
@@ -132,8 +131,34 @@ example
132131
133132 Run ``utensor-cli convert --help `` for detailed information.
134133
135- :mod: `utensor_cgen ` as Library
136- ==============================
134+ Configuration
135+ -------------
136+
137+ ``utensor-cli `` use ``toml `` as configuration format.
138+
139+ You can generate configuration file of given target as following:
140+
141+ .. code-block :: console
142+
143+ $ utensor-cli generate-config --target <target name> [-o filename.toml]
144+
145+ This command will generate a ``toml `` file listing all configurable values with its defaults.
146+
147+ You can modify the value and pass the file to cli with ``--config `` flag.
148+
149+ example
150+ ~~~~~~~
151+
152+ .. code-block :: console
153+
154+ # generate config file
155+ $ utensor-cli generate-config --target utensor -o myconfig.toml
156+
157+ # after editting myconfig.toml
158+ $ utensor-cli convert mymodel.pb --config=myconfig.toml --output-nodes=output,...
159+
160+ Use :mod: `utensor_cgen ` as Library
161+ ==================================
137162
138163.. subgraph-match-begine
139164
@@ -201,12 +226,32 @@ Use Case: Dropout Layer Removal
201226
202227\ |cnn-dropout |
203228
204- .. subgraph-match-end
205-
206229We use mainly `Tensorflow `_ for declaring the pattern graph for matcher now.
207230
208231High-level graph builder is on its way, see `Future Works <#future-works >`_ for detail.
209232
233+ .. subgraph-match-end
234+
235+ .. offline-tensor-alloc-start
236+
237+ Offline Tensor Memory Allocation
238+ --------------------------------
239+
240+ Considering following simple multi layers perceptron (`simple_mnist.pb `_):
241+
242+ \ |mlp-alloc-graph |
243+
244+ Once enabled the optimization transformer, ``tensor_alloc ``, an offline tensor memory allocation planner,
245+ ``utensor-cli `` will generate ``uTensor `` runtime codes that use following optimized allocation plan:
246+
247+ \ |mlp-alloc |
248+
249+ - y-axis: tensor names ordered by topological sorting
250+ - x-axis: these are the memory span occupied by each tensor, that is, the memory address offset and
251+ the size of the tensor
252+
253+ .. offline-tensor-alloc-end
254+
210255 Tutorials
211256=========
212257
@@ -223,8 +268,8 @@ TensorFlow_
223268
2242691. Freeze your `tensorflow.Graph `
225270
226- - please refer to the ` official doc <https://www. tensorflow.org/guide/extend/model_files >`_
227- and read the ` Freezing <https://www. tensorflow.org/guide/extend/model_files#freezing >`_ section
271+ - please refer to this ` issue track <https://github.com/ tensorflow/tensorflow/issues/27614 >`_ for detail
272+ - especially this ` comment <https://github.com/ tensorflow/tensorflow/issues/27614#issuecomment-571889676 >`_ by Robin2091
228273
2292742. Follow instructions in :ref: `install ` section to install :mod: `utensor_cgen `
230275
@@ -288,6 +333,7 @@ Future Works
288333.. _Tensorflow : https://www.tensorflow.org
289334.. _PyTorch : https://pytorch.org/
290335.. _uTensor : https://github.com/uTensor/uTensor
336+ .. _simple_mnist.pb : https://github.com/uTensor/utensor_cgen/blob/develop/tests/deep_mlp/simple_mnist.pb
291337
292338.. readme_end
293339
@@ -297,7 +343,10 @@ Future Works
297343 :alt: conv-pool-fuse
298344.. |convert-example | image :: doc/source/_images/convert_example.png
299345 :alt: convert-example
300-
346+ .. |mlp-alloc | image :: doc/source/_images/mlp_alloc.png
347+ :alt: mlp-alloc
348+ .. |mlp-alloc-graph | image :: doc/source/_images/mlp_alloc_graph.png
349+ :alt: mlp-alloc-graph
301350
302351.. TODOs
303352.. =====
0 commit comments