Skip to content

Commit 3afd209

Browse files
committed
fix(//core/conversion): Check for calibrator before setting int8 mode
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 8d22bdd commit 3afd209

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

core/conversion/conversionctx/ConversionCtx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ConversionCtx::ConversionCtx(BuilderSettings build_settings)
5252
TRTORCH_CHECK(builder->platformHasFastInt8(), "Requested inference in INT8 but platform does support INT8");
5353
cfg->setFlag(nvinfer1::BuilderFlag::kINT8);
5454
input_type = nvinfer1::DataType::kFLOAT;
55-
// If the calibrator is nullptr then TRT will use default quantization
55+
TRTORCH_CHECK(settings.calibrator != nullptr, "Requested inference in INT8 but no calibrator provided, set the ptq_calibrator field in the ExtraInfo struct with your calibrator");
5656
cfg->setInt8Calibrator(settings.calibrator);
5757
break;
5858
case nvinfer1::DataType::kFLOAT:

core/util/logging/TRTorchLogger.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace trt = nvinfer1;
1515

1616
namespace util {
1717
namespace logging {
18-
18+
1919
TRTorchLogger::TRTorchLogger(std::string prefix, Severity severity, bool color)
2020
: prefix_(prefix), reportable_severity_(severity), color_(color) {}
2121

@@ -32,7 +32,7 @@ void TRTorchLogger::log(Severity severity, const char* msg) {
3232
if (severity > reportable_severity_) {
3333
return;
3434
}
35-
35+
3636
if (color_) {
3737
switch (severity) {
3838
case Severity::kINTERNAL_ERROR: std::cerr << TERM_RED; break;
@@ -41,9 +41,9 @@ void TRTorchLogger::log(Severity severity, const char* msg) {
4141
case Severity::kINFO: std::cerr << TERM_GREEN; break;
4242
case Severity::kVERBOSE: std::cerr << TERM_MAGENTA; break;
4343
default: break;
44-
}
44+
}
4545
}
46-
46+
4747
switch (severity) {
4848
case Severity::kINTERNAL_ERROR: std::cerr << "INTERNAL_ERROR: "; break;
4949
case Severity::kERROR: std::cerr << "ERROR: "; break;
@@ -52,11 +52,11 @@ void TRTorchLogger::log(Severity severity, const char* msg) {
5252
case Severity::kVERBOSE: std::cerr << "DEBUG: "; break;
5353
default: std::cerr << "UNKNOWN: "; break;
5454
}
55-
55+
5656
if (color_) {
5757
std::cerr << TERM_NORMAL;
5858
}
59-
59+
6060
std::cerr << prefix_ << msg << std::endl;
6161
}
6262

@@ -92,7 +92,7 @@ bool TRTorchLogger::get_is_colored_output_on() {
9292
return color_;
9393
}
9494

95-
95+
9696
namespace {
9797

9898
TRTorchLogger& get_global_logger() {
@@ -104,7 +104,7 @@ TRTorchLogger& get_global_logger() {
104104
static TRTorchLogger global_logger("[TRTorch] - ",
105105
LogLevel::kERROR,
106106
false);
107-
#endif
107+
#endif
108108
return global_logger;
109109
}
110110

0 commit comments

Comments
 (0)