13#include <cuda_runtime_api.h>
19namespace uni20::linalg::detail::cuda_reference
22inline constexpr std::size_t elementwise_arithmetic_maximum_rank = 8;
23using ElementwiseFillPlan32 = StridedElementwisePlan32<1, elementwise_arithmetic_maximum_rank>;
24using ElementwiseFillPlan64 = StridedElementwisePlan64<1, elementwise_arithmetic_maximum_rank>;
25using LoweredElementwiseFillPlan = LoweredStridedElementwisePlan<1, elementwise_arithmetic_maximum_rank>;
26using ElementwiseUnaryPlan32 = StridedElementwisePlan32<2, elementwise_arithmetic_maximum_rank>;
27using ElementwiseUnaryPlan64 = StridedElementwisePlan64<2, elementwise_arithmetic_maximum_rank>;
28using LoweredElementwiseUnaryPlan = LoweredStridedElementwisePlan<2, elementwise_arithmetic_maximum_rank>;
29using ElementwiseBinaryPlan32 = StridedElementwisePlan32<3, elementwise_arithmetic_maximum_rank>;
30using ElementwiseBinaryPlan64 = StridedElementwisePlan64<3, elementwise_arithmetic_maximum_rank>;
31using LoweredElementwiseBinaryPlan = LoweredStridedElementwisePlan<3, elementwise_arithmetic_maximum_rank>;
32using ElementwiseInplaceUnaryPlan32 = ElementwiseFillPlan32;
33using ElementwiseInplaceUnaryPlan64 = ElementwiseFillPlan64;
34using ElementwiseInplaceBinaryPlan32 = ElementwiseUnaryPlan32;
35using ElementwiseInplaceBinaryPlan64 = ElementwiseUnaryPlan64;
37template <
class Function>
38concept RegisteredStatelessUnary =
39 std::same_as<Function, negate> || std::same_as<Function, square> || std::same_as<Function, reciprocal>;
41template <
class Function>
42concept RegisteredStatelessBinary = std::same_as<Function, add> || std::same_as<Function, subtract> ||
43 std::same_as<Function, multiply> || std::same_as<Function, divide>;
45template <
class Scalar>
46inline constexpr bool supports_elementwise_arithmetic =
47 std::same_as<Scalar, float> || std::same_as<Scalar, double> || std::same_as<Scalar, uni20::cfloat> ||
48 std::same_as<Scalar, uni20::cdouble>;
50template <
class Scalar>
51void enqueue_elementwise_fill(Scalar* output, Scalar
value, ElementwiseFillPlan32
const& plan, cudaStream_t stream,
54template <
class Scalar>
55void enqueue_elementwise_fill(Scalar* output, Scalar
value, ElementwiseFillPlan64
const& plan, cudaStream_t stream,
58template <
class Function,
class Scalar>
59void enqueue_elementwise_unary(Scalar* output, Scalar
const* input, Function function,
60 ElementwiseUnaryPlan32
const& plan, cudaStream_t stream,
int device);
62template <
class Function,
class Scalar>
63void enqueue_elementwise_unary(Scalar* output, Scalar
const* input, Function function,
64 ElementwiseUnaryPlan64
const& plan, cudaStream_t stream,
int device);
66template <
class Function,
class Scalar>
67void enqueue_elementwise_binary(Scalar* output, Scalar
const* lhs, Scalar
const* rhs, Function function,
68 ElementwiseBinaryPlan32
const& plan, cudaStream_t stream,
int device);
70template <
class Function,
class Scalar>
71void enqueue_elementwise_binary(Scalar* output, Scalar
const* lhs, Scalar
const* rhs, Function function,
72 ElementwiseBinaryPlan64
const& plan, cudaStream_t stream,
int device);
74template <
class Scalar,
class Factor>
75void enqueue_elementwise_inplace_scale(Scalar* output, Factor factor, ElementwiseInplaceUnaryPlan32
const& plan,
76 cudaStream_t stream,
int device);
78template <
class Scalar,
class Factor>
79void enqueue_elementwise_inplace_scale(Scalar* output, Factor factor, ElementwiseInplaceUnaryPlan64
const& plan,
80 cudaStream_t stream,
int device);
82template <
class Function,
class Scalar>
83void enqueue_elementwise_inplace_binary(Scalar* output, Scalar
const* input, Function function,
84 ElementwiseInplaceBinaryPlan32
const& plan, cudaStream_t stream,
int device);
86template <
class Function,
class Scalar>
87void enqueue_elementwise_inplace_binary(Scalar* output, Scalar
const* input, Function function,
88 ElementwiseInplaceBinaryPlan64
const& plan, cudaStream_t stream,
int device);
90template <
class Scalar,
class Factor>
91void enqueue_elementwise_add_scaled(Scalar* output, Scalar
const* input, Factor factor,
92 ElementwiseInplaceBinaryPlan32
const& plan, cudaStream_t stream,
int device);
94template <
class Scalar,
class Factor>
95void enqueue_elementwise_add_scaled(Scalar* output, Scalar
const* input, Factor factor,
96 ElementwiseInplaceBinaryPlan64
const& plan, cudaStream_t stream,
int device);
locale_t value
Definition data_table.cpp:49
Named backend-neutral function objects for elementwise transforms.
CUDA lowering for compact affine elementwise iteration plans.