!4993 benchmark device param check

Merge pull request !4993 from cjh9368/dts-0718
This commit is contained in:
mindspore-ci-bot 2020-08-24 10:12:58 +08:00 committed by Gitee
commit b7c92aa8b1
2 changed files with 12 additions and 4 deletions

View File

@ -544,6 +544,11 @@ int Benchmark::Init() {
return RET_ERROR;
}
if (_flags->device != "CPU" && _flags->device != "GPU") {
MS_LOG(ERROR) << "Device type:" << _flags->device << " is not supported.";
return RET_ERROR;
}
return RET_OK;
}
@ -576,10 +581,13 @@ int RunBenchmark(int argc, const char **argv) {
return RET_ERROR;
}
if (flags.device == "NPU") {
status = mBenchmark.RunBenchmark("NPU");
} else {
if (flags.device == "GPU") {
status = mBenchmark.RunBenchmark("GPU");
} else if (flags.device == "CPU") {
status = mBenchmark.RunBenchmark("CPU");
} else {
MS_LOG(ERROR) << "Device type" << flags.device << " not support.";
return RET_ERROR;
}
if (status != 0) {

View File

@ -56,7 +56,7 @@ class MS_API BenchmarkFlags : public virtual FlagParser {
AddFlag(&BenchmarkFlags::inDataPath, "inDataPath", "Input data path, if not set, use random input", "");
AddFlag(&BenchmarkFlags::inDataTypeIn, "inDataType", "Input data type. img | bin", "bin");
AddFlag(&BenchmarkFlags::omModelPath, "omModelPath", "OM model path, only required when device is NPU", "");
AddFlag(&BenchmarkFlags::device, "device", "CPU | NPU | GPU", "CPU");
AddFlag(&BenchmarkFlags::device, "device", "CPU | GPU", "CPU");
AddFlag(&BenchmarkFlags::cpuBindMode, "cpuBindMode",
"Input -1 for MID_CPU, 1 for HIGHER_CPU, 0 for NO_BIND, defalut value: 1", 1);
// MarkPerformance