PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
plssvm::hip::csvm Class Referenceabstract

A C-SVM implementation using HIP as backend. More...

#include <csvm.hpp>

Inheritance diagram for plssvm::hip::csvm:
[legend]
Collaboration diagram for plssvm::hip::csvm:
[legend]

Public Types

using device_ptr_type = detail::device_ptr< real_type >
 The type of the device pointer (dependent on the used backend).
 
using queue_type = int
 The type of the device queue (dependent on the used backend).
 

Public Member Functions

 csvm (parameter params={})
 Construct a new C-SVM using the HIP backend with the parameters given through params. More...
 
 csvm (target_platform target, parameter params={})
 Construct a new C-SVM using the HIP backend on the target platform with the parameters given through params. More...
 
template<typename... Args, PLSSVM_REQUIRES(::plssvm::detail::has_only_parameter_named_args_v< Args... >) >
 csvm (Args &&...named_args)
 Construct a new C-SVM using the HIP backend and the optionally provided named_args. More...
 
template<typename... Args, PLSSVM_REQUIRES(::plssvm::detail::has_only_parameter_named_args_v< Args... >) >
 csvm (const target_platform target, Args &&...named_args)
 Construct a new C-SVM using the HIP backend on the target platform and the optionally provided named_args. More...
 
 csvm (const csvm &)=delete
 Delete copy-constructor since a CSVM is a move-only type. More...
 
 csvm (csvm &&) noexcept=default
 Default move-constructor since a virtual destructor has been declared. noexcept More...
 
csvmoperator= (const csvm &)=delete
 Delete copy-assignment operator since a CSVM is a move-only type. More...
 
csvmoperator= (csvm &&) noexcept=default
 Default move-assignment operator since a virtual destructor has been declared. noexcept More...
 
 ~csvm () override
 Wait for all operations on all HIP devices to finish. More...
 
std::size_t num_available_devices () const noexcept
 Return the number of available devices for the current backend. More...
 
target_platform get_target_platform () const noexcept
 Return the target platform (i.e, CPU or GPU including the vendor) this SVM runs on. More...
 
parameter get_params () const noexcept
 Return the currently used SVM parameter. More...
 
void set_params (parameter params) noexcept
 Override the old SVM parameter with the new plssvm::parameter params. More...
 
template<typename... Args, PLSSVM_REQUIRES(detail::has_only_parameter_named_args_v< Args... >) >
void set_params (Args &&...named_args)
 Override the old SVM parameter with the new ones given as named parameters in named_args. More...
 
template<typename real_type , typename label_type , typename... Args>
model< real_type, label_type > fit (const data_set< real_type, label_type > &data, Args &&...named_args) const
 Fit a model using the current SVM on the data. More...
 
template<typename real_type , typename label_type >
std::vector< label_type > predict (const model< real_type, label_type > &model, const data_set< real_type, label_type > &data) const
 Predict the labels for the data set using the model. More...
 
template<typename real_type , typename label_type >
real_type score (const model< real_type, label_type > &model) const
 Calculate the accuracy of the model. More...
 
template<typename real_type , typename label_type >
real_type score (const model< real_type, label_type > &model, const data_set< real_type, label_type > &data) const
 Calculate the accuracy of the labeled data set using the model. More...
 

Protected Types

using base_type = ::plssvm::detail::gpu_csvm< detail::device_ptr, int >
 The template base type of the HIP C-SVM class.
 

Protected Member Functions

void device_synchronize (const queue_type &queue) const final
 Synchronize the device denoted by queue. More...
 
void run_q_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< float > &params, device_ptr_type< float > &q_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_data_points_padded, std::size_t num_features) const final
 Run the device kernel filling the q vector. More...
 
void run_q_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< double > &params, device_ptr_type< double > &q_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_data_points_padded, std::size_t num_features) const final
 Run the device kernel filling the q vector. More...
 
template<typename real_type >
void run_q_kernel_impl (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< real_type > &params, device_ptr_type< real_type > &q_d, const device_ptr_type< real_type > &data_d, const device_ptr_type< real_type > &data_last_d, std::size_t num_data_points_padded, std::size_t num_features) const
 Run the device kernel filling the q vector. More...
 
void run_svm_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< float > &params, const device_ptr_type< float > &q_d, device_ptr_type< float > &r_d, const device_ptr_type< float > &x_d, const device_ptr_type< float > &data_d, float QA_cost, float add, std::size_t num_data_points_padded, std::size_t num_features) const final
 Run the main device kernel used in the CG algorithm. More...
 
void run_svm_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< double > &params, const device_ptr_type< double > &q_d, device_ptr_type< double > &r_d, const device_ptr_type< double > &x_d, const device_ptr_type< double > &data_d, double QA_cost, double add, std::size_t num_data_points_padded, std::size_t num_features) const final
 Run the main device kernel used in the CG algorithm. More...
 
template<typename real_type >
void run_svm_kernel_impl (std::size_t device, const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< real_type > &params, const device_ptr_type< real_type > &q_d, device_ptr_type< real_type > &r_d, const device_ptr_type< real_type > &x_d, const device_ptr_type< real_type > &data_d, real_type QA_cost, real_type add, std::size_t num_data_points_padded, std::size_t num_features) const
 Run the main device kernel used in the CG algorithm. More...
 
void run_w_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, device_ptr_type< float > &w_d, const device_ptr_type< float > &alpha_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_data_points, std::size_t num_features) const final
 Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function. More...
 
void run_w_kernel (std::size_t device, const ::plssvm::detail::execution_range &range, device_ptr_type< double > &w_d, const device_ptr_type< double > &alpha_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_data_points, std::size_t num_features) const final
 Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function. More...
 
template<typename real_type >
void run_w_kernel_impl (std::size_t device, const ::plssvm::detail::execution_range &range, device_ptr_type< real_type > &w_d, const device_ptr_type< real_type > &alpha_d, const device_ptr_type< real_type > &data_d, const device_ptr_type< real_type > &data_last_d, std::size_t num_data_points, std::size_t num_features) const
 Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function. More...
 
void run_predict_kernel (const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< float > &params, device_ptr_type< float > &out_d, const device_ptr_type< float > &alpha_d, const device_ptr_type< float > &point_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_support_vectors, std::size_t num_predict_points, std::size_t num_features) const final
 Run the device kernel (only on the first device) to predict the new data points point_d. More...
 
void run_predict_kernel (const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< double > &params, device_ptr_type< double > &out_d, const device_ptr_type< double > &alpha_d, const device_ptr_type< double > &point_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_support_vectors, std::size_t num_predict_points, std::size_t num_features) const final
 Run the device kernel (only on the first device) to predict the new data points point_d. More...
 
template<typename real_type >
void run_predict_kernel_impl (const ::plssvm::detail::execution_range &range, const ::plssvm::detail::parameter< real_type > &params, device_ptr_type< real_type > &out_d, const device_ptr_type< real_type > &alpha_d, const device_ptr_type< real_type > &point_d, const device_ptr_type< real_type > &data_d, const device_ptr_type< real_type > &data_last_d, std::size_t num_support_vectors, std::size_t num_predict_points, std::size_t num_features) const
 Run the device kernel (only on the first device) to predict the new data points point_d. More...
 
std::pair< std::vector< float >, float > solve_system_of_linear_equations (const parameter< float > &params, const std::vector< std::vector< float >> &A, std::vector< float > b, float eps, unsigned long long max_iter) const final
 Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm. More...
 
std::pair< std::vector< double >, double > solve_system_of_linear_equations (const parameter< double > &params, const std::vector< std::vector< double >> &A, std::vector< double > b, double eps, unsigned long long max_iter) const final
 Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm. More...
 
std::pair< std::vector< real_type >, real_type > solve_system_of_linear_equations_impl (const parameter< real_type > &params, const std::vector< std::vector< real_type >> &A, std::vector< real_type > b, real_type eps, unsigned long long max_iter) const
 Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm. More...
 
std::vector< float > predict_values (const parameter< float > &params, const std::vector< std::vector< float >> &support_vectors, const std::vector< float > &alpha, float rho, std::vector< float > &w, const std::vector< std::vector< float >> &predict_points) const final
 Uses the already learned model to predict the class of multiple (new) data points. More...
 
std::vector< double > predict_values (const parameter< double > &params, const std::vector< std::vector< double >> &support_vectors, const std::vector< double > &alpha, double rho, std::vector< double > &w, const std::vector< std::vector< double >> &predict_points) const final
 Uses the already learned model to predict the class of multiple (new) data points. More...
 
std::vector< real_type > predict_values_impl (const parameter< real_type > &params, const std::vector< std::vector< real_type >> &support_vectors, const std::vector< real_type > &alpha, real_type rho, std::vector< real_type > &w, const std::vector< std::vector< real_type >> &predict_points) const
 Uses the already learned model to predict the class of multiple (new) data points. More...
 
std::size_t select_num_used_devices (kernel_function_type kernel, std::size_t num_features) const noexcept
 Returns the number of usable devices given the kernel function kernel and the number of features num_features. More...
 
std::tuple< std::vector< device_ptr_type< real_type > >, std::vector< device_ptr_type< real_type > >, std::vector< std::size_t > > setup_data_on_device (const std::vector< std::vector< real_type >> &data, std::size_t num_data_points_to_setup, std::size_t num_features_to_setup, std::size_t boundary_size, std::size_t num_used_devices) const
 Performs all necessary steps such that the data is available on the device with the correct layout. More...
 
std::vector< real_type > generate_q (const parameter< real_type > &params, const std::vector< device_ptr_type< real_type >> &data_d, const std::vector< device_ptr_type< real_type >> &data_last_d, std::size_t num_data_points, const std::vector< std::size_t > &feature_ranges, std::size_t boundary_size) const
 Calculate the q vector used in the dimensional reduction. More...
 
std::vector< real_type > calculate_w (const std::vector< device_ptr_type< real_type >> &data_d, const std::vector< device_ptr_type< real_type >> &data_last_d, const std::vector< device_ptr_type< real_type >> &alpha_d, std::size_t num_data_points, const std::vector< std::size_t > &feature_ranges) const
 Precalculate the w vector to speedup up the prediction using the linear kernel function. More...
 
void run_device_kernel (std::size_t device, const parameter< real_type > &params, const device_ptr_type< real_type > &q_d, device_ptr_type< real_type > &r_d, const device_ptr_type< real_type > &x_d, const device_ptr_type< real_type > &data_d, const std::vector< std::size_t > &feature_ranges, real_type QA_cost, real_type add, std::size_t dept, std::size_t boundary_size) const
 Select the correct kernel based on the value of kernel_ and run it on the device denoted by device. More...
 
void device_reduction (std::vector< device_ptr_type< real_type >> &buffer_d, std::vector< real_type > &buffer) const
 Combines the data in buffer_d from all devices into buffer and distributes them back to each device. More...
 
virtual void run_q_kernel (std::size_t device, const detail::execution_range &range, const parameter< float > &params, device_ptr_type< float > &q_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_data_points_padded, std::size_t num_features) const=0
 Run the device kernel filling the q vector. More...
 
