Defines TypeInfo class and utilities.
More...
#include <treelite/error.h>
#include <cstdint>
#include <typeinfo>
#include <string>
#include <unordered_map>
#include <sstream>
#include <utility>
#include <type_traits>
Go to the source code of this file.
|
enum | TypeInfo : uint8_t { kInvalid = 0,
kUInt32 = 1,
kFloat32 = 2,
kFloat64 = 3
} |
| Types used by thresholds and leaf outputs.
|
|
|
TypeInfo | GetTypeInfoByName (const std::string &str) |
| conversion table from string to TypeInfo, defined in tables.cc
|
|
std::string | TypeInfoToString (treelite::TypeInfo type) |
| Get string representation of type info. More...
|
|
template<typename T > |
TypeInfo | TypeToInfo () |
| Convert a template type into a type info. More...
|
|
template<template< class > class Dispatcher, typename ... Args> |
auto | DispatchWithTypeInfo (TypeInfo type, Args &&...args) |
| Given a TypeInfo, dispatch a function with the corresponding template arg. More precisely, we shall call Dispatcher<T>::Dispatch() where the template arg T corresponds to the type parameter. More...
|
|
template<template< class, class > class Dispatcher, typename ... Args> |
auto | DispatchWithModelTypes (TypeInfo threshold_type, TypeInfo leaf_output_type, Args &&...args) |
| Given the types for thresholds and leaf outputs, validate that they consist of a valid combination for a model and then dispatch a function with the corresponding template args. More precisely, we shall call Dispatcher<ThresholdType, LeafOutputType>::Dispatch() where the template args ThresholdType and LeafOutputType correspond to the parameters threshold_type and leaf_output_type , respectively. More...
|
|
Defines TypeInfo class and utilities.
Copyright (c) 2017-2020 by Contributors
- Author
- Hyunsu Cho
Definition in file typeinfo.h.
◆ DispatchWithModelTypes()
auto treelite::DispatchWithModelTypes |
( |
TypeInfo |
threshold_type, |
|
|
TypeInfo |
leaf_output_type, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Given the types for thresholds and leaf outputs, validate that they consist of a valid combination for a model and then dispatch a function with the corresponding template args. More precisely, we shall call Dispatcher<ThresholdType, LeafOutputType>::Dispatch() where the template args ThresholdType and LeafOutputType correspond to the parameters threshold_type
and leaf_output_type
, respectively.
- Template Parameters
-
Dispatcher | Function object that takes in two template args. It must have a Dispatch() static function. |
Parameter | pack, to forward an arbitrary number of args to Dispatcher::Dispatch() |
- Parameters
-
threshold_type | TypeInfo indicating the type of thresholds |
leaf_output_type | TypeInfo indicating the type of leaf outputs |
args | Other extra parameters to pass to Dispatcher::Dispatch() |
- Returns
- Whatever that's returned by the dispatcher
Definition at line 118 of file typeinfo.h.
◆ DispatchWithTypeInfo()
auto treelite::DispatchWithTypeInfo |
( |
TypeInfo |
type, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Given a TypeInfo, dispatch a function with the corresponding template arg. More precisely, we shall call Dispatcher<T>::Dispatch() where the template arg T corresponds to the type
parameter.
- Template Parameters
-
Dispatcher | Function object that takes in one template arg. It must have a Dispatch() static function. |
Parameter | pack, to forward an arbitrary number of args to Dispatcher::Dispatch() |
- Parameters
-
type | TypeInfo corresponding to the template arg T with which Dispatcher<T>::Dispatch() is called. |
args | Other extra parameters to pass to Dispatcher::Dispatch() |
- Returns
- Whatever that's returned by the dispatcher
Definition at line 88 of file typeinfo.h.
◆ TypeInfoToString()
Get string representation of type info.
- Parameters
-
- Returns
- string representation
Definition at line 40 of file typeinfo.h.
◆ TypeToInfo()
TypeInfo treelite::TypeToInfo |
( |
| ) |
|
|
inline |
Convert a template type into a type info.
- Template Parameters
-
template | type to be converted |
- Returns
- TypeInfo corresponding to the template type arg
Definition at line 62 of file typeinfo.h.