# Two ways of TensorRT to optimize Neural Network Computation Graph

GIE is now TensorRT [https://devblogs.nvidia.com/deploying-deep-learning-nvidia-tensorrt/](https://devblogs.nvidia.com/deploying-deep-learning-nvidia-tensorrt/)

\
GIE performs several important transformations and optimizations to the neural network graph. First, layers with unused output are eliminated to avoid unnecessary computation. Next, where possible convolution, bias, and ReLU layers are fused to form a single layer. Figure 4 shows the result of this vertical layer fusion on the original network from Figure 3 (fused layers are labeled CBR in Figure 4). Layer fusion improves the efficiency of running GIE-optimized networks on the GPU.

![Figure 3. An example convolutional neural network with multiple convolutional and activation layers.](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LGSbLY3FJBpjmIt-zGW%2F-LGScIi0ZgFEt0hXUt2V%2FED24BB8B-422A-4C45-B03A-283D07D949B3.png?alt=media\&token=52d93c33-d43e-474e-b0fd-b352f53f36f4)

![Figure 4. An example of vertical layer fusion on a convolutional neural network. Here, convolutional layers are combined with subsequent bias and activation (ReLU) layers.](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LGSbLY3FJBpjmIt-zGW%2F-LGSc9pU4gE5lAXhHdYx%2FCA618F5C-1326-4A7F-A338-871EBE4A5403.png?alt=media\&token=a5810c8f-1f6f-45dd-bd2a-c50128c64aba)

Another transformation is horizontal layer fusion, or layer aggregation, along with the required division of aggregated layers to their respective outputs, as Figure 5 shows. Horizontal layer fusion improves performance by combining layers that take the same source tensor and apply the same operations with similar parameters, resulting in a single larger layer for higher computational efficiency. The example in Figure 5 shows the combination of 3 1×1 CBR layers from Figure 4 that take the same input into a single larger 1×1 CBR layer. Note that the output of this layer must be disaggregated to feed into the different subsequent layers from the original input graph.

![Figure 5. An example of horizontal layer fusion on a convolutional neural network. Here, multiple 1×1 CBR layers from Figure 4 are fused “horizontally”, or across similar layers in the graph that share the same input.](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LGSbLY3FJBpjmIt-zGW%2F-LGSbYXUpXV21Y-6f4Tc%2F6C48904E-1AB9-4360-83F8-DA581A20D6AA.png?alt=media\&token=8d1eb18d-f70a-4ff3-826f-2a6fe373f289)

