/usr/local/lib64/python3.6/site-packages/torch/include/ATen/native
NameSizeModeActions
cpu/-0755rm
cuda/-0755rm
quantized/-0755rm
Activation.h30690644editdlrm
AdaptivePooling.h11650644editdlrm
BatchLinearAlgebra.h82460644editdlrm
batch_norm.h12850644editdlrm
BinaryOps.h49160644editdlrm
BucketizationUtils.h42480644editdlrm
ComplexHelper.h37970644editdlrm
CompositeRandomAccessor.h8880644editdlrm
CompositeRandomAccessorCommon.h67130644editdlrm
ConvUtils.h53500644editdlrm
Copy.h3560644editdlrm
CPUBlas.h41990644editdlrm
CPUFallback.h24040644editdlrm
Cross.h2620644editdlrm
DilatedConvolutionUtils.h64160644editdlrm
DispatchStub.h76720644editdlrm
Distance.h7320644editdlrm
Distributions.h216540644editdlrm
DistributionTemplates.h186230644editdlrm
EmbeddingBag.h13200644editdlrm
Fill.h3840644editdlrm
ForeachUtils.h59620644editdlrm
FunctionOfAMatrixUtils.h4360644editdlrm
GridSampler.h105250644editdlrm
group_norm.h8960644editdlrm
Histogram.h4920644editdlrm
im2col.h28380644editdlrm
im2col_shape_check.h61810644editdlrm
IndexingUtils.h53730644editdlrm
layer_norm.h28920644editdlrm
Lerp.h5530644editdlrm
LinearAlgebra.h6030644editdlrm
LinearAlgebraUtils.h252360644editdlrm
LossMulti.h21970644editdlrm
Math.h913560644editdlrm
MathBitFallThroughLists.h40860644editdlrm
MathBitsFallback.h73260644editdlrm
MaxPooling.h12340644editdlrm
Normalization.h3020644editdlrm
PointwiseOps.h7490644editdlrm
Pool.h109220644editdlrm
Pow.h16940644editdlrm
ReduceAllOps.h3780644editdlrm
ReduceOps.h17450644editdlrm
ReduceOpsUtils.h122450644editdlrm
Repeat.h12860644editdlrm
Resize.h65010644editdlrm
ResizeCommon.h13210644editdlrm
RNN.h24670644editdlrm
ScatterGatherChecks.h36410644editdlrm
SegmentReduce.h6850644editdlrm
SharedReduceOps.h157850644editdlrm
SobolEngineOpsUtils.h17230644editdlrm
Sorting.h5360644editdlrm
SortingUtils.h57220644editdlrm
SpectralOpsUtils.h31460644editdlrm
StridedRandomAccessor.h68470644editdlrm
TensorAdvancedIndexing.h30720644editdlrm
TensorCompare.h13330644editdlrm
TensorDimApply.h18320644editdlrm
TensorFactories.h33820644editdlrm
TensorIterator.h460644editdlrm
TensorIteratorDynamicCasting.h20250644editdlrm
TensorShape.h10490644editdlrm
TensorTransformations.h9380644editdlrm
TriangularOpsUtils.h20000644editdlrm
TypeProperties.h4960644editdlrm
UnaryOps.h44640644editdlrm
Unfold2d.h5510644editdlrm
Unfold3d.h8520644editdlrm
UnfoldBackward.h53980644editdlrm
UpSample.h135990644editdlrm
vol2col.h36420644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/ATen/native/TensorFactories.h (3382B)
#pragma once #include #include #include #include #include namespace at { namespace native { // Different combinations of row, col, and offset can lead to two cases: // // Case 1 - Trapezoid (Triangle as a special case): row + offset <= col // Example A: offset > 0 // 1 1 0 0 0 // 1 1 1 0 0 // 1 1 1 1 0 // Example B: offset <= 0 // 0 0 0 // 1 0 0 // 1 1 0 // In this case, we calculate the number of elements in the first row and // last row of the tril respectively, and then compute the tril size. // // Case 2 - Trapezoid + Rectangle: row + offset > col // Example: // 1 1 0 // 1 1 1 // 1 1 1 // In this case, we first calculate the size of top trapezoid, and then // calculate the size of the bottom rectangle. inline int64_t get_tril_size(int64_t row, int64_t col, int64_t offset) { // number of elements in the first row of the tril auto m_first_row = offset > 0 ? std::min(col, 1 + offset) : // upper bounded by col row + offset > 0; // either 0 or 1 // number of elements in the last row of the tril, bounded by [0, col] auto m_last_row = std::max(0, std::min(col, row + offset)); // number of rows, bounded by [0, row] auto n_row_all = std::max(0, std::min(row, row + offset)); auto n_row_trapezoid = (m_last_row - m_first_row + 1); // calculate # of elements in the top trapezoid auto tril_size = (m_first_row + m_last_row) * n_row_trapezoid >> 1; // calculate # of elements in the bottom rectangle if there is any auto diff_row = n_row_all - n_row_trapezoid; if (diff_row > 0) { tril_size += diff_row * col; } return tril_size; } inline void check_args( int64_t row, int64_t col, c10::optional layout_opt) { TORCH_CHECK(row >= 0, "row must be non-negative, got", row); TORCH_CHECK(col >= 0, "col must be non-negative, got", col); if (layout_opt.has_value()) { TORCH_CHECK( *layout_opt == at::kStrided, "only support layout=torch.strided, got", *layout_opt) } } using at::check_size_nonnegative; // assumes maximum value in created tensor is n-1 (e.g., torch.randperm(n)) inline void check_supported_max_int_with_precision(int64_t n, const Tensor& tensor) { // match defined() to behavior of checks below TORCH_CHECK(at::scalar_tensor(n>0?n-1:n, tensor.options()).defined(), "n is too large for result tensor type: '", tensor.toString(), "'"); // Ensure sufficient precision for floating point representation. switch (tensor.scalar_type()) { case at::ScalarType::Half: TORCH_CHECK(n <= (int64_t(1) << 11) + 1, "n cannot be greater than 2049 for Half type."); break; case at::ScalarType::Float: TORCH_CHECK(n <= (int64_t(1) << 24) + 1, "n cannot be greater than 2^24+1 for Float type."); break; case at::ScalarType::Double: // Unlikely to happen, but doesn't hurt to check TORCH_CHECK(n <= (int64_t(1) << 53) + 1, "n cannot be greater than 2^53+1 for Double type."); break; default: break; } } using binary_fn = void (*)(TensorIterator&); DECLARE_DISPATCH(binary_fn, complex_stub); DECLARE_DISPATCH(binary_fn, polar_stub); } // namespace native } // namespace at