ZTWHHH commited on
Commit
0574444
·
verified ·
1 Parent(s): 21dde6e

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. deepseek/lib/python3.10/site-packages/numpy/core/tests/__pycache__/test_numeric.cpython-310.pyc +3 -0
  3. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Azores +0 -0
  4. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Bermuda +0 -0
  5. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Canary +0 -0
  6. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Cape_Verde +0 -0
  7. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Faeroe +0 -0
  8. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Faroe +0 -0
  9. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Madeira +0 -0
  10. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/St_Helena +0 -0
  11. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/ACT +0 -0
  12. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Adelaide +0 -0
  13. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Brisbane +0 -0
  14. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Currie +0 -0
  15. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Darwin +0 -0
  16. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Eucla +0 -0
  17. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Hobart +0 -0
  18. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/LHI +0 -0
  19. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Lindeman +0 -0
  20. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Perth +0 -0
  21. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Queensland +0 -0
  22. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Tasmania +0 -0
  23. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Victoria +0 -0
  24. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Yancowinna +0 -0
  25. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Belgrade +0 -0
  26. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Bratislava +0 -0
  27. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Istanbul +0 -0
  28. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Mariehamn +0 -0
  29. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Moscow +0 -0
  30. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Simferopol +0 -0
  31. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Vaduz +0 -0
  32. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Chagos +0 -0
  33. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Cocos +0 -0
  34. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Comoro +0 -0
  35. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mahe +0 -0
  36. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Maldives +0 -0
  37. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mauritius +0 -0
  38. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mayotte +0 -0
  39. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Reunion +0 -0
  40. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Aleutian +0 -0
  41. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Arizona +0 -0
  42. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Central +0 -0
  43. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Eastern +0 -0
  44. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Hawaii +0 -0
  45. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Indiana-Starke +0 -0
  46. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Michigan +0 -0
  47. deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Pacific +0 -0
  48. deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/Allocator.h +269 -0
  49. deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/Backend.h +338 -0
  50. deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/CPUAllocator.h +57 -0
.gitattributes CHANGED
@@ -699,3 +699,4 @@ deepseek/lib/python3.10/site-packages/numpy/random/mtrand.cpython-310-x86_64-lin
699
  deepseek/lib/python3.10/site-packages/numpy/core/__pycache__/fromnumeric.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
700
  deepseek/lib/python3.10/site-packages/numpy/lib/__pycache__/function_base.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
701
  deepseek/lib/python3.10/site-packages/numpy/lib/tests/__pycache__/test_function_base.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
 
 
699
  deepseek/lib/python3.10/site-packages/numpy/core/__pycache__/fromnumeric.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
700
  deepseek/lib/python3.10/site-packages/numpy/lib/__pycache__/function_base.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
701
  deepseek/lib/python3.10/site-packages/numpy/lib/tests/__pycache__/test_function_base.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
