Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onnx隐式batch size的问题 #34

Open
scteam1994 opened this issue Nov 12, 2024 · 1 comment
Open

onnx隐式batch size的问题 #34

scteam1994 opened this issue Nov 12, 2024 · 1 comment

Comments

@scteam1994
Copy link

我看到了

Assert(this->context_ != nullptr);
// nvinfer1::Dims maxDims = this->context_->engine_->getProfileDimensions(0, 0, nvinfer1::OptProfileSelector::kMAX);
// int max_batchsize = maxDims.d[0];
// return max_batchsize;
return this->context_->engine_->getMaxBatchSize();

int nbBindings = context->engine_->getNbBindings();
// nvinfer1::Dims maxDims = context->engine_->getProfileDimensions(0, 0, nvinfer1::OptProfileSelector::kMAX);
// int max_batchsize = maxDims.d[0];
int max_batchsize = context->engine_->getMaxBatchSize();

这两处代码,你是否是在这里尝试解决显式batch导出的onnx无法使用mImpl->getMaxBatchSize()的问题?
请问这个问题有什么进展吗?使用torch.export模块导出的onnx模型是不是必然是显式batch的?

@Melody-Zhou
Copy link
Owner

@scteam1994

  1. 注释的代码是解决高版本 TensorRT 动态 batch 时 getMaxBatchSize() 这个 API 弃用的问题,这里通过查询 profile 的维度获得 maxBatchSize。静态 batch 不知道能不能直接通过 getMaxBatchSize() 这个 API 获取 batch,没尝试过
  2. torch.onnx.export 函数导出的模型是动态维度还是静态维度取决于其中的 dynamic_axes 参数是否指定

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants