class
SushiBLAS::ElementwiseOps
Records element-wise arithmetic and mathematical operations on contiguous tensors.
- Declared in
include/SushiBLAS/engine/math/elementwise.hpp
Note
Every operand must have storage and dense strides, and the operands of one call must share one shape: the library does not broadcast.
Public member functions
explicit ElementwiseOps(TaskRecorder &recorder) noexceptBuilds a view that records through recorder, which must outlive the view.
explicit ElementwiseOps(Engine &engine) noexceptBuilds a view that records on engine's own graph.
ElementwiseOps(const ElementwiseOps &)=defaultElementwiseOps & operator=(const ElementwiseOps &)=deleteElementwiseOps(ElementwiseOps &&)=defaultElementwiseOps & operator=(ElementwiseOps &&)=delete~ElementwiseOps()=defaultTaskHandle add(const Tensor &A, const Tensor &B, Tensor &C)Element-wise addition.
Computes C = A + B element-wise.
Parameters
AFirst input tensor.
BSecond input tensor.
COutput tensor to store the result.
Returns
The handle of the recorded task.
TaskHandle sub(const Tensor &A, const Tensor &B, Tensor &C)Element-wise subtraction.
Computes C = A - B element-wise.
Parameters
AFirst input tensor.
BSecond input tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle mul(const Tensor &A, const Tensor &B, Tensor &C)Element-wise multiplication (Hadamard product).
Computes C = A * B element-wise.
Parameters
AFirst input tensor.
BSecond input tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle div(const Tensor &A, const Tensor &B, Tensor &C)Element-wise division.
Computes C = A / B element-wise.
Parameters
AFirst input tensor (dividend).
BSecond input tensor (divisor).
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle sqrt(Tensor &t)Element-wise square root.
Computes t = sqrt(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle square(Tensor &t)Element-wise square.
Computes t = t * t for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle reciprocal(Tensor &t)Element-wise reciprocal.
Computes t = 1 / t for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle neg(Tensor &t)Element-wise negation.
Computes t = -t for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle exp(Tensor &t)Element-wise exponential.
Computes t = exp(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle log(Tensor &t)Element-wise natural logarithm.
Computes t = log(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle abs(Tensor &t)Element-wise absolute value.
Computes t = abs(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle pow(Tensor &t, double exponent)Raises each element of t to exponent in place.
Parameters
exponentThe power, narrowed to the element type when the call is recorded.
Returns
The handle of the recorded task.
TaskHandle sin(Tensor &t)Element-wise sine.
Computes t = sin(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle cos(Tensor &t)Element-wise cosine.
Computes t = cos(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle tan(Tensor &t)Element-wise tangent.
Computes t = tan(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle asin(Tensor &t)Element-wise arcsine.
Computes t = asin(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle acos(Tensor &t)Element-wise arccosine.
Computes t = acos(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle atan(Tensor &t)Element-wise arctangent.
Computes t = atan(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle sinh(Tensor &t)Element-wise hyperbolic sine.
Computes t = sinh(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle cosh(Tensor &t)Element-wise hyperbolic cosine.
Computes t = cosh(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle asinh(Tensor &t)Element-wise inverse hyperbolic sine.
Computes t = asinh(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle acosh(Tensor &t)Element-wise inverse hyperbolic cosine.
Computes t = acosh(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle atanh(Tensor &t)Element-wise inverse hyperbolic tangent.
Computes t = atanh(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle ceil(Tensor &t)Element-wise ceiling.
Computes t = ceil(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle floor(Tensor &t)Element-wise floor.
Computes t = floor(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle round(Tensor &t)Element-wise rounding.
Computes t = round(t) for each element in-place.
Parameters
tInput/Output tensor.
Returns
The handle of the recorded task.
TaskHandle min(const Tensor &A, const Tensor &B, Tensor &C)Element-wise minimum.
Computes C = min(A, B) element-wise.
Parameters
AFirst input tensor.
BSecond input tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle max(const Tensor &A, const Tensor &B, Tensor &C)Element-wise maximum.
Computes C = max(A, B) element-wise.
Parameters
AFirst input tensor.
BSecond input tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle fmod(const Tensor &A, const Tensor &B, Tensor &C)Element-wise floating-point remainder.
Computes C = fmod(A, B) element-wise.
Parameters
ADividend tensor.
BDivisor tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle remainder(const Tensor &A, const Tensor &B, Tensor &C)Element-wise remainder.
Computes C = remainder(A, B) element-wise.
Parameters
ADividend tensor.
BDivisor tensor.
COutput tensor.
Returns
The handle of the recorded task.
TaskHandle clamp(Tensor &t, double min_val, double max_val)Clamps each element of t in place to [min_val, max_val].
Parameters
min_valLower bound; an integer tensor truncates it toward zero.
max_valUpper bound; an integer tensor truncates it toward zero.
Returns
The handle of the recorded task.
Exceptions
std::runtime_errorif min_val > max_val, when the call is recorded.
TaskHandle convert(const Tensor &src, Tensor &dst)Copies src into dst, converting the element type.
Parameters
srcMust be contiguous and have storage.
dstMust be contiguous, have storage, match src's shape and layout and not overlap it.
Returns
The handle of the recorded task.
Exceptions
std::invalid_argumentif an operand has no storage, is not contiguous, or the shapes or layouts differ.
std::runtime_errornaming both dtypes if either falls outside Domain::REAL.
See also
include/SushiBLAS/engine/math/README.md

