/usr/local/lib64/python3.6/site-packages/torch/include/ATen
NameSizeModeActions
core/-0755rm
cpu/-0755rm
cuda/-0755rm
cudnn/-0755rm
detail/-0755rm
hip/-0755rm
native/-0755rm
quantized/-0755rm
AccumulateType.h44380644editdlrm
ArrayRef.h440644editdlrm
ATen.h9980644editdlrm
autocast_mode.h67160644editdlrm
Backend.h430644editdlrm
Backtrace.h460644editdlrm
BatchedFallback.h9650644editdlrm
BatchedTensorImpl.h53830644editdlrm
CompositeExplicitAutogradFunctions.h16220644editdlrm
CompositeExplicitAutogradFunctions_inl.h540750644editdlrm
CompositeImplicitAutogradFunctions.h16220644editdlrm
CompositeImplicitAutogradFunctions_inl.h1420820644editdlrm
Config.h7340644editdlrm
Context.h127670644editdlrm
cpp_custom_type_hack.h53260644editdlrm
CPUApplyUtils.h125820644editdlrm
CPUFixedAllocator.h8300644editdlrm
CPUFunctions.h16000644editdlrm
CPUFunctions_inl.h1719240644editdlrm
CPUGeneratorImpl.h14310644editdlrm
CUDAFunctions.h16010644editdlrm
CUDAFunctions_inl.h1856960644editdlrm
CUDAGeneratorImpl.h46950644editdlrm
Device.h420644editdlrm
DeviceGuard.h11340644editdlrm
Dimname.h310644editdlrm
DimVector.h460644editdlrm
Dispatch.h521370644editdlrm
div_rtn.h2040644editdlrm
DLConvertor.h5760644editdlrm
dlpack.h52440644editdlrm
DynamicLibrary.h3690644editdlrm
ExpandUtils.h145060644editdlrm
Formatting.h340644editdlrm
Functions.h8463260644editdlrm
Generator.h460644editdlrm
InferSize.h21430644editdlrm
InitialTensorOptions.h4450644editdlrm
Layout.h420644editdlrm
MapAllocator.h29990644editdlrm
MatrixRef.h30160644editdlrm
MemoryOverlap.h11170644editdlrm
MetaFunctions.h16010644editdlrm
MetaFunctions_inl.h840060644editdlrm
NamedTensor.h350644editdlrm
NamedTensorUtils.h57470644editdlrm
NativeFunctions.h3546510644editdlrm
NativeMetaFunctions.h354450644editdlrm
NumericUtils.h27870644editdlrm
OpaqueTensorImpl.h60800644editdlrm
Operators.h17071990644editdlrm
OpMathType.h4600644editdlrm
Parallel.h48750644editdlrm
ParallelNative.h24430644editdlrm
ParallelNativeTBB.h29340644editdlrm
ParallelOpenMP.h30490644editdlrm
PTThreadPool.h3940644editdlrm
record_function.h240440644editdlrm
RedispatchFunctions.h11128860644editdlrm
RegistrationDeclarations.h5457770644editdlrm
SavedTensorHooks.h3280644editdlrm
Scalar.h440644editdlrm
ScalarOps.h22720644editdlrm
ScalarType.h1290644editdlrm
SequenceNumber.h3730644editdlrm
SmallVector.h470644editdlrm
SparseCsrTensorImpl.h20450644editdlrm
SparseCsrTensorUtils.h5230644editdlrm
SparseTensorImpl.h124170644editdlrm
SparseTensorUtils.h42190644editdlrm
Storage.h430644editdlrm
Tensor.h480644editdlrm
TensorAccessor.h510644editdlrm
TensorGeometry.h18550644editdlrm
TensorIndexing.h219230644editdlrm
TensorIterator.h299620644editdlrm
TensorIteratorInternal.h18620644editdlrm
TensorMeta.h29170644editdlrm
TensorNames.h25190644editdlrm
TensorOperators.h32750644editdlrm
TensorOptions.h490644editdlrm
TensorUtils.h56870644editdlrm
ThreadLocalState.h32890644editdlrm
TracerMode.h55760644editdlrm
TypeDefault.h6800644editdlrm
Utils.h59930644editdlrm
Version.h3400644editdlrm
VmapMode.h9520644editdlrm
VmapTransforms.h76540644editdlrm
WrapDimUtils.h34380644editdlrm
WrapDimUtilsMulti.h7680644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/ATen/WrapDimUtils.h (3438B)
#pragma once #include #include #include namespace at { static inline int64_t maybe_wrap_dim(int64_t dim, int64_t dim_post_expr, bool wrap_scalar=true) { // if dim_post_expr is 0 and wrap_scalar is true, then dim must be in the range [-1, 0]. // This is a special case for scalar tensors and manifests in e.g. torch.sum(scalar_tensor, 0) // Otherwise, dim should be in the range [-dim_post_expr, dim_post_expr-1]. return c10::maybe_wrap_dim(dim, dim_post_expr, wrap_scalar); } static inline int64_t maybe_wrap_dim(int64_t dim, TensorImpl *tensor) { return maybe_wrap_dim(dim, tensor->dim()); } static inline int64_t maybe_wrap_dim(int64_t dim, TensorList tensors) { if (tensors.size() == 0) { // can't wrap empty TensorList; rely on underlying implementation to throw error if necessary. return dim; } return maybe_wrap_dim(dim, tensors[0].dim()); } static inline int64_t maybe_wrap_dim(int64_t dim, const std::vector> & tensor_sizes) { if (tensor_sizes.size() == 0) { // can't wrap empty list; rely on underlying implementation to throw error if necessary return dim; } return maybe_wrap_dim(dim, tensor_sizes[0].size()); } // wrap each dim in the dims array, taking dim_post_expr as the true number of dimensions static inline void maybe_wrap_dims_n(int64_t* dims, int64_t ndims, int64_t dim_post_expr) { if (dim_post_expr <= 0) { dim_post_expr = 1; // this will make range [-1, 0] } int64_t min = -dim_post_expr; int64_t max = dim_post_expr - 1; for (int64_t i = 0; i < ndims; ++i) { auto &dim = dims[i]; if (dim < min || dim > max) { TORCH_CHECK_INDEX(false, "Dimension out of range (expected to be in range of [", min, ", ", max, "], but got ", dim, ")"); } if (dim < 0) dim += dim_post_expr; } } // Wrap each dim in a contiguous container, taking dim_post_expr as the true number of dimensions // E.g. could also be std::array or c10::SmallVector template inline void maybe_wrap_dims(Container& dims, int64_t dim_post_expr) { return maybe_wrap_dims_n(dims.data(), dims.size(), dim_post_expr); } // previously, size [0] tensors were the only possible empty tensors; thus, it wasn't possible // to cat empty tensors unless all the other tensors were 1-dimensional, so we allowed these tensors // to be "skipped" (both for wrap dimension behavior and dimension size checking). // We maintain this behavior for backwards compatibility, but only for this specific size // (i.e. other empty sizes are not skipped). static inline int64_t legacy_cat_wrap_dim(int64_t dim, const std::vector>& tensor_sizes) { for (auto& sizes : tensor_sizes) { if (sizes == std::vector({0})) { continue; } return maybe_wrap_dim(dim, sizes.size()); } return dim; } static inline int64_t legacy_cat_wrap_dim(int64_t dim, TensorList tensors) { for (auto& tensor : tensors) { if (tensor.dim() == 1 && tensor.sizes()[0] == 0) { continue; } return maybe_wrap_dim(dim, tensor.dim()); } return dim; } // wrap negative dims in a vector static inline void wrap_all_dims(std::vector& dims_to_wrap, int64_t tensor_total_dims) { for (size_t i = 0; i < dims_to_wrap.size(); i++) { dims_to_wrap[i] = maybe_wrap_dim(dims_to_wrap[i], tensor_total_dims); } } }