diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index d9f55d903..38ec34b72 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -1227,669 +1227,7 @@ CLParser::ParseCommandLine(int argc, char** argv) index++; } -<<<<<<< HEAD - if (!IsNonNegativeInteger(sequence_id)) { - Usage( - "Failed to parse --sequence-id-range. The range values must " - "be >= 0."); - } - - switch (index) { - case 0: - params_->start_sequence_id = std::stoull(sequence_id); - break; - case 1: - if (params_->start_sequence_id > std::stoull(sequence_id)) { - Usage( - "Failed to parse --sequence-id-range. The 'end' value " - "must be greater than 'start' value."); - } - params_->sequence_id_range = - std::stoull(sequence_id) - params_->start_sequence_id; - break; - } - index++; - } - - break; - } - case 31: { - params_->ssl_options.ssl_grpc_use_ssl = true; - break; - } - case 32: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_root_certifications_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-root-certifications-file. The " - "value must be a valid file path."); - } - break; - } - case 33: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_private_key_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-private-key-file. The value must " - "be a valid file path."); - } - break; - } - case 34: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_certificate_chain_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-certificate-chain-file. The value " - "must be a valid file path."); - } - break; - } - case 35: { - if (std::atol(optarg) == 0 || std::atol(optarg) == 1) { - params_->ssl_options.ssl_https_verify_peer = std::atol(optarg); - } else { - Usage( - "Failed to parse --ssl-https-verify-peer. The value must be " - "either 0 or 1."); - } - break; - } - case 36: { - if (std::atol(optarg) == 0 || std::atol(optarg) == 1 || - std::atol(optarg) == 2) { - params_->ssl_options.ssl_https_verify_host = std::atol(optarg); - } else { - Usage( - "Failed to parse --ssl-https-verify-host. The value must be " - "either 0, 1, or 2."); - } - break; - } - case 37: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_ca_certificates_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-ca-certificates-file. The value " - "must be a valid file path."); - } - break; - } - case 38: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_client_certificate_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-client-certificate-file. The " - "value must be a valid file path."); - } - break; - } - case 39: { - if (std::string(optarg) == "PEM" || std::string(optarg) == "DER") { - params_->ssl_options.ssl_https_client_certificate_type = optarg; - } else { - Usage( - "Failed to parse --ssl-https-client-certificate-type. " - "Unsupported type provided: '" + - std::string{optarg} + - "'. The available options are 'PEM' or 'DER'."); - } - break; - } - case 40: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_private_key_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-private-key-file. The value must " - "be a valid file path."); - } - break; - } - case 41: { - if (std::string(optarg) == "PEM" || std::string(optarg) == "DER") { - params_->ssl_options.ssl_https_private_key_type = optarg; - } else { - Usage( - "Failed to parse --ssl-https-private-key-type. Unsupported " - "type provided: '" + - std::string{optarg} + - "'. The available options are 'PEM' or 'DER'."); - } - break; - } - case 42: { - params_->verbose_csv = true; - break; - } - case 43: { - params_->enable_mpi = true; - break; - } - case 44: { - params_->trace_options["trace_file"] = {optarg}; - break; - } - case 45: { - std::string trace_level{optarg}; - if (trace_level == "OFF" || trace_level == "TIMESTAMPS" || - trace_level == "TENSORS") { - params_->trace_options["trace_level"] = {trace_level}; - } else { - Usage( - "Failed to parse --trace-level. Unsupported type provided: '" + - trace_level + - "'. The available options are 'OFF', 'TIMESTAMPS', or " - "'TENSORS'."); - } - break; - } - case 46: { - params_->trace_options["trace_rate"] = {optarg}; - break; - } - case 47: { - std::string trace_count{optarg}; - if (std::stoi(trace_count) >= -1) { - params_->trace_options["trace_count"] = {trace_count}; - } else { - Usage( - "Failed to parse --trace-count. The value must be >= 0 or set " - "to -1 (default)."); - } - break; - } - case 48: { - std::string log_frequency{optarg}; - if (std::stoi(log_frequency) >= 0) { - params_->trace_options["log_frequency"] = {log_frequency}; - } else { - Usage("Failed to parse --log-frequency. The value must be >= 0."); - } - break; - } - case 49: { - params_->should_collect_metrics = true; - break; - } - case 50: { - params_->metrics_url = optarg; - params_->metrics_url_specified = true; - break; - } - case 51: { - std::string metrics_interval_ms{optarg}; - if (std::stoi(metrics_interval_ms) > 0) { - params_->metrics_interval_ms = std::stoull(metrics_interval_ms); - params_->metrics_interval_ms_specified = true; - } else { - Usage( - "Failed to parse --metrics-interval. The value must be > 0 " - "msecs."); - } - break; - } - case 52: { - params_->sequence_length_variation = std::stod(optarg); - break; - } - case 53: { - std::string arg = optarg; - - // Remove all spaces in the string - arg.erase( - std::remove_if(arg.begin(), arg.end(), ::isspace), arg.end()); - - std::stringstream ss(arg); - while (ss.good()) { - std::string model_name; - std::string model_version{""}; - std::string tmp_model_name; - - getline(ss, tmp_model_name, ','); - - size_t colon_pos = tmp_model_name.find(":"); - - if (colon_pos == std::string::npos) { - model_name = tmp_model_name; - } else { - model_name = tmp_model_name.substr(0, colon_pos); - model_version = tmp_model_name.substr(colon_pos + 1); - } - - params_->bls_composing_models.push_back( - {model_name, model_version}); - } - break; - } - case 54: { - params_->serial_sequences = true; - break; - } - case 55: { - cb::TensorFormat input_tensor_format{ParseTensorFormat(optarg)}; - if (input_tensor_format == cb::TensorFormat::UNKNOWN) { - Usage( - "Failed to parse --input-tensor-format. Unsupported type " - "provided: '" + - std::string{optarg} + - "'. The available options are 'binary' or 'json'."); - } - params_->input_tensor_format = input_tensor_format; - break; - } - case 56: { - cb::TensorFormat output_tensor_format{ParseTensorFormat(optarg)}; - if (output_tensor_format == cb::TensorFormat::UNKNOWN) { - Usage( - "Failed to parse --output-tensor-format. Unsupported type " - "provided: '" + - std::string{optarg} + - "'. The available options are 'binary' or 'json'."); - } - params_->output_tensor_format = output_tensor_format; - break; - } - case 57: { - PrintVersion(); - break; - } - case 58: { - std::string profile_export_file{optarg}; - if (IsFile(profile_export_file) || IsDirectory(profile_export_file)) { - Usage( - "Failed to parse --profile-export-file. Path must not already " - "exist."); - } - params_->profile_export_file = profile_export_file; - break; - } - case 'v': - params_->extra_verbose = params_->verbose; - params_->verbose = true; - break; - case 'z': - params_->zero_input = true; - break; - case 'd': - params_->using_old_options = true; - params_->dynamic_concurrency_mode = true; - break; - case 'u': - params_->url_specified = true; - params_->url = optarg; - break; - case 'm': - params_->model_name = optarg; - break; - case 'x': - params_->model_version = optarg; - break; - case 'b': { - std::string batch_size{optarg}; - if (std::stoi(batch_size) > 0) { - params_->batch_size = std::stoull(batch_size); - params_->using_batch_size = true; - } else { - Usage("Failed to parse -b (batch size). The value must be > 0."); - } - break; - } - case 't': - params_->using_old_options = true; - params_->concurrent_request_count = std::atoi(optarg); - break; - case 'i': - params_->protocol = ParseProtocol(optarg); - break; - case 'H': { - std::string arg = optarg; - std::string header = arg.substr(0, arg.find(":")); - (*params_->http_headers)[header] = arg.substr(header.size() + 1); - break; - } - case 'c': - params_->using_old_options = true; - params_->max_concurrency = std::atoi(optarg); - break; - case 'f': - params_->filename = optarg; - break; - case '?': - Usage(); - break; -||||||| parent of 52a123a (Avoid relying on std::stoi + try/catch to check valid input) - if (!IsNonNegativeInteger(sequence_id)) { - Usage( - "Failed to parse --sequence-id-range. The range values must " - "be >= 0."); - } - - switch (index) { - case 0: - params_->start_sequence_id = std::stoull(sequence_id); - break; - case 1: - if (params_->start_sequence_id > std::stoull(sequence_id)) { - Usage( - "Failed to parse --sequence-id-range. The 'end' value " - "must be greater than 'start' value."); - } - params_->sequence_id_range = - std::stoull(sequence_id) - params_->start_sequence_id; - break; - } - index++; - } - - break; - } - case 31: { - params_->ssl_options.ssl_grpc_use_ssl = true; - break; - } - case 32: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_root_certifications_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-root-certifications-file. The " - "value must be a valid file path."); - } - break; - } - case 33: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_private_key_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-private-key-file. The value must " - "be a valid file path."); - } - break; - } - case 34: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_grpc_certificate_chain_file = optarg; - } else { - Usage( - "Failed to parse --ssl-grpc-certificate-chain-file. The value " - "must be a valid file path."); - } - break; - } - case 35: { - if (std::atol(optarg) == 0 || std::atol(optarg) == 1) { - params_->ssl_options.ssl_https_verify_peer = std::atol(optarg); - } else { - Usage( - "Failed to parse --ssl-https-verify-peer. The value must be " - "either 0 or 1."); - } - break; - } - case 36: { - if (std::atol(optarg) == 0 || std::atol(optarg) == 1 || - std::atol(optarg) == 2) { - params_->ssl_options.ssl_https_verify_host = std::atol(optarg); - } else { - Usage( - "Failed to parse --ssl-https-verify-host. The value must be " - "either 0, 1, or 2."); - } - break; - } - case 37: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_ca_certificates_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-ca-certificates-file. The value " - "must be a valid file path."); - } - break; - } - case 38: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_client_certificate_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-client-certificate-file. The " - "value must be a valid file path."); - } - break; - } - case 39: { - if (std::string(optarg) == "PEM" || std::string(optarg) == "DER") { - params_->ssl_options.ssl_https_client_certificate_type = optarg; - } else { - Usage( - "Failed to parse --ssl-https-client-certificate-type. " - "Unsupported type provided: '" + - std::string{optarg} + - "'. The available options are 'PEM' or 'DER'."); - } - break; - } - case 40: { - if (IsFile(optarg)) { - params_->ssl_options.ssl_https_private_key_file = optarg; - } else { - Usage( - "Failed to parse --ssl-https-private-key-file. The value must " - "be a valid file path."); - } - break; - } - case 41: { - if (std::string(optarg) == "PEM" || std::string(optarg) == "DER") { - params_->ssl_options.ssl_https_private_key_type = optarg; - } else { - Usage( - "Failed to parse --ssl-https-private-key-type. Unsupported " - "type provided: '" + - std::string{optarg} + - "'. The available options are 'PEM' or 'DER'."); - } - break; - } - case 42: { - params_->verbose_csv = true; - break; - } - case 43: { - params_->enable_mpi = true; - break; - } - case 44: { - params_->trace_options["trace_file"] = {optarg}; - break; - } - case 45: { - std::string trace_level{optarg}; - if (trace_level == "OFF" || trace_level == "TIMESTAMPS" || - trace_level == "TENSORS") { - params_->trace_options["trace_level"] = {trace_level}; - } else { - Usage( - "Failed to parse --trace-level. Unsupported type provided: '" + - trace_level + - "'. The available options are 'OFF', 'TIMESTAMPS', or " - "'TENSORS'."); - } - break; - } - case 46: { - params_->trace_options["trace_rate"] = {optarg}; - break; - } - case 47: { - std::string trace_count{optarg}; - if (std::stoi(trace_count) >= -1) { - params_->trace_options["trace_count"] = {trace_count}; - } else { - Usage( - "Failed to parse --trace-count. The value must be >= 0 or set " - "to -1 (default)."); - } - break; - } - case 48: { - std::string log_frequency{optarg}; - if (std::stoi(log_frequency) >= 0) { - params_->trace_options["log_frequency"] = {log_frequency}; - } else { - Usage("Failed to parse --log-frequency. The value must be >= 0."); - } - break; - } - case 49: { - params_->should_collect_metrics = true; - break; - } - case 50: { - params_->metrics_url = optarg; - params_->metrics_url_specified = true; - break; - } - case 51: { - std::string metrics_interval_ms{optarg}; - if (std::stoi(metrics_interval_ms) > 0) { - params_->metrics_interval_ms = std::stoull(metrics_interval_ms); - params_->metrics_interval_ms_specified = true; - } else { - Usage( - "Failed to parse --metrics-interval. The value must be > 0 " - "msecs."); - } - break; - } - case 52: { - params_->sequence_length_variation = std::stod(optarg); - break; - } - case 53: { - std::string arg = optarg; - - // Remove all spaces in the string - arg.erase( - std::remove_if(arg.begin(), arg.end(), ::isspace), arg.end()); - - std::stringstream ss(arg); - while (ss.good()) { - std::string model_name; - std::string model_version{""}; - std::string tmp_model_name; - - getline(ss, tmp_model_name, ','); - - size_t colon_pos = tmp_model_name.find(":"); - - if (colon_pos == std::string::npos) { - model_name = tmp_model_name; - } else { - model_name = tmp_model_name.substr(0, colon_pos); - model_version = tmp_model_name.substr(colon_pos + 1); - } - - params_->bls_composing_models.push_back( - {model_name, model_version}); - } - break; - } - case 54: { - params_->serial_sequences = true; - break; - } - case 55: { - cb::TensorFormat input_tensor_format{ParseTensorFormat(optarg)}; - if (input_tensor_format == cb::TensorFormat::UNKNOWN) { - Usage( - "Failed to parse --input-tensor-format. Unsupported type " - "provided: '" + - std::string{optarg} + - "'. The available options are 'binary' or 'json'."); - } - params_->input_tensor_format = input_tensor_format; - break; - } - case 56: { - cb::TensorFormat output_tensor_format{ParseTensorFormat(optarg)}; - if (output_tensor_format == cb::TensorFormat::UNKNOWN) { - Usage( - "Failed to parse --output-tensor-format. Unsupported type " - "provided: '" + - std::string{optarg} + - "'. The available options are 'binary' or 'json'."); - } - params_->output_tensor_format = output_tensor_format; - break; - } - case 57: { - PrintVersion(); - break; - } - case 'v': - params_->extra_verbose = params_->verbose; - params_->verbose = true; - break; - case 'z': - params_->zero_input = true; - break; - case 'd': - params_->using_old_options = true; - params_->dynamic_concurrency_mode = true; - break; - case 'u': - params_->url_specified = true; - params_->url = optarg; - break; - case 'm': - params_->model_name = optarg; - break; - case 'x': - params_->model_version = optarg; - break; - case 'b': { - std::string batch_size{optarg}; - if (std::stoi(batch_size) > 0) { - params_->batch_size = std::stoull(batch_size); - params_->using_batch_size = true; - } else { - Usage("Failed to parse -b (batch size). The value must be > 0."); - } - break; - } - case 't': - params_->using_old_options = true; - params_->concurrent_request_count = std::atoi(optarg); - break; - case 'i': - params_->protocol = ParseProtocol(optarg); - break; - case 'H': { - std::string arg = optarg; - std::string header = arg.substr(0, arg.find(":")); - (*params_->http_headers)[header] = arg.substr(header.size() + 1); - break; - } - case 'c': - params_->using_old_options = true; - params_->max_concurrency = std::atoi(optarg); - break; - case 'f': - params_->filename = optarg; - break; - case '?': - Usage(); - break; -======= break; ->>>>>>> 52a123a (Avoid relying on std::stoi + try/catch to check valid input) } case 31: { params_->ssl_options.ssl_grpc_use_ssl = true; @@ -2410,5 +1748,4 @@ CLParser::VerifyOptions() } } } - }} // namespace triton::perfanalyzer