virtual void run_q_kernel (std::size_t device, const detail::execution_range &range, const parameter< double > &params, device_ptr_type< double > &q_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_data_points_padded, std::size_t num_features) const=0
 Run the device kernel filling the q vector. More...
 
virtual void run_svm_kernel (std::size_t device, const detail::execution_range &range, const parameter< float > &params, const device_ptr_type< float > &q_d, device_ptr_type< float > &r_d, const device_ptr_type< float > &x_d, const device_ptr_type< float > &data_d, float QA_cost, float add, std::size_t num_data_points_padded, std::size_t num_features) const=0
 Run the main device kernel used in the CG algorithm. More...
 
virtual void run_svm_kernel (std::size_t device, const detail::execution_range &range, const parameter< double > &params, const device_ptr_type< double > &q_d, device_ptr_type< double > &r_d, const device_ptr_type< double > &x_d, const device_ptr_type< double > &data_d, double QA_cost, double add, std::size_t num_data_points_padded, std::size_t num_features) const=0
 Run the main device kernel used in the CG algorithm. More...
 
virtual void run_w_kernel (std::size_t device, const detail::execution_range &range, device_ptr_type< float > &w_d, const device_ptr_type< float > &alpha_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_data_points, std::size_t num_features) const=0
 Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function. More...
 
virtual void run_w_kernel (std::size_t device, const detail::execution_range &range, device_ptr_type< double > &w_d, const device_ptr_type< double > &alpha_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_data_points, std::size_t num_features) const=0
 Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function. More...
 
virtual void run_predict_kernel (const detail::execution_range &range, const parameter< float > &params, device_ptr_type< float > &out_d, const device_ptr_type< float > &alpha_d, const device_ptr_type< float > &point_d, const device_ptr_type< float > &data_d, const device_ptr_type< float > &data_last_d, std::size_t num_support_vectors, std::size_t num_predict_points, std::size_t num_features) const=0
 Run the device kernel (only on the first device) to predict the new data points point_d. More...
 
virtual void run_predict_kernel (const detail::execution_range &range, const parameter< double > &params, device_ptr_type< double > &out_d, const device_ptr_type< double > &alpha_d, const device_ptr_type< double > &point_d, const device_ptr_type< double > &data_d, const device_ptr_type< double > &data_last_d, std::size_t num_support_vectors, std::size_t num_predict_points, std::size_t num_features) const=0
 Run the device kernel (only on the first device) to predict the new data points point_d. More...
 

Protected Attributes

std::vector< queue_typedevices_
 The available/used backend devices.
 
target_platform target_ { plssvm::target_platform::automatic }
 The target platform of this SVM.
 

Private Member Functions

void init (target_platform target)
 Initialize all important states related to the HIP backend. More...
 
void sanity_check_parameter () const
 Perform some sanity checks on the passed SVM parameters. More...
 

Private Attributes

parameter params_ {}
 The SVM parameter (e.g., cost, degree, gamma, coef0) currently in use.
 

Detailed Description

A C-SVM implementation using HIP as backend.

Constructor & Destructor Documentation

◆ csvm() [1/6]

plssvm::hip::csvm::csvm ( parameter  params = {})
explicit

Construct a new C-SVM using the HIP backend with the parameters given through params.

Currently only tested with AMD GPUs.

Parameters
[in]paramsstruct encapsulating all possible parameters
Exceptions
plssvm::exceptionall exceptions thrown in the base class constructor
plssvm::hip::backend_exceptionif the target platform isn't plssvm::target_platform::automatic or plssvm::target_platform::gpu_amd
plssvm::hip::backend_exceptionif the plssvm::target_platform::gpu_amd target isn't available
plssvm::hip::backend_exceptionif no HIP capable devices could be found

◆ csvm() [2/6]

plssvm::hip::csvm::csvm ( target_platform  target,
parameter  params = {} 
)
explicit

Construct a new C-SVM using the HIP backend on the target platform with the parameters given through params.

Currently only tested with AMD GPUs.

Parameters
[in]targetthe target platform used for this C-SVM
[in]paramsstruct encapsulating all possible SVM parameters
Exceptions
plssvm::exceptionall exceptions thrown in the base class constructor
plssvm::hip::backend_exceptionif the target platform isn't plssvm::target_platform::automatic or plssvm::target_platform::gpu_amd
plssvm::hip::backend_exceptionif the plssvm::target_platform::gpu_amd target isn't available
plssvm::hip::backend_exceptionif no HIP capable devices could be found

◆ csvm() [3/6]

template<typename... Args, PLSSVM_REQUIRES(::plssvm::detail::has_only_parameter_named_args_v< Args... >) >
plssvm::hip::csvm::csvm ( Args &&...  named_args)
inlineexplicit

Construct a new C-SVM using the HIP backend and the optionally provided named_args.

Currently only tested with AMD GPUs.

Parameters
[in]named_argsthe additional optional named-parameter
Exceptions
plssvm::exceptionall exceptions thrown in the base class constructor
plssvm::hip::backend_exceptionif the target platform isn't plssvm::target_platform::automatic or plssvm::target_platform::gpu_amd
plssvm::hip::backend_exceptionif the plssvm::target_platform::gpu_amd target isn't available
plssvm::hip::backend_exceptionif no HIP capable devices could be found

◆ csvm() [4/6]

template<typename... Args, PLSSVM_REQUIRES(::plssvm::detail::has_only_parameter_named_args_v< Args... >) >
plssvm::hip::csvm::csvm ( const target_platform  target,
Args &&...  named_args 
)
inlineexplicit

Construct a new C-SVM using the HIP backend on the target platform and the optionally provided named_args.

Currently only tested with AMD GPUs.

