33 #ifndef LINALG_BACKEND_BASE_H__ 34 #define LINALG_BACKEND_BASE_H__ 36 #include <shogun/lib/config.h> 54 #define DEFINE_FOR_ALL_PTYPE(METHODNAME, Container) \ 55 METHODNAME(bool, Container); \ 56 METHODNAME(char, Container); \ 57 METHODNAME(int8_t, Container); \ 58 METHODNAME(uint8_t, Container); \ 59 METHODNAME(int16_t, Container); \ 60 METHODNAME(uint16_t, Container); \ 61 METHODNAME(int32_t, Container); \ 62 METHODNAME(uint32_t, Container); \ 63 METHODNAME(int64_t, Container); \ 64 METHODNAME(uint64_t, Container); \ 65 METHODNAME(float32_t, Container); \ 66 METHODNAME(float64_t, Container); \ 67 METHODNAME(floatmax_t, Container); \ 68 METHODNAME(complex128_t, Container); \ 70 #define DEFINE_FOR_REAL_PTYPE(METHODNAME, Container) \ 71 METHODNAME(bool, Container); \ 72 METHODNAME(char, Container); \ 73 METHODNAME(int8_t, Container); \ 74 METHODNAME(uint8_t, Container); \ 75 METHODNAME(int16_t, Container); \ 76 METHODNAME(uint16_t, Container); \ 77 METHODNAME(int32_t, Container); \ 78 METHODNAME(uint32_t, Container); \ 79 METHODNAME(int64_t, Container); \ 80 METHODNAME(uint64_t, Container); \ 81 METHODNAME(float32_t, Container); \ 82 METHODNAME(float64_t, Container); \ 83 METHODNAME(floatmax_t, Container); 85 #define DEFINE_FOR_NON_INTEGER_PTYPE(METHODNAME, Container) \ 86 METHODNAME(float32_t, Container); \ 87 METHODNAME(float64_t, Container); \ 88 METHODNAME(floatmax_t, Container); \ 89 METHODNAME(complex128_t, Container); 96 #define BACKEND_GENERIC_IN_PLACE_ADD(Type, Container) \ 97 virtual void add(Container<Type>& a, Container<Type>& b, Type alpha, Type beta, Container<Type>& result) const \ 103 #undef BACKEND_GENERIC_IN_PLACE_ADD 110 #define BACKEND_GENERIC_CHOLESKY_FACTOR(Type, Container) \ 111 virtual Container<Type> cholesky_factor(const Container<Type>& A, \ 112 const bool lower) const \ 114 SG_SNOTIMPLEMENTED; \ 118 #undef BACKEND_GENERIC_CHOLESKY_FACTOR 125 #define BACKEND_GENERIC_CHOLESKY_SOLVER(Type, Container) \ 126 virtual SGVector<Type> cholesky_solver(const Container<Type>& L, \ 127 const SGVector<Type>& b, const bool lower) const \ 129 SG_SNOTIMPLEMENTED; \ 133 #undef BACKEND_GENERIC_CHOLESKY_SOLVER 140 #define BACKEND_GENERIC_DOT(Type, Container) \ 141 virtual Type dot(const Container<Type>& a, const Container<Type>& b) const \ 143 SG_SNOTIMPLEMENTED; \ 147 #undef BACKEND_GENERIC_DOT 154 #define BACKEND_GENERIC_IN_PLACE_ELEMENT_PROD(Type, Container) \ 155 virtual void element_prod(Container<Type>& a, Container<Type>& b,\ 156 Container<Type>& result) const \ 158 SG_SNOTIMPLEMENTED; \ 161 #undef BACKEND_GENERIC_IN_PLACE_ELEMENT_PROD 168 #define BACKEND_GENERIC_IN_PLACE_BLOCK_ELEMENT_PROD(Type, Container) \ 169 virtual void element_prod(linalg::Block<Container<Type>>& a, \ 170 linalg::Block<Container<Type>>& b, Container<Type>& result) const \ 172 SG_SNOTIMPLEMENTED; \ 175 #undef BACKEND_GENERIC_IN_PLACE_BLOCK_ELEMENT_PROD 182 #define BACKEND_GENERIC_LOGISTIC(Type, Container) \ 183 virtual void logistic(Container<Type>& a, Container<Type>& result) const \ 185 SG_SNOTIMPLEMENTED; \ 188 #undef BACKEND_GENERIC_LOGISTIC 195 #define BACKEND_GENERIC_IN_PLACE_MATRIX_PROD(Type, Container) \ 196 virtual void matrix_prod(SGMatrix<Type>& a, Container<Type>& b,\ 197 Container<Type>& result, bool transpose_A, bool transpose_B) const \ 199 SG_SNOTIMPLEMENTED; \ 203 #undef BACKEND_GENERIC_IN_PLACE_MATRIX_PROD 210 #define BACKEND_GENERIC_MAX(Type, Container) \ 211 virtual Type max(const Container<Type>& a) const \ 213 SG_SNOTIMPLEMENTED; \ 218 #undef BACKEND_GENERIC_MAX 226 #define BACKEND_GENERIC_REAL_MEAN(Type, Container) \ 227 virtual float64_t mean(const Container<Type>& a) const \ 229 SG_SNOTIMPLEMENTED; \ 234 #undef BACKEND_GENERIC_REAL_MEAN 242 #define BACKEND_GENERIC_COMPLEX_MEAN(Container) \ 243 virtual complex128_t mean(const Container<complex128_t>& a) const \ 245 SG_SNOTIMPLEMENTED; \ 250 #undef BACKEND_GENERIC_COMPLEX_MEAN 257 #define BACKEND_GENERIC_RANGE_FILL(Type, Container) \ 258 virtual void range_fill(Container<Type>& a, const Type start) const \ 260 SG_SNOTIMPLEMENTED; \ 264 #undef BACKEND_GENERIC_RANGE_FILL 271 #define BACKEND_GENERIC_IN_PLACE_SCALE(Type, Container) \ 272 virtual void scale(Container<Type>& a, Type alpha, Container<Type>& result) const \ 274 SG_SNOTIMPLEMENTED; \ 278 #undef BACKEND_GENERIC_IN_PLACE_SCALE 285 #define BACKEND_GENERIC_SET_CONST(Type, Container) \ 286 virtual void set_const(Container<Type>& a, const Type value) const \ 288 SG_SNOTIMPLEMENTED; \ 292 #undef BACKEND_GENERIC_SET_CONST 299 #define BACKEND_GENERIC_SUM(Type, Container) \ 300 virtual Type sum(const Container<Type>& a, bool no_diag) const \ 302 SG_SNOTIMPLEMENTED; \ 307 #undef BACKEND_GENERIC_SUM 314 #define BACKEND_GENERIC_BLOCK_SUM(Type, Container) \ 315 virtual Type sum(const linalg::Block<Container<Type>>& a, bool no_diag) const \ 317 SG_SNOTIMPLEMENTED; \ 321 #undef BACKEND_GENERIC_BLOCK_SUM 328 #define BACKEND_GENERIC_SYMMETRIC_SUM(Type, Container) \ 329 virtual Type sum_symmetric(const Container<Type>& a, bool no_diag) const \ 331 SG_SNOTIMPLEMENTED; \ 335 #undef BACKEND_GENERIC_SYMMETRIC_SUM 342 #define BACKEND_GENERIC_SYMMETRIC_BLOCK_SUM(Type, Container) \ 343 virtual Type sum_symmetric(const linalg::Block<Container<Type>>& a, bool no_diag) const \ 345 SG_SNOTIMPLEMENTED; \ 349 #undef BACKEND_GENERIC_SYMMETRIC_BLOCK_SUM 356 #define BACKEND_GENERIC_COLWISE_SUM(Type, Container) \ 357 virtual SGVector<Type> colwise_sum(const Container<Type>& a, bool no_diag) const \ 359 SG_SNOTIMPLEMENTED; \ 363 #undef BACKEND_GENERIC_COLWISE_SUM 370 #define BACKEND_GENERIC_BLOCK_COLWISE_SUM(Type, Container) \ 371 virtual SGVector<Type> colwise_sum(const linalg::Block<Container<Type>>& a, bool no_diag) const \ 373 SG_SNOTIMPLEMENTED; \ 377 #undef BACKEND_GENERIC_BLOCK_COLWISE_SUM 384 #define BACKEND_GENERIC_ROWWISE_SUM(Type, Container) \ 385 virtual SGVector<Type> rowwise_sum(const Container<Type>& a, bool no_diag) const \ 387 SG_SNOTIMPLEMENTED; \ 391 #undef BACKEND_GENERIC_ROWWISE_SUM 398 #define BACKEND_GENERIC_BLOCK_ROWWISE_SUM(Type, Container) \ 399 virtual SGVector<Type> rowwise_sum(const linalg::Block<Container<Type>>& a, bool no_diag) const \ 401 SG_SNOTIMPLEMENTED; \ 405 #undef BACKEND_GENERIC_BLOCK_ROWWISE_SUM 413 #define BACKEND_GENERIC_TO_GPU(Type, Container) \ 414 virtual GPUMemoryBase<Type>* to_gpu(const Container<Type>&) const \ 416 SG_SNOTIMPLEMENTED; \ 421 #undef BACKEND_GENERIC_TO_GPU 428 #define BACKEND_GENERIC_FROM_GPU(Type, Container) \ 429 virtual void from_gpu(const Container<Type>&, Type* data) const \ 431 SG_SNOTIMPLEMENTED; \ 435 #undef BACKEND_GENERIC_FROM_GPU 437 #undef DEFINE_FOR_ALL_PTYPE 438 #undef DEFINE_FOR_REAL_PTYPE 439 #undef DEFINE_FOR_NON_INTEGER_PTYPE 444 #endif //LINALG_BACKEND_BASE_H__ #define BACKEND_GENERIC_MAX(Type, Container)
#define BACKEND_GENERIC_IN_PLACE_ADD(Type, Container)
#define BACKEND_GENERIC_ROWWISE_SUM(Type, Container)
#define BACKEND_GENERIC_RANGE_FILL(Type, Container)
#define DEFINE_FOR_NON_INTEGER_PTYPE(METHODNAME, Container)
#define DEFINE_FOR_ALL_PTYPE(METHODNAME, Container)
#define BACKEND_GENERIC_IN_PLACE_SCALE(Type, Container)
#define BACKEND_GENERIC_SET_CONST(Type, Container)
#define BACKEND_GENERIC_REAL_MEAN(Type, Container)
#define BACKEND_GENERIC_CHOLESKY_SOLVER(Type, Container)
#define BACKEND_GENERIC_DOT(Type, Container)
#define BACKEND_GENERIC_LOGISTIC(Type, Container)
#define BACKEND_GENERIC_SYMMETRIC_SUM(Type, Container)
#define BACKEND_GENERIC_SUM(Type, Container)
#define DEFINE_FOR_REAL_PTYPE(METHODNAME, Container)
#define BACKEND_GENERIC_COMPLEX_MEAN(Container)
#define BACKEND_GENERIC_SYMMETRIC_BLOCK_SUM(Type, Container)
#define BACKEND_GENERIC_FROM_GPU(Type, Container)
#define BACKEND_GENERIC_IN_PLACE_MATRIX_PROD(Type, Container)
#define BACKEND_GENERIC_BLOCK_COLWISE_SUM(Type, Container)
#define BACKEND_GENERIC_CHOLESKY_FACTOR(Type, Container)
#define BACKEND_GENERIC_IN_PLACE_ELEMENT_PROD(Type, Container)
all of classes and functions are contained in the shogun namespace
Base interface of generic linalg methods and generic memory transfer methods.
#define BACKEND_GENERIC_TO_GPU(Type, Container)
#define BACKEND_GENERIC_BLOCK_SUM(Type, Container)
#define BACKEND_GENERIC_COLWISE_SUM(Type, Container)
#define BACKEND_GENERIC_BLOCK_ROWWISE_SUM(Type, Container)
#define BACKEND_GENERIC_IN_PLACE_BLOCK_ELEMENT_PROD(Type, Container)