| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #pragma once
- #include <ATen/core/TensorBase.h>
- namespace at::detail {
- inline void check_size_nonnegative(ArrayRef<int64_t> size) {
- for (const auto& x : size) {
- TORCH_CHECK(
- x >= 0,
- "Trying to create tensor with negative dimension ",
- x,
- ": ",
- size);
- }
- }
- inline void check_size_nonnegative(ArrayRef<c10::SymInt> size) {
- for (const auto& x : size) {
- TORCH_CHECK(
- x.expect_size(__FILE__, __LINE__),
- "Trying to create tensor with negative dimension ",
- x,
- ": ",
- size);
- }
- }
- TORCH_API size_t computeStorageNbytesContiguous(
- IntArrayRef sizes,
- size_t itemsize,
- size_t storage_offset = 0);
- TORCH_API SymInt computeStorageNbytesContiguous(
- SymIntArrayRef sizes,
- const SymInt& itemsize,
- const SymInt& storage_offset = 0);
- TORCH_API size_t computeStorageNbytes(
- IntArrayRef sizes,
- IntArrayRef strides,
- size_t itemsize,
- size_t storage_offset = 0);
- TORCH_API SymInt computeStorageNbytes(
- SymIntArrayRef sizes,
- SymIntArrayRef strides,
- const SymInt& itemsize,
- const SymInt& storage_offset = 0);
- TORCH_API TensorBase empty_generic(
- IntArrayRef size,
- c10::Allocator* allocator,
- c10::DispatchKeySet ks,
- ScalarType scalar_type,
- std::optional<c10::MemoryFormat> memory_format_opt);
- TORCH_API TensorBase empty_generic_symint(
- SymIntArrayRef size,
- c10::Allocator* allocator,
- c10::DispatchKeySet ks,
- ScalarType scalar_type,
- std::optional<c10::MemoryFormat> memory_format_opt);
- TORCH_API TensorBase empty_strided_generic(
- IntArrayRef size,
- IntArrayRef stride,
- c10::Allocator* allocator,
- c10::DispatchKeySet ks,
- ScalarType scalar_type);
- TORCH_API TensorBase empty_strided_symint_generic(
- SymIntArrayRef size,
- SymIntArrayRef stride,
- c10::Allocator* allocator,
- c10::DispatchKeySet ks,
- ScalarType scalar_type);
- TORCH_API TensorBase empty_cpu(
- IntArrayRef size,
- ScalarType dtype,
- bool pin_memory = false,
- std::optional<c10::MemoryFormat> memory_format_opt = c10::nullopt);
- TORCH_API TensorBase empty_cpu(
- IntArrayRef size,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt,
- std::optional<c10::MemoryFormat> memory_format_opt);
- TORCH_API TensorBase empty_cpu(IntArrayRef size, const TensorOptions& options);
- TORCH_API TensorBase empty_strided_cpu(
- IntArrayRef size,
- IntArrayRef stride,
- ScalarType dtype,
- bool pin_memory = false);
- TORCH_API TensorBase empty_strided_cpu(
- IntArrayRef size,
- IntArrayRef stride,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt);
- TORCH_API TensorBase empty_strided_cpu(
- IntArrayRef size,
- IntArrayRef stride,
- const TensorOptions& options);
- TORCH_API TensorBase empty_meta(
- IntArrayRef size,
- ScalarType dtype,
- std::optional<c10::MemoryFormat> memory_format_opt = c10::nullopt);
- TORCH_API TensorBase empty_meta(
- IntArrayRef size,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt,
- std::optional<c10::MemoryFormat> memory_format_opt);
- TORCH_API TensorBase empty_symint_meta(
- SymIntArrayRef size,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt,
- std::optional<c10::MemoryFormat> memory_format_opt);
- TORCH_API TensorBase empty_meta(IntArrayRef size, const TensorOptions& options);
- TORCH_API TensorBase
- empty_strided_meta(IntArrayRef size, IntArrayRef stride, ScalarType dtype);
- TORCH_API TensorBase empty_strided_meta(
- IntArrayRef size,
- IntArrayRef stride,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt);
- TORCH_API TensorBase empty_strided_meta(
- IntArrayRef size,
- IntArrayRef stride,
- const TensorOptions& options);
- TORCH_API TensorBase empty_strided_symint_meta(
- SymIntArrayRef size,
- SymIntArrayRef stride,
- ScalarType dtype);
- TORCH_API TensorBase empty_strided_symint_meta(
- SymIntArrayRef size,
- SymIntArrayRef stride,
- std::optional<ScalarType> dtype_opt,
- std::optional<Layout> layout_opt,
- std::optional<Device> device_opt,
- std::optional<bool> pin_memory_opt);
- TORCH_API TensorBase empty_strided_symint_meta(
- SymIntArrayRef size,
- SymIntArrayRef stride,
- const TensorOptions& options);
- } // namespace at::detail
|