Parameters
[in]targetthe target platform used for this C-SVM
[in]named_argsthe additional optional named-parameter
Exceptions
plssvm::exceptionall exceptions thrown in the base class constructor
plssvm::hip::backend_exceptionif the target platform isn't plssvm::target_platform::automatic or plssvm::target_platform::gpu_amd
plssvm::hip::backend_exceptionif the plssvm::target_platform::gpu_amd target isn't available
plssvm::hip::backend_exceptionif no HIP capable devices could be found

◆ csvm() [5/6]

plssvm::hip::csvm::csvm ( const csvm )
delete

Delete copy-constructor since a CSVM is a move-only type.

◆ csvm() [6/6]

plssvm::hip::csvm::csvm ( csvm &&  )
defaultnoexcept

Default move-constructor since a virtual destructor has been declared. noexcept

noexcept

◆ ~csvm()

plssvm::hip::csvm::~csvm ( )
overridevirtual

Wait for all operations on all HIP devices to finish.

Terminates the program, if any exception is thrown.

Reimplemented from plssvm::csvm.

Member Function Documentation

◆ operator=() [1/2]

csvm& plssvm::hip::csvm::operator= ( const csvm )
delete

Delete copy-assignment operator since a CSVM is a move-only type.

Returns
*this

◆ operator=() [2/2]

csvm& plssvm::hip::csvm::operator= ( csvm &&  )
defaultnoexcept

Default move-assignment operator since a virtual destructor has been declared. noexcept

Returns
*this noexcept

◆ device_synchronize()

void plssvm::hip::csvm::device_synchronize ( const queue_type queue) const
finalprotectedvirtual

Synchronize the device denoted by queue.

Parameters
[in]queuethe queue denoting the device to synchronize

Implements plssvm::detail::gpu_csvm< detail::device_ptr, int >.

◆ run_q_kernel() [1/4]

void plssvm::hip::csvm::run_q_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< float > &  params,
device_ptr_type< float > &  q_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel filling the q vector.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]q_dthe q vector to fill located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation on the device

◆ run_q_kernel() [2/4]

void plssvm::hip::csvm::run_q_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< double > &  params,
device_ptr_type< double > &  q_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel filling the q vector.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]q_dthe q vector to fill located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation on the device

◆ run_q_kernel_impl()

template<typename real_type >
void plssvm::hip::csvm::run_q_kernel_impl ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< real_type > &  params,
device_ptr_type< real_type > &  q_d,
const device_ptr_type< real_type > &  data_d,
const device_ptr_type< real_type > &  data_last_d,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protected

Run the device kernel filling the q vector.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]q_dthe q vector to fill located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation on the device

◆ run_svm_kernel() [1/4]

void plssvm::hip::csvm::run_svm_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< float > &  params,
const device_ptr_type< float > &  q_d,
device_ptr_type< float > &  r_d,
const device_ptr_type< float > &  x_d,
const device_ptr_type< float > &  data_d,
float  QA_cost,
float  add,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
inlinefinalprotected

Run the main device kernel used in the CG algorithm.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dthe q vector located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]adddenotes whether the values are added or subtracted from the result vector
[in]QA_costa value used in the dimensional reduction
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation in the device

◆ run_svm_kernel() [2/4]

void plssvm::hip::csvm::run_svm_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< double > &  params,
const device_ptr_type< double > &  q_d,
device_ptr_type< double > &  r_d,
const device_ptr_type< double > &  x_d,
const device_ptr_type< double > &  data_d,
double  QA_cost,
double  add,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
inlinefinalprotected

Run the main device kernel used in the CG algorithm.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dthe q vector located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]adddenotes whether the values are added or subtracted from the result vector
[in]QA_costa value used in the dimensional reduction
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation in the device

◆ run_svm_kernel_impl()

template<typename real_type >
void plssvm::hip::csvm::run_svm_kernel_impl ( std::size_t  device,
const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< real_type > &  params,
const device_ptr_type< real_type > &  q_d,
device_ptr_type< real_type > &  r_d,
const device_ptr_type< real_type > &  x_d,
const device_ptr_type< real_type > &  data_d,
real_type  QA_cost,
real_type  add,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protected

Run the main device kernel used in the CG algorithm.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dthe q vector located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]adddenotes whether the values are added or subtracted from the result vector
[in]QA_costa value used in the dimensional reduction
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation in the device

◆ run_w_kernel() [1/4]

void plssvm::hip::csvm::run_w_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
device_ptr_type< float > &  w_d,
const device_ptr_type< float > &  alpha_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_data_points,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]rangethe execution range used to launch the
[out]w_dthe w vector to fill, used to speed up the prediction when using the linear kernel located on the device(s)
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points
[in]num_featuresnumber of features used for the calculation on the device

◆ run_w_kernel() [2/4]

void plssvm::hip::csvm::run_w_kernel ( std::size_t  device,
const ::plssvm::detail::execution_range range,
device_ptr_type< double > &  w_d,
const device_ptr_type< double > &  alpha_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_data_points,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]rangethe execution range used to launch the
[out]w_dthe w vector to fill, used to speed up the prediction when using the linear kernel located on the device(s)
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points
[in]num_featuresnumber of features used for the calculation on the device

◆ run_w_kernel_impl()

template<typename real_type >
void plssvm::hip::csvm::run_w_kernel_impl ( std::size_t  device,
const ::plssvm::detail::execution_range range,
device_ptr_type< real_type > &  w_d,
const device_ptr_type< real_type > &  alpha_d,
const device_ptr_type< real_type > &  data_d,
const device_ptr_type< real_type > &  data_last_d,
std::size_t  num_data_points,
std::size_t  num_features 
) const
protected

Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]rangethe execution range used to launch the
[out]w_dthe w vector to fill, used to speed up the prediction when using the linear kernel located on the device(s)
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points
[in]num_featuresnumber of features used for the calculation on the device

