Forums - Cannot convert dense layers: ERROR - Conversion failed: Some operations in the Tensorflow graph were not resolved to a layer!

10 posts / 0 new
Last post
Cannot convert dense layers: ERROR - Conversion failed: Some operations in the Tensorflow graph were not resolved to a layer!
vellamike
Join Date: 23 Oct 17
Posts: 11
Posted: Thu, 2017-11-02 06:56

When converting a custom tensorflow graph I am seeing errors relating to the conversion of a dense layer to DLC:

2017-11-02 13:43:35,260 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/transpose) not consumed by converter: Transpose.
2017-11-02 13:43:35,261 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/transpose_1) not consumed by converter: Transpose.
2017-11-02 13:43:35,261 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/MatMul) not consumed by converter: MatMul.
2017-11-02 13:43:35,261 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/BiasAdd) not consumed by converter: BiasAdd.
2017-11-02 13:43:35,261 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/transpose) not consumed by converter: Transpose.
2017-11-02 13:43:35,262 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/transpose_1) not consumed by converter: Transpose.
2017-11-02 13:43:35,262 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/MatMul) not consumed by converter: MatMul.
2017-11-02 13:43:35,262 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/BiasAdd) not consumed by converter: BiasAdd.
2017-11-02 13:43:35,263 - 123 - ERROR - Conversion failed: Some operations in the Tensorflow graph were not resolved to a layer!
I am a bit confused by this because the layer is simply a dense layer following a 2D convolutional which I am sure is supported by the SNPE. What is the cause of the error?
 
The topology of the graph is as follows:
 
