/TopK_5: K exceeds the maximum value allowed (3840)


I have been having issues with getting a .onnx model to build using either TensorRT or trtexec.exe. I receive the following error using TRT in C++ on the call:
std::unique_ptr<IHostMemory> plan{ builder->buildSerializedNetwork(*network, *config) };
4: [graphShapeAnalyzer.cpp::nvinfer1::builder::anonymous-namespace’::ShapeAnalyzerImpl::processCheck::862] Error Code 4: Internal Error (/TopK_5: K exceeds the maximum value allowed (3840).)`

Using trtexec.exe gives me a similar error in TRT 8.6 or 10.0:

[E] Error[4]: [graphShapeAnalyzer.cpp::nvinfer1::builder::`anonymous-namespace'::ShapeAnalyzerImpl::analyzeShapes::2084] Error Code 4: Miscellaneous (ITopKLayer /TopK_5: /TopK_5: K exceeds the maximum value allowed (3840).)
[06/11/2024-10:31:56] [E] Engine could not be created from network
[06/11/2024-10:31:56] [E] Building engine failed
[06/11/2024-10:31:56] [E] Failed to create engine from model or file.
[06/11/2024-10:31:56] [E] Engine set up failed

I understand that the issue is with /TopK_5 having too large of a k value so is there are way I can reduce it to fix the model?


TensorRT Version: and
GPU Type: NVIDIA GeForce RTX 3070
Nvidia Driver Version: GeForce Game Ready Driver, Version: 555.99
CUDA Version: 12.3
CUDNN Version: 9.0
Operating System + Version: Windows 11Pro for Workstations

Relevant Files

The Onnx model:

Steps To Reproduce

trtexec.exe --onnx=fruit.onnx --saveEngine=fruit.engine