◆ run_predict_kernel() [1/4]

void plssvm::hip::csvm::run_predict_kernel ( const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< float > &  params,
device_ptr_type< float > &  out_d,
const device_ptr_type< float > &  alpha_d,
const device_ptr_type< float > &  point_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_support_vectors,
std::size_t  num_predict_points,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel (only on the first device) to predict the new data points point_d.

Parameters
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]out_dthe calculated prediction
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]point_dthe data points to predict located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_support_vectorsthe number of support vectors
[in]num_predict_pointsthe number of data points to predict
[in]num_featuresnumber of features used for the calculation on the device

◆ run_predict_kernel() [2/4]

void plssvm::hip::csvm::run_predict_kernel ( const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< double > &  params,
device_ptr_type< double > &  out_d,
const device_ptr_type< double > &  alpha_d,
const device_ptr_type< double > &  point_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_support_vectors,
std::size_t  num_predict_points,
std::size_t  num_features 
) const
inlinefinalprotected

Run the device kernel (only on the first device) to predict the new data points point_d.

Parameters
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]out_dthe calculated prediction
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]point_dthe data points to predict located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_support_vectorsthe number of support vectors
[in]num_predict_pointsthe number of data points to predict
[in]num_featuresnumber of features used for the calculation on the device

◆ run_predict_kernel_impl()

template<typename real_type >
void plssvm::hip::csvm::run_predict_kernel_impl ( const ::plssvm::detail::execution_range range,
const ::plssvm::detail::parameter< real_type > &  params,
device_ptr_type< real_type > &  out_d,
const device_ptr_type< real_type > &  alpha_d,
const device_ptr_type< real_type > &  point_d,
const device_ptr_type< real_type > &  data_d,
const device_ptr_type< real_type > &  data_last_d,
std::size_t  num_support_vectors,
std::size_t  num_predict_points,
std::size_t  num_features 
) const
protected

Run the device kernel (only on the first device) to predict the new data points point_d.

Parameters
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]out_dthe calculated prediction
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]point_dthe data points to predict located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_support_vectorsthe number of support vectors
[in]num_predict_pointsthe number of data points to predict
[in]num_featuresnumber of features used for the calculation on the device

◆ init()

void plssvm::hip::csvm::init ( target_platform  target)
private

Initialize all important states related to the HIP backend.

Parameters
[in]targetthe target platform to use
Exceptions
plssvm::hip::backend_exceptionif the target platform isn't plssvm::target_platform::automatic or plssvm::target_platform::gpu_amd
plssvm::hip::backend_exceptionif the plssvm::target_platform::gpu_amd target isn't available
plssvm::hip::backend_exceptionif no HIP capable devices could be found

◆ num_available_devices()

std::size_t plssvm::detail::gpu_csvm< detail::device_ptr , int >::num_available_devices ( ) const
inlinenoexceptinherited

Return the number of available devices for the current backend.

Returns
the number of available devices ([[nodiscard]])

◆ solve_system_of_linear_equations() [1/2]

std::pair<std::vector<float>, float> plssvm::detail::gpu_csvm< detail::device_ptr , int >::solve_system_of_linear_equations ( const parameter< float > &  params,
const std::vector< std::vector< float >> &  A,
std::vector< float >  b,
float  eps,
unsigned long long  max_iter 
) const
inlinefinalprotectedvirtualinherited

Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm.

Uses a slightly modified version of the CG algorithm described by Jonathan Richard Shewchuk:

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]Athe matrix of the equation \(Ax = b\) (symmetric positive definite)
[in]bthe right-hand side of the equation \(Ax = b\)
[in]epsthe error tolerance
[in]max_iterthe maximum number of CG iterations
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a pair of [the result vector x, the resulting bias] ([[nodiscard]])

Implements plssvm::csvm.

◆ solve_system_of_linear_equations() [2/2]

std::pair<std::vector<double>, double> plssvm::detail::gpu_csvm< detail::device_ptr , int >::solve_system_of_linear_equations ( const parameter< double > &  params,
const std::vector< std::vector< double >> &  A,
std::vector< double >  b,
double  eps,
unsigned long long  max_iter 
) const
inlinefinalprotectedvirtualinherited

Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm.

Uses a slightly modified version of the CG algorithm described by Jonathan Richard Shewchuk:

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]Athe matrix of the equation \(Ax = b\) (symmetric positive definite)
[in]bthe right-hand side of the equation \(Ax = b\)
[in]epsthe error tolerance
[in]max_iterthe maximum number of CG iterations
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a pair of [the result vector x, the resulting bias] ([[nodiscard]])

Implements plssvm::csvm.

◆ solve_system_of_linear_equations_impl()

std::pair< std::vector< real_type >, real_type > plssvm::detail::gpu_csvm< detail::device_ptr , int >::solve_system_of_linear_equations_impl ( const parameter< real_type > &  params,
const std::vector< std::vector< real_type >> &  A,
std::vector< real_type >  b,
real_type  eps,
unsigned long long  max_iter 
) const
protectedinherited

Solves the equation \(Ax = b\) using the Conjugated Gradients algorithm.

Uses a slightly modified version of the CG algorithm described by Jonathan Richard Shewchuk:

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]Athe matrix of the equation \(Ax = b\) (symmetric positive definite)
[in]bthe right-hand side of the equation \(Ax = b\)
[in]epsthe error tolerance
[in]max_iterthe maximum number of CG iterations
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a pair of [the result vector x, the resulting bias] ([[nodiscard]])

◆ predict_values() [1/2]

