From 5c646a3055b1d1cd72d21f3040de46fe31e51f52 Mon Sep 17 00:00:00 2001 From: Anurag Dixit Date: Tue, 9 Aug 2022 14:29:17 -0700 Subject: [PATCH 1/2] refdctor: Changed the hardcoded values to macros Signed-off-by: Anurag Dixit --- core/conversion/conversionctx/ConversionCtx.cpp | 6 +++--- core/conversion/conversionctx/ConversionCtx.h | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/conversion/conversionctx/ConversionCtx.cpp b/core/conversion/conversionctx/ConversionCtx.cpp index 71159eb2b5..c9a76602c2 100644 --- a/core/conversion/conversionctx/ConversionCtx.cpp +++ b/core/conversion/conversionctx/ConversionCtx.cpp @@ -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); } } diff --git a/core/conversion/conversionctx/ConversionCtx.h b/core/conversion/conversionctx/ConversionCtx.h index 988a58bf49..a138a45672 100644 --- a/core/conversion/conversionctx/ConversionCtx.h +++ b/core/conversion/conversionctx/ConversionCtx.h @@ -11,6 +11,10 @@ #include #include "core/util/prelude.h" +#define DLA_SRAM_SIZE 1048576 +#define DLA_LOCAL_DRAM_SIZE 1073741824 +#define DLA_GLOBAL_DRAM_SIZE 536870912 + namespace torch_tensorrt { namespace core { namespace conversion { @@ -35,9 +39,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; From ad7c081695f7c56c51e2cea97e79ee73e240d7f9 Mon Sep 17 00:00:00 2001 From: Anurag Dixit Date: Wed, 10 Aug 2022 11:28:29 -0700 Subject: [PATCH 2/2] chore: Moved macros to core/utils Signed-off-by: Anurag Dixit --- core/conversion/conversionctx/ConversionCtx.h | 4 ---- core/util/macros.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/conversion/conversionctx/ConversionCtx.h b/core/conversion/conversionctx/ConversionCtx.h index a138a45672..5f8d6e955b 100644 --- a/core/conversion/conversionctx/ConversionCtx.h +++ b/core/conversion/conversionctx/ConversionCtx.h @@ -11,10 +11,6 @@ #include #include "core/util/prelude.h" -#define DLA_SRAM_SIZE 1048576 -#define DLA_LOCAL_DRAM_SIZE 1073741824 -#define DLA_GLOBAL_DRAM_SIZE 536870912 - namespace torch_tensorrt { namespace core { namespace conversion { diff --git a/core/util/macros.h b/core/util/macros.h index e58b5f0daf..c05822c975 100644 --- a/core/util/macros.h +++ b/core/util/macros.h @@ -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{}; \