0 input_layer Placeholder
1 conv2d/kernel Const
2 conv2d/kernel/read Identity
└─── Input0 ─ conv2d/kernel
3 conv2d/bias Const
4 conv2d/bias/read Identity
└─── Input0 ─ conv2d/bias
5 conv2d/convolution Conv2D
└─── Input0 ─ input_layer
└─── Input1 ─ conv2d/kernel/read
6 conv2d/BiasAdd BiasAdd
└─── Input0 ─ conv2d/convolution
└─── Input1 ─ conv2d/bias/read
7 conv2d/Relu Relu
└─── Input0 ─ conv2d/BiasAdd
8 max_pooling2d/MaxPool MaxPool
└─── Input0 ─ conv2d/Relu
9 conv2d_1/kernel Const
10 conv2d_1/kernel/read Identity
└─── Input0 ─ conv2d_1/kernel
11 conv2d_1/bias Const
12 conv2d_1/bias/read Identity
└─── Input0 ─ conv2d_1/bias
13 conv2d_2/convolution Conv2D
└─── Input0 ─ max_pooling2d/MaxPool
└─── Input1 ─ conv2d_1/kernel/read
14 conv2d_2/BiasAdd BiasAdd
└─── Input0 ─ conv2d_2/convolution
└─── Input1 ─ conv2d_1/bias/read
15 conv2d_2/Relu Relu
└─── Input0 ─ conv2d_2/BiasAdd
16 max_pooling2d_2/MaxPool MaxPool
└─── Input0 ─ conv2d_2/Relu
17 conv2d_2/kernel Const
18 conv2d_2/kernel/read Identity
└─── Input0 ─ conv2d_2/kernel
19 conv2d_2/bias Const
20 conv2d_2/bias/read Identity
└─── Input0 ─ conv2d_2/bias
21 conv2d_3/convolution Conv2D
└─── Input0 ─ max_pooling2d_2/MaxPool
└─── Input1 ─ conv2d_2/kernel/read
22 conv2d_3/BiasAdd BiasAdd
└─── Input0 ─ conv2d_3/convolution
└─── Input1 ─ conv2d_2/bias/read
23 conv2d_3/Relu Relu
└─── Input0 ─ conv2d_3/BiasAdd
24 conv2d_3/kernel Const
25 conv2d_3/kernel/read Identity
└─── Input0 ─ conv2d_3/kernel
26 conv2d_3/bias Const
27 conv2d_3/bias/read Identity
└─── Input0 ─ conv2d_3/bias
28 conv2d_4/convolution Conv2D
└─── Input0 ─ conv2d_3/Relu
└─── Input1 ─ conv2d_3/kernel/read
29 conv2d_4/BiasAdd BiasAdd
└─── Input0 ─ conv2d_4/convolution
└─── Input1 ─ conv2d_3/bias/read
30 conv2d_4/Relu Relu
└─── Input0 ─ conv2d_4/BiasAdd
31 dense/kernel Const
32 dense/kernel/read Identity
└─── Input0 ─ dense/kernel
33 dense/bias Const
34 dense/bias/read Identity
└─── Input0 ─ dense/bias
35 dense/Tensordot/transpose/perm Const
36 dense/Tensordot/transpose Transpose
└─── Input0 ─ conv2d_4/Relu
└─── Input1 ─ dense/Tensordot/transpose/perm
37 dense/Tensordot/Reshape/shape Const
38 dense/Tensordot/Reshape Reshape
└─── Input0 ─ dense/Tensordot/transpose
└─── Input1 ─ dense/Tensordot/Reshape/shape
39 dense/Tensordot/transpose_1/perm Const
40 dense/Tensordot/transpose_1 Transpose
└─── Input0 ─ dense/kernel/read
└─── Input1 ─ dense/Tensordot/transpose_1/perm
41 dense/Tensordot/Reshape_1/shape Const
42 dense/Tensordot/Reshape_1 Reshape
└─── Input0 ─ dense/Tensordot/transpose_1
└─── Input1 ─ dense/Tensordot/Reshape_1/shape
43 dense/Tensordot/MatMul MatMul
└─── Input0 ─ dense/Tensordot/Reshape
└─── Input1 ─ dense/Tensordot/Reshape_1
44 dense/Tensordot/shape Const
45 dense/Tensordot Reshape
└─── Input0 ─ dense/Tensordot/MatMul
└─── Input1 ─ dense/Tensordot/shape
46 dense/BiasAdd BiasAdd
└─── Input0 ─ dense/Tensordot
└─── Input1 ─ dense/bias/read
47 dense/Relu Relu
└─── Input0 ─ dense/BiasAdd
48 logit/kernel Const
49 logit/kernel/read Identity
└─── Input0 ─ logit/kernel
50 logit/bias Const
51 logit/bias/read Identity
└─── Input0 ─ logit/bias
52 logit/Tensordot/transpose/perm Const
53 logit/Tensordot/transpose Transpose
└─── Input0 ─ dense/Relu
└─── Input1 ─ logit/Tensordot/transpose/perm
54 logit/Tensordot/Reshape/shape Const
55 logit/Tensordot/Reshape Reshape
└─── Input0 ─ logit/Tensordot/transpose
└─── Input1 ─ logit/Tensordot/Reshape/shape
56 logit/Tensordot/transpose_1/perm Const
57 logit/Tensordot/transpose_1 Transpose
└─── Input0 ─ logit/kernel/read
└─── Input1 ─ logit/Tensordot/transpose_1/perm
58 logit/Tensordot/Reshape_1/shape Const
59 logit/Tensordot/Reshape_1 Reshape
└─── Input0 ─ logit/Tensordot/transpose_1
└─── Input1 ─ logit/Tensordot/Reshape_1/shape
60 logit/Tensordot/MatMul MatMul
└─── Input0 ─ logit/Tensordot/Reshape
└─── Input1 ─ logit/Tensordot/Reshape_1
61 logit/Tensordot/shape Const
62 logit/Tensordot Reshape
└─── Input0 ─ logit/Tensordot/MatMul
└─── Input1 ─ logit/Tensordot/shape
63 logit/BiasAdd BiasAdd
└─── Input0 ─ logit/Tensordot
└─── Input1 ─ logit/bias/read
64 output Identity
└─── Input0 ─ logit/BiasAdd
 

 

  • Up0
  • Down0
yuan.wenhua
Join Date: 14 Sep 17
Posts: 8
Posted: Thu, 2017-11-02 23:18

Maybe you can try --allow_unconsumed_nodes parameter for snpe-tensorflow-to-dlc command.

  • Up0
  • Down0
vellamike
Join Date: 23 Oct 17
Posts: 11
Posted: Fri, 2017-11-03 02:05

What does that command do exactly? I tried running it and the result was a different error so it seems like some progress has been made.

 