std::vector<float> plssvm::detail::gpu_csvm< detail::device_ptr , int >::predict_values ( const parameter< float > &  params,
const std::vector< std::vector< float >> &  support_vectors,
const std::vector< float > &  alpha,
float  rho,
std::vector< float > &  w,
const std::vector< std::vector< float >> &  predict_points 
) const
inlinefinalprotectedvirtualinherited

Uses the already learned model to predict the class of multiple (new) data points.

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]support_vectorsthe previously learned support vectors
[in]alphathe alpha values (weights) associated with the support vectors
[in]rhothe rho value determined after training the model
[in,out]wthe normal vector to speedup prediction in case of the linear kernel function, an empty vector in case of the polynomial or rbf kernel
[in]predict_pointsthe points to predict
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a vector filled with the predictions (not the actual labels!) ([[nodiscard]])

Implements plssvm::csvm.

◆ predict_values() [2/2]

std::vector<double> plssvm::detail::gpu_csvm< detail::device_ptr , int >::predict_values ( const parameter< double > &  params,
const std::vector< std::vector< double >> &  support_vectors,
const std::vector< double > &  alpha,
double  rho,
std::vector< double > &  w,
const std::vector< std::vector< double >> &  predict_points 
) const
inlinefinalprotectedvirtualinherited

Uses the already learned model to predict the class of multiple (new) data points.

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]support_vectorsthe previously learned support vectors
[in]alphathe alpha values (weights) associated with the support vectors
[in]rhothe rho value determined after training the model
[in,out]wthe normal vector to speedup prediction in case of the linear kernel function, an empty vector in case of the polynomial or rbf kernel
[in]predict_pointsthe points to predict
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a vector filled with the predictions (not the actual labels!) ([[nodiscard]])

Implements plssvm::csvm.

◆ predict_values_impl()

std::vector< real_type > plssvm::detail::gpu_csvm< detail::device_ptr , int >::predict_values_impl ( const parameter< real_type > &  params,
const std::vector< std::vector< real_type >> &  support_vectors,
const std::vector< real_type > &  alpha,
real_type  rho,
std::vector< real_type > &  w,
const std::vector< std::vector< real_type >> &  predict_points 
) const
protectedinherited

Uses the already learned model to predict the class of multiple (new) data points.

Parameters
[in]paramsthe SVM parameters used in the respective kernel functions
[in]support_vectorsthe previously learned support vectors
[in]alphathe alpha values (weights) associated with the support vectors
[in]rhothe rho value determined after training the model
[in,out]wthe normal vector to speedup prediction in case of the linear kernel function, an empty vector in case of the polynomial or rbf kernel
[in]predict_pointsthe points to predict
Exceptions
plssvm::exceptionany exception thrown by the backend's implementation
Returns
a vector filled with the predictions (not the actual labels!) ([[nodiscard]])

◆ select_num_used_devices()

std::size_t plssvm::detail::gpu_csvm< detail::device_ptr , int >::select_num_used_devices ( kernel_function_type  kernel,
std::size_t  num_features 
) const
protectednoexceptinherited

Returns the number of usable devices given the kernel function kernel and the number of features num_features.

Only the linear kernel supports multi-GPU execution, i.e., for the polynomial and rbf kernel, this function always returns 1. In addition, at most num_features devices may be used (i.e., if more devices than features are present not all devices are used).

Parameters
[in]kernelthe kernel function type
[in]num_featuresthe number of features
Returns
the number of usable devices; may be less than the discovered devices in the system ([[nodiscard]])

◆ setup_data_on_device()

std::tuple<std::vector<device_ptr_type<real_type> >, std::vector<device_ptr_type<real_type> >, std::vector<std::size_t> > plssvm::detail::gpu_csvm< detail::device_ptr , int >::setup_data_on_device ( const std::vector< std::vector< real_type >> &  data,
std::size_t  num_data_points_to_setup,
std::size_t  num_features_to_setup,
std::size_t  boundary_size,
std::size_t  num_used_devices 
) const
protectedinherited

Performs all necessary steps such that the data is available on the device with the correct layout.

Distributed the data evenly across all devices, adds padding data points, and transforms the data layout to SoA.

Template Parameters
real_typethe type of the data points (either float or double)
Parameters
[in]datathe data that should be copied to the device(s)
[in]num_data_points_to_setupthe number of data points that should be copied to the device
[in]num_features_to_setupthe number of features in the data set
[in]boundary_sizethe size of the padding boundary
[in]num_used_devicesthe number of devices to distribute the data across
Returns
a tuple: [pointers to the main data distributed across the devices, pointers to the last data point of the data set distributed across the devices, the feature ranges a specific device is responsible for] ([[nodiscard]])

◆ generate_q()

std::vector< real_type > plssvm::detail::gpu_csvm< detail::device_ptr , int >::generate_q ( const parameter< real_type > &  params,
const std::vector< device_ptr_type< real_type >> &  data_d,
const std::vector< device_ptr_type< real_type >> &  data_last_d,
std::size_t  num_data_points,
const std::vector< std::size_t > &  feature_ranges,
std::size_t  boundary_size 
) const
protectedinherited

Calculate the q vector used in the dimensional reduction.

Template Parameters
real_typethe type of the data points (either float or double)
Parameters
[in]paramsthe SVM parameter used to calculate q (e.g., kernel_type)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points in data_p
[in]feature_rangesthe range of features a specific device is responsible for
[in]boundary_sizethe size of the padding boundary
Returns
the q vector ([[nodiscard]])

◆ calculate_w()

