forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmptyTensor.h
166 lines (141 loc) · 4.6 KB
/
EmptyTensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#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 = std::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 = std::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);
TORCH_API TensorBase empty_strided_symint_meta(
SymIntArrayRef size,
SymIntArrayRef stride,
const TensorOptions& options);
} // namespace at::detail