Hello,
InceptionV3, DenseNet and InceptionResNetV2 from keras applications use layer.concatenate in their design. Since this layer uses tf.ones_like beneath, the UFF converter throws errors stating Fill layer is not supported.
I decided to implement this layer using the plugin API. My base code is uff_custom_plugin from TensorRT samples (https://docs.nvidia.com/deeplearning/sdk/tensorrt-sample-support-guide/index.html#uff_custom_plugin).
Before using the graph surgeon, the layers not being supported look like this:
.
.
.
, 'batch_normalization_4/ones_like/Shape': name: "batch_normalization_4/ones_like/Shape"
op: "Const"
attr {
key: "dtype"
value {
type: DT_INT32
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_INT32
tensor_shape {
dim {
size: 1
}
}
int_val: 80
}
}
}
, 'batch_normalization_4/ones_like/Const': name: "batch_normalization_4/ones_like/Const"
op: "Const"
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
attr {
key: "value"
value {
tensor {
dtype: DT_FLOAT
tensor_shape {
}
float_val: 1.0
}
}
}
, 'batch_normalization_4/ones_like': name: "batch_normalization_4/ones_like"
op: "Fill"
input: "batch_normalization_4/ones_like/Shape"
input: "batch_normalization_4/ones_like/Const"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "index_type"
value {
type: DT_INT32
}
}
.
.
.
This is expected since the tf.fill operation has 2 input arguments: shape and value (https://www.tensorflow.org/api_docs/python/tf/fill)
So using graph surgeon API, I search for the nodes with Fill operation and collapse their namespace while replacing them with the CustomClipPlugin:
, 'batch_normalization_4/ones_like': name: "batch_normalization_4/ones_like"
op: "CustomClipPlugin"
attr {
key: "dims_u_int"
value {
i: 80
}
}
attr {
key: "value_u_float"
value {
f: 1.0
}
}
Although I haven’t implemented the actual CUDA kernel, I wanted to make sure things work at high level when only converting to UFF and building the engine without inference. However, I get the following error (I am also printing each function call in customClipPlugin.cpp):
ClipPluginCreator::getPluginName
ClipPluginCreator::getFieldNames
ClipPluginCreator::createPlugin
ClipPlugin::ClipPlugin
ClipPlugin::setPluginNamespace
ClipPlugin::getNbOutputs
ClipPlugin::clone
ClipPlugin::ClipPlugin
ClipPlugin::getNbOutputs
[libprotobuf FATAL /home/erisuser/p4sw/sw/gpgpu/MachineLearning/DIT/externals/protobuf/aarch64/10.0/include/google/protobuf/repeated_field.h:1408] CHECK failed: (index) < (current_size_):
ClipPlugin::destroy
ClipPlugin::destroy
Traceback (most recent call last):
File "../hands_uff_custom_plugin.py", line 225, in <module>
main()
File "../hands_uff_custom_plugin.py", line 211, in main
engine = build_engine(MODEL_PATH)
File "../hands_uff_custom_plugin.py", line 176, in build_engine
parser.parse(uff_path, network)
RuntimeError: CHECK failed: (index) < (current_size_):
So do you have any thoughts on why I get the error "RuntimeError: CHECK failed: (index) < (current_size_): "?