std::vector< real_type > plssvm::detail::gpu_csvm< detail::device_ptr , int >::calculate_w ( const std::vector< device_ptr_type< real_type >> &  data_d,
const std::vector< device_ptr_type< real_type >> &  data_last_d,
const std::vector< device_ptr_type< real_type >> &  alpha_d,
std::size_t  num_data_points,
const std::vector< std::size_t > &  feature_ranges 
) const
protectedinherited

Precalculate the w vector to speedup up the prediction using the linear kernel function.

Template Parameters
real_typethe type of the data points (either float or double)
Parameters
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]alpha_dthe previously learned weights located on the device(s)
[in]num_data_pointsthe number of data points in data_p
[in]feature_rangesthe range of features a specific device is responsible for
Returns
the w vector ([[nodiscard]])

◆ run_device_kernel()

void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_device_kernel ( std::size_t  device,
const parameter< real_type > &  params,
const device_ptr_type< real_type > &  q_d,
device_ptr_type< real_type > &  r_d,
const device_ptr_type< real_type > &  x_d,
const device_ptr_type< real_type > &  data_d,
const std::vector< std::size_t > &  feature_ranges,
real_type  QA_cost,
real_type  add,
std::size_t  dept,
std::size_t  boundary_size 
) const
protectedinherited

Select the correct kernel based on the value of kernel_ and run it on the device denoted by device.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dsubvector of the least-squares matrix equation located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]feature_rangesthe range of features a specific device is responsible for
[in]QA_costa value used in the dimensional reduction
[in]adddenotes whether the values are added or subtracted from the result vector
[in]deptthe number of data points after the dimensional reduction
[in]boundary_sizethe size of the padding boundary

◆ device_reduction()

void plssvm::detail::gpu_csvm< detail::device_ptr , int >::device_reduction ( std::vector< device_ptr_type< real_type >> &  buffer_d,
std::vector< real_type > &  buffer 
) const
protectedinherited

Combines the data in buffer_d from all devices into buffer and distributes them back to each device.

Parameters
[in,out]buffer_dthe data to gather
[in,out]bufferthe reduced data

