20 if (A_shape.
size() != 2) {
23 if (A_shape[0] == 0 || A_shape[1] == 0) {
25 "Tensor shapes should not contain dimensions with zero.");
27 if (diagonal <= -1 * A_shape[0] || diagonal >= A_shape[1]) {
29 "Diagonal parameter must be between [-{}, {}] for a matrix "
30 "with shape {}, but got {}.",
40 #ifdef BUILD_CUDA_MODULE
46 }
else if (device.
IsSYCL()) {
47 #ifdef BUILD_SYCL_MODULE
62 #ifdef BUILD_CUDA_MODULE
68 }
else if (device.
IsSYCL()) {
69 #ifdef BUILD_SYCL_MODULE
85 #ifdef BUILD_CUDA_MODULE
87 TriulCUDA(A.
Contiguous(), upper, lower, diagonal);
91 }
else if (device.
IsSYCL()) {
92 #ifdef BUILD_SYCL_MODULE
When CUDA is not enabled, this is a dummy class.
bool IsCUDA() const
Returns true iff device type is CUDA.
bool IsSYCL() const
Returns true iff device type is SYCL GPU.
std::string ToString() const
Tensor Contiguous() const
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Device GetDevice() const override
SizeVector GetShape() const
void TrilCPU(const Tensor &A, Tensor &output, const int diagonal)
void TrilSYCL(const Tensor &A, Tensor &output, const int diagonal)
void Triu(const Tensor &A, Tensor &output, const int diagonal)
void Triul(const Tensor &A, Tensor &upper, Tensor &lower, const int diagonal)
void Tril(const Tensor &A, Tensor &output, const int diagonal)
void TriulSYCL(const Tensor &A, Tensor &upper, Tensor &lower, const int diagonal)
void TriulCPU(const Tensor &A, Tensor &upper, Tensor &lower, const int diagonal)
void TriuCPU(const Tensor &A, Tensor &output, const int diagonal)
void TriuSYCL(const Tensor &A, Tensor &output, const int diagonal)
static void CheckInput(const Tensor &A, const int diagonal)
Generic file read and write utility for python interface.