# 3d Keras Optimize on Tensor Rt

**URL:** <https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375>\
**Category:** Jetson Nano\
**Tags:** tensorrt\
**Created:** [July 17, 2020, 3:08am UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375 "2020-07-17T03:08:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AgarwaN23](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@AgarwaN23](https://forums.developer.nvidia.com/u/AgarwaN23)\
**Post date:** [July 17, 2020, 3:08am UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/1 "2020-07-17T03:08:07Z")

</div>

Hello,

I have a keras 3d convolutional model that I would like to optimize on Tensor RT. I have successfully converted the .h5 into a .pb, and the .pb into a onnx file. I am trying to optimize this onnx model with tensor rt with this script:

> <https://github.com/jkjung-avt/keras_imagenet/blob/master/tensorrt/build_engine.py>

However this returns a plugin error for max pooling 3d. I am not sure why I am receiving this error because I have tensor rt 7 and I thought it provides support for 3d convolution and pooling, How do I solve this?

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [July 17, 2020, 6:25am UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/3 "2020-07-17T06:25:24Z")

</div>

Hi,

There are some limitation in the 3D pooling.  
Would you mind to check if your model is supported by both TensorRT API and onnx2trt first?

**TensorRT** : [Support Matrix :: NVIDIA Deep Learning TensorRT Documentation](https://docs.nvidia.com/deeplearning/tensorrt/support-matrix/index.html#layers-matrix)  
**ONNX2TRT** : [https://github.com/onnx/onnx-tensorrt/blob/master/operators.md](https://github.com/onnx/onnx-tensorrt/blob/master/operators.md)

Thanks.

---

<div class="post-metadata">

**Author:** ![AgarwaN23](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@AgarwaN23](https://forums.developer.nvidia.com/u/AgarwaN23)\
**Post date:** [July 17, 2020, 3:19pm UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/4 "2020-07-17T15:19:48Z")

</div>

From what I’ve read, it shows support for 2d and 3d for pooling. However, I am unsure on max pooling because Onnx2TRT simply says yes for max pooling. [Release Notes :: NVIDIA Deep Learning TensorRT Documentation](https://docs.nvidia.com/deeplearning/tensorrt/release-notes/tensorrt-6.html) shows support for pooling.  
Here is my onnx file in case you want to try it out:  
[https://drive.google.com/file/d/1Doj9sZWI7KrBT2\_-aTQoNhxZx6Zxvdb3/view?usp=sharing](https://drive.google.com/file/d/1Doj9sZWI7KrBT2_-aTQoNhxZx6Zxvdb3/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![AgarwaN23](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@AgarwaN23](https://forums.developer.nvidia.com/u/AgarwaN23)\
**Post date:** [July 20, 2020, 6:11pm UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/5 "2020-07-20T18:11:58Z")

</div>

Any follow ups?

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [August 5, 2020, 5:36am UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/6 "2020-08-05T05:36:41Z")

</div>

Hi,

Sorry for the late update.

It looks like _ONNX2TRT_ only support **MaxPool** and no **MaxPool3D** operation support.

> <https://github.com/onnx/onnx-tensorrt/blob/main/builtin_op_importers.cpp#L2131>

Here are two possible workarounds for your reference.

1. Add the `MaxPool3D` support into _ONNX2TRT_.
2. Update the operation into _MaxPool_ when generating the onnx model from your .pb file.

Thanks.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 5:40pm UTC](https://forums.developer.nvidia.com/t/3d-keras-optimize-on-tensor-rt/142375/8 "2021-10-18T17:40:22Z")

</div>