702
+ deepseek/lib/python3.10/site-packages/numpy/core/tests/__pycache__/test_numeric.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
deepseek/lib/python3.10/site-packages/numpy/core/tests/__pycache__/test_numeric.cpython-310.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37e00abe340d625cc21f2794e11f2c08e4679f553ca45593e531d017f7cda903
3
+ size 118193
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Azores ADDED
Binary file (3.44 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Bermuda ADDED
Binary file (2.4 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Canary ADDED
Binary file (1.9 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Cape_Verde ADDED
Binary file (256 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Faeroe ADDED
Binary file (1.82 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Faroe ADDED
Binary file (1.82 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/Madeira ADDED
Binary file (3.38 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Atlantic/St_Helena ADDED
Binary file (148 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/ACT ADDED
Binary file (2.19 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Adelaide ADDED
Binary file (2.21 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Brisbane ADDED
Binary file (419 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Currie ADDED
Binary file (2.36 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Darwin ADDED
Binary file (325 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Eucla ADDED
Binary file (456 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Hobart ADDED
Binary file (2.36 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/LHI ADDED
Binary file (1.85 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Lindeman ADDED
Binary file (475 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Perth ADDED
Binary file (446 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Queensland ADDED
Binary file (419 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Tasmania ADDED
Binary file (2.36 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Victoria ADDED
Binary file (2.19 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Australia/Yancowinna ADDED
Binary file (2.23 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Belgrade ADDED
Binary file (1.92 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Bratislava ADDED
Binary file (2.3 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Istanbul ADDED
Binary file (1.93 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Mariehamn ADDED
Binary file (1.9 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Moscow ADDED
Binary file (1.54 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Simferopol ADDED
Binary file (1.47 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Europe/Vaduz ADDED
Binary file (1.91 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Chagos ADDED
Binary file (185 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Cocos ADDED
Binary file (254 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Comoro ADDED
Binary file (265 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mahe ADDED
Binary file (151 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Maldives ADDED
Binary file (185 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mauritius ADDED
Binary file (227 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Mayotte ADDED
Binary file (265 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/Indian/Reunion ADDED
Binary file (151 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Aleutian ADDED
Binary file (2.36 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Arizona ADDED
Binary file (360 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Central ADDED
Binary file (3.59 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Eastern ADDED
Binary file (3.55 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Hawaii ADDED
Binary file (329 Bytes). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Indiana-Starke ADDED
Binary file (2.44 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Michigan ADDED
Binary file (2.23 kB). View file
 
deepseek/lib/python3.10/site-packages/pytz/zoneinfo/US/Pacific ADDED
Binary file (2.85 kB). View file
 
deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/Allocator.h ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <stddef.h>
4
+ #include <memory>
5
+
6
+ #include <c10/core/Device.h>
7
+ #include <c10/util/Exception.h>
8
+ #include <c10/util/ThreadLocalDebugInfo.h>
9
+ #include <c10/util/UniqueVoidPtr.h>
10
+
11
+ namespace c10 {
12
+
13
+ // A DataPtr is a unique pointer (with an attached deleter and some
14
+ // context for the deleter) to some memory, which also records what
15
+ // device is for its data.
16
+ //
17
+ // nullptr DataPtrs can still have a nontrivial device; this allows
18
+ // us to treat zero-size allocations uniformly with non-zero allocations.
19
+ //
20
+ class C10_API DataPtr {
21
+ private:
22
+ c10::detail::UniqueVoidPtr ptr_;
23
+ Device device_;
24
+
25
+ public:
26
+ // Choice of CPU here is arbitrary; if there's an "undefined" device
27
+ // we could use that too
28
+ DataPtr() : ptr_(), device_(DeviceType::CPU) {}
29
+ DataPtr(void* data, Device device) : ptr_(data), device_(device) {}
30
+ DataPtr(void* data, void* ctx, DeleterFnPtr ctx_deleter, Device device)
31
+ : ptr_(data, ctx, ctx_deleter), device_(device) {}
32
+ void* operator->() const {
33
+ return ptr_.get();
34
+ }
35
+ void clear() {
36
+ ptr_.clear();
37
+ }
38
+ void* get() const {
39
+ return ptr_.get();
40
+ }
41
+ void* get_context() const {
42
+ return ptr_.get_context();
43
+ }
44
+ void* release_context() {
45
+ return ptr_.release_context();
46
+ }
47
+ std::unique_ptr<void, DeleterFnPtr>&& move_context() {
48
+ return ptr_.move_context();
49
+ }
50
+ operator bool() const {
51
+ return static_cast<bool>(ptr_);
52
+ }
53
+ template <typename T>
54
+ T* cast_context(DeleterFnPtr expected_deleter) const {
55
+ return ptr_.cast_context<T>(expected_deleter);
56
+ }
57
+ DeleterFnPtr get_deleter() const {
58
+ return ptr_.get_deleter();
59
+ }
60
+ /**
61
+ * Compare the deleter in a DataPtr to expected_deleter.
62
+ * If it matches, replace the deleter with new_deleter
63
+ * and return true; otherwise, does nothing and returns
64
+ * false.
65
+ *
66
+ * In general, it is not safe to unconditionally set the
67
+ * deleter on a DataPtr, because you don't know what
68
+ * the deleter is, and thus will have a hard time properly
69
+ * disposing of the deleter without storing the original
70
+ * deleter (this is difficult to do, because DeleterFnPtr
71
+ * is not a closure, and because the context on DataPtr is
72
+ * only a single word, you generally don't have enough
73
+ * space to store both the original deleter and its context).
74
+ * However, in some cases, you know /exactly/ what the deleter
75
+ * is, and you have a new deleter that manually wraps
76
+ * the old one. In this case, you can safely swap the deleter
77
+ * after asserting that the deleters line up.
78
+ *
79
+ * What are the requirements on new_deleter? It must still
80
+ * properly dispose of the void* pointer passed in as its argument,
81
+ * where void* is whatever the context of the original deleter
82
+ * is. So in general, you expect the new deleter to look something
83
+ * like this:
84
+ *
85
+ * [](void* ptr) {
86
+ * some_new_stuff(ptr);
87
+ * get_orig_allocator()->raw_deleter(ptr);
88
+ * }
89
+ *
90
+ * Note that it won't work to close over the original
91
+ * allocator; you don't have enough space to do that! Also,
92
+ * it's unsafe to assume that the passed in pointer in
93
+ * question is the memory pointer in question; it might not
94
+ * be; be sure to read the source code of the Allocator
95
+ * in question to confirm this.
96
+ */
97
+ C10_NODISCARD bool compare_exchange_deleter(
98
+ DeleterFnPtr expected_deleter,
99
+ DeleterFnPtr new_deleter) {
100
+ return ptr_.compare_exchange_deleter(expected_deleter, new_deleter);
101
+ }
102
+ Device device() const {
103
+ return device_;
104
+ }
105
+ // Unsafely mutates the device on a DataPtr. Under normal use,
106
+ // you should never actually need to call this function.
107
+ // We need this for the implementation of the hack detailed
108
+ // in Note [Masquerading as CUDA]
109
+ void unsafe_set_device(Device device) {
110
+ device_ = device;
111
+ }
112
+ };
113
+
114
+ // NB: Device is NOT tested for here; a CUDA nullptr is as much a nullptr as a
115
+ // CPU nullptr
116
+
117
+ inline bool operator==(const DataPtr& dp, std::nullptr_t) noexcept {
118
+ return !dp;
119
+ }
120
+ inline bool operator==(std::nullptr_t, const DataPtr& dp) noexcept {
121
+ return !dp;
122
+ }
123
+ inline bool operator!=(const DataPtr& dp, std::nullptr_t) noexcept {
124
+ return dp;
125
+ }
126
+ inline bool operator!=(std::nullptr_t, const DataPtr& dp) noexcept {
127
+ return dp;
128
+ }
129
+
130
+ // Note [raw_allocate/raw_deallocate and Thrust]
131
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132
+ // Thrust's support for custom allocators requires us to write something
133
+ // like this:
134
+ //
135
+ // class ThrustAllocator {
136
+ // char* allocate(size_t);
137
+ // void deallocate(char*, size_t);
138
+ // };
139
+ //
140
+ // This is not good for our unique_ptr based allocator interface, as
141
+ // there is no way to get to the context when we free.
142
+ //
143
+ // However, in some cases the context is exactly the same as
144
+ // the data pointer. In this case, we can support the "raw"
145
+ // allocate and deallocate interface. This is what
146
+ // raw_deleter signifies. By default, it returns a nullptr, which means that
147
+ // the raw interface is not implemented. Be sure to implement it whenever
148
+ // possible, or the raw interface will incorrectly reported as unsupported,
149
+ // when it is actually possible.
150
+
151
+ struct C10_API Allocator {
152
+ virtual ~Allocator() = default;
153
+
154
+ virtual DataPtr allocate(size_t n) const = 0;
155
+
156
+ // If this returns a non nullptr, it means that allocate()
157
+ // is guaranteed to return a unique_ptr with this deleter attached;
158
+ // it means the rawAllocate and rawDeallocate APIs are safe to use.
159
+ // This function MUST always return the same BoundDeleter.
160
+ virtual DeleterFnPtr raw_deleter() const {
161
+ return nullptr;
162
+ }
163
+ void* raw_allocate(size_t n) {
164
+ auto dptr = allocate(n);
165
+ AT_ASSERT(dptr.get() == dptr.get_context());
166
+ return dptr.release_context();
167
+ }
168
+ void raw_deallocate(void* ptr) {
169
+ auto d = raw_deleter();
170
+ AT_ASSERT(d);
171
+ d(ptr);
172
+ }
173
+ };
174
+
175
+ // This context is used to generate DataPtr which have arbitrary
176
+ // std::function deleters associated with them. In some user facing
177
+ // functions, we give a (user-friendly) interface for constructing
178
+ // tensors from external data which take an arbitrary std::function
179
+ // deleter. Grep for InefficientStdFunctionContext to find these
180
+ // occurrences.
181
+ //
182
+ // This context is inefficient because we have to do a dynamic
183
+ // allocation InefficientStdFunctionContext, on top of the dynamic
184
+ // allocation which is implied by std::function itself.
185
+ struct C10_API InefficientStdFunctionContext {
186
+ std::unique_ptr<void, std::function<void(void*)>> ptr_;
187
+ InefficientStdFunctionContext(
188
+ std::unique_ptr<void, std::function<void(void*)>>&& ptr)
189
+ : ptr_(std::move(ptr)) {}
190
+ static DataPtr makeDataPtr(
191
+ void* ptr,
192
+ const std::function<void(void*)>& deleter,
193
+ Device device);
194
+ };
195
+
196
+ /** Set the allocator for DeviceType `t`. The passed in allocator pointer is
197
+ * expected to have static lifetime; this function does NOT take ownership
198
+ * of the raw pointer. (The reason for this is to prevent existing pointers
199
+ * to an allocator of a particular device from being invalidated when
200
+ * SetAllocator is called.)
201
+ *
202
+ * Also note that this is not thread-safe, and we assume this function will
203
+ * only be called during initialization.
204
+ *
205
+ * The 'priority' flag is introduced when we want to overwrite the default
206
+ * allocator, since the allocators are set statically. The default priority
207
+ * is 0, which means the lowest. Only higher or equal priority can overwrite
208
+ * existing ones.
209
+ */
210
+ C10_API void SetAllocator(DeviceType t, Allocator* alloc, uint8_t priority = 0);
211
+ C10_API Allocator* GetAllocator(const DeviceType& t);
212
+
213
+ template <DeviceType t>
214
+ struct AllocatorRegisterer {
215
+ explicit AllocatorRegisterer(Allocator* alloc) {
216
+ SetAllocator(t, alloc);
217
+ }
218
+ };
219
+
220
+ #define REGISTER_ALLOCATOR(t, f) \
221
+ namespace { \
222
+ static c10::AllocatorRegisterer<t> g_allocator_d(f); \
223
+ }
224
+
225
+ // An interface for reporting thread local memory usage
226
+ // per device
227
+ struct C10_API MemoryReportingInfoBase : public c10::DebugInfoBase {
228
+ MemoryReportingInfoBase();
229
+ ~MemoryReportingInfoBase() override = default;
230
+
231
+ /**
232
+ * alloc_size corresponds to the size of the ptr.
233
+ *
234
+ * total_allocated corresponds to total allocated memory.
235
+ *
236
+ * total_reserved corresponds to total size of memory pool, both used and
237
+ * unused, if applicable.
238
+ */
239
+ virtual void reportMemoryUsage(
240
+ void* ptr,
241
+ int64_t alloc_size,
242
+ size_t total_allocated,
243
+ size_t total_reserved,
244
+ Device device) = 0;
245
+
246
+ virtual void reportOutOfMemory(
247
+ int64_t alloc_size,
248
+ size_t total_allocated,
249
+ size_t total_reserved,
250
+ Device device);
251
+
252
+ virtual bool memoryProfilingEnabled() const = 0;
253
+ };
254
+
255
+ C10_API bool memoryProfilingEnabled();
256
+ C10_API void reportMemoryUsageToProfiler(
257
+ void* ptr,
258
+ int64_t alloc_size,
259
+ size_t total_allocated,
260
+ size_t total_reserved,
261
+ Device device);
262
+
263
+ C10_API void reportOutOfMemoryToProfiler(
264
+ int64_t alloc_size,
265
+ size_t total_allocated,
266
+ size_t total_reserved,
267
+ Device device);
268
+
269
+ } // namespace c10
deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/Backend.h ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <c10/core/DeviceType.h>
4
+ #include <c10/core/DispatchKey.h>
5
+ #include <c10/core/DispatchKeySet.h>
6
+ #include <c10/util/Exception.h>
7
+
8
+ #include <stdexcept>
9
+
10
+ namespace c10 {
11
+
12
+ /**
13
+ * This legacy enum class defines the set of backends supported by old school,
14
+ * code generated Type-based ATen. A "backend" in this sense roughly
15
+ * corresponds to the cartesian product of (device type, layout), but restricted
16
+ * only to combinations which we actually have kernels for. Backend does NOT
17
+ * include dtype.
18
+ *
19
+ * The reason we are sunsetting this enum class is because it doesn't allow for
20
+ * open registration; e.g., if you want to add SparseXLA, you'd have to
21
+ * edit this enum; you wouldn't be able to do it out of tree. DispatchKey is
22
+ * the replacement for Backend which supports open registration.
23
+ *
24
+ * NB: The concept of 'Backend' here disagrees with the notion of backend
25
+ * exposed to users in torch.backends. Backend here is something like "CPU"
26
+ * or "SparseCUDA"; backend in torch.backends is something like "MKL" or
27
+ * "CUDNN".
28
+ */
29
+ enum class Backend {
30
+ CPU,
31
+ CUDA,
32
+ HIP,
33
+ VE,
34
+ FPGA,
35
+ IPU,
36
+ XPU,
37
+ SparseCPU,
38
+ SparseCUDA,
39
+ SparseCsrCPU,
40
+ SparseCsrCUDA,
41
+ SparseHIP,
42
+ SparseVE,
43
+ SparseXPU,
44
+ ORT,
45
+ XLA,
46
+ Vulkan,
47
+ Metal,
48
+ Meta,
49
+ QuantizedCPU,
50
+ QuantizedCUDA,
51
+ QuantizedXPU,
52
+ Undefined,
53
+ MkldnnCPU,
54
+ MPS,
55
+ HPU,
56
+ Lazy,
57
+ MTIA,
58
+ PrivateUse1,
59
+ NumOptions
60
+ };
61
+
62
+ static inline Backend dispatchKeyToBackend(DispatchKey t) {
63
+ if (t == DispatchKey::CPU || t == DispatchKey::AutogradCPU) {
64
+ return Backend::CPU;
65
+ } else if (t == DispatchKey::CUDA || t == DispatchKey::AutogradCUDA) {
66
+ return Backend::CUDA;
67
+ } else if (t == DispatchKey::HIP) {
68
+ return Backend::HIP;
69
+ } else if (t == DispatchKey::VE) {
70
+ return Backend::VE;
71
+ } else if (t == DispatchKey::FPGA) {
72
+ return Backend::FPGA;
73
+ } else if (t == DispatchKey::ORT) {
74
+ return Backend::ORT;
75
+ } else if (t == DispatchKey::XLA || t == DispatchKey::AutogradXLA) {
76
+ return Backend::XLA;
77
+ } else if (t == DispatchKey::Lazy || t == DispatchKey::AutogradLazy) {
78
+ return Backend::Lazy;
79
+ } else if (t == DispatchKey::MPS || t == DispatchKey::AutogradMPS) {
80
+ return Backend::MPS;
81
+ } else if (t == DispatchKey::Vulkan) {
82
+ return Backend::Vulkan;
83
+ } else if (t == DispatchKey::Metal) {
84
+ return Backend::Metal;
85
+ } else if (t == DispatchKey::Meta) {
86
+ return Backend::Meta;
87
+ } else if (t == DispatchKey::SparseCPU) {
88
+ return Backend::SparseCPU;
89
+ } else if (t == DispatchKey::SparseCUDA) {
90
+ return Backend::SparseCUDA;
91
+ } else if (t == DispatchKey::SparseHIP) {
92
+ return Backend::SparseHIP;
93
+ } else if (t == DispatchKey::SparseVE) {
94
+ return Backend::SparseVE;
95
+ } else if (t == DispatchKey::SparseCsrCPU) {
96
+ return Backend::SparseCsrCPU;
97
+ } else if (t == DispatchKey::SparseCsrCUDA) {
98
+ return Backend::SparseCsrCUDA;
99
+ } else if (t == DispatchKey::MkldnnCPU) {
100
+ return Backend::MkldnnCPU;
101
+ } else if (t == DispatchKey::QuantizedCPU) {
102
+ return Backend::QuantizedCPU;
103
+ } else if (t == DispatchKey::QuantizedCUDA) {
104
+ return Backend::QuantizedCUDA;
105
+ } else if (t == DispatchKey::IPU || t == DispatchKey::AutogradIPU) {
106
+ return Backend::IPU;
107
+ } else if (t == DispatchKey::XPU || t == DispatchKey::AutogradXPU) {
108
+ return Backend::XPU;
109
+ } else if (t == DispatchKey::SparseXPU) {
110
+ return Backend::SparseXPU;
111
+ } else if (t == DispatchKey::QuantizedXPU) {
112
+ return Backend::QuantizedXPU;
113
+ } else if (t == DispatchKey::HPU || t == DispatchKey::AutogradHPU) {
114
+ return Backend::HPU;
115
+ } else if (t == DispatchKey::MTIA) {
116
+ return Backend::MTIA;
117
+ } else if (t == DispatchKey::PrivateUse1) {
118
+ return Backend::PrivateUse1;
119
+ } else if (t == DispatchKey::Undefined) {
120
+ return Backend::Undefined;
121
+ } else {
122
+ TORCH_CHECK(false, "Unrecognized tensor type ID: ", t);
123
+ }
124
+ }
125
+
126
+ static inline DispatchKey backendToDispatchKey(Backend b) {
127
+ switch (b) {
128
+ case Backend::CPU:
129
+ return DispatchKey::CPU;
130
+ case Backend::CUDA:
131
+ return DispatchKey::CUDA;
132
+ case Backend::HIP:
133
+ return DispatchKey::HIP;
134
+ case Backend::VE:
135
+ return DispatchKey::VE;
136
+ case Backend::FPGA:
137
+ return DispatchKey::FPGA;
138
+ case Backend::ORT:
139
+ return DispatchKey::ORT;
140
+ case Backend::XLA:
141
+ return DispatchKey::XLA;
142
+ case Backend::Lazy:
143
+ return DispatchKey::Lazy;
144
+ case Backend::IPU:
145
+ return DispatchKey::IPU;
146
+ case Backend::XPU:
147
+ return DispatchKey::XPU;
148
+ case Backend::SparseXPU:
149
+ return DispatchKey::SparseXPU;
150
+ case Backend::SparseCPU:
151
+ return DispatchKey::SparseCPU;
152
+ case Backend::SparseCUDA:
153
+ return DispatchKey::SparseCUDA;
154
+ case Backend::SparseHIP:
155
+ return DispatchKey::SparseHIP;
156
+ case Backend::SparseVE:
157
+ return DispatchKey::SparseVE;
158
+ case Backend::SparseCsrCPU:
159
+ return DispatchKey::SparseCsrCPU;
160
+ case Backend::SparseCsrCUDA:
161
+ return DispatchKey::SparseCsrCUDA;
162
+ case Backend::MkldnnCPU:
163
+ return DispatchKey::MkldnnCPU;
164
+ case Backend::Vulkan:
165
+ return DispatchKey::Vulkan;
166
+ case Backend::Metal:
167
+ return DispatchKey::Metal;
168
+ case Backend::Meta:
169
+ return DispatchKey::Meta;
170
+ case Backend::QuantizedCPU:
171
+ return DispatchKey::QuantizedCPU;
172
+ case Backend::QuantizedCUDA:
173
+ return DispatchKey::QuantizedCUDA;
174
+ case Backend::Undefined:
175
+ return DispatchKey::Undefined;
176
+ case Backend::MPS:
177
+ return DispatchKey::MPS;
178
+ case Backend::HPU:
179
+ return DispatchKey::HPU;
180
+ case Backend::MTIA:
181
+ return DispatchKey::MTIA;
182
+ case Backend::PrivateUse1:
183
+ return DispatchKey::PrivateUse1;
184
+ default:
185
+ throw std::runtime_error("Unknown backend");
186
+ }
187
+ }
188
+
189
+ static inline DeviceType backendToDeviceType(Backend b) {
190
+ switch (b) {
191
+ case Backend::CPU:
192
+ return DeviceType::CPU;
193
+ case Backend::CUDA:
194
+ return DeviceType::CUDA;
195
+ case Backend::HIP:
196
+ return DeviceType::HIP;
197
+ case Backend::VE:
198
+ return DeviceType::VE;
199
+ case Backend::FPGA:
200
+ return DeviceType::FPGA;
201
+ case Backend::ORT:
202
+ return DeviceType::ORT;
203
+ case Backend::XLA:
204
+ return DeviceType::XLA;
205
+ case Backend::Lazy:
206
+ return DeviceType::Lazy;
207
+ case Backend::SparseCPU:
208
+ return DeviceType::CPU;
209
+ case Backend::SparseCUDA:
210
+ return DeviceType::CUDA;
211
+ case Backend::SparseHIP:
212
+ return DeviceType::HIP;
213
+ case Backend::SparseVE:
214
+ return DeviceType::VE;
215
+ case Backend::SparseCsrCPU:
216
+ return DeviceType::CPU;
217
+ case Backend::SparseCsrCUDA:
218
+ return DeviceType::CUDA;
219
+ case Backend::IPU:
220
+ return DeviceType::IPU;
221
+ case Backend::XPU:
222
+ case Backend::SparseXPU:
223
+ case Backend::QuantizedXPU:
224
+ return DeviceType::XPU;
225
+ case Backend::MkldnnCPU:
226
+ case Backend::QuantizedCPU:
227
+ return DeviceType::CPU;
228
+ case Backend::QuantizedCUDA:
229
+ return DeviceType::CUDA;
230
+ case Backend::Vulkan:
231
+ return DeviceType::Vulkan;
232
+ case Backend::Metal:
233
+ return DeviceType::Metal;
234
+ case Backend::Meta:
235
+ return DeviceType::Meta;
236
+ case Backend::MPS:
237
+ return DeviceType::MPS;
238
+ case Backend::HPU:
239
+ return DeviceType::HPU;
240
+ case Backend::MTIA:
241
+ return DeviceType::MTIA;
242
+ case Backend::PrivateUse1:
243
+ return DeviceType::PrivateUse1;
244
+ case Backend::Undefined:
245
+ TORCH_CHECK(false, "Undefined backend is not a valid device type");
246
+ default:
247
+ TORCH_CHECK(false, "Unknown backend");
248
+ }
249
+ }
250
+
251
+ // TODO: This probably shouldn't actually be static inline
252
+ static inline const char* toString(Backend b) {
253
+ switch (b) {
254
+ case Backend::CPU:
255
+ return "CPU";
256
+ case Backend::CUDA:
257
+ return "CUDA";
258
+ case Backend::HIP:
259
+ return "HIP";
260
+ case Backend::VE:
261
+ return "VE";
262
+ case Backend::FPGA:
263
+ return "FPGA";
264
+ case Backend::XPU:
265
+ return "XPU";
266
+ case Backend::IPU:
267
+ return "IPU";
268
+ case Backend::ORT:
269
+ return "ORT";
270
+ case Backend::XLA:
271
+ return "XLA";
272
+ case Backend::Lazy:
273
+ return "Lazy";
274
+ case Backend::MPS:
275
+ return "MPS";
276
+ case Backend::SparseCPU:
277
+ return "SparseCPU";
278
+ case Backend::SparseCUDA:
279
+ return "SparseCUDA";
280
+ case Backend::SparseHIP:
281
+ return "SparseHIP";
282
+ case Backend::SparseVE:
283
+ return "SparseVE";
284
+ case Backend::SparseXPU:
285
+ return "SparseXPU";
286
+ case Backend::SparseCsrCPU:
287
+ return "SparseCsrCPU";
288
+ case Backend::SparseCsrCUDA:
289
+ return "SparseCsrCUDA";
290
+ case Backend::MkldnnCPU:
291
+ return "MkldnnCPU";
292
+ case Backend::Vulkan:
293
+ return "Vulkan";
294
+ case Backend::Metal:
295
+ return "Metal";
296
+ case Backend::Meta:
297
+ return "Meta";
298
+ case Backend::QuantizedCPU:
299
+ return "QuantizedCPU";
300
+ case Backend::QuantizedCUDA:
301
+ return "QuantizedCUDA";
302
+ case Backend::QuantizedXPU:
303
+ return "QuantizedXPU";
304
+ case Backend::HPU:
305
+ return "HPU";
306
+ case Backend::MTIA:
307
+ return "MTIA";
308
+ case Backend::PrivateUse1:
309
+ return "PrivateUseOne";
310
+ default:
311
+ return "UNKNOWN_BACKEND";
312
+ }
313
+ }
314
+
315
+ static inline bool isSparse(Backend b) {
316
+ switch (b) {
317
+ case Backend::SparseXPU:
318
+ case Backend::SparseCPU:
319
+ case Backend::SparseCUDA:
320
+ case Backend::SparseHIP:
321
+ case Backend::SparseVE:
322
+ return true;
323
+ default:
324
+ return false;
325
+ }
326
+ }
327
+
328
+ static inline bool isSparseCsr(Backend b) {
329
+ switch (b) {
330
+ case Backend::SparseCsrCPU:
331
+ case Backend::SparseCsrCUDA:
332
+ return true;
333
+ default:
334
+ return false;
335
+ }
336
+ }
337
+
338
+ } // namespace c10
deepseekvl2/lib/python3.10/site-packages/torch/include/c10/core/CPUAllocator.h ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <cstring>
4
+ #include <mutex>
5
+ #include <unordered_map>
6
+
7
+ #include <c10/core/Allocator.h>
8
+ #include <c10/util/Flags.h>
9
+
10
+ // TODO: rename to c10
11
+ C10_DECLARE_bool(caffe2_report_cpu_memory_usage);
12
+
13
+ namespace c10 {
14
+
15
+ using MemoryDeleter = void (*)(void*);
16
+
17
+ // A helper function that is basically doing nothing.
18
+ C10_API void NoDelete(void*);
19
+
20
+ // A simple struct that is used to report C10's memory allocation,
21
+ // deallocation status and out-of-memory events to the profiler
22
+ class C10_API ProfiledCPUMemoryReporter {
23
+ public:
24
+ ProfiledCPUMemoryReporter() = default;
25
+ void New(void* ptr, size_t nbytes);
26
+ void OutOfMemory(size_t nbytes);
27
+ void Delete(void* ptr);
28
+
29
+ private:
30
+ std::mutex mutex_;
31
+ std::unordered_map<void*, size_t> size_table_;
32
+ size_t allocated_ = 0;
33
+ size_t log_cnt_ = 0;
34
+ };
35
+
36
+ C10_API ProfiledCPUMemoryReporter& profiledCPUMemoryReporter();
37
+
38
+ // Get the CPU Allocator.
39
+ C10_API at::Allocator* GetCPUAllocator();
40
+ // Sets the CPU allocator to the given allocator: the caller gives away the
41
+ // ownership of the pointer.
42
+ C10_API void SetCPUAllocator(at::Allocator* alloc, uint8_t priority = 0);
43
+
44
+ // Get the Default CPU Allocator
45
+ C10_API at::Allocator* GetDefaultCPUAllocator();
46
+
47
+ // Get the Default Mobile CPU Allocator
48
+ C10_API at::Allocator* GetDefaultMobileCPUAllocator();
49
+
50
+ // The CPUCachingAllocator is experimental and might disappear in the future.
51
+ // The only place that uses it is in StaticRuntime.
52
+ // Set the CPU Caching Allocator
53
+ C10_API void SetCPUCachingAllocator(Allocator* alloc, uint8_t priority = 0);
54
+ // Get the CPU Caching Allocator
55
+ C10_API Allocator* GetCPUCachingAllocator();
56
+
57
+ } // namespace c10