From 420d074e263d5c4d3811d7120f7799150cbd21ea Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Wed, 27 Sep 2023 14:22:21 -0700 Subject: [PATCH 1/6] Initial parameter passing support --- src/c++/library/common.h | 15 +++++++++++ src/c++/library/grpc_client.cc | 17 ++++++++++++ .../client_backend/client_backend.h | 15 +++++++++++ .../triton/triton_client_backend.cc | 16 ++++++++++++ src/c++/perf_analyzer/concurrency_manager.cc | 9 +++++-- src/c++/perf_analyzer/concurrency_manager.h | 5 ++++ src/c++/perf_analyzer/custom_load_manager.cc | 17 ++++++++---- src/c++/perf_analyzer/custom_load_manager.h | 11 ++++++-- src/c++/perf_analyzer/infer_data_manager.cc | 3 +++ src/c++/perf_analyzer/infer_data_manager.h | 5 +++- .../perf_analyzer/infer_data_manager_base.cc | 5 ++++ .../perf_analyzer/infer_data_manager_base.h | 13 +++++++--- .../infer_data_manager_factory.h | 24 ++++++++++++----- .../perf_analyzer/infer_data_manager_shm.cc | 2 ++ .../perf_analyzer/infer_data_manager_shm.h | 8 ++++-- src/c++/perf_analyzer/load_manager.cc | 9 ++++--- src/c++/perf_analyzer/load_manager.h | 5 +++- .../perf_analyzer/mock_infer_data_manager.h | 26 ++++++++++++++----- src/c++/perf_analyzer/perf_analyzer.cc | 15 ++++++----- .../periodic_concurrency_manager.h | 8 ++++-- src/c++/perf_analyzer/request_rate_manager.cc | 11 +++++--- src/c++/perf_analyzer/request_rate_manager.h | 11 ++++++-- .../perf_analyzer/test_concurrency_manager.cc | 20 +++++++------- .../perf_analyzer/test_custom_load_manager.cc | 4 +-- src/c++/perf_analyzer/test_load_manager.cc | 3 ++- .../test_request_rate_manager.cc | 22 +++++++++------- 26 files changed, 229 insertions(+), 70 deletions(-) diff --git a/src/c++/library/common.h b/src/c++/library/common.h index ba98d82ca..913e78764 100644 --- a/src/c++/library/common.h +++ b/src/c++/library/common.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -153,6 +154,18 @@ class InferenceServerClient { InferStat infer_stat_; }; +enum RequestParameterType { STRING = 0, INT = 1, UINT = 2, BOOL = 3 }; +/// +/// Structure to hold Request parameter data for Inference Request. +/// +struct RequestParameter { + std::string str_value; + int64_t int_value; + uint64_t uint_value; + bool bool_value; + RequestParameterType type; +}; + //============================================================================== /// Structure to hold options for Inference Request. /// @@ -221,6 +234,8 @@ struct InferOptions { uint64_t client_timeout_; /// Whether to tell Triton to enable an empty final response. bool triton_enable_empty_final_response_; + /// Additional parameters to pass to the model + std::unordered_map request_parameters; }; //============================================================================== diff --git a/src/c++/library/grpc_client.cc b/src/c++/library/grpc_client.cc index 537608fba..5b931cb44 100644 --- a/src/c++/library/grpc_client.cc +++ b/src/c++/library/grpc_client.cc @@ -1408,6 +1408,23 @@ InferenceServerGrpcClient::PreRunProcessing( options.server_timeout_); } + + for (auto& param : options.request_parameters) { + if (param.second.type == RequestParameterType::STRING) { + (*infer_request_.mutable_parameters())[param.first].set_string_param( + param.second.str_value); + } else if (param.second.type == RequestParameterType::INT) { + (*infer_request_.mutable_parameters())[param.first].set_int64_param( + param.second.int_value); + } else if (param.second.type == RequestParameterType::UINT) { + (*infer_request_.mutable_parameters())[param.first].set_uint64_param( + param.second.uint_value); + } else if (param.second.type == RequestParameterType::BOOL) { + (*infer_request_.mutable_parameters())[param.first].set_bool_param( + param.second.bool_value); + } + } + int index = 0; infer_request_.mutable_raw_input_contents()->Clear(); for (const auto input : inputs) { diff --git a/src/c++/perf_analyzer/client_backend/client_backend.h b/src/c++/perf_analyzer/client_backend/client_backend.h index dd632e67e..526377208 100644 --- a/src/c++/perf_analyzer/client_backend/client_backend.h +++ b/src/c++/perf_analyzer/client_backend/client_backend.h @@ -192,6 +192,18 @@ struct ModelStatistics { uint64_t cache_miss_time_ns_; }; +enum RequestParameterType { STRING = 0, INT = 1, UINT = 2, BOOL = 3 }; +/// +/// Structure to hold Request parameter data for Inference Request. +/// +struct RequestParameter { + std::string str_value; + int64_t int_value; + uint64_t uint_value; + bool bool_value; + RequestParameterType type; +}; + //============================================================================== /// Structure to hold options for Inference Request. /// @@ -230,6 +242,9 @@ struct InferOptions { bool sequence_end_; /// Whether to tell Triton to enable an empty final response. bool triton_enable_empty_final_response_; + + /// Additional parameters to pass to the model + std::unordered_map request_parameters_; }; struct SslOptionsBase { diff --git a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc index 1be578a95..b57260f86 100644 --- a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc +++ b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc @@ -590,6 +590,22 @@ TritonClientBackend::ParseInferOptionsToTriton( } triton_options->triton_enable_empty_final_response_ = options.triton_enable_empty_final_response_; + + for (auto& map_entry : options.request_parameters_) { + auto rp = tc::RequestParameter(); + rp.str_value = map_entry.second.str_value; + rp.int_value = map_entry.second.int_value; + rp.uint_value = map_entry.second.uint_value; + rp.bool_value = map_entry.second.bool_value; + uint64_t val = + static_cast::type>( + map_entry.second.type); + rp.type = static_cast(val); + triton_options->request_parameters.insert( + std::make_pair(map_entry.first, rp)); + } + // triton_options->request_parameters.insert(rp) + // options.request_parameters.begin(), options.request_parameters.end()); } diff --git a/src/c++/perf_analyzer/concurrency_manager.cc b/src/c++/perf_analyzer/concurrency_manager.cc index 7489d95e0..6c3d806a6 100644 --- a/src/c++/perf_analyzer/concurrency_manager.cc +++ b/src/c++/perf_analyzer/concurrency_manager.cc @@ -42,13 +42,16 @@ ConcurrencyManager::Create( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager) { std::unique_ptr local_manager(new ConcurrencyManager( async, streaming, batch_size, max_threads, max_concurrency, - shared_memory_type, output_shm_size, parser, factory)); + shared_memory_type, output_shm_size, request_parameters, parser, + factory)); *manager = std::move(local_manager); @@ -59,11 +62,13 @@ ConcurrencyManager::ConcurrencyManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory) : LoadManager( async, streaming, batch_size, max_threads, shared_memory_type, - output_shm_size, parser, factory), + output_shm_size, request_parameters, parser, factory), execute_(true), max_concurrency_(max_concurrency) { threads_config_.reserve(max_threads); diff --git a/src/c++/perf_analyzer/concurrency_manager.h b/src/c++/perf_analyzer/concurrency_manager.h index 15e211ca1..cb5d522fb 100644 --- a/src/c++/perf_analyzer/concurrency_manager.h +++ b/src/c++/perf_analyzer/concurrency_manager.h @@ -70,6 +70,7 @@ class ConcurrencyManager : public LoadManager { /// \param shared_memory_type The type of shared memory to use for inputs. /// \param output_shm_size The size in bytes of the shared memory to /// allocate for the output. + /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. @@ -79,6 +80,8 @@ class ConcurrencyManager : public LoadManager { const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager); @@ -99,6 +102,8 @@ class ConcurrencyManager : public LoadManager { const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory); diff --git a/src/c++/perf_analyzer/custom_load_manager.cc b/src/c++/perf_analyzer/custom_load_manager.cc index 2dddf3ab2..d35b2c20d 100644 --- a/src/c++/perf_analyzer/custom_load_manager.cc +++ b/src/c++/perf_analyzer/custom_load_manager.cc @@ -39,14 +39,18 @@ CustomLoadManager::Create( const std::string& request_intervals_file, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager) { std::unique_ptr local_manager(new CustomLoadManager( async, streaming, request_intervals_file, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, - shared_memory_type, output_shm_size, serial_sequences, parser, factory)); + shared_memory_type, output_shm_size, serial_sequences, request_parameters, + parser, factory)); *manager = std::move(local_manager); @@ -59,13 +63,16 @@ CustomLoadManager::CustomLoadManager( const uint64_t measurement_window_ms, const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory) : RequestRateManager( async, streaming, Distribution::CUSTOM, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, - shared_memory_type, output_shm_size, serial_sequences, parser, - factory), + shared_memory_type, output_shm_size, serial_sequences, + request_parameters, parser, factory), request_intervals_file_(request_intervals_file) { } diff --git a/src/c++/perf_analyzer/custom_load_manager.h b/src/c++/perf_analyzer/custom_load_manager.h index 6b61de2f0..922a4b20f 100644 --- a/src/c++/perf_analyzer/custom_load_manager.h +++ b/src/c++/perf_analyzer/custom_load_manager.h @@ -68,6 +68,7 @@ class CustomLoadManager : public RequestRateManager { /// \param output_shm_size The size of the shared memory to allocate for the /// output. /// \param serial_sequences Enable serial sequence mode. + /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. @@ -79,7 +80,10 @@ class CustomLoadManager : public RequestRateManager { const std::string& request_intervals_file, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager); @@ -102,7 +106,10 @@ class CustomLoadManager : public RequestRateManager { const uint64_t measurement_window_ms, const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory); cb::Error GenerateSchedule(); diff --git a/src/c++/perf_analyzer/infer_data_manager.cc b/src/c++/perf_analyzer/infer_data_manager.cc index 99a3bcb08..8b89ea806 100644 --- a/src/c++/perf_analyzer/infer_data_manager.cc +++ b/src/c++/perf_analyzer/infer_data_manager.cc @@ -167,6 +167,9 @@ InferDataManager::InitInferDataInput( infer_input->AppendRaw(input_data.data_ptr, input_data.batch1_size)); } } + + AddInferDataParameters(infer_data); + return cb::Error::Success; } diff --git a/src/c++/perf_analyzer/infer_data_manager.h b/src/c++/perf_analyzer/infer_data_manager.h index dd1973c2d..4b41cc776 100644 --- a/src/c++/perf_analyzer/infer_data_manager.h +++ b/src/c++/perf_analyzer/infer_data_manager.h @@ -41,11 +41,14 @@ class InferDataManager : public InferDataManagerBase { public: InferDataManager( const size_t max_threads, const int32_t batch_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) : max_threads_(max_threads), - InferDataManagerBase(batch_size, parser, factory, data_loader) + InferDataManagerBase( + batch_size, request_parameters, parser, factory, data_loader) { } diff --git a/src/c++/perf_analyzer/infer_data_manager_base.cc b/src/c++/perf_analyzer/infer_data_manager_base.cc index 08bd19588..f21fbbc00 100644 --- a/src/c++/perf_analyzer/infer_data_manager_base.cc +++ b/src/c++/perf_analyzer/infer_data_manager_base.cc @@ -179,5 +179,10 @@ InferDataManagerBase::CreateInferInput( return cb::InferInput::Create(infer_input, kind, name, dims, datatype); } +void +InferDataManagerBase::AddInferDataParameters(InferData& infer_data) +{ + infer_data.options_->request_parameters_ = request_parameters_; +} }} // namespace triton::perfanalyzer diff --git a/src/c++/perf_analyzer/infer_data_manager_base.h b/src/c++/perf_analyzer/infer_data_manager_base.h index 7ff6a07c5..d0ae2ab16 100644 --- a/src/c++/perf_analyzer/infer_data_manager_base.h +++ b/src/c++/perf_analyzer/infer_data_manager_base.h @@ -41,11 +41,15 @@ namespace triton { namespace perfanalyzer { class InferDataManagerBase : public IInferDataManager { public: InferDataManagerBase( - const int32_t batch_size, const std::shared_ptr& parser, + const int32_t batch_size, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) - : batch_size_(batch_size), parser_(parser), factory_(factory), - data_loader_(data_loader), backend_kind_(factory->Kind()) + : batch_size_(batch_size), request_parameters_(request_parameters), + parser_(parser), factory_(factory), data_loader_(data_loader), + backend_kind_(factory->Kind()) { } @@ -72,6 +76,7 @@ class InferDataManagerBase : public IInferDataManager { std::shared_ptr data_loader_; std::unique_ptr backend_; cb::BackendKind backend_kind_; + std::unordered_map request_parameters_; /// Gets the input data for the specified input for the specified batch size /// @@ -135,6 +140,8 @@ class InferDataManagerBase : public IInferDataManager { virtual cb::Error InitInferDataOutput( const std::string& name, InferData& infer_data) = 0; + void AddInferDataParameters(InferData& infer_data); + #ifndef DOCTEST_CONFIG_DISABLE public: InferDataManagerBase() = default; diff --git a/src/c++/perf_analyzer/infer_data_manager_factory.h b/src/c++/perf_analyzer/infer_data_manager_factory.h index 58eab717d..6bf24bef8 100644 --- a/src/c++/perf_analyzer/infer_data_manager_factory.h +++ b/src/c++/perf_analyzer/infer_data_manager_factory.h @@ -30,6 +30,7 @@ #include "infer_data_manager.h" #include "infer_data_manager_shm.h" #include "model_parser.h" +#include "perf_utils.h" namespace triton { namespace perfanalyzer { @@ -38,40 +39,49 @@ class InferDataManagerFactory { static std::shared_ptr CreateInferDataManager( const size_t max_threads, const int32_t batch_size, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) { if (shared_memory_type == SharedMemoryType::NO_SHARED_MEMORY) { return CreateInferDataManagerNoShm( - max_threads, batch_size, parser, factory, data_loader); + max_threads, batch_size, request_parameters, parser, factory, + data_loader); } else { return CreateInferDataManagerShm( - batch_size, shared_memory_type, output_shm_size, parser, factory, - data_loader); + batch_size, shared_memory_type, output_shm_size, request_parameters, + parser, factory, data_loader); } } private: static std::shared_ptr CreateInferDataManagerNoShm( const size_t max_threads, const int32_t batch_size, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) { return std::make_shared( - max_threads, batch_size, parser, factory, data_loader); + max_threads, batch_size, request_parameters, parser, factory, + data_loader); } static std::shared_ptr CreateInferDataManagerShm( const int32_t batch_size, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, const std::shared_ptr& parser, + const size_t output_shm_size, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) { return std::make_shared( - batch_size, shared_memory_type, output_shm_size, parser, factory, - data_loader); + batch_size, shared_memory_type, output_shm_size, request_parameters, + parser, factory, data_loader); } }; diff --git a/src/c++/perf_analyzer/infer_data_manager_shm.cc b/src/c++/perf_analyzer/infer_data_manager_shm.cc index 91d691830..6ca4a87ff 100644 --- a/src/c++/perf_analyzer/infer_data_manager_shm.cc +++ b/src/c++/perf_analyzer/infer_data_manager_shm.cc @@ -331,6 +331,8 @@ InferDataManagerShm::InitInferDataInput( RETURN_IF_ERROR(infer_input->SetSharedMemory( region_name, shared_memory_regions_[region_name].byte_size_)); + AddInferDataParameters(infer_data); + return cb::Error::Success; } diff --git a/src/c++/perf_analyzer/infer_data_manager_shm.h b/src/c++/perf_analyzer/infer_data_manager_shm.h index 14d1fd2ee..b684544c5 100644 --- a/src/c++/perf_analyzer/infer_data_manager_shm.h +++ b/src/c++/perf_analyzer/infer_data_manager_shm.h @@ -94,12 +94,16 @@ class InferDataManagerShm : public InferDataManagerBase { public: InferDataManagerShm( const int32_t batch_size, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, const std::shared_ptr& parser, + const size_t output_shm_size, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) : shared_memory_type_(shared_memory_type), output_shm_size_(output_shm_size), - InferDataManagerBase(batch_size, parser, factory, data_loader) + InferDataManagerBase( + batch_size, request_parameters, parser, factory, data_loader) { } diff --git a/src/c++/perf_analyzer/load_manager.cc b/src/c++/perf_analyzer/load_manager.cc index 369317e66..02333cb29 100644 --- a/src/c++/perf_analyzer/load_manager.cc +++ b/src/c++/perf_analyzer/load_manager.cc @@ -159,7 +159,10 @@ LoadManager::GetAndResetNumSentRequests() LoadManager::LoadManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, const std::shared_ptr& parser, + const size_t output_shm_size, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory) : async_(async), streaming_(streaming), batch_size_(batch_size), max_threads_(max_threads), parser_(parser), factory_(factory), @@ -172,8 +175,8 @@ LoadManager::LoadManager( data_loader_.reset(new DataLoader(batch_size_)); infer_data_manager_ = InferDataManagerFactory::CreateInferDataManager( - max_threads, batch_size, shared_memory_type, output_shm_size, parser, - factory, data_loader_); + max_threads, batch_size, shared_memory_type, output_shm_size, + request_parameters, parser, factory, data_loader_); } void diff --git a/src/c++/perf_analyzer/load_manager.h b/src/c++/perf_analyzer/load_manager.h index 5e75ab9ea..bc883e6f6 100644 --- a/src/c++/perf_analyzer/load_manager.h +++ b/src/c++/perf_analyzer/load_manager.h @@ -111,7 +111,10 @@ class LoadManager { LoadManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, const std::shared_ptr& parser, + const size_t output_shm_size, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory); /// Complete any subclass-specific manager initialization tasks. diff --git a/src/c++/perf_analyzer/mock_infer_data_manager.h b/src/c++/perf_analyzer/mock_infer_data_manager.h index f001c20ad..5d6bfaa0e 100644 --- a/src/c++/perf_analyzer/mock_infer_data_manager.h +++ b/src/c++/perf_analyzer/mock_infer_data_manager.h @@ -32,17 +32,22 @@ namespace triton { namespace perfanalyzer { +// std::unordered_map +// request_parameters; class MockInferDataManagerShm : public InferDataManagerShm { public: MockInferDataManagerShm( const int32_t batch_size, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, const std::shared_ptr& parser, + const size_t output_shm_size, + std::unordered_map + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) : InferDataManagerShm( - batch_size, shared_memory_type, output_shm_size, parser, factory, - data_loader) + batch_size, shared_memory_type, output_shm_size, request_parameters, + parser, factory, data_loader) { } @@ -83,10 +88,14 @@ class MockInferDataManager : public InferDataManager { MockInferDataManager( const size_t max_threads, const int32_t batch_size, + std::unordered_map + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) - : InferDataManager(max_threads, batch_size, parser, factory, data_loader) + : InferDataManager( + max_threads, batch_size, request_parameters, parser, factory, + data_loader) { SetupMocks(); } @@ -122,17 +131,20 @@ class MockInferDataManagerFactory { static std::shared_ptr CreateMockInferDataManager( const size_t max_threads, const int32_t batch_size, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + std::unordered_map + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, const std::shared_ptr& data_loader) { if (shared_memory_type == SharedMemoryType::NO_SHARED_MEMORY) { return std::make_shared>( - max_threads, batch_size, parser, factory, data_loader); + max_threads, batch_size, request_parameters, parser, factory, + data_loader); } else { return std::make_shared>( - batch_size, shared_memory_type, output_shm_size, parser, factory, - data_loader); + batch_size, shared_memory_type, output_shm_size, request_parameters, + parser, factory, data_loader); } } }; diff --git a/src/c++/perf_analyzer/perf_analyzer.cc b/src/c++/perf_analyzer/perf_analyzer.cc index c3e5e5f90..ea59e22b4 100644 --- a/src/c++/perf_analyzer/perf_analyzer.cc +++ b/src/c++/perf_analyzer/perf_analyzer.cc @@ -205,8 +205,8 @@ PerfAnalyzer::CreateAnalyzerObjects() pa::ConcurrencyManager::Create( params_->async, params_->streaming, params_->batch_size, params_->max_threads, params_->max_concurrency, - params_->shared_memory_type, params_->output_shm_size, parser_, - factory, &manager), + params_->shared_memory_type, params_->output_shm_size, + params_->request_parameters, parser_, factory, &manager), "failed to create concurrency manager"); } else if (params_->is_using_periodic_concurrency_mode) { @@ -214,7 +214,8 @@ PerfAnalyzer::CreateAnalyzerObjects() params_->async, params_->streaming, params_->batch_size, params_->max_threads, params_->max_concurrency, params_->shared_memory_type, params_->output_shm_size, parser_, factory, - params_->periodic_concurrency_range, params_->request_period); + params_->periodic_concurrency_range, params_->request_period, + params_->request_parameters); } else if (params_->using_request_rate_range) { if ((params_->sequence_id_range != 0) && (params_->sequence_id_range < params_->num_of_sequences)) { @@ -230,8 +231,8 @@ PerfAnalyzer::CreateAnalyzerObjects() params_->max_trials, params_->request_distribution, params_->batch_size, params_->max_threads, params_->num_of_sequences, params_->shared_memory_type, - params_->output_shm_size, params_->serial_sequences, parser_, - factory, &manager), + params_->output_shm_size, params_->serial_sequences, + params_->request_parameters, parser_, factory, &manager), "failed to create request rate manager"); } else { @@ -249,8 +250,8 @@ PerfAnalyzer::CreateAnalyzerObjects() params_->max_trials, params_->request_intervals_file, params_->batch_size, params_->max_threads, params_->num_of_sequences, params_->shared_memory_type, - params_->output_shm_size, params_->serial_sequences, parser_, - factory, &manager), + params_->output_shm_size, params_->serial_sequences, + params_->request_parameters, parser_, factory, &manager), "failed to create custom load manager"); } diff --git a/src/c++/perf_analyzer/periodic_concurrency_manager.h b/src/c++/perf_analyzer/periodic_concurrency_manager.h index dca2797b7..db612fd96 100644 --- a/src/c++/perf_analyzer/periodic_concurrency_manager.h +++ b/src/c++/perf_analyzer/periodic_concurrency_manager.h @@ -42,12 +42,16 @@ class PeriodicConcurrencyManager : public ConcurrencyManager { const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, + const std::shared_ptr& parser, const std::shared_ptr& factory, - const Range concurrency_range, const uint64_t request_period) + const Range concurrency_range, const uint64_t request_period, + const std::unordered_map& + request_parameters) : ConcurrencyManager( async, streaming, batch_size, max_threads, max_concurrency, - shared_memory_type, output_shm_size, parser, factory), + shared_memory_type, output_shm_size, parser, factory, + request_parameters), concurrency_range_(concurrency_range), request_period_(request_period) { } diff --git a/src/c++/perf_analyzer/request_rate_manager.cc b/src/c++/perf_analyzer/request_rate_manager.cc index 8463c40c4..26f68d79a 100644 --- a/src/c++/perf_analyzer/request_rate_manager.cc +++ b/src/c++/perf_analyzer/request_rate_manager.cc @@ -42,14 +42,17 @@ RequestRateManager::Create( Distribution request_distribution, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager) { std::unique_ptr local_manager(new RequestRateManager( async, streaming, request_distribution, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, shared_memory_type, - output_shm_size, serial_sequences, parser, factory)); + output_shm_size, serial_sequences, request_parameters, parser, factory)); *manager = std::move(local_manager); @@ -62,11 +65,13 @@ RequestRateManager::RequestRateManager( const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, const bool serial_sequences, + const std::unordered_map& + request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory) : LoadManager( async, streaming, batch_size, max_threads, shared_memory_type, - output_shm_size, parser, factory), + output_shm_size, request_parameters, parser, factory), request_distribution_(request_distribution), execute_(false), num_of_sequences_(num_of_sequences), serial_sequences_(serial_sequences) { diff --git a/src/c++/perf_analyzer/request_rate_manager.h b/src/c++/perf_analyzer/request_rate_manager.h index a698f0139..0d53f4ac8 100644 --- a/src/c++/perf_analyzer/request_rate_manager.h +++ b/src/c++/perf_analyzer/request_rate_manager.h @@ -80,6 +80,7 @@ class RequestRateManager : public LoadManager { /// \param output_shm_size The size of the shared memory to allocate for the /// output. /// \param serial_sequences Enable serial sequence mode. + /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. @@ -91,7 +92,10 @@ class RequestRateManager : public LoadManager { Distribution request_distribution, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory, std::unique_ptr* manager); @@ -108,7 +112,10 @@ class RequestRateManager : public LoadManager { const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, const std::shared_ptr& parser, + const bool serial_sequences, + const std::unordered_map& + request_parameters, + const std::shared_ptr& parser, const std::shared_ptr& factory); void InitManagerFinalize() override; diff --git a/src/c++/perf_analyzer/test_concurrency_manager.cc b/src/c++/perf_analyzer/test_concurrency_manager.cc index b454e6272..a5ded6f1a 100644 --- a/src/c++/perf_analyzer/test_concurrency_manager.cc +++ b/src/c++/perf_analyzer/test_concurrency_manager.cc @@ -53,8 +53,8 @@ class TestConcurrencyManager : public TestLoadManagerBase, ConcurrencyManager( params.async, params.streaming, params.batch_size, params.max_threads, params.max_concurrency, - params.shared_memory_type, params.output_shm_size, GetParser(), - GetFactory()) + params.shared_memory_type, params.output_shm_size, + params.request_parameters, GetParser(), GetFactory()) { } @@ -561,8 +561,8 @@ TEST_CASE("Concurrency - shared memory infer input calls") tcm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, tcm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, tcm.factory_, mip.mock_data_loader_); std::shared_ptr thread_stat{std::make_shared()}; std::shared_ptr thread_config{ @@ -635,8 +635,8 @@ TEST_CASE("Concurrency - Shared memory methods") tcm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, tcm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, tcm.factory_, mip.mock_data_loader_); tcm.InitManager( params.string_length, params.string_data, params.zero_input, @@ -660,8 +660,8 @@ TEST_CASE("Concurrency - Shared memory methods") tcm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, tcm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, tcm.factory_, mip.mock_data_loader_); tcm.InitManager( params.string_length, params.string_data, params.zero_input, @@ -682,8 +682,8 @@ TEST_CASE("Concurrency - Shared memory methods") tcm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, tcm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, tcm.factory_, mip.mock_data_loader_); tcm.InitManager( params.string_length, params.string_data, params.zero_input, params.user_data, params.start_sequence_id, params.sequence_id_range, diff --git a/src/c++/perf_analyzer/test_custom_load_manager.cc b/src/c++/perf_analyzer/test_custom_load_manager.cc index bf92f329d..fe03ef0ea 100644 --- a/src/c++/perf_analyzer/test_custom_load_manager.cc +++ b/src/c++/perf_analyzer/test_custom_load_manager.cc @@ -58,8 +58,8 @@ class TestCustomLoadManager : public TestLoadManagerBase, params.async, params.streaming, "INTERVALS_FILE", params.batch_size, params.measurement_window_ms, params.max_trials, params.max_threads, params.num_of_sequences, params.shared_memory_type, - params.output_shm_size, params.serial_sequences, GetParser(), - GetFactory()) + params.output_shm_size, params.serial_sequences, + params.request_parameters, GetParser(), GetFactory()) { InitManager( params.string_length, params.string_data, params.zero_input, diff --git a/src/c++/perf_analyzer/test_load_manager.cc b/src/c++/perf_analyzer/test_load_manager.cc index 2a11e0749..992b84e65 100644 --- a/src/c++/perf_analyzer/test_load_manager.cc +++ b/src/c++/perf_analyzer/test_load_manager.cc @@ -58,7 +58,8 @@ class TestLoadManager : public TestLoadManagerBase, public LoadManager { LoadManager( params.async, params.streaming, params.batch_size, params.max_threads, params.shared_memory_type, - params.output_shm_size, GetParser(), GetFactory()) + params.output_shm_size, params.request_parameters, GetParser(), + GetFactory()) { } diff --git a/src/c++/perf_analyzer/test_request_rate_manager.cc b/src/c++/perf_analyzer/test_request_rate_manager.cc index 3e29a8e63..31f3b9da3 100644 --- a/src/c++/perf_analyzer/test_request_rate_manager.cc +++ b/src/c++/perf_analyzer/test_request_rate_manager.cc @@ -61,7 +61,8 @@ class TestRequestRateManager : public TestLoadManagerBase, params.batch_size, params.measurement_window_ms, params.max_trials, params.max_threads, params.num_of_sequences, params.shared_memory_type, params.output_shm_size, - params.serial_sequences, GetParser(), GetFactory()) + params.serial_sequences, params.request_parameters, GetParser(), + GetFactory()) { } @@ -368,7 +369,8 @@ class TestRequestRateManager : public TestLoadManagerBase, infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params_.max_threads, params_.batch_size, params_.shared_memory_type, - params_.output_shm_size, mmp, factory_, mdl); + params_.output_shm_size, params_.request_parameters, mmp, factory_, + mdl); parser_ = mmp; data_loader_ = mdl; @@ -1549,8 +1551,8 @@ TEST_CASE("Request rate - Shared memory methods") trrm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, trrm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, trrm.factory_, mip.mock_data_loader_); trrm.parser_ = mip.mock_model_parser_; trrm.data_loader_ = mip.mock_data_loader_; @@ -1576,8 +1578,8 @@ TEST_CASE("Request rate - Shared memory methods") trrm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, trrm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, trrm.factory_, mip.mock_data_loader_); trrm.parser_ = mip.mock_model_parser_; trrm.data_loader_ = mip.mock_data_loader_; @@ -1601,8 +1603,8 @@ TEST_CASE("Request rate - Shared memory methods") trrm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, trrm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, trrm.factory_, mip.mock_data_loader_); trrm.parser_ = mip.mock_model_parser_; trrm.data_loader_ = mip.mock_data_loader_; @@ -1692,8 +1694,8 @@ TEST_CASE("Request rate - Shared memory infer input calls") trrm.infer_data_manager_ = MockInferDataManagerFactory::CreateMockInferDataManager( params.max_threads, params.batch_size, params.shared_memory_type, - params.output_shm_size, mip.mock_model_parser_, trrm.factory_, - mip.mock_data_loader_); + params.output_shm_size, params.request_parameters, + mip.mock_model_parser_, trrm.factory_, mip.mock_data_loader_); std::shared_ptr thread_stat{std::make_shared()}; std::shared_ptr thread_config{ From ffd81cbb80164cd786e99b808556ba8edc38f827 Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Wed, 27 Sep 2023 16:28:34 -0700 Subject: [PATCH 2/6] Fix parameter ordering --- src/c++/perf_analyzer/command_line_parser.cc | 8 +++---- src/c++/perf_analyzer/command_line_parser.h | 2 +- src/c++/perf_analyzer/concurrency_manager.cc | 18 +++++++------- src/c++/perf_analyzer/concurrency_manager.h | 14 +++++------ src/c++/perf_analyzer/custom_load_manager.cc | 24 +++++++++---------- src/c++/perf_analyzer/custom_load_manager.h | 18 +++++++------- src/c++/perf_analyzer/load_manager.cc | 7 +++--- src/c++/perf_analyzer/load_manager.h | 7 +++--- src/c++/perf_analyzer/perf_analyzer.cc | 12 +++++----- src/c++/perf_analyzer/perf_utils.h | 16 ++++++------- src/c++/perf_analyzer/request_rate_manager.cc | 19 +++++++-------- src/c++/perf_analyzer/request_rate_manager.h | 18 +++++++------- .../perf_analyzer/test_command_line_parser.cc | 10 ++++---- .../perf_analyzer/test_concurrency_manager.cc | 4 ++-- .../perf_analyzer/test_custom_load_manager.cc | 4 ++-- src/c++/perf_analyzer/test_load_manager.cc | 4 ++-- .../test_request_rate_manager.cc | 4 ++-- 17 files changed, 90 insertions(+), 99 deletions(-) diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index 5a73d5927..d4ec474b8 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -1601,15 +1601,15 @@ CLParser::ParseCommandLine(int argc, char** argv) std::string value{values[1]}; std::string type{values[2]}; - RequestParameter param; + cb::RequestParameter param; if (type == "bool") { - param.type = RequestParameterType::BOOL; + param.type = cb::RequestParameterType::BOOL; param.bool_value = value == "true" ? true : false; } else if (type == "int") { - param.type = RequestParameterType::INT; + param.type = cb::RequestParameterType::INT; param.int_value = std::stoll(value); } else if (type == "string") { - param.type = RequestParameterType::STRING; + param.type = cb::RequestParameterType::STRING; param.str_value = value; } else { Usage( diff --git a/src/c++/perf_analyzer/command_line_parser.h b/src/c++/perf_analyzer/command_line_parser.h index 518e7b2cf..9ff4869ff 100644 --- a/src/c++/perf_analyzer/command_line_parser.h +++ b/src/c++/perf_analyzer/command_line_parser.h @@ -58,7 +58,7 @@ struct PerfAnalyzerParameters { uint64_t measurement_window_ms = 5000; bool using_concurrency_range = false; Range concurrency_range{1, 1, 1}; - std::unordered_map request_parameters; + std::unordered_map request_parameters; uint64_t latency_threshold_ms = NO_LIMIT; double stability_threshold = 0.1; size_t max_trials = 10; diff --git a/src/c++/perf_analyzer/concurrency_manager.cc b/src/c++/perf_analyzer/concurrency_manager.cc index 6c3d806a6..a64062cc0 100644 --- a/src/c++/perf_analyzer/concurrency_manager.cc +++ b/src/c++/perf_analyzer/concurrency_manager.cc @@ -42,16 +42,16 @@ ConcurrencyManager::Create( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const std::unordered_map& - request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager) + std::unique_ptr* manager, + const std::unordered_map& + request_parameters) { std::unique_ptr local_manager(new ConcurrencyManager( async, streaming, batch_size, max_threads, max_concurrency, - shared_memory_type, output_shm_size, request_parameters, parser, - factory)); + shared_memory_type, output_shm_size, parser, factory, + request_parameters)); *manager = std::move(local_manager); @@ -62,13 +62,13 @@ ConcurrencyManager::ConcurrencyManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const std::unordered_map& - request_parameters, const std::shared_ptr& parser, - const std::shared_ptr& factory) + const std::shared_ptr& factory, + const std::unordered_map& + request_parameters) : LoadManager( async, streaming, batch_size, max_threads, shared_memory_type, - output_shm_size, request_parameters, parser, factory), + output_shm_size, parser, factory, request_parameters), execute_(true), max_concurrency_(max_concurrency) { threads_config_.reserve(max_threads); diff --git a/src/c++/perf_analyzer/concurrency_manager.h b/src/c++/perf_analyzer/concurrency_manager.h index cb5d522fb..513d7396c 100644 --- a/src/c++/perf_analyzer/concurrency_manager.h +++ b/src/c++/perf_analyzer/concurrency_manager.h @@ -70,21 +70,21 @@ class ConcurrencyManager : public LoadManager { /// \param shared_memory_type The type of shared memory to use for inputs. /// \param output_shm_size The size in bytes of the shared memory to /// allocate for the output. - /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. /// \param manager Returns a new ConcurrencyManager object. + /// \param request_parameters Custom request parameters to send to the server /// \return cb::Error object indicating success or failure. static cb::Error Create( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const std::unordered_map& - request_parameters, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager); + std::unique_ptr* manager, + const std::unordered_map& + request_parameters); /// Adjusts the number of concurrent requests to be the same as /// 'concurrent_request_count' (by creating or pausing threads) @@ -102,10 +102,10 @@ class ConcurrencyManager : public LoadManager { const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const size_t max_concurrency, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const std::unordered_map& - request_parameters, const std::shared_ptr& parser, - const std::shared_ptr& factory); + const std::shared_ptr& factory, + const std::unordered_map& + request_parameters); // The number of worker threads with non-zero concurrencies size_t active_threads_; diff --git a/src/c++/perf_analyzer/custom_load_manager.cc b/src/c++/perf_analyzer/custom_load_manager.cc index d35b2c20d..32e5693b0 100644 --- a/src/c++/perf_analyzer/custom_load_manager.cc +++ b/src/c++/perf_analyzer/custom_load_manager.cc @@ -39,18 +39,17 @@ CustomLoadManager::Create( const std::string& request_intervals_file, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, - const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, + const bool serial_sequences, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager) + std::unique_ptr* manager, + const std::unordered_map& + request_parameters) { std::unique_ptr local_manager(new CustomLoadManager( async, streaming, request_intervals_file, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, - shared_memory_type, output_shm_size, serial_sequences, request_parameters, - parser, factory)); + shared_memory_type, output_shm_size, serial_sequences, parser, factory, + request_parameters)); *manager = std::move(local_manager); @@ -63,16 +62,15 @@ CustomLoadManager::CustomLoadManager( const uint64_t measurement_window_ms, const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, + const bool serial_sequences, const std::shared_ptr& parser, + const std::shared_ptr& factory, const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, - const std::shared_ptr& factory) + request_parameters) : RequestRateManager( async, streaming, Distribution::CUSTOM, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, - shared_memory_type, output_shm_size, serial_sequences, - request_parameters, parser, factory), + shared_memory_type, output_shm_size, serial_sequences, parser, + factory, request_parameters), request_intervals_file_(request_intervals_file) { } diff --git a/src/c++/perf_analyzer/custom_load_manager.h b/src/c++/perf_analyzer/custom_load_manager.h index 922a4b20f..c762e9c7e 100644 --- a/src/c++/perf_analyzer/custom_load_manager.h +++ b/src/c++/perf_analyzer/custom_load_manager.h @@ -68,11 +68,11 @@ class CustomLoadManager : public RequestRateManager { /// \param output_shm_size The size of the shared memory to allocate for the /// output. /// \param serial_sequences Enable serial sequence mode. - /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. /// \param manager Returns a new ConcurrencyManager object. + /// \param request_parameters Custom request parameters to send to the server /// \return cb::Error object indicating success or failure. static cb::Error Create( const bool async, const bool streaming, @@ -80,12 +80,11 @@ class CustomLoadManager : public RequestRateManager { const std::string& request_intervals_file, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, - const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, + const bool serial_sequences, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager); + std::unique_ptr* manager, + const std::unordered_map& + request_parameter); /// Initializes the load manager with the provided file containing request /// intervals @@ -106,11 +105,10 @@ class CustomLoadManager : public RequestRateManager { const uint64_t measurement_window_ms, const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, + const bool serial_sequences, const std::shared_ptr& parser, + const std::shared_ptr& factory, const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, - const std::shared_ptr& factory); + request_parameters); cb::Error GenerateSchedule(); diff --git a/src/c++/perf_analyzer/load_manager.cc b/src/c++/perf_analyzer/load_manager.cc index 02333cb29..ac9150a9d 100644 --- a/src/c++/perf_analyzer/load_manager.cc +++ b/src/c++/perf_analyzer/load_manager.cc @@ -159,11 +159,10 @@ LoadManager::GetAndResetNumSentRequests() LoadManager::LoadManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, + const size_t output_shm_size, const std::shared_ptr& parser, + const std::shared_ptr& factory, const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, - const std::shared_ptr& factory) + request_parameters) : async_(async), streaming_(streaming), batch_size_(batch_size), max_threads_(max_threads), parser_(parser), factory_(factory), using_json_data_(false) diff --git a/src/c++/perf_analyzer/load_manager.h b/src/c++/perf_analyzer/load_manager.h index bc883e6f6..799bfa75f 100644 --- a/src/c++/perf_analyzer/load_manager.h +++ b/src/c++/perf_analyzer/load_manager.h @@ -111,11 +111,10 @@ class LoadManager { LoadManager( const bool async, const bool streaming, const int32_t batch_size, const size_t max_threads, const SharedMemoryType shared_memory_type, - const size_t output_shm_size, + const size_t output_shm_size, const std::shared_ptr& parser, + const std::shared_ptr& factory, const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, - const std::shared_ptr& factory); + request_parameters); /// Complete any subclass-specific manager initialization tasks. virtual void InitManagerFinalize() {} diff --git a/src/c++/perf_analyzer/perf_analyzer.cc b/src/c++/perf_analyzer/perf_analyzer.cc index ea59e22b4..46b665757 100644 --- a/src/c++/perf_analyzer/perf_analyzer.cc +++ b/src/c++/perf_analyzer/perf_analyzer.cc @@ -205,8 +205,8 @@ PerfAnalyzer::CreateAnalyzerObjects() pa::ConcurrencyManager::Create( params_->async, params_->streaming, params_->batch_size, params_->max_threads, params_->max_concurrency, - params_->shared_memory_type, params_->output_shm_size, - params_->request_parameters, parser_, factory, &manager), + params_->shared_memory_type, params_->output_shm_size, parser_, + factory, &manager, params_->request_parameters), "failed to create concurrency manager"); } else if (params_->is_using_periodic_concurrency_mode) { @@ -231,8 +231,8 @@ PerfAnalyzer::CreateAnalyzerObjects() params_->max_trials, params_->request_distribution, params_->batch_size, params_->max_threads, params_->num_of_sequences, params_->shared_memory_type, - params_->output_shm_size, params_->serial_sequences, - params_->request_parameters, parser_, factory, &manager), + params_->output_shm_size, params_->serial_sequences, parser_, + factory, &manager, params_->request_parameters), "failed to create request rate manager"); } else { @@ -250,8 +250,8 @@ PerfAnalyzer::CreateAnalyzerObjects() params_->max_trials, params_->request_intervals_file, params_->batch_size, params_->max_threads, params_->num_of_sequences, params_->shared_memory_type, - params_->output_shm_size, params_->serial_sequences, - params_->request_parameters, parser_, factory, &manager), + params_->output_shm_size, params_->serial_sequences, parser_, + factory, &manager, params_->request_parameters), "failed to create custom load manager"); } diff --git a/src/c++/perf_analyzer/perf_utils.h b/src/c++/perf_analyzer/perf_utils.h index 0871de42c..79b7090f3 100644 --- a/src/c++/perf_analyzer/perf_utils.h +++ b/src/c++/perf_analyzer/perf_utils.h @@ -83,14 +83,14 @@ class Range { T step; }; -enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; - -struct RequestParameter { - std::string str_value; - int64_t int_value; - bool bool_value; - RequestParameterType type; -}; +// enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; + +// struct RequestParameter { +// std::string str_value; +// int64_t int_value; +// bool bool_value; +// RequestParameterType type; +// }; // Converts the datatype from tensorflow to perf analyzer space // \param tf_dtype The data type string returned from the model metadata. diff --git a/src/c++/perf_analyzer/request_rate_manager.cc b/src/c++/perf_analyzer/request_rate_manager.cc index 26f68d79a..a79c52ff4 100644 --- a/src/c++/perf_analyzer/request_rate_manager.cc +++ b/src/c++/perf_analyzer/request_rate_manager.cc @@ -42,17 +42,16 @@ RequestRateManager::Create( Distribution request_distribution, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, - const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, + const bool serial_sequences, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager) + std::unique_ptr* manager, + const std::unordered_map& + request_parameters) { std::unique_ptr local_manager(new RequestRateManager( async, streaming, request_distribution, batch_size, measurement_window_ms, max_trials, max_threads, num_of_sequences, shared_memory_type, - output_shm_size, serial_sequences, request_parameters, parser, factory)); + output_shm_size, serial_sequences, parser, factory, request_parameters)); *manager = std::move(local_manager); @@ -65,13 +64,13 @@ RequestRateManager::RequestRateManager( const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, const bool serial_sequences, - const std::unordered_map& - request_parameters, const std::shared_ptr& parser, - const std::shared_ptr& factory) + const std::shared_ptr& factory, + const std::unordered_map& + request_parameters) : LoadManager( async, streaming, batch_size, max_threads, shared_memory_type, - output_shm_size, request_parameters, parser, factory), + output_shm_size, parser, factory, request_parameters), request_distribution_(request_distribution), execute_(false), num_of_sequences_(num_of_sequences), serial_sequences_(serial_sequences) { diff --git a/src/c++/perf_analyzer/request_rate_manager.h b/src/c++/perf_analyzer/request_rate_manager.h index 0d53f4ac8..deb8ed953 100644 --- a/src/c++/perf_analyzer/request_rate_manager.h +++ b/src/c++/perf_analyzer/request_rate_manager.h @@ -80,11 +80,11 @@ class RequestRateManager : public LoadManager { /// \param output_shm_size The size of the shared memory to allocate for the /// output. /// \param serial_sequences Enable serial sequence mode. - /// \param request_parameters Custom request parameters to send to the server /// \param parser The ModelParser object to get the model details. /// \param factory The ClientBackendFactory object used to create /// client to the server. /// \param manager Returns a new ConcurrencyManager object. + /// \param request_parameters Custom request parameters to send to the server /// \return cb::Error object indicating success or failure. static cb::Error Create( const bool async, const bool streaming, @@ -92,12 +92,11 @@ class RequestRateManager : public LoadManager { Distribution request_distribution, const int32_t batch_size, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, - const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, + const bool serial_sequences, const std::shared_ptr& parser, const std::shared_ptr& factory, - std::unique_ptr* manager); + std::unique_ptr* manager, + const std::unordered_map& + request_parameters); /// Adjusts the rate of issuing requests to be the same as 'request_rate' /// \param request_rate The rate at which requests must be issued to the @@ -112,11 +111,10 @@ class RequestRateManager : public LoadManager { const size_t max_trials, const size_t max_threads, const uint32_t num_of_sequences, const SharedMemoryType shared_memory_type, const size_t output_shm_size, - const bool serial_sequences, + const bool serial_sequences, const std::shared_ptr& parser, + const std::shared_ptr& factory, const std::unordered_map& - request_parameters, - const std::shared_ptr& parser, - const std::shared_ptr& factory); + request_parameters); void InitManagerFinalize() override; diff --git a/src/c++/perf_analyzer/test_command_line_parser.cc b/src/c++/perf_analyzer/test_command_line_parser.cc index bdf819ff8..0a802e3f1 100644 --- a/src/c++/perf_analyzer/test_command_line_parser.cc +++ b/src/c++/perf_analyzer/test_command_line_parser.cc @@ -196,11 +196,11 @@ CHECK_PARAMS(PAParamsPtr act, PAParamsPtr exp) "Unexpected parameter: ", act_param.first); CHECK(act_param.second.type == exp_param->second.type); - if (act_param.second.type == RequestParameterType::STRING) { + if (act_param.second.type == cb::RequestParameterType::STRING) { CHECK(act_param.second.str_value == exp_param->second.str_value); - } else if (act_param.second.type == RequestParameterType::INT) { + } else if (act_param.second.type == cb::RequestParameterType::INT) { CHECK(act_param.second.int_value == exp_param->second.int_value); - } else if (act_param.second.type == RequestParameterType::BOOL) { + } else if (act_param.second.type == cb::RequestParameterType::BOOL) { CHECK(act_param.second.bool_value == exp_param->second.bool_value); } } @@ -1392,9 +1392,9 @@ TEST_CASE("Testing Command Line Parser") REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); CHECK(!parser.UsageCalled()); - RequestParameter param; + cb::RequestParameter param; param.int_value = 256; - param.type = RequestParameterType::INT; + param.type = cb::RequestParameterType::INT; exp->request_parameters["max_tokens"] = param; } diff --git a/src/c++/perf_analyzer/test_concurrency_manager.cc b/src/c++/perf_analyzer/test_concurrency_manager.cc index a5ded6f1a..58d3a3031 100644 --- a/src/c++/perf_analyzer/test_concurrency_manager.cc +++ b/src/c++/perf_analyzer/test_concurrency_manager.cc @@ -53,8 +53,8 @@ class TestConcurrencyManager : public TestLoadManagerBase, ConcurrencyManager( params.async, params.streaming, params.batch_size, params.max_threads, params.max_concurrency, - params.shared_memory_type, params.output_shm_size, - params.request_parameters, GetParser(), GetFactory()) + params.shared_memory_type, params.output_shm_size, GetParser(), + GetFactory(), params.request_parameters) { } diff --git a/src/c++/perf_analyzer/test_custom_load_manager.cc b/src/c++/perf_analyzer/test_custom_load_manager.cc index fe03ef0ea..0cb6c4c5c 100644 --- a/src/c++/perf_analyzer/test_custom_load_manager.cc +++ b/src/c++/perf_analyzer/test_custom_load_manager.cc @@ -58,8 +58,8 @@ class TestCustomLoadManager : public TestLoadManagerBase, params.async, params.streaming, "INTERVALS_FILE", params.batch_size, params.measurement_window_ms, params.max_trials, params.max_threads, params.num_of_sequences, params.shared_memory_type, - params.output_shm_size, params.serial_sequences, - params.request_parameters, GetParser(), GetFactory()) + params.output_shm_size, params.serial_sequences, GetParser(), + GetFactory(), params.request_parameters) { InitManager( params.string_length, params.string_data, params.zero_input, diff --git a/src/c++/perf_analyzer/test_load_manager.cc b/src/c++/perf_analyzer/test_load_manager.cc index 992b84e65..c057516f0 100644 --- a/src/c++/perf_analyzer/test_load_manager.cc +++ b/src/c++/perf_analyzer/test_load_manager.cc @@ -58,8 +58,8 @@ class TestLoadManager : public TestLoadManagerBase, public LoadManager { LoadManager( params.async, params.streaming, params.batch_size, params.max_threads, params.shared_memory_type, - params.output_shm_size, params.request_parameters, GetParser(), - GetFactory()) + params.output_shm_size, GetParser(), GetFactory(), + params.request_parameters) { } diff --git a/src/c++/perf_analyzer/test_request_rate_manager.cc b/src/c++/perf_analyzer/test_request_rate_manager.cc index 31f3b9da3..008424b72 100644 --- a/src/c++/perf_analyzer/test_request_rate_manager.cc +++ b/src/c++/perf_analyzer/test_request_rate_manager.cc @@ -61,8 +61,8 @@ class TestRequestRateManager : public TestLoadManagerBase, params.batch_size, params.measurement_window_ms, params.max_trials, params.max_threads, params.num_of_sequences, params.shared_memory_type, params.output_shm_size, - params.serial_sequences, params.request_parameters, GetParser(), - GetFactory()) + params.serial_sequences, GetParser(), GetFactory(), + params.request_parameters) { } From 49a9cae83f27efd4933057563daa1a4c82b15d9f Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Thu, 28 Sep 2023 10:39:07 -0700 Subject: [PATCH 3/6] Remove commented code --- src/c++/perf_analyzer/perf_utils.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/c++/perf_analyzer/perf_utils.h b/src/c++/perf_analyzer/perf_utils.h index 79b7090f3..7166936a9 100644 --- a/src/c++/perf_analyzer/perf_utils.h +++ b/src/c++/perf_analyzer/perf_utils.h @@ -83,15 +83,6 @@ class Range { T step; }; -// enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; - -// struct RequestParameter { -// std::string str_value; -// int64_t int_value; -// bool bool_value; -// RequestParameterType type; -// }; - // Converts the datatype from tensorflow to perf analyzer space // \param tf_dtype The data type string returned from the model metadata. // \param datatype Returns the datatype in perf_analyzer space. From f255c2222ddb475d30b9e2b6e6d0d1c7bb26c0e6 Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Thu, 28 Sep 2023 11:12:35 -0700 Subject: [PATCH 4/6] Remove unnecessary type in request parameter --- src/c++/library/common.h | 3 +-- src/c++/library/grpc_client.cc | 3 --- src/c++/perf_analyzer/client_backend/client_backend.h | 3 +-- .../client_backend/triton/triton_client_backend.cc | 3 --- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/c++/library/common.h b/src/c++/library/common.h index 913e78764..0588762a3 100644 --- a/src/c++/library/common.h +++ b/src/c++/library/common.h @@ -154,14 +154,13 @@ class InferenceServerClient { InferStat infer_stat_; }; -enum RequestParameterType { STRING = 0, INT = 1, UINT = 2, BOOL = 3 }; +enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; /// /// Structure to hold Request parameter data for Inference Request. /// struct RequestParameter { std::string str_value; int64_t int_value; - uint64_t uint_value; bool bool_value; RequestParameterType type; }; diff --git a/src/c++/library/grpc_client.cc b/src/c++/library/grpc_client.cc index 5b931cb44..36fdead87 100644 --- a/src/c++/library/grpc_client.cc +++ b/src/c++/library/grpc_client.cc @@ -1416,9 +1416,6 @@ InferenceServerGrpcClient::PreRunProcessing( } else if (param.second.type == RequestParameterType::INT) { (*infer_request_.mutable_parameters())[param.first].set_int64_param( param.second.int_value); - } else if (param.second.type == RequestParameterType::UINT) { - (*infer_request_.mutable_parameters())[param.first].set_uint64_param( - param.second.uint_value); } else if (param.second.type == RequestParameterType::BOOL) { (*infer_request_.mutable_parameters())[param.first].set_bool_param( param.second.bool_value); diff --git a/src/c++/perf_analyzer/client_backend/client_backend.h b/src/c++/perf_analyzer/client_backend/client_backend.h index 526377208..3070afaa2 100644 --- a/src/c++/perf_analyzer/client_backend/client_backend.h +++ b/src/c++/perf_analyzer/client_backend/client_backend.h @@ -192,14 +192,13 @@ struct ModelStatistics { uint64_t cache_miss_time_ns_; }; -enum RequestParameterType { STRING = 0, INT = 1, UINT = 2, BOOL = 3 }; +enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; /// /// Structure to hold Request parameter data for Inference Request. /// struct RequestParameter { std::string str_value; int64_t int_value; - uint64_t uint_value; bool bool_value; RequestParameterType type; }; diff --git a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc index b57260f86..67ee4ac12 100644 --- a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc +++ b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc @@ -595,7 +595,6 @@ TritonClientBackend::ParseInferOptionsToTriton( auto rp = tc::RequestParameter(); rp.str_value = map_entry.second.str_value; rp.int_value = map_entry.second.int_value; - rp.uint_value = map_entry.second.uint_value; rp.bool_value = map_entry.second.bool_value; uint64_t val = static_cast::type>( @@ -604,8 +603,6 @@ TritonClientBackend::ParseInferOptionsToTriton( triton_options->request_parameters.insert( std::make_pair(map_entry.first, rp)); } - // triton_options->request_parameters.insert(rp) - // options.request_parameters.begin(), options.request_parameters.end()); } From eb4ca9b6f716c6d7b4572babb9146b10c3a8cfbb Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Thu, 28 Sep 2023 16:18:50 -0700 Subject: [PATCH 5/6] Fix includes and map assignment --- src/c++/library/common.h | 2 +- .../client_backend/triton/triton_client_backend.cc | 3 +-- src/c++/perf_analyzer/mock_infer_data_manager.h | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/c++/library/common.h b/src/c++/library/common.h index 0588762a3..9337a12e0 100644 --- a/src/c++/library/common.h +++ b/src/c++/library/common.h @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include #include +#include #include #ifdef TRITON_INFERENCE_SERVER_CLIENT_CLASS diff --git a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc index 67ee4ac12..7672a22ba 100644 --- a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc +++ b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc @@ -600,8 +600,7 @@ TritonClientBackend::ParseInferOptionsToTriton( static_cast::type>( map_entry.second.type); rp.type = static_cast(val); - triton_options->request_parameters.insert( - std::make_pair(map_entry.first, rp)); + triton_options->request_parameters[map_entry.first] = rp; } } diff --git a/src/c++/perf_analyzer/mock_infer_data_manager.h b/src/c++/perf_analyzer/mock_infer_data_manager.h index 5d6bfaa0e..8f9cd7ec0 100644 --- a/src/c++/perf_analyzer/mock_infer_data_manager.h +++ b/src/c++/perf_analyzer/mock_infer_data_manager.h @@ -32,8 +32,6 @@ namespace triton { namespace perfanalyzer { -// std::unordered_map -// request_parameters; class MockInferDataManagerShm : public InferDataManagerShm { public: From 6feff757961587cbd42896c8923dcf7402ec9ed0 Mon Sep 17 00:00:00 2001 From: Elias Bermudez Date: Fri, 29 Sep 2023 10:10:22 -0700 Subject: [PATCH 6/6] Update grpc request parameters to use only strings in PA --- src/c++/library/common.h | 11 ++----- src/c++/library/grpc_client.cc | 18 ++++++----- .../client_backend/client_backend.h | 8 ++--- .../triton/triton_client_backend.cc | 10 ++---- src/c++/perf_analyzer/command_line_parser.cc | 17 ++-------- .../perf_analyzer/test_command_line_parser.cc | 31 ++----------------- 6 files changed, 26 insertions(+), 69 deletions(-) diff --git a/src/c++/library/common.h b/src/c++/library/common.h index 9337a12e0..9cf99c478 100644 --- a/src/c++/library/common.h +++ b/src/c++/library/common.h @@ -154,15 +154,10 @@ class InferenceServerClient { InferStat infer_stat_; }; -enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; -/// -/// Structure to hold Request parameter data for Inference Request. -/// struct RequestParameter { - std::string str_value; - int64_t int_value; - bool bool_value; - RequestParameterType type; + std::string name; + std::string value; + std::string type; }; //============================================================================== diff --git a/src/c++/library/grpc_client.cc b/src/c++/library/grpc_client.cc index 36fdead87..cc3a9a85f 100644 --- a/src/c++/library/grpc_client.cc +++ b/src/c++/library/grpc_client.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include "common.h" @@ -1410,15 +1411,18 @@ InferenceServerGrpcClient::PreRunProcessing( for (auto& param : options.request_parameters) { - if (param.second.type == RequestParameterType::STRING) { + if (param.second.type == "string") { (*infer_request_.mutable_parameters())[param.first].set_string_param( - param.second.str_value); - } else if (param.second.type == RequestParameterType::INT) { + param.second.value); + } else if (param.second.type == "int") { (*infer_request_.mutable_parameters())[param.first].set_int64_param( - param.second.int_value); - } else if (param.second.type == RequestParameterType::BOOL) { - (*infer_request_.mutable_parameters())[param.first].set_bool_param( - param.second.bool_value); + std::stoi(param.second.value)); + } else if (param.second.type == "bool") { + bool val = false; + if (param.second.value == "true") { + val = true; + } + (*infer_request_.mutable_parameters())[param.first].set_bool_param(val); } } diff --git a/src/c++/perf_analyzer/client_backend/client_backend.h b/src/c++/perf_analyzer/client_backend/client_backend.h index 3070afaa2..870ea3dd5 100644 --- a/src/c++/perf_analyzer/client_backend/client_backend.h +++ b/src/c++/perf_analyzer/client_backend/client_backend.h @@ -192,15 +192,13 @@ struct ModelStatistics { uint64_t cache_miss_time_ns_; }; -enum RequestParameterType { STRING = 0, INT = 1, BOOL = 2 }; /// /// Structure to hold Request parameter data for Inference Request. /// struct RequestParameter { - std::string str_value; - int64_t int_value; - bool bool_value; - RequestParameterType type; + std::string name; + std::string value; + std::string type; }; //============================================================================== diff --git a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc index 7672a22ba..70de5f52b 100644 --- a/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc +++ b/src/c++/perf_analyzer/client_backend/triton/triton_client_backend.cc @@ -593,13 +593,9 @@ TritonClientBackend::ParseInferOptionsToTriton( for (auto& map_entry : options.request_parameters_) { auto rp = tc::RequestParameter(); - rp.str_value = map_entry.second.str_value; - rp.int_value = map_entry.second.int_value; - rp.bool_value = map_entry.second.bool_value; - uint64_t val = - static_cast::type>( - map_entry.second.type); - rp.type = static_cast(val); + rp.name = map_entry.second.name; + rp.value = map_entry.second.value; + rp.type = map_entry.second.type; triton_options->request_parameters[map_entry.first] = rp; } } diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index d4ec474b8..b6b2194d6 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -1602,20 +1602,9 @@ CLParser::ParseCommandLine(int argc, char** argv) std::string type{values[2]}; cb::RequestParameter param; - if (type == "bool") { - param.type = cb::RequestParameterType::BOOL; - param.bool_value = value == "true" ? true : false; - } else if (type == "int") { - param.type = cb::RequestParameterType::INT; - param.int_value = std::stoll(value); - } else if (type == "string") { - param.type = cb::RequestParameterType::STRING; - param.str_value = value; - } else { - Usage( - "Failed to parse --request-parameter. Unsupported type: '" + - type + "'."); - } + param.name = name; + param.value = value; + param.type = type; params_->request_parameters[name] = param; break; } diff --git a/src/c++/perf_analyzer/test_command_line_parser.cc b/src/c++/perf_analyzer/test_command_line_parser.cc index 0a802e3f1..bb65f4dc5 100644 --- a/src/c++/perf_analyzer/test_command_line_parser.cc +++ b/src/c++/perf_analyzer/test_command_line_parser.cc @@ -195,14 +195,8 @@ CHECK_PARAMS(PAParamsPtr act, PAParamsPtr exp) exp_param != exp->request_parameters.end(), "Unexpected parameter: ", act_param.first); + CHECK(act_param.second.value == exp_param->second.value); CHECK(act_param.second.type == exp_param->second.type); - if (act_param.second.type == cb::RequestParameterType::STRING) { - CHECK(act_param.second.str_value == exp_param->second.str_value); - } else if (act_param.second.type == cb::RequestParameterType::INT) { - CHECK(act_param.second.int_value == exp_param->second.int_value); - } else if (act_param.second.type == cb::RequestParameterType::BOOL) { - CHECK(act_param.second.bool_value == exp_param->second.bool_value); - } } } @@ -1393,8 +1387,8 @@ TEST_CASE("Testing Command Line Parser") CHECK(!parser.UsageCalled()); cb::RequestParameter param; - param.int_value = 256; - param.type = cb::RequestParameterType::INT; + param.value = "256"; + param.type = "int"; exp->request_parameters["max_tokens"] = param; } @@ -1420,25 +1414,6 @@ TEST_CASE("Testing Command Line Parser") check_params = false; } - - SUBCASE("unsupported type") - { - args.push_back(option_name); - args.push_back("max_tokens:256:hello"); - - int argc = args.size(); - char* argv[argc]; - std::copy(args.begin(), args.end(), argv); - - REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); - CHECK(parser.UsageCalled()); - - expected_msg = - CreateUsageMessage(option_name, "Unsupported type: 'hello'."); - CHECK_STRING("Usage Message", parser.GetUsageMessage(), expected_msg); - - check_params = false; - } } SUBCASE("Option : --latency-threshold")