Title: ATen: Tensor Library — PyTorch main documentation
Description: ATen C++ API — the foundational tensor library powering PyTorch, including tensor operations, types, and CUDA support.
Keywords:
Domain: docs.pytorch.org
{
"@context": "https://schema.org",
"@type": "Article",
"name": "ATen: Tensor Library",
"headline": "ATen: Tensor Library",
"description": "ATen C++ API \u2014 the foundational tensor library powering PyTorch, including tensor operations, types, and CUDA support.",
"url": "/api/aten/index.html",
"articleBody": "ATen: Tensor Library# ATen (A Tensor Library) is the foundational tensor and mathematical operation library on which all of PyTorch is built. It provides the core Tensor class and hundreds of mathematical operations that work on tensors. When to use ATen directly: When writing low-level tensor operations or custom kernels When you need direct access to tensor data and metadata When working with the PyTorch internals or extending PyTorch Basic usage: #include \u003cATen/ATen.h\u003e // Create tensors at::Tensor a = at::ones({2, 3}); at::Tensor b = at::randn({2, 3}); // Perform operations at::Tensor c = a + b; at::Tensor d = at::matmul(a.t(), b); // Move to GPU if (at::cuda::is_available()) { at::Tensor gpu_tensor = c.to(at::kCUDA); } For most applications, prefer using the higher-level torch:: namespace (see Neural Network Modules (torch::nn), Optimizers (torch::optim)) which provides a more user-friendly API. Header Files# The following headers are part of the ATen public API: ATen/ATen.h - Main ATen header ATen/Backend.h - Backend enumeration ATen/core/Tensor.h - Tensor class ATen/core/ivalue.h - IValue type (see C10: Core Utilities) ATen/core/ScalarType.h - Data type definitions ATen/TensorOptions.h - Tensor creation options ATen/Scalar.h - Scalar type ATen/Layout.h - Tensor layout ATen/DeviceGuard.h - Device context management ATen/native/TensorShape.h - Tensor shape operations ATen/cuda/CUDAContext.h - CUDA context (see CUDA Support) ATen/cudnn/Descriptors.h - cuDNN descriptors ATen/mkl/Descriptors.h - MKL descriptors Note The core at::Tensor class is defined in a generated header file (TensorBody.h) that only exists after building PyTorch. The documentation below describes the API manually. ATen Categories# Tensor Class Tensor Creation Tensor Indexing Tensor Accessors",
"author": {
"@type": "Organization",
"name": "PyTorch Contributors",
"url": "https://pytorch.org"
},
"image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "/api/aten/index.html"
},
"datePublished": "2023-01-01T00:00:00Z",
"dateModified": "2023-01-01T00:00:00Z"
}
| docsearch:language | en |
| llm:site-type | documentation |
| llm:framework | PyTorch |
| llm:description | ATen C++ API — the foundational tensor library powering PyTorch, including tensor operations, types, and CUDA support. |
| llm:navigation-file | https://pytorch.org/docs/stable/llms.txt |
| llm:sitemap | https://pytorch.org/docs/stable/sitemap.xml |
| llm:version | main |
| llm:project | PyTorch |
| llm:page-type | documentation |
| og:image | https://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png |
| None | 2 |
Links:
Viewport: width=device-width, initial-scale=1