Unsupported operation: _NoOp on TensorRT

Hi

Im trying to run an inference on my Jetson Xavier AGX in TensorRT of a custom TF2 model that predicts age and gender using a face image, built and trained by me.
I exported the model using the tf.saved_model.save function, but I converted this .pb file into a TF1 frozen graph pb (due the fact that the UFF conversor can’t read TF2 format).

After that, I converted the frozen graph into a UFF file, and when I attempted to read this UFF file through trt.UffParser(), first it gave me the following error:

“Unsupported operation: _AddV2”

I could fix this by replacing all ‘AddV2’ operation layers for “Add” through graphsurgeon, but now another error appears:

“Unsupported operation: _NoOp”

As I understand, this operation does nothing, but I couldn’t find anything to fix or replace this operation for another compatible (I tried with Placeholder, Constant, Identity, but get more errors).

Any idea how can I fix it? I don’t want to retrain my model in TF1 or Keras, so bad.

Thank you very much. Regards.

Hi,

If the operation do nothing, you can just remove it with graphsurgeon.

all_noop_nodes = graph.find_nodes_by_op("NoOp")
graph.forward_inputs(all_noop_nodes)

Thanks.

Hi! First of all, thanks for the quick response.
I tried what you suggest but now got the following error message:

uff/UffParser.cpp:1033: std::shared_ptr<ParserLayer> UffParser::parseConv(const uff::Node&, const Fields&, NodesMap&): Assertion isRegisteredConst(node.inputs(1)) failed.

What could be going wrong?
If need specific files that Im using, let me now.
Thanks.

Hi,

The error occurs when checking the 2nd input tensor of Conv is a constant or not.
Do you have an tensor-type 2nd input for a certain conv layer?
In general, it should be a predefined kernel weight.

Thanks.

Hi again, srry for not answering.
I make it work using the followinf script:

import graphsurgeon as gs
import numpy as np

def add_plugin(graph):
    # Change AddV2
    for node in graph.find_nodes_by_op('AddV2'):
        gs.update_node(node, op='Add')
    
    # Remove NoOp
    for node in graph.find_nodes_by_op('NoOp'):
        gs.update_node(node, op='Identity')
    
    all_noop_nodes = graph.find_nodes_by_op("Identity")
    graph.forward_inputs(all_noop_nodes)

    return graph

What this does is replace the “NoOp” op to an “Identity” one, then all the “Identity” operations are removed since these last one outputs are the same as the inputs, so everything should work normal.
Hope it helps to anyone having similar issues.