From: 박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 27 Jun 2019 07:10:18 +0000 (+0900) Subject: [moco/tf] How to convert TensorFlow Const (#4002) X-Git-Tag: nncc_backup~249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6880c45634920015adfd5865c3c5eada8379fda0;p=platform%2Fcore%2Fml%2Fnnfw.git [moco/tf] How to convert TensorFlow Const (#4002) Conversion.md now explains how to convert T/F Const node (which tf.constant API internally generates) into loco. Signed-off-by: Jonghyun Park --- diff --git a/contrib/moco-tf/doc/Conversion.md b/contrib/moco-tf/doc/Conversion.md index 55492aa..08551cc 100644 --- a/contrib/moco-tf/doc/Conversion.md +++ b/contrib/moco-tf/doc/Conversion.md @@ -94,3 +94,47 @@ _loco_: %ident = Forward(%input) Push(%ident) ``` + +### Const + +**Const** in _TensorFlow_ corresponds to **ConstGen** in _loco_. + +_Python_: +```python +import tensorflow as tf +constant = tf.constant(value=[1.0], dtype=tf.float32, shape=[3, 4]) +tf.get_default_graph().as_graph_def() +``` + +API reference: [tf.constant](https://www.tensorflow.org/versions/r1.13/api_docs/python/tf/constant) + +_TensorFlow_: +``` +node { + name: "Const" + op: "Const" + attr { + key: "dtype" + value { type: DT_FLOAT } + } + attr { + key: "value" + value { + tensor { + dtype: DT_FLOAT + tensor_shape { + dim { size: 3 } + dim { size: 4 } + } + float_val: 1.0 + } + } + } +} +``` + +_loco_: +``` +%constant = ConstGen(dtype: FLOAT32, shape: [3, 4], data: ...); +Push(%constant) +```