[moco/tf] How to convert TensorFlow Const (#4002)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 27 Jun 2019 07:10:18 +0000 (16:10 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 27 Jun 2019 07:10:18 +0000 (16:10 +0900)
Conversion.md now explains how to convert T/F Const node (which
tf.constant API internally generates) into loco.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/moco-tf/doc/Conversion.md

index 55492aa..08551cc 100644 (file)
@@ -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)
+```