HEBench
hebench_logreg.h
Go to the documentation of this file.
1 
2 // Copyright (C) 2021 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef _HEBench_Harness_DataGenerator_LogisticRegression_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_DataGenerator_LogisticRegression_H_0596d40a3cce4b108a81595c50eb286d
7 
8 #include <memory>
9 
10 #include "hebench/modules/general/include/nocopy.h"
11 #include "hebench/modules/logging/include/logging.h"
12 
14 
17 
18 namespace hebench {
19 namespace TestHarness {
20 namespace LogisticRegression {
21 
23 {
24 public:
25  DISABLE_COPY(BenchmarkDescriptorCategory)
26  DISABLE_MOVE(BenchmarkDescriptorCategory)
27 private:
29 public:
30  static constexpr const char *BaseWorkloadName = "Logistic Regression";
31  static constexpr std::uint64_t WorkloadParameterCount = 1; // number of parameters for this workload
32  static constexpr std::uint64_t OpParameterCount = 3; // number of parameters for this operation
33  static constexpr std::uint64_t OpResultCount = 1; // number of outputs for this operation
35 
36  static std::uint64_t fetchVectorSize(const std::vector<hebench::APIBridge::WorkloadParam> &w_params);
37 
38 public:
40  ~BenchmarkDescriptorCategory() override = default;
41 
42 protected:
44  const std::vector<hebench::APIBridge::WorkloadParam> &w_params) const override;
46  const Engine &engine,
47  const BenchmarkDescription::Backend &backend_desc,
48  const BenchmarkDescription::Configuration &config) const override;
49 };
50 
52 {
53 public:
54  DISABLE_COPY(DataLoader)
55  DISABLE_MOVE(DataLoader)
56 private:
57  IL_DECLARE_CLASS_NAME(LogisticRegression::DataLoader)
58 
59 public:
60  typedef std::shared_ptr<DataLoader> Ptr;
61  enum class PolynomialDegree
62  {
63  None,
64  PD3,
65  PD5,
66  PD7
67  };
68 
69  static constexpr std::size_t Index_W = 0;
70  static constexpr std::size_t Index_b = 1;
71  static constexpr std::size_t Index_X = 2;
72 
73  static DataLoader::Ptr create(PolynomialDegree polynomial_degree,
74  std::uint64_t vector_size,
75  std::uint64_t batch_size_input,
77  static DataLoader::Ptr create(PolynomialDegree polynomial_degree,
78  std::uint64_t vector_size,
79  std::uint64_t batch_size_input,
81  const std::string &dataset_filename);
82 
83  ~DataLoader() override {}
84 
85 protected:
86  void computeResult(std::vector<hebench::APIBridge::NativeDataBuffer *> &result,
87  const std::uint64_t *param_data_pack_indices,
88  hebench::APIBridge::DataType data_type) override;
89 
90 private:
91  static constexpr std::size_t InputDim0 = BenchmarkDescriptorCategory::OpParameterCount;
92  static constexpr std::size_t OutputDim0 = BenchmarkDescriptorCategory::OpResultCount;
93  PolynomialDegree m_polynomial_degree;
94  std::uint64_t m_vector_size;
95 
96  DataLoader();
97  void init(PolynomialDegree polynomial_degree,
98  std::uint64_t vector_size,
99  std::uint64_t batch_size_input,
100  hebench::APIBridge::DataType data_type);
101  void init(PolynomialDegree polynomial_degree,
102  std::uint64_t expected_vector_size,
103  std::uint64_t max_batch_size_input,
105  const std::string &dataset_filename);
106 };
107 
108 } // namespace LogisticRegression
109 } // namespace TestHarness
110 } // namespace hebench
111 
112 #endif // defined _HEBench_Harness_DataGenerator_LogisticRegression_H_0596d40a3cce4b108a81595c50eb286d
static hebench::APIBridge::WorkloadParamType::WorkloadParamType WorkloadParameterType[WorkloadParameterCount]
bool matchBenchmarkDescriptor(const hebench::APIBridge::BenchmarkDescriptor &bench_desc, const std::vector< hebench::APIBridge::WorkloadParam > &w_params) const override
Determines if the represented benchmark can perform the workload described by a specified HEBench ben...
void completeWorkloadDescription(WorkloadDescriptionOutput &output, const Engine &engine, const BenchmarkDescription::Backend &backend_desc, const BenchmarkDescription::Configuration &config) const override
Completes the description for the matched benchmark.
static std::uint64_t fetchVectorSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
void computeResult(std::vector< hebench::APIBridge::NativeDataBuffer * > &result, const std::uint64_t *param_data_pack_indices, hebench::APIBridge::DataType data_type) override
Computes result of the operation on the input data given the of the input sample.
static DataLoader::Ptr create(PolynomialDegree polynomial_degree, std::uint64_t vector_size, std::uint64_t batch_size_input, hebench::APIBridge::DataType data_type)
Provides boilerplate implementation to common methods of interface IBenchmarkDescription and implemen...
Bundles values that need to be filled by a workload during completeWorkloadDescription().
WorkloadParamType
Defines the possible data types for a workload flexible parameter.
Definition: types.h:303
DataType
Defines data types for a workload.
Definition: types.h:379
Defines a benchmark test.
Definition: types.h:527