# Using The TensorRT Network API


## Introduction

In addition to loading existing models, TensorRT allows you to define networks by hand
using the network API.

In this example, we'll look at how you can use Polygraphy's `extend` decorator, covered in
[example 03](../03_interoperating_with_tensorrt), in conjunction with the `CreateNetwork`
loader to seamlessly integrate a network defined using TensorRT APIs with Polygraphy.


## Running The Example

1. Install prerequisites
    * Ensure that TensorRT is installed
    * Install other dependencies with `python3 -m pip install -r requirements.txt`

2. **[Optional]** Inspect the TensorRT network generated by `create_network()`.
    This will invoke `create_network()` from within the script and display the generated TensorRT network:

    ```bash
    polygraphy inspect model example.py --trt-network-func create_network --show layers attrs weights
    ```

3. Run the example:

    ```bash
    python3 example.py
    ```

## Further Reading

For more information on the TensorRT Network API, see the
[TensorRT API documentation](https://docs.nvidia.com/deeplearning/tensorrt/latest/_static/python-api/infer/Graph/Network.html)
