From 67418f2a12cdcb410cf31138c9bec9dfba7be69f Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 17 Oct 2019 23:03:02 -0700 Subject: [PATCH 1/5] Start to update TF frontend docs --- docs/frontend/tensorflow.md | 63 +++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/docs/frontend/tensorflow.md b/docs/frontend/tensorflow.md index 06a6fcc32b4f..a787678bec33 100644 --- a/docs/frontend/tensorflow.md +++ b/docs/frontend/tensorflow.md @@ -16,38 +16,55 @@ # Tensorflow Frontend -Tensorflow frontend helps in importing tensorflow released model into TVM. +The Tensorflow frontend helps in importing TensorFlow models into TVM. -This document helps few steps while importing various different models from -[tensorflow research/slim](https://github.com/tensorflow/models/tree/master/research/slim). +Supported versions: +- 1.12 and below -Current frontend is tested with all versions of below models +Tested models: - Inception (V1/V2/V3/V4) - Resnet (All) - Mobilenet (V1/V2 All) - Vgg (16/19) +- BERT (Base/3-layer) -Tensorflow frontend expects a freezed protobuf format as input. +## Preparing a Model for Inference -Not all models are released as freezed protobuf. Some of them are checkpoints (.ckpt). -Please refer to [export](https://github.com/tensorflow/models/tree/master/research/slim#exporting-the-inference-graph) -and [freeze](https://github.com/tensorflow/models/tree/master/research/slim#freezing-the-exported-graph) -instructions to generate protobuf from checkpoint. +### Remove Unneeded Nodes -## General Instructions +The export process will remove many nodes that are not needed for inference, but unfortunately will leave some remaining. +The nodes that should be manually removed are: +- Dropout, including the [dropout node](https://www.tensorflow.org/api_docs/python/tf/nn/dropout) and [dropout wrapper](https://www.tensorflow.org/versions/r1.12/api_docs/python/tf/nn/rnn_cell/DropoutWrapper?hl=hr) +- Assert -### Add Shapes: -While freezing of protobuf add additional option ```add_shapes=True``` to embed output shapes of each node into graph. -You may use ```tvm.relay.testing.tf.AddShapesToGraphDef``` from nnvm for the same. -Please refer to [tensorflow tutorial](https://github.com/dmlc/tvm/blob/master/tutorials/nnvm/from_tensorflow.py). +### Convert None Dimensions to Constants + +TVM has minimal support for dynamic tensor shapes. Dimensions that are ```None``` should be replaced with constants. For example, a model may accept an input with shape ```(None,20)```. This should be converted to something like ```(1,20)```. The model should be modified accordingly to ensure that these shapes match throughout the graph. + +### Export + +TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). +The graphdef needed to pass into the TensorFlow frontend can be extracted using the [TFParser](https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py) helper class. + +The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```. This will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: + +```TODO: code example``` + +Another method is to [export and freeze the graph](https://github.com/tensorflow/models/tree/master/research/slim#exporting-the-inference-graph). + +## Import the Model + +## Explicit Shape: +```add_shapes=True``` might not provide sufficient shape information. Passing an explicit dictionary of input names to shape in ```from_tensorflow``` will help ensure that the shapes can be known throughout the entire graph. Please refer to these [test cases](https://github.com/dmlc/tvm/blob/master/nnvm/tests/python/frontend/tensorflow/test_forward.py#L36) as an example. + +## Data Layout +Most TensorFlow models are released with NHWC layout. NCHW layout often provides better performance, especially on GPU. The TensorFlow frontend can automatically convert the model's data layout by passing the argument ```layout='NCHW'``` to ```from_tensorflow```. + +## Best Practices + +- Use static tensor shapes instead of dynamic shapes (remove ```None``` dimensions). +- Use static RNN instead of dynamic RNN, as ```TensorArray``` isn't supported yet. + +## Supported Ops -### Explicit Shape: -There might be situations where the add_shapes=True may not provide sufficient information about shape. -You may pass explicit dictionary of input shapes argument for ```from_tensorflow```. -Please refer to [test cases](https://github.com/dmlc/tvm/blob/master/nnvm/tests/python/frontend/tensorflow/test_forward.py#L36). -### GPU: -Most of these tensorflow models are released for CPU with NHWC layout. -To compile for GPU we need to pass extra argument ```layout='NCHW'``` for from_tensorflow. -This option will do a layout conversion before and after for neural network ops. -Remaining nnvm build options for GPU compilation remain as it is. From e935435697994b37c88d29cabee0497e0816524c Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2019 10:01:46 -0700 Subject: [PATCH 2/5] Add rst --- docs/frontend/tensorflow.md | 160 +++++++++++++++++++++++-- docs/frontend/tensorflow.rst | 226 +++++++++++++++++++++++++++++++++++ docs/index.rst | 6 + 3 files changed, 379 insertions(+), 13 deletions(-) create mode 100644 docs/frontend/tensorflow.rst diff --git a/docs/frontend/tensorflow.md b/docs/frontend/tensorflow.md index a787678bec33..c9b7fc207b0b 100644 --- a/docs/frontend/tensorflow.md +++ b/docs/frontend/tensorflow.md @@ -32,32 +32,56 @@ Tested models: ### Remove Unneeded Nodes -The export process will remove many nodes that are not needed for inference, but unfortunately will leave some remaining. -The nodes that should be manually removed are: +The export process will remove many nodes that are not needed for inference, but unfortunately will leave some remaining. The nodes that should be manually removed are: - Dropout, including the [dropout node](https://www.tensorflow.org/api_docs/python/tf/nn/dropout) and [dropout wrapper](https://www.tensorflow.org/versions/r1.12/api_docs/python/tf/nn/rnn_cell/DropoutWrapper?hl=hr) - Assert ### Convert None Dimensions to Constants -TVM has minimal support for dynamic tensor shapes. Dimensions that are ```None``` should be replaced with constants. For example, a model may accept an input with shape ```(None,20)```. This should be converted to something like ```(1,20)```. The model should be modified accordingly to ensure that these shapes match throughout the graph. +TVM has minimal support for dynamic tensor shapes. Dimensions that are ```None``` should be replaced with constants. For example, a model may accept an input with shape ```(None,20)```. This should be converted to a shape like ```(1,20)```. The model should be modified accordingly to ensure that these shapes match throughout the graph. ### Export -TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). -The graphdef needed to pass into the TensorFlow frontend can be extracted using the [TFParser](https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py) helper class. - -The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```. This will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: - -```TODO: code example``` +TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the [TFParser](https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py) helper class. + +The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```, as this will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: + +```python +import tensorflow as tf +from tensorflow.tools.graph_transforms import TransformGraph + +def export_pb(session): + with tf.gfile.GFile("myexportedmodel.pb", "wb") as f: + inputs = ["myinput1", "myinput2"] # replace with your input names + outputs = ["myoutput1"] # replace with your output names + graph_def = session.graph.as_graph_def(add_shapes=True) + graph_def = tf.graph.util.convert_variables_to_constants(session, graph_def, outputs) + graph_def = TransformGraph( + graph_def, + inputs, + outputs, + [ + "remove_nodes(op=Identity, op=CheckNumerics, op=StopGradient)", + "sort_by_execution_order", # sort by execution order after each transform to ensure correct node ordering + "remove_device", + "sort_by_execution_order", + "fold_batch_norms", + "sort_by_execution_order", + "fold_old_batch_norms", + "sort_by_execution_order" + ] + ) + f.write(graph_def.SerializeToString()) +``` Another method is to [export and freeze the graph](https://github.com/tensorflow/models/tree/master/research/slim#exporting-the-inference-graph). ## Import the Model -## Explicit Shape: -```add_shapes=True``` might not provide sufficient shape information. Passing an explicit dictionary of input names to shape in ```from_tensorflow``` will help ensure that the shapes can be known throughout the entire graph. Please refer to these [test cases](https://github.com/dmlc/tvm/blob/master/nnvm/tests/python/frontend/tensorflow/test_forward.py#L36) as an example. +### Explicit Shape: +To ensure shapes can be known throughout the entire graph, pass the ```shape``` argument to ```from_tensorflow```. This dictionary maps input names to input shapes. Please refer to these [test cases](https://github.com/dmlc/tvm/blob/master/nnvm/tests/python/frontend/tensorflow/test_forward.py#L36) for examples. -## Data Layout +### Data Layout Most TensorFlow models are released with NHWC layout. NCHW layout often provides better performance, especially on GPU. The TensorFlow frontend can automatically convert the model's data layout by passing the argument ```layout='NCHW'``` to ```from_tensorflow```. ## Best Practices @@ -67,4 +91,114 @@ Most TensorFlow models are released with NHWC layout. NCHW layout often provides ## Supported Ops - +- Abs +- Add +- All +- ArgMax +- ArgMin +- AvgPool +- BatchMatMul +- BatchMatMulV2 +- BatchNormWithGlobalNormalization +- BatchToSpaceND +- BiasAdd +- BroadcastTo +- Cast +- Ceil +- CheckNumerics +- ClipByValue +- Concat +- ConcatV2 +- Conv2D +- CropAndResize +- DecodeJpeg +- DepthwiseConv2dNative +- DepthToSpace +- Equal +- Elu +- Erf +- Exp +- ExpandDims +- Fill +- Floor +- FloorDiv +- FusedBatchNorm +- FusedBatchNormV2 +- Gather +- GatherNd +- GatherV2 +- Greater +- GreaterEqual +- Identity +- LeakyRelu +- LeftShift +- Less +- LessEqual +- Log +- Log1p +- Cos +- Sin +- LogicalAnd +- LogicalOr +- LogicalNot +- LogSoftmax +- LRN +- MatMul +- Max +- MaxPool +- Maximum +- Mean +- Min +- Minimum +- MirrorPad +- Mod +- Mul +- Neg +- NotEqual +- OneHot +- Pack +- Pad +- PadV2 +- Pow +- Prod +- range +- Rank +- RealDiv +- Relu +- Relu6 +- Reshape +- ResizeBilinear +- ResizeBicubic +- ResizeNearestNeighbor +- ReverseV2 +- RightShift +- Round +- Rsqrt +- Select +- Selu +- Shape +- Sigmoid +- Sign +- Size +- Slice +- Softmax +- Softplus +- SpaceToBatchND +- SpaceToDepth, +- Split +- SplitV +- Sqrt +- Square +- SquareDifference +- Squeeze +- StridedSlice +- Sub +- Sum +- Tanh +- Tile +- TopKV2 +- Transpose +- TruncateMod +- Unpack +- Where +- ZerosLike \ No newline at end of file diff --git a/docs/frontend/tensorflow.rst b/docs/frontend/tensorflow.rst new file mode 100644 index 000000000000..6afc3295b36c --- /dev/null +++ b/docs/frontend/tensorflow.rst @@ -0,0 +1,226 @@ +.. Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + +.. http://www.apache.org/licenses/LICENSE-2.0 + +.. Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +TensorFlow Frontend +=================== + +The TensorFlow frontend helps in importing TensorFlow models into TVM. + +Supported versions: + +- 1.12 and below + +Tested models: + +- Inception (V1/V2/V3/V4) +- Resnet (All) +- Mobilenet (V1/V2 All) +- Vgg (16/19) +- BERT (Base/3-layer) + +Preparing a Model for Inference +------------------------------- + +Remove Unneeded Nodes +~~~~~~~~~~~~~~~~~~~~~ + +The export process will remove many nodes that are not needed for inference, but unfortunately will leave some remaining. The nodes that should be manually removed are: + +- Dropout, including `Dropout`_ and `DropoutWrapper`_ +- `Assert`_ + +.. _Dropout: https://www.tensorflow.org/api_docs/python/tf/nn/dropout +.. _DropoutWrapper: https://www.tensorflow.org/versions/r1.12/api_docs/python/tf/nn/rnn_cell/DropoutWrapper?hl=hr +.. _Assert: https://www.tensorflow.org/api_docs/python/tf/debugging/Assert + +Convert None Dimensions to Constants +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +TVM has minimal support for dynamic tensor shapes. Dimensions that are ``None`` should be replaced with constants. For example, a model may accept an input with shape ``(None,20)``. This should be converted to a shape like ``(1,20)``. The model should be modified accordingly to ensure that these shapes match throughout the graph. + +Export +~~~~~~ + +TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the `TFParser`_ helper class. + +.. _TFParser: https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py + +The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```, as this will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: + +.. code:: python + + import tensorflow as tf + from tensorflow.tools.graph_transforms import TransformGraph + + def export_pb(session): + with tf.gfile.GFile("myexportedmodel.pb", "wb") as f: + inputs = ["myinput1", "myinput2"] # replace with your input names + outputs = ["myoutput1"] # replace with your output names + graph_def = session.graph.as_graph_def(add_shapes=True) + graph_def = tf.graph.util.convert_variables_to_constants(session, graph_def, outputs) + graph_def = TransformGraph( + graph_def, + inputs, + outputs, + [ + "remove_nodes(op=Identity, op=CheckNumerics, op=StopGradient)", + "sort_by_execution_order", # sort by execution order after each transform to ensure correct node ordering + "remove_device", + "sort_by_execution_order", + "fold_batch_norms", + "sort_by_execution_order", + "fold_old_batch_norms", + "sort_by_execution_order" + ] + ) + f.write(graph_def.SerializeToString()) + +Another method is to `export and freeze the graph `_. + +Import the Model +---------------- + +Explicit Shape: +~~~~~~~~~~~~~~~ + +To ensure shapes can be known throughout the entire graph, pass the ```shape``` argument to ```from_tensorflow```. This dictionary maps input names to input shapes. Please refer to these `test cases `_ for examples. + +Data Layout +~~~~~~~~~~~ + +Most TensorFlow models are released with NHWC layout. NCHW layout often provides better performance, especially on GPU. The TensorFlow frontend can automatically convert the model's data layout by passing the argument ```layout='NCHW'``` to ```from_tensorflow```. + +Best Practices +-------------- + +- Use static tensor shapes instead of dynamic shapes (remove ```None``` dimensions). +- Use static RNN instead of dynamic RNN, as ```TensorArray``` isn't supported yet. + +Supported Ops +------------- + +- Abs +- Add +- All +- ArgMax +- ArgMin +- AvgPool +- BatchMatMul +- BatchMatMulV2 +- BatchNormWithGlobalNormalization +- BatchToSpaceND +- BiasAdd +- BroadcastTo +- Cast +- Ceil +- CheckNumerics +- ClipByValue +- Concat +- ConcatV2 +- Conv2D +- CropAndResize +- DecodeJpeg +- DepthwiseConv2dNative +- DepthToSpace +- Equal +- Elu +- Erf +- Exp +- ExpandDims +- Fill +- Floor +- FloorDiv +- FusedBatchNorm +- FusedBatchNormV2 +- Gather +- GatherNd +- GatherV2 +- Greater +- GreaterEqual +- Identity +- LeakyRelu +- LeftShift +- Less +- LessEqual +- Log +- Log1p +- Cos +- Sin +- LogicalAnd +- LogicalOr +- LogicalNot +- LogSoftmax +- LRN +- MatMul +- Max +- MaxPool +- Maximum +- Mean +- Min +- Minimum +- MirrorPad +- Mod +- Mul +- Neg +- NotEqual +- OneHot +- Pack +- Pad +- PadV2 +- Pow +- Prod +- range +- Rank +- RealDiv +- Relu +- Relu6 +- Reshape +- ResizeBilinear +- ResizeBicubic +- ResizeNearestNeighbor +- ReverseV2 +- RightShift +- Round +- Rsqrt +- Select +- Selu +- Shape +- Sigmoid +- Sign +- Size +- Slice +- Softmax +- Softplus +- SpaceToBatchND +- SpaceToDepth, +- Split +- SplitV +- Sqrt +- Square +- SquareDifference +- Squeeze +- StridedSlice +- Sub +- Sum +- Tanh +- Tile +- TopKV2 +- Transpose +- TruncateMod +- Unpack +- Where +- ZerosLike diff --git a/docs/index.rst b/docs/index.rst index 9666fff0c5d3..f02dcc7c91e2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -47,6 +47,12 @@ Developer Guide dev/index nnvm_top +Frontends +---------------- +.. toctree:: + :maxdepth: 1 + + frontend/tensorflow Index ----- From 0264a861d236c93def7a04bfa54508f77e81676e Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2019 10:01:58 -0700 Subject: [PATCH 3/5] Remove markdown --- docs/frontend/tensorflow.md | 204 ------------------------------------ 1 file changed, 204 deletions(-) delete mode 100644 docs/frontend/tensorflow.md diff --git a/docs/frontend/tensorflow.md b/docs/frontend/tensorflow.md deleted file mode 100644 index c9b7fc207b0b..000000000000 --- a/docs/frontend/tensorflow.md +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - -# Tensorflow Frontend -The Tensorflow frontend helps in importing TensorFlow models into TVM. - -Supported versions: -- 1.12 and below - -Tested models: -- Inception (V1/V2/V3/V4) -- Resnet (All) -- Mobilenet (V1/V2 All) -- Vgg (16/19) -- BERT (Base/3-layer) - -## Preparing a Model for Inference - -### Remove Unneeded Nodes - -The export process will remove many nodes that are not needed for inference, but unfortunately will leave some remaining. The nodes that should be manually removed are: -- Dropout, including the [dropout node](https://www.tensorflow.org/api_docs/python/tf/nn/dropout) and [dropout wrapper](https://www.tensorflow.org/versions/r1.12/api_docs/python/tf/nn/rnn_cell/DropoutWrapper?hl=hr) -- Assert - -### Convert None Dimensions to Constants - -TVM has minimal support for dynamic tensor shapes. Dimensions that are ```None``` should be replaced with constants. For example, a model may accept an input with shape ```(None,20)```. This should be converted to a shape like ```(1,20)```. The model should be modified accordingly to ensure that these shapes match throughout the graph. - -### Export - -TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the [TFParser](https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py) helper class. - -The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```, as this will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: - -```python -import tensorflow as tf -from tensorflow.tools.graph_transforms import TransformGraph - -def export_pb(session): - with tf.gfile.GFile("myexportedmodel.pb", "wb") as f: - inputs = ["myinput1", "myinput2"] # replace with your input names - outputs = ["myoutput1"] # replace with your output names - graph_def = session.graph.as_graph_def(add_shapes=True) - graph_def = tf.graph.util.convert_variables_to_constants(session, graph_def, outputs) - graph_def = TransformGraph( - graph_def, - inputs, - outputs, - [ - "remove_nodes(op=Identity, op=CheckNumerics, op=StopGradient)", - "sort_by_execution_order", # sort by execution order after each transform to ensure correct node ordering - "remove_device", - "sort_by_execution_order", - "fold_batch_norms", - "sort_by_execution_order", - "fold_old_batch_norms", - "sort_by_execution_order" - ] - ) - f.write(graph_def.SerializeToString()) -``` - -Another method is to [export and freeze the graph](https://github.com/tensorflow/models/tree/master/research/slim#exporting-the-inference-graph). - -## Import the Model - -### Explicit Shape: -To ensure shapes can be known throughout the entire graph, pass the ```shape``` argument to ```from_tensorflow```. This dictionary maps input names to input shapes. Please refer to these [test cases](https://github.com/dmlc/tvm/blob/master/nnvm/tests/python/frontend/tensorflow/test_forward.py#L36) for examples. - -### Data Layout -Most TensorFlow models are released with NHWC layout. NCHW layout often provides better performance, especially on GPU. The TensorFlow frontend can automatically convert the model's data layout by passing the argument ```layout='NCHW'``` to ```from_tensorflow```. - -## Best Practices - -- Use static tensor shapes instead of dynamic shapes (remove ```None``` dimensions). -- Use static RNN instead of dynamic RNN, as ```TensorArray``` isn't supported yet. - -## Supported Ops - -- Abs -- Add -- All -- ArgMax -- ArgMin -- AvgPool -- BatchMatMul -- BatchMatMulV2 -- BatchNormWithGlobalNormalization -- BatchToSpaceND -- BiasAdd -- BroadcastTo -- Cast -- Ceil -- CheckNumerics -- ClipByValue -- Concat -- ConcatV2 -- Conv2D -- CropAndResize -- DecodeJpeg -- DepthwiseConv2dNative -- DepthToSpace -- Equal -- Elu -- Erf -- Exp -- ExpandDims -- Fill -- Floor -- FloorDiv -- FusedBatchNorm -- FusedBatchNormV2 -- Gather -- GatherNd -- GatherV2 -- Greater -- GreaterEqual -- Identity -- LeakyRelu -- LeftShift -- Less -- LessEqual -- Log -- Log1p -- Cos -- Sin -- LogicalAnd -- LogicalOr -- LogicalNot -- LogSoftmax -- LRN -- MatMul -- Max -- MaxPool -- Maximum -- Mean -- Min -- Minimum -- MirrorPad -- Mod -- Mul -- Neg -- NotEqual -- OneHot -- Pack -- Pad -- PadV2 -- Pow -- Prod -- range -- Rank -- RealDiv -- Relu -- Relu6 -- Reshape -- ResizeBilinear -- ResizeBicubic -- ResizeNearestNeighbor -- ReverseV2 -- RightShift -- Round -- Rsqrt -- Select -- Selu -- Shape -- Sigmoid -- Sign -- Size -- Slice -- Softmax -- Softplus -- SpaceToBatchND -- SpaceToDepth, -- Split -- SplitV -- Sqrt -- Square -- SquareDifference -- Squeeze -- StridedSlice -- Sub -- Sum -- Tanh -- Tile -- TopKV2 -- Transpose -- TruncateMod -- Unpack -- Where -- ZerosLike \ No newline at end of file From e47057969af0573f52589a80f4a967aba0bb7fe7 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2019 10:05:47 -0700 Subject: [PATCH 4/5] Update wording --- docs/frontend/tensorflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/frontend/tensorflow.rst b/docs/frontend/tensorflow.rst index 6afc3295b36c..453066ce6850 100644 --- a/docs/frontend/tensorflow.rst +++ b/docs/frontend/tensorflow.rst @@ -55,7 +55,7 @@ TVM has minimal support for dynamic tensor shapes. Dimensions that are ``None`` Export ~~~~~~ -TensorFlow frontend expects a freezed protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the `TFParser`_ helper class. +TensorFlow frontend expects a frozen protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the `TFParser`_ helper class. .. _TFParser: https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py From 1ea72406eb69d3ec1169e8c08eab77cf870239e1 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 21 Oct 2019 09:46:10 -0700 Subject: [PATCH 5/5] Resolve comments --- docs/frontend/tensorflow.rst | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/frontend/tensorflow.rst b/docs/frontend/tensorflow.rst index 453066ce6850..827f5d637988 100644 --- a/docs/frontend/tensorflow.rst +++ b/docs/frontend/tensorflow.rst @@ -57,7 +57,7 @@ Export TensorFlow frontend expects a frozen protobuf (.pb) or saved model as input. It currently does not support checkpoint (.ckpt). The graphdef needed by the TensorFlow frontend can be extracted from the active session, or by using the `TFParser`_ helper class. -.. _TFParser: https://github.com/dmlc/tvm/blob/77445311540c0dfa7b124304b5cf89da6f2c210f/python/tvm/relay/frontend/tensorflow_parser.py +.. _TFParser: https://github.com/dmlc/tvm/blob/master/python/tvm/relay/frontend/tensorflow_parser.py The model should be exported with a number of transformations to prepare the model for inference. It is also important to set ```add_shapes=True```, as this will embed the output shapes of each node into the graph. Here is one function to export a model as a protobuf given a session: @@ -132,13 +132,16 @@ Supported Ops - Concat - ConcatV2 - Conv2D +- Cos - CropAndResize - DecodeJpeg - DepthwiseConv2dNative - DepthToSpace - Equal - Elu +- Enter - Erf +- Exit - Exp - ExpandDims - Fill @@ -158,24 +161,26 @@ Supported Ops - LessEqual - Log - Log1p -- Cos -- Sin +- LoopCond - LogicalAnd - LogicalOr - LogicalNot - LogSoftmax - LRN +- LSTMBlockCell - MatMul - Max - MaxPool - Maximum - Mean +- Merge - Min - Minimum - MirrorPad - Mod - Mul - Neg +- NextIteration - NotEqual - OneHot - Pack @@ -183,7 +188,7 @@ Supported Ops - PadV2 - Pow - Prod -- range +- Range - Rank - RealDiv - Relu @@ -201,6 +206,7 @@ Supported Ops - Shape - Sigmoid - Sign +- Sin - Size - Slice - Softmax @@ -216,7 +222,16 @@ Supported Ops - StridedSlice - Sub - Sum +- Switch - Tanh +- TensorArrayV3 +- TensorArrayScatterV3 +- TensorArrayGatherV3 +- TensorArraySizeV3 +- TensorArrayWriteV3 +- TensorArrayReadV3 +- TensorArraySplitV3 +- TensorArrayConcatV3 - Tile - TopKV2 - Transpose