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

caffe2plan should proceed gracefully if int8 or fp16 not supported #11

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/test/caffe2plan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,23 @@ CaffeToPlan(
const std::string& output_filename, const std::string& prototxt_filename,
const std::string& model_filename,
const std::vector<std::string>& output_names,
const nvinfer1::DataType model_dtype, const std::string& calibration_filename,
nvinfer1::DataType model_dtype, const std::string& calibration_filename,
const size_t max_batch_size, const size_t max_workspace_size)
{
nvinfer1::IBuilder* builder = nvinfer1::createInferBuilder(gLogger);
nvinfer1::INetworkDefinition* network = builder->createNetwork();
nvcaffeparser1::ICaffeParser* parser = nvcaffeparser1::createCaffeParser();

if (
((model_dtype == nvinfer1::DataType::kINT8) &&
!builder->platformHasFastInt8()) ||
((model_dtype == nvinfer1::DataType::kHALF) &&
!builder->platformHasFastFp16())) {
return false;
(model_dtype == nvinfer1::DataType::kINT8) &&
!builder->platformHasFastInt8()) {
std::cerr << "WARNING: GPU does not support int8, using fp32" << std::endl;
model_dtype = nvinfer1::DataType::kFLOAT;
} else if (
(model_dtype == nvinfer1::DataType::kHALF) &&
!builder->platformHasFastFp16()) {
std::cerr << "WARNING: GPU does not support fp16, using fp32" << std::endl;
model_dtype = nvinfer1::DataType::kFLOAT;
}

const nvcaffeparser1::IBlobNameToTensor* name_to_tensor = parser->parse(
Expand Down