/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
ATen
/
native
/
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/native
mkdir
upload
Name
Size
Mode
Actions
cpu/
-
0755
rm
cuda/
-
0755
rm
quantized/
-
0755
rm
Activation.h
3069
0644
edit
dl
rm
AdaptivePooling.h
1165
0644
edit
dl
rm
BatchLinearAlgebra.h
8246
0644
edit
dl
rm
batch_norm.h
1285
0644
edit
dl
rm
BinaryOps.h
4916
0644
edit
dl
rm
BucketizationUtils.h
4248
0644
edit
dl
rm
ComplexHelper.h
3797
0644
edit
dl
rm
CompositeRandomAccessor.h
888
0644
edit
dl
rm
CompositeRandomAccessorCommon.h
6713
0644
edit
dl
rm
ConvUtils.h
5350
0644
edit
dl
rm
Copy.h
356
0644
edit
dl
rm
CPUBlas.h
4199
0644
edit
dl
rm
CPUFallback.h
2404
0644
edit
dl
rm
Cross.h
262
0644
edit
dl
rm
DilatedConvolutionUtils.h
6416
0644
edit
dl
rm
DispatchStub.h
7672
0644
edit
dl
rm
Distance.h
732
0644
edit
dl
rm
Distributions.h
21654
0644
edit
dl
rm
DistributionTemplates.h
18623
0644
edit
dl
rm
EmbeddingBag.h
1320
0644
edit
dl
rm
Fill.h
384
0644
edit
dl
rm
ForeachUtils.h
5962
0644
edit
dl
rm
FunctionOfAMatrixUtils.h
436
0644
edit
dl
rm
GridSampler.h
10525
0644
edit
dl
rm
group_norm.h
896
0644
edit
dl
rm
Histogram.h
492
0644
edit
dl
rm
im2col.h
2838
0644
edit
dl
rm
im2col_shape_check.h
6181
0644
edit
dl
rm
IndexingUtils.h
5373
0644
edit
dl
rm
layer_norm.h
2892
0644
edit
dl
rm
Lerp.h
553
0644
edit
dl
rm
LinearAlgebra.h
603
0644
edit
dl
rm
LinearAlgebraUtils.h
25236
0644
edit
dl
rm
LossMulti.h
2197
0644
edit
dl
rm
Math.h
91356
0644
edit
dl
rm
MathBitFallThroughLists.h
4086
0644
edit
dl
rm
MathBitsFallback.h
7326
0644
edit
dl
rm
MaxPooling.h
1234
0644
edit
dl
rm
Normalization.h
302
0644
edit
dl
rm
PointwiseOps.h
749
0644
edit
dl
rm
Pool.h
10922
0644
edit
dl
rm
Pow.h
1694
0644
edit
dl
rm
ReduceAllOps.h
378
0644
edit
dl
rm
ReduceOps.h
1745
0644
edit
dl
rm
ReduceOpsUtils.h
12245
0644
edit
dl
rm
Repeat.h
1286
0644
edit
dl
rm
Resize.h
6501
0644
edit
dl
rm
ResizeCommon.h
1321
0644
edit
dl
rm
RNN.h
2467
0644
edit
dl
rm
ScatterGatherChecks.h
3641
0644
edit
dl
rm
SegmentReduce.h
685
0644
edit
dl
rm
SharedReduceOps.h
15785
0644
edit
dl
rm
SobolEngineOpsUtils.h
1723
0644
edit
dl
rm
Sorting.h
536
0644
edit
dl
rm
SortingUtils.h
5722
0644
edit
dl
rm
SpectralOpsUtils.h
3146
0644
edit
dl
rm
StridedRandomAccessor.h
6847
0644
edit
dl
rm
TensorAdvancedIndexing.h
3072
0644
edit
dl
rm
TensorCompare.h
1333
0644
edit
dl
rm
TensorDimApply.h
1832
0644
edit
dl
rm
TensorFactories.h
3382
0644
edit
dl
rm
TensorIterator.h
46
0644
edit
dl
rm
TensorIteratorDynamicCasting.h
2025
0644
edit
dl
rm
TensorShape.h
1049
0644
edit
dl
rm
TensorTransformations.h
938
0644
edit
dl
rm
TriangularOpsUtils.h
2000
0644
edit
dl
rm
TypeProperties.h
496
0644
edit
dl
rm
UnaryOps.h
4464
0644
edit
dl
rm
Unfold2d.h
551
0644
edit
dl
rm
Unfold3d.h
852
0644
edit
dl
rm
UnfoldBackward.h
5398
0644
edit
dl
rm
UpSample.h
13599
0644
edit
dl
rm
vol2col.h
3642
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/native/TensorFactories.h
(3382B)
#pragma once #include <ATen/Functions.h> #include <ATen/Utils.h> #include <ATen/native/DispatchStub.h> #include <ATen/native/TensorIterator.h> #include <c10/core/TensorOptions.h> 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<int64_t>(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<int64_t>(0, std::min<int64_t>(col, row + offset)); // number of rows, bounded by [0, row] auto n_row_all = std::max<int64_t>(0, std::min<int64_t>(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> 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
Save
cmd:
run