Skip to content

refactor: Changed the hardcoded values to macros for DLA memory sizes #1247

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

Merged
merged 2 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/conversion/conversionctx/ConversionCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ ConversionCtx::ConversionCtx(BuilderSettings build_settings)
settings.enabled_precisions.find(nvinfer1::DataType::kFLOAT) == settings.enabled_precisions.end(),
"DLA supports only fp16 or int8 precision");
cfg->setDLACore(settings.device.dla_core);
if (settings.dla_sram_size != 1048576) {
if (settings.dla_sram_size != DLA_SRAM_SIZE) {
cfg->setMemoryPoolLimit(nvinfer1::MemoryPoolType::kDLA_MANAGED_SRAM, settings.dla_sram_size);
}
if (settings.dla_local_dram_size != 1073741824) {
if (settings.dla_local_dram_size != DLA_LOCAL_DRAM_SIZE) {
cfg->setMemoryPoolLimit(nvinfer1::MemoryPoolType::kDLA_LOCAL_DRAM, settings.dla_local_dram_size);
}
if (settings.dla_global_dram_size != 536870912) {
if (settings.dla_global_dram_size != DLA_GLOBAL_DRAM_SIZE) {
cfg->setMemoryPoolLimit(nvinfer1::MemoryPoolType::kDLA_GLOBAL_DRAM, settings.dla_global_dram_size);
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/conversion/conversionctx/ConversionCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ struct BuilderSettings {
nvinfer1::IInt8Calibrator* calibrator = nullptr;
uint64_t num_avg_timing_iters = 1;
uint64_t workspace_size = 0;
uint64_t dla_sram_size = 1048576;
uint64_t dla_local_dram_size = 1073741824;
uint64_t dla_global_dram_size = 536870912;
uint64_t dla_sram_size = DLA_SRAM_SIZE;
uint64_t dla_local_dram_size = DLA_LOCAL_DRAM_SIZE;
uint64_t dla_global_dram_size = DLA_GLOBAL_DRAM_SIZE;

BuilderSettings() = default;
BuilderSettings(const BuilderSettings& other) = default;
Expand Down
5 changes: 5 additions & 0 deletions core/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#define GET_MACRO(_1, _2, NAME, ...) NAME

// DLA Memory related macros
#define DLA_SRAM_SIZE 1048576
#define DLA_LOCAL_DRAM_SIZE 1073741824
#define DLA_GLOBAL_DRAM_SIZE 536870912

#define TORCHTRT_LOG(l, sev, msg) \
do { \
std::stringstream ss{}; \
Expand Down