Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ ADD_BINARY_OPERATION_WITH_CUSTOM_CODE

#define ADD_BINARY_OPERATION_WITH_CUSTOM_CODE (   class_name,
  function_name,
  scalar_type_expr,
  operation,
  ... 
)
Value:
template <typename T_a, typename T_b> \
class class_name : public binary_operation<class_name<T_a, T_b>, \
scalar_type_expr, T_a, T_b> { \
using base \
= binary_operation<class_name<T_a, T_b>, scalar_type_expr, T_a, T_b>; \
using base::arguments_; \
\
public: \
using base::rows; \
using base::cols; \
class_name(T_a&& a, T_b&& b) /* NOLINT */ \
: base(std::forward<T_a>(a), std::forward<T_b>(b), operation) {} \
inline auto deep_copy() const { \
auto&& a_copy = this->template get_arg<0>().deep_copy(); \
auto&& b_copy = this->template get_arg<1>().deep_copy(); \
return class_name<std::remove_reference_t<decltype(a_copy)>, \
std::remove_reference_t<decltype(b_copy)>>( \
std::move(a_copy), std::move(b_copy)); \
} \
__VA_ARGS__ \
}; \
\
template <typename T_a, typename T_b, \
require_all_kernel_expressions_t<T_a, T_b>* = nullptr, \
require_any_not_arithmetic_t<T_a, T_b>* = nullptr> \
inline class_name<as_operation_cl_t<T_a>, as_operation_cl_t<T_b>> \
function_name(T_a&& a, T_b&& b) { /* NOLINT */ \
return {as_operation_cl(std::forward<T_a>(a)), \
as_operation_cl(std::forward<T_b>(b))}; \
}
T_operation && as_operation_cl(T_operation &&a)
Converts any valid kernel generator expression into an operation.

Defines a new binary operation in kernel generator that needs to implement custom function that determines the view of the result.

Parameters
class_nameThe name of the class this macro will define to represent this operation
function_nameThe name of the function this macro will define that will be used to create this operation.
scalar_type_exprThe type of the scalar in the result of this operation. Can be a C++ expression that uses T_a and T_b as types of the scalars in the arguments to this operation.
operationString containing operator that is used to implement this operation in kernel. Should be a valid infix operator in OpenCL C.
...Code that implements body of the .view() member function of the class that represents this expression. Should return an object of type matrix_cl_view. Can use base::arguments_ to access arguments to this expression. This is a variadic argument to allow commas in code with no special handling.

Definition at line 154 of file binary_operation.hpp.