Dimension number 1 in profile 0 does not match network definition

My network input image is C=3, H=24, W=94.

When I set optimization profile dimension as
auto profile = builder->createOptimizationProfile();
const int batchSize{1};
profile->setDimensions(inputName, OptProfileSelector::kMIN, Dims4{batchSize, 3, 24, 94});
profile->setDimensions(inputName, OptProfileSelector::kOPT, Dims4{batchSize, 3, 24, 94});
profile->setDimensions(inputName, OptProfileSelector::kMAX, Dims4{batchSize, 3, 24, 94});

Runtime error is input:0: for dimension number 1 in profile 0 does not match network definition (got min=3, opt=3, max=3), expected min=opt=max=24)

When I set
profile->setDimensions(inputName, OptProfileSelector::kMIN, Dims4{batchSize, 24, 94, 3});
profile->setDimensions(inputName, OptProfileSelector::kOPT, Dims4{batchSize, 24, 94, 3});
profile->setDimensions(inputName, OptProfileSelector::kMAX, Dims4{batchSize, 24, 94, 3});
Runtime error is input:0: for dimension number 1 in profile 0 does not match network definition (got min=24, opt=24, max=24), expected min=opt=max=1)

When I set
profile->setDimensions(inputName, OptProfileSelector::kMIN, Dims4{batchSize, 1, 24, 94});
profile->setDimensions(inputName, OptProfileSelector::kOPT, Dims4{batchSize, 1, 24, 94});
profile->setDimensions(inputName, OptProfileSelector::kMAX, Dims4{batchSize, 1, 24, 94});
Runtime error is input:0: for dimension number 1 in profile 0 does not match network definition (got min=1, opt=1, max=1), expected min=opt=max=24)

What could be the problem?

My error is because of this line
auto input = preprocessorNetwork->addInput("input:0", nvinfer1::DataType::kFLOAT, Dims4{-1, 1, -1, -1});

I need to change to
auto input = preprocessorNetwork->addInput("input:0", nvinfer1::DataType::kFLOAT, Dims4{-1, 24, 94, 3}); to match my input.

1 Like