2017-11-03 09:02:21.214193: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-03 09:02:21.214441: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-03 09:02:21.214722: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-11-03 09:02:21,306 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/transpose) not consumed by converter: Transpose.
2017-11-03 09:02:21,308 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/transpose_1) not consumed by converter: Transpose.
2017-11-03 09:02:21,308 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/Tensordot/MatMul) not consumed by converter: MatMul.
2017-11-03 09:02:21,308 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (dense/BiasAdd) not consumed by converter: BiasAdd.
2017-11-03 09:02:21,309 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/transpose) not consumed by converter: Transpose.
2017-11-03 09:02:21,309 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/transpose_1) not consumed by converter: Transpose.
2017-11-03 09:02:21,309 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/Tensordot/MatMul) not consumed by converter: MatMul.
2017-11-03 09:02:21,309 - 305 - WARNING - WARNING_TF_SCOPE_OP_NOT_CONSUMED: Operation (logit/BiasAdd) not consumed by converter: BiasAdd.
2017-11-03 09:02:21,412 - 123 - ERROR - Conversion failed: ERROR_TF_LAYER_NO_INPUT_FOUND: Reshape layer dense/Tensordot/Reshape_1 requires at least one input layer.
 

 

  • Up0
  • Down0
dmarques
Join Date: 15 Sep 17
Posts: 27
Posted: Fri, 2017-11-03 10:32

Your graph seems to have Reshape operations to reshape weights? This is not supported and SNPE fails to convert as it thinks you have a reshape layer in the model which is related to weights and not to the graph computation.

Please post a minimal sample graph that reproduces the error if you require further support.

  • Up0
  • Down0
vellamike
Join Date: 23 Oct 17
Posts: 11
Posted: Mon, 2017-11-06 03:24

Dear dmarques, I am not sure where the reshape operations are coming from, the graph is defined in python as follows:

input_layer = tf.placeholder(tf.float32, shape=[1, 1, 8000, 1], name='input_layer')

 
# Convolutional Layer #1
conv1 = tf.layers.conv2d(
        inputs=input_layer,
        filters=32,
        kernel_size=[1,11],
        padding="same",
        strides=1,
        activation=tf.nn.relu)
 
pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=(1,2), strides=2)
 
# Convolutional Layer #1
conv2 = tf.layers.conv2d(
        inputs=pool1,
        filters=32,
        kernel_size=[1,11],
        padding="same",
        strides=1,
        activation=tf.nn.relu)
 
pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=(1,2), strides=2)
 
conv3 = tf.layers.conv2d(
        inputs=pool2,
        filters=32,
        kernel_size=[1,11],
        padding="same",
        strides=1,
        activation=tf.nn.relu)
 
conv4 = tf.layers.conv2d(
        inputs=conv3,
        filters=32,
        kernel_size=[1,11],
        padding="same",
        strides=1,
        activation=tf.nn.relu)
 
 
# Dense Layer
dense = tf.layers.dense(inputs=conv4, units=1024, activation=tf.nn.relu)
 
# Logits Layerf
logits = tf.layers.dense(inputs=dense, units=5, name='logit')
output = tf.identity(logits, 'output')
  • Up0
  • Down0
dmarques
Join Date: 15 Sep 17
Posts: 27
Posted: Mon, 2017-11-06 11:29

We don't currently support tf.layers.dense. It transforms weights and biases in a way that is not currently supported.

I tried using tflearn.layers.fully_connected API in your example and that will work although be aware we don't currently support batch and your fullycoinnected operations are using batches.

Hope that helps
  • Up0
  • Down0
vellamike
Join Date: 23 Oct 17
Posts: 11
Posted: Mon, 2017-11-06 15:25

Thanks dmarques! Could you post a sample of the code you used to get it to work with tflearn.layers.fully_connected ? I haven't used that API and it would be helpful to me.

  • Up0
  • Down0
dmarques
Join Date: 15 Sep 17
Posts: 27
Posted: Tue, 2017-11-07 09:45

You can find samples at http://tflearn.org/getting_started/

  • Up0
  • Down0
vellamike
Join Date: 23 Oct 17
Posts: 11
Posted: Wed, 2017-11-08 15:26

@dmarques according to the documentation (v.1.6.0) both dense and reshape layers are supported on all cores?

I'm not sure using tflearn is going to work because I am unable to get it to train using my data (where the target is 2D onehot encoded) and in addition I cannot understand how it would apply the output of a 2D conv layer to a fully connected layer without a reshape or squeeze operation? A tf.Matmul wouldn't work in this case.

  • Up0
  • Down0
dmarques
Join Date: 15 Sep 17
Posts: 27
Posted: Thu, 2017-11-09 07:02

The issue here is that there is a reshape operation being applied to wheights (introduced by tf.layer.dense API) and the converter missinterprets it as part of the model execution and hence tries to convert to a layer which it can't since there are no input layers to it.

You can use reshape between a convolution and fully connected to flatten the tensor and it will work fine.

 

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.