◆ run_q_kernel() [3/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_q_kernel ( std::size_t  device,
const detail::execution_range range,
const parameter< float > &  params,
device_ptr_type< float > &  q_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel filling the q vector.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]q_dthe q vector to fill located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation on the device

◆ run_q_kernel() [4/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_q_kernel ( std::size_t  device,
const detail::execution_range range,
const parameter< double > &  params,
device_ptr_type< double > &  q_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel filling the q vector.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]q_dthe q vector to fill located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation on the device

◆ run_svm_kernel() [3/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_svm_kernel ( std::size_t  device,
const detail::execution_range range,
const parameter< float > &  params,
const device_ptr_type< float > &  q_d,
device_ptr_type< float > &  r_d,
const device_ptr_type< float > &  x_d,
const device_ptr_type< float > &  data_d,
float  QA_cost,
float  add,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the main device kernel used in the CG algorithm.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dthe q vector located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]adddenotes whether the values are added or subtracted from the result vector
[in]QA_costa value used in the dimensional reduction
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation in the device

◆ run_svm_kernel() [4/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_svm_kernel ( std::size_t  device,
const detail::execution_range range,
const parameter< double > &  params,
const device_ptr_type< double > &  q_d,
device_ptr_type< double > &  r_d,
const device_ptr_type< double > &  x_d,
const device_ptr_type< double > &  data_d,
double  QA_cost,
double  add,
std::size_t  num_data_points_padded,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the main device kernel used in the CG algorithm.

Parameters
[in]devicethe device ID denoting the GPU on which the kernel should be executed
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[in]q_dthe q vector located on the device(s)
[in,out]r_dthe result vector located on the device(s)
[in]x_dthe right-hand side of the equation located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]adddenotes whether the values are added or subtracted from the result vector
[in]QA_costa value used in the dimensional reduction
[in]num_data_points_paddedthe number of data points after the padding has been applied
[in]num_featuresnumber of features used for the calculation in the device

◆ run_w_kernel() [3/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_w_kernel ( std::size_t  device,
const detail::execution_range range,
device_ptr_type< float > &  w_d,
const device_ptr_type< float > &  alpha_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_data_points,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]rangethe execution range used to launch the
[out]w_dthe w vector to fill, used to speed up the prediction when using the linear kernel located on the device(s)
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points
[in]num_featuresnumber of features used for the calculation on the device

◆ run_w_kernel() [4/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_w_kernel ( std::size_t  device,
const detail::execution_range range,
device_ptr_type< double > &  w_d,
const device_ptr_type< double > &  alpha_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_data_points,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel the calculate the w vector used to speed up the prediction when using the linear kernel function.

Parameters
[in]devicethe device ID denoting the device on which the kernel should be executed
[in]rangethe execution range used to launch the
[out]w_dthe w vector to fill, used to speed up the prediction when using the linear kernel located on the device(s)
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_data_pointsthe number of data points
[in]num_featuresnumber of features used for the calculation on the device

◆ run_predict_kernel() [3/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_predict_kernel ( const detail::execution_range range,
const parameter< float > &  params,
device_ptr_type< float > &  out_d,
const device_ptr_type< float > &  alpha_d,
const device_ptr_type< float > &  point_d,
const device_ptr_type< float > &  data_d,
const device_ptr_type< float > &  data_last_d,
std::size_t  num_support_vectors,
std::size_t  num_predict_points,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel (only on the first device) to predict the new data points point_d.

Parameters
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]out_dthe calculated prediction
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]point_dthe data points to predict located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_support_vectorsthe number of support vectors
[in]num_predict_pointsthe number of data points to predict
[in]num_featuresnumber of features used for the calculation on the device

◆ run_predict_kernel() [4/4]

virtual void plssvm::detail::gpu_csvm< detail::device_ptr , int >::run_predict_kernel ( const detail::execution_range range,
const parameter< double > &  params,
device_ptr_type< double > &  out_d,
const device_ptr_type< double > &  alpha_d,
const device_ptr_type< double > &  point_d,
const device_ptr_type< double > &  data_d,
const device_ptr_type< double > &  data_last_d,
std::size_t  num_support_vectors,
std::size_t  num_predict_points,
std::size_t  num_features 
) const
protectedpure virtualinherited

Run the device kernel (only on the first device) to predict the new data points point_d.

Parameters
[in]rangethe execution range used to launch the kernel
[in]paramsthe SVM parameter used (e.g., kernel_type)
[out]out_dthe calculated prediction
[in]alpha_dthe previously calculated weight for each data point located on the device(s)
[in]point_dthe data points to predict located on the device(s)
[in]data_dthe data points used in the dimensional reduction located on the device(s)
[in]data_last_dthe last data point of the data set located on the device(s)
[in]num_support_vectorsthe number of support vectors
[in]num_predict_pointsthe number of data points to predict
[in]num_featuresnumber of features used for the calculation on the device

◆ get_target_platform()

target_platform plssvm::csvm::get_target_platform ( ) const
inlinenoexceptinherited

Return the target platform (i.e, CPU or GPU including the vendor) this SVM runs on.

Returns
the target platform ([[nodiscard]])

◆ get_params()

parameter plssvm::csvm::get_params ( ) const
inlinenoexceptinherited

Return the currently used SVM parameter.

Returns
the SVM parameter ([[nodiscard]])

◆ set_params() [1/2]

void plssvm::csvm::set_params ( parameter  params)
inlinenoexceptinherited

Override the old SVM parameter with the new plssvm::parameter params.

Parameters
[in]paramsthe new SVM parameter to use

◆ set_params() [2/2]

template<typename... Args, std::enable_if_t< detail::has_only_parameter_named_args_v< Args... >, bool > >
void plssvm::csvm::set_params ( Args &&...  named_args)
inherited

Override the old SVM parameter with the new ones given as named parameters in named_args.

Template Parameters
Argsthe type of the named-parameters
Parameters
[in]named_argsthe potential named-parameters

◆ fit()

template<typename real_type , typename label_type , typename... Args>
model< real_type, label_type > plssvm::csvm::fit ( const data_set< real_type, label_type > &  data,
Args &&...  named_args 
) const
inherited

Fit a model using the current SVM on the data.

Template Parameters
real_typethe type of the data (float or double)
label_typethe type of the label (an arithmetic type or std::string)
Argsthe type of the potential additional parameters
Parameters
[in]datathe data used to train the SVM model
[in]named_argsthe potential additional parameters (epsilon and/or max_iter)
Exceptions
plssvm::invalid_parameter_exceptionif the provided value for epsilon is greater or equal than zero
plssvm::invlaid_parameter_exceptionif the provided maximum number of iterations is less or equal than zero
plssvm::invalid_parameter_exceptionif the training data does not include labels
plssvm::exceptionany exception thrown in the respective backend's implementation of plssvm::csvm::solve_system_of_linear_equations
Returns
the learned model ([[nodiscard]])

◆ predict()

template<typename real_type , typename label_type >
std::vector< label_type > plssvm::csvm::predict ( const model< real_type, label_type > &  model,
const data_set< real_type, label_type > &  data 
) const
inherited

Predict the labels for the data set using the model.

Template Parameters
real_typethe type of the data (float or double)
label_typethe type of the label (an arithmetic type or std::string)
Parameters
[in]modela previously learned model
[in]datathe data to predict the labels for
Exceptions
plssvm::invalid_parameter_exceptionif the number of features in the model's support vectors don't match the number of features in the data set
plssvm::exceptionany exception thrown in the respective backend's implementation of plssvm::csvm::predict_values
Returns
the predicted labels ([[nodiscard]])
Examples
csvm_examples.cpp.

◆ score() [1/2]

template<typename real_type , typename label_type >
real_type plssvm::csvm::score ( const model< real_type, label_type > &  model) const
inherited

Calculate the accuracy of the model.

Template Parameters
real_typethe type of the data (float or double)
label_typethe type of the label (an arithmetic type or std::string)
Parameters
[in]modela previously learned model
Exceptions
plssvm::exceptionany exception thrown in the respective backend's implementation of plssvm::csvm::predict_values
Returns
the accuracy of the model ([[nodiscard]])

◆ score() [2/2]

template<typename real_type , typename label_type >
real_type plssvm::csvm::score ( const model< real_type, label_type > &  model,
const data_set< real_type, label_type > &  data 
) const
inherited

Calculate the accuracy of the labeled data set using the model.

Template Parameters
real_typethe type of the data (float or double)
label_typethe type of the label (an arithmetic type or std::string)
Parameters
[in]modela previously learned model
[in]datathe labeled data set to score
Exceptions
plssvm::invalid_parameter_exceptionif the data to score has no labels
plssvm::invalid_parameter_exceptionif the number of features in the model's support vectors don't match the number of features in the data set
plssvm::exceptionany exception thrown in the respective backend's implementation of plssvm::csvm::predict_values
Returns
the accuracy of the labeled data ([[nodiscard]])

◆ sanity_check_parameter()

void plssvm::csvm::sanity_check_parameter ( ) const
inlineprivateinherited

Perform some sanity checks on the passed SVM parameters.

Exceptions
plssvm::invalid_parameter_exceptionif the kernel function is invalid
plssvm::invalid_parameter_exceptionif the gamma value for the polynomial or radial basis function kernel is not greater than zero

The documentation for this class was generated from the following file: