tf.sqrt error: Unary not supported for other non-constant node (Solved)

I coded an instance norm layer, which include a tf.sqrt opperation.

def instance_norm(x, n_features):
with tf.variable_scope(‘instance_norm’) as scope:
gama = tf.Variable(tf.ones([n_features]),name=“gama”)
beta = tf.Variable(tf.zeros([n_features]), name=“beta”)
epsilon = 1e-3
mean = tf.reduce_mean(x, [1,2], keep_dims=True)
var = tf.reduce_mean(tf.multiply(tf.substract(x,mean), tf.substract(x, mean)), [1,2], keep_dims=True)
norm = tf.div(tf.subtract(x,mean), tf.sqrt(tf.add(var, epsilon)))
return gama * norm + beta

tensorrt raised errors
[TensorRT] ERROR: UFFParser: Parser error: generator/dmux1/instance_norm/Sqrt: Unary not supported for other non-constant node

Ubuntu 16.04
cuda 9.0 cudnn 7.1.3
tensorflow-gpu 1.10
python 2.7


We believe this should be fixed in TensorRT5. can you update to TRT 5RC, and try again?

NVIDIA Enterprise Support

Hello, I have tested it on TensorRT5.0.0.10 , it is still the same error. not support the non-constant value.


My apologies for the confusion. The fix was committed after we froze 5RC. It is scheduled for the next TRT release.

As a workaround, please try to modify the network to make the input to Unary op a constant node.

Hello, one more question, I think a sqrt operation should be included in tf fused batchnorm op.

tf fusedbatchnorm is supported by tensorrt, because resnet has this layer, and tensorrt speed up for resnet.

how does this works? could you please give some explanation.

Hello, per engineering:

“The UFF converter converts the fused batchnorm operation to a TRT batch norm operation. If the fused batch norm operation has a sqrt function, it will be processed as a separate op by the UFF converter and the parser.”

Thank you, and when will next tensorrt version be released? lots of norm layers need sqrt ops.

I’ve created plugin that can add sqrt / rsqrt / max operations . Please see for details here