# How to set context inputDims when there are two inputs to the network and two outputs

**URL:** <https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452>\
**Category:** TensorRT\
**Created:** [September 2, 2020, 1:07pm UTC](https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452 "2020-09-02T13:07:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shir](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shir](https://forums.developer.nvidia.com/u/shir)\
**Post date:** [September 2, 2020, 1:07pm UTC](https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452/1 "2020-09-02T13:07:43Z")

</div>

## Description

In keras my input looks like this:

 ![image](https://global.discourse-cdn.com/nvidia/original/3X/f/4/f4e8dfffdc37ff8a71e4e8451c4f0a972867e974.png)  
Its a list of two tensors

And my outputs:  
 ![image](https://global.discourse-cdn.com/nvidia/original/3X/1/9/1939f6ca4cc7f5bd990d3b5e670d946c0544c427.png)

I’m working with the “simpleOnnx” example and I wonder how to set the input tensor and output tensors:  
(Based my conde on [https://developer.nvidia.com/blog/speed-up-inference-tensorrt/](https://developer.nvidia.com/blog/speed-up-inference-tensorrt/))

For one inputTensor I used this code:

```
    Dims dims_i{engine->getBindingDimensions(0)};
    Dims3 inputDims{batchSize, dims_i.d[1], dims_i.d[2]};
    context->setBindingDimensions(0, inputDims);
    launchInference(context.get(), stream, inputTensor, outputTensor, bindings, batchSize);

```

Any suggestions? or maybe an example for multiple inputs and outputs?

## Environment

**TensorRT Version** : 7.0.0-1  
**GPU Type** : RTX  
**Nvidia Driver Version** :  
**CUDA Version** : 11.0  
**CUDNN Version** :  
**Operating System + Version** : Ubuntu 18.04  
**Python Version (if applicable)** : 3.6  
**TensorFlow Version (if applicable)** : 2.3  
**PyTorch Version (if applicable)** :  
**Baremetal or Container (if container which image + tag)** :

Update:  
I’ve tried to change  
Dims3 inputDims{batchSize, dims\_i.d[1], dims\_i.d[2]}  
to  
Dims4 inputDims{batchSize, 2, dims\_i.d[1], dims\_i.d[2]}

But I’m getting:  
size outputTensor : 4  
size inputTensor: 495  
0 0 0 0 ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine)

---

<div class="post-metadata">

**Author:** ![AakankshaS](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aakankshas/32/14047_2.png) [@AakankshaS](https://forums.developer.nvidia.com/u/AakankshaS)\
**Post date:** [September 2, 2020, 6:57pm UTC](https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452/2 "2020-09-02T18:57:43Z")

</div>

Hi @shir

> [@shir](#):
>
> 0 0 0 0 ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine)

Could you please check if you have set the input size for the preprocessor during inference using setBindingDimensions?  
Please refer below sample:

> <https://github.com/NVIDIA/TensorRT/blob/07ed9b57b1ff7c24664388e5564b17f7ce2873e5/samples/opensource/sampleDynamicReshape/sampleDynamicReshape.cpp#L239>

Thanks!

---

<div class="post-metadata">

**Author:** ![shir](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shir](https://forums.developer.nvidia.com/u/shir)\
**Post date:** [September 2, 2020, 8:01pm UTC](https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452/3 "2020-09-02T20:01:06Z")

</div>

> [@AakankshaS](#):
>
> `setBindingDimensions`

Hi,  
Thanks for you answer.  
I have set the bindingDimensions like this:

```
Dims3 inputDims{1, 55, 3};
context->setBindingDimensions(0, inputDims); 

```

I’m not sure that it’s the right way cause as I said above, I have two input tensors with the size of (55,3)  
But I’m still getting this error:  
`ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine`

Any suggestions on how to set the “binding dimensions”?  
Any example on how to use with multiple outputs and inputs?

Update:  
Fixed it by setting the binding dimensions for both of my inputs, like this:  
context-\>setBindingDimensions(0, inputDims);  
context-\>setBindingDimensions(1, inputDims);

But I’ve tried to insert a tensor of ones in the size of both my inputs, both in Keras and in tensorRT but didn’t got the same results? any idea why it happens ?

---

<div class="post-metadata">

**Author:** ![AakankshaS](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aakankshas/32/14047_2.png) [@AakankshaS](https://forums.developer.nvidia.com/u/AakankshaS)\
**Post date:** [November 29, 2020, 8:29pm UTC](https://forums.developer.nvidia.com/t/how-to-set-context-inputdims-when-there-are-two-inputs-to-the-network-and-two-outputs/153452/4 "2020-11-29T20:29:37Z")

</div>

Hi @shir,  
Apologies for delayed response  
Are you still facing the issue?  
Can you please share the model with us, as the error shows that there might be some issue with your model.  
Thanks!
