repo
stringlengths
1
152
file
stringlengths
14
221
code
stringlengths
501
25k
file_length
int64
501
25k
avg_line_length
float64
20
99.5
max_line_length
int64
21
134
extension_type
stringclasses
2 values
null
pytorch-main/aten/src/ATen/nnapi/nnapi_bind.h
#ifndef NNAPI_BIND_H_ #define NNAPI_BIND_H_ #include <vector> #include <ATen/ATen.h> #include <torch/custom_class.h> #include <ATen/nnapi/nnapi_wrapper.h> namespace torch { namespace nnapi { namespace bind { // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) TORCH_API extern nnapi_wrapper* nnapi...
1,772
25.462687
120
h
null
pytorch-main/aten/src/ATen/nnapi/nnapi_model_loader.h
#ifndef NNAPI_MODEL_LOADER_H_ #define NNAPI_MODEL_LOADER_H_ #include <stdint.h> #include <ATen/nnapi/NeuralNetworks.h> #include <ATen/nnapi/nnapi_wrapper.h> namespace caffe2 { namespace nnapi { int load_nnapi_model( struct nnapi_wrapper* nnapi, ANeuralNetworksModel* model, const void* serialized_model, ...
675
21.533333
38
h
null
pytorch-main/aten/src/ATen/ops/from_blob.h
#pragma once #include <ATen/core/Tensor.h> namespace at { namespace detail { TORCH_API inline void noopDelete(void*) {} } // namespace detail /// Provides a fluent API to construct tensors from external data. /// /// The fluent API can be used instead of `from_blob` functions in case the /// required set of parame...
3,930
23.879747
83
h
null
pytorch-main/aten/src/ATen/ops/tensor.h
#pragma once #include <ATen/core/Tensor.h> #include <c10/core/ScalarType.h> namespace at { // These functions are defined in ATen/Utils.cpp. #define TENSOR(T, S) \ TORCH_API Tensor tensor(ArrayRef<T> values, const TensorOptions& options); \ inline Tensor t...
1,631
51.645161
79
h
null
pytorch-main/aten/src/ATen/quantized/QTensorImpl.h
#pragma once #include <ATen/quantized/Quantizer.h> #include <c10/core/TensorImpl.h> #include <c10/util/Exception.h> namespace at { /** * QTensorImpl is a TensorImpl for Quantized Tensors, it stores Quantizer which * specifies the quantization scheme and parameters, for more information please * see ATen/quantized...
4,009
30.825397
112
h
null
pytorch-main/aten/src/ATen/quantized/Quantizer.h
#pragma once #include <c10/core/QScheme.h> #include <c10/core/MemoryFormat.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/intrusive_ptr.h> #include <c10/core/ScalarType.h> #include <c10/core/TensorOptions.h> #include <ATen/Tensor.h> #include <ATen/TensorUtils.h> #include <ATen/c...
9,232
31.975
93
h
null
pytorch-main/aten/src/ATen/templates/DispatchKeyFunction.h
#pragma once // ${generated_comment} // NB: The implementing C++ file is RegisterDispatchKey.cpp // The only #includes we need are for custom classes that have defaults in the C++ API #include <c10/core/MemoryFormat.h> #include <c10/core/Scalar.h> #include <ATen/core/Reduction.h> // Forward declarations of any types...
702
28.291667
95
h
null
pytorch-main/aten/src/ATen/templates/DispatchKeyFunctions.h
#include <ATen/core/TensorBody.h> // TODO Undo all logic introduced for Note [Avoiding Include Cycles In Static Dispatch] // Code introduced to avoid cyclic dependency in static dispatch is no longer // needed as static dispatch logic is moved from TensorBody.h, which caused cycles in the first place, // to Operators....
1,932
63.433333
108
h
null
pytorch-main/aten/src/ATen/templates/DispatchKeyFunctions_inl.h
#pragma once // ${generated_comment} // NB: The implementing C++ file is RegisterDispatchKey.cpp // The only #includes we need are for custom classes that have defaults in the C++ API #include <c10/core/MemoryFormat.h> #include <c10/core/Scalar.h> #include <ATen/core/Reduction.h> #if defined(AT_PER_OPERATOR_HEADERS)...
824
34.869565
86
h
null
pytorch-main/aten/src/ATen/templates/Functions.h
#pragma once // ${generated_comment} #ifdef TORCH_ASSERT_NO_OPERATORS #error This change adds a dependency on native_functions.yaml, \ meaning the file will need to be re-compiled every time an operator \ is changed or added. Consider if your change would be better placed in \ another file, or i...
4,688
31.5625
91
h
null
pytorch-main/aten/src/ATen/templates/LazyIr.h
#pragma once // This file contains autogenerated LazyTensor IR nodes ${lazy_ir_sysinc} ${lazy_ir_inc} ${namespace_prologue} using at::operator<<; // kNullValue is used to contribute a static hash value any time // a node has an Optional<Value> input that is nullopt. It is important // to differentiate between HASH(...
575
27.8
82
h
null
pytorch-main/aten/src/ATen/templates/MethodOperators.h
#pragma once // ${generated_comment} #ifdef TORCH_ASSERT_NO_OPERATORS #error This change adds a dependency on native_functions.yaml, \ meaning the file will need to be re-compiled every time an operator \ is changed or added. Consider if your change would be better placed in \ another file, o...
830
32.24
95
h
null
pytorch-main/aten/src/ATen/templates/NativeFunctions.h
#pragma once // ${generated_comment} #ifdef TORCH_ASSERT_NO_OPERATORS #error This change adds a dependency on native_functions.yaml, \ meaning the file will need to be re-compiled every time an operator \ is changed or added. Consider if your change would be better placed in \ another file, or i...
1,160
33.147059
83
h
null
pytorch-main/aten/src/ATen/templates/RedispatchFunctions.h
#pragma once // ${generated_comment} #ifdef TORCH_ASSERT_ONLY_METHOD_OPERATORS #error This change adds a dependency on all pytorch operators, meaning the \ file will need to be re-compiled every time an operator is changed or added. \ Consider using the at::_ops::{name}::redispatch() interface by including ...
893
26.090909
80
h
null
pytorch-main/aten/src/ATen/templates/UnboxingFunctions.h
// ${generated_comment} // Generated by tools/jit/gen_unboxing.py. This file declares code generated boxed C++ functions for operators, // base off of native_functions.yaml (or similar yaml file with the same syntax). The definition of such a boxed // function will pop out IValues from the stack then convert them into...
1,026
30.121212
120
h
null
pytorch-main/aten/src/ATen/templates/aten_interned_strings.h
#pragma once // ${generated_comment} #if defined(TORCH_ASSERT_NO_OPERATORS) || defined(TORCH_ASSERT_ONLY_METHOD_OPERATORS) #error This change adds a dependency on native_functions.yaml, \ meaning the file will need to be re-compiled every time an operator \ is changed or added. Consider if including <A...
805
34.043478
85
h
null
pytorch-main/aten/src/ATen/test/reportMemoryUsage.h
#pragma once #include <ATen/ATen.h> #include <c10/core/Allocator.h> #include <c10/util/ThreadLocalDebugInfo.h> class TestMemoryReportingInfo : public c10::MemoryReportingInfoBase { public: struct Record { void* ptr; int64_t alloc_size; size_t total_allocated; size_t total_reserved; c10::Device...
861
20.02439
74
h
null
pytorch-main/aten/src/ATen/test/rng_test.h
#include <gtest/gtest.h> #include <ATen/Generator.h> #include <ATen/Tensor.h> #include <ATen/native/TensorIterator.h> #include <torch/library.h> #include <c10/util/Optional.h> #include <torch/all.h> #include <stdexcept> namespace { constexpr auto int64_min_val = std::numeric_limits<int64_t>::lowest(); constexpr auto ...
6,512
29.152778
102
h
null
pytorch-main/aten/src/ATen/test/test_assert.h
#pragma once #include <stdexcept> #include <stdarg.h> static inline void barf(const char *fmt, ...) { char msg[2048]; va_list args; va_start(args, fmt); vsnprintf(msg, 2048, fmt, args); va_end(args); throw std::runtime_error(msg); } #if defined(_MSC_VER) && _MSC_VER <= 1900 #define __func__ __FUNCTION__ #...
2,038
32.42623
101
h
null
pytorch-main/benchmarks/static_runtime/deep_wide_pt.h
#pragma once #include <ATen/CPUFunctions.h> #include <ATen/NativeFunctions.h> #include <torch/torch.h> struct DeepAndWide : torch::nn::Module { DeepAndWide(int num_features = 50) { mu_ = register_parameter("mu_", torch::randn({1, num_features})); sigma_ = register_parameter("sigma_", torch::randn({1, num_fe...
5,034
34.457746
80
h
null
pytorch-main/benchmarks/static_runtime/test_utils.h
// Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. #pragma once #include <string> #include <vector> #include <torch/csrc/jit/ir/ir.h> #include <torch/csrc/jit/runtime/static/impl....
1,859
26.352941
78
h
null
pytorch-main/binaries/benchmark_args.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
3,163
31.958333
79
h
null
pytorch-main/binaries/benchmark_helper.h
/** * Copyright (c) 2016-present, Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable ...
5,475
31.211765
77
h
null
pytorch-main/c10/core/Allocator.h
#pragma once #include <stddef.h> #include <memory> #include <c10/core/Device.h> #include <c10/util/Exception.h> #include <c10/util/ThreadLocalDebugInfo.h> #include <c10/util/UniqueVoidPtr.h> namespace c10 { // A DataPtr is a unique pointer (with an attached deleter and some // context for the deleter) to some memor...
9,201
32.100719
80
h
null
pytorch-main/c10/core/AutogradState.h
#pragma once #include <c10/macros/Export.h> namespace c10 { // Structure used to pack all the thread local boolean // flags used by autograd struct C10_API AutogradState { static AutogradState& get_tls_state(); static void set_tls_state(AutogradState state); AutogradState( bool grad_mode, bool inf...
1,591
20.808219
64
h
null
pytorch-main/c10/core/Backend.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/core/DispatchKey.h> #include <c10/core/DispatchKeySet.h> #include <c10/util/Exception.h> #include <stdexcept> namespace c10 { /** * This legacy enum class defines the set of backends supported by old school, * code generated Type-based ATen. A "backend"...
10,056
27.652422
80
h
null
pytorch-main/c10/core/CPUAllocator.h
#pragma once #include <cstring> #include <mutex> #include <unordered_map> #include <c10/core/Allocator.h> #include <c10/util/Flags.h> // TODO: rename to c10 C10_DECLARE_bool(caffe2_report_cpu_memory_usage); namespace c10 { using MemoryDeleter = void (*)(void*); // A helper function that is basically doing nothing...
1,638
27.258621
77
h
null
pytorch-main/c10/core/CompileTimeFunctionPointer.h
#pragma once #include <c10/util/TypeTraits.h> namespace c10 { /** * Represent a function pointer as a C++ type. * This allows using the function pointer as a type * in a template and calling it from inside the template * allows the compiler to inline the call because it * knows the function pointer at compile t...
1,677
28.438596
72
h
null
pytorch-main/c10/core/CopyBytes.h
#pragma once #include <c10/core/Device.h> namespace c10 { using CopyBytesFunction = void (*)( size_t nbytes, const void* src, Device src_device, void* dst, Device dst_device); struct C10_API _CopyBytesFunctionRegisterer { _CopyBytesFunctionRegisterer( DeviceType from, DeviceType to...
1,229
26.333333
78
h
null
pytorch-main/c10/core/DefaultTensorOptions.h
#pragma once #include <c10/core/Backend.h> #include <c10/core/Device.h> #include <c10/core/Layout.h> #include <c10/core/ScalarType.h> namespace c10 { struct TensorOptions; /// Like TensorOptions, but all fields are guaranteed to be filled. struct DefaultTensorOptions { DefaultTensorOptions() = default; caffe2:...
1,032
21.955556
70
h
null
pytorch-main/c10/core/Device.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/macros/Export.h> #include <c10/util/Exception.h> #include <cstddef> #include <functional> #include <iosfwd> #include <string> namespace c10 { /// An index representing a specific device; e.g., the 1 in GPU 1. /// A DeviceIndex is not independently meaningf...
6,883
30.87037
80
h
null
pytorch-main/c10/core/DeviceArray.h
#include <c10/core/Allocator.h> namespace c10 { template <typename T> class DeviceArray { public: DeviceArray(c10::Allocator& allocator, size_t size) : data_ptr_(allocator.allocate(size * sizeof(T))) { static_assert(std::is_trivial<T>::value, "T must be a trivial type"); TORCH_INTERNAL_ASSERT( ...
595
22.84
80
h
null
pytorch-main/c10/core/DeviceGuard.h
#pragma once #include <c10/core/impl/InlineDeviceGuard.h> namespace c10 { /// RAII guard that sets a certain default device in its constructor, and /// changes it back to the device that was originally active upon destruction. /// /// The device is always reset to the one that was active at the time of /// construct...
7,554
37.545918
80
h
null
pytorch-main/c10/core/DeviceType.h
#pragma once // This is directly synchronized with caffe2/proto/caffe2.proto, but // doesn't require me to figure out how to get Protobuf headers into // ATen/core (which would require a lot more build system hacking.) // If you modify me, keep me synchronized with that file. #include <c10/macros/Export.h> #include ...
4,297
35.423729
79
h
null
pytorch-main/c10/core/DynamicCast.h
#pragma once #include <c10/core/ScalarType.h> #include <c10/macros/Macros.h> #include <c10/util/Load.h> #include <c10/util/TypeCast.h> namespace c10 { // Dynamic type casting utils: // - fetch_and_cast // - cast_and_store // // fetch_and_cast fetch a value with dynamic type specified by a ScalarType // from a void p...
4,192
33.941667
80
h
null
pytorch-main/c10/core/Event.h
#pragma once #include <c10/core/impl/InlineEvent.h> #include <c10/core/impl/VirtualGuardImpl.h> namespace c10 { /** * A backend-generic movable, not copyable, not thread-safe event. * * The design of this event follows that of CUDA and HIP events. These events * are recorded and waited on by streams and can be r...
4,187
32.504
79
h
null
pytorch-main/c10/core/GeneratorImpl.h
#pragma once #include <stdint.h> #include <mutex> #include <c10/core/Device.h> #include <c10/core/DispatchKeySet.h> #include <c10/core/TensorImpl.h> #include <c10/macros/Export.h> #include <c10/util/intrusive_ptr.h> #include <c10/util/python_stub.h> /** * Note [Generator] * ~~~~~~~~~~~~~~~~ * A Pseudo Random Numb...
3,700
33.268519
80
h
null
pytorch-main/c10/core/GradMode.h
#pragma once #include <c10/core/AutogradState.h> #include <c10/macros/Export.h> namespace c10 { struct C10_API GradMode { static bool is_enabled(); static void set_enabled(bool enabled); }; // A RAII, thread local (!) guard that enables or disables grad mode upon // construction, and sets it back to the origina...
1,253
26.866667
78
h
null
pytorch-main/c10/core/InferenceMode.h
#pragma once #include <c10/core/AutogradState.h> #include <c10/core/impl/LocalDispatchKeySet.h> #include <c10/macros/Export.h> namespace c10 { // A RAII, thread local (!) guard that enables or disables inference mode upon // construction, and sets it back to the original value upon destruction. struct C10_API Infere...
3,487
40.035294
80
h
null
pytorch-main/c10/core/LargeNegativeIntSymNodeImpl.h
#include <c10/core/SymNodeImpl.h> namespace c10 { // Represents an otherwise unrepresentable large negative integer constant. // Unlike other SymNodeImpl, this cannot be "dispatched" conventionally, // as it typically needs to defer to another SymNodeImpl class C10_API LargeNegativeIntSymNodeImpl : public SymNodeImpl...
1,172
22
75
h
null
pytorch-main/c10/core/Layout.h
#pragma once #include <c10/core/Backend.h> #include <c10/util/Exception.h> #include <ostream> namespace c10 { enum class Layout : int8_t { Strided, Sparse, SparseCsr, Mkldnn, SparseCsc, SparseBsr, SparseBsc, NumOptions }; constexpr auto kStrided = Layout::Strided; constexpr auto kSparse = Layout::Sp...
1,682
23.042857
79
h
null
pytorch-main/c10/core/MemoryFormat.h
#pragma once #include <c10/core/Backend.h> #include <c10/util/ArrayRef.h> #include <c10/util/Exception.h> #include <ostream> // Memory format is not the property of a Tensor. It is the way to tell an // operator how the result should be organized in memory and nothing more. That // means memory format should never b...
9,300
31.295139
80
h
null
pytorch-main/c10/core/PyHandleCache.h
#pragma once #include <c10/core/impl/PyInterpreter.h> #include <c10/macros/Macros.h> #include <c10/util/python_stub.h> #include <atomic> namespace c10 { // A PyHandleCache represents a cached pointer from a C++ object to // a Python object that represents that object analogously in Python. // Upon a cache hit, the ...
3,076
39.486842
77
h
null
pytorch-main/c10/core/QEngine.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/core/DispatchKey.h> #include <c10/util/Exception.h> namespace c10 { /** * QEngine is an enum that is used to select the engine to run quantized ops. * Keep this enum in sync with get_qengine_id() in * torch/backends/quantized/__init__.py */ enum class Q...
1,040
21.148936
79
h
null
pytorch-main/c10/core/QScheme.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/util/Exception.h> namespace c10 { /** * QScheme is an enum that specifies the type of quantization. This has a one * to one correspondence with Quantizer * Please refer to ATen/quantized/Quantizer.h to see the Quantizers classes. * Keep this file in syn...
1,562
30.26
78
h
null
pytorch-main/c10/core/SafePyObject.h
#pragma once #include <c10/core/impl/PyInterpreter.h> #include <c10/macros/Export.h> #include <c10/util/python_stub.h> namespace c10 { // This is an safe owning holder for a PyObject, akin to pybind11's // py::object, with two major differences: // // - It is in c10/core; i.e., you can use this type in contexts whe...
2,488
28.987952
78
h
null
pytorch-main/c10/core/Scalar.h
#pragma once #include <stdint.h> #include <stdexcept> #include <type_traits> #include <utility> #include <c10/core/OptionalRef.h> #include <c10/core/ScalarType.h> #include <c10/core/SymFloat.h> #include <c10/core/SymInt.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/Half.h> #incl...
10,570
27.340483
96
h
null
pytorch-main/c10/core/ScalarType.h
#pragma once #include <c10/util/BFloat16.h> #include <c10/util/Deprecated.h> #include <c10/util/Exception.h> #include <c10/util/Half.h> #include <c10/util/bits.h> #include <c10/util/complex.h> #include <c10/util/qint32.h> #include <c10/util/qint8.h> #include <c10/util/quint2x4.h> #include <c10/util/quint4x2.h> #includ...
19,365
37.88755
129
h
null
pytorch-main/c10/core/ScalarTypeToTypeMeta.h
#pragma once #include <c10/core/ScalarType.h> #include <c10/util/Optional.h> #include <c10/util/typeid.h> // these just expose TypeMeta/ScalarType bridge functions in c10 // TODO move to typeid.h (or codemod away) when TypeMeta et al // are moved from caffe2 to c10 (see note at top of typeid.h) namespace c10 { /** ...
1,396
23.086207
77
h
null
pytorch-main/c10/core/Storage.h
#pragma once #include <c10/core/StorageImpl.h> namespace c10 { struct C10_API Storage { public: struct use_byte_size_t {}; Storage() = default; Storage(c10::intrusive_ptr<StorageImpl> ptr) : storage_impl_(std::move(ptr)) {} // Allocates memory buffer using given allocator and creates a storage with ...
4,715
25.346369
86
h
null
pytorch-main/c10/core/StorageImpl.h
#pragma once #include <c10/core/Allocator.h> #include <c10/core/SymInt.h> #include <c10/core/impl/PyObjectSlot.h> #include <c10/util/intrusive_ptr.h> namespace c10 { // A storage represents the underlying backing data buffer for a // tensor. This concept was inherited from the original Torch7 // codebase; we'd kin...
6,645
27.895652
79
h
null
pytorch-main/c10/core/Stream.h
#pragma once #include <c10/core/Device.h> namespace c10 { /// An index representing a specific stream. A StreamId is not independently /// meaningful without knowing the Device it is associated with; try to /// use Stream rather than StreamId directly. /// /// StreamIds are opaque; they are assigned by some DeviceT...
6,190
35.417647
79
h
null
pytorch-main/c10/core/StreamGuard.h
#pragma once #include <c10/core/impl/InlineStreamGuard.h> namespace c10 { /** * A StreamGuard is an RAII class that changes the current device * to the device corresponding to some stream, and changes the * default stream on that device to be this stream. * * Use of StreamGuard is HIGHLY discouraged in operator...
6,314
37.042169
80
h
null
pytorch-main/c10/core/SymBool.h
#pragma once #include <c10/core/SymNodeImpl.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/intrusive_ptr.h> namespace c10 { class C10_API SymBool { public: /*implicit*/ SymBool(bool b) : data_(b){}; SymBool(SymNode ptr) : data_(false), ptr_(std::move(ptr)) { TORCH_CHECK...
1,697
21.945946
74
h
null
pytorch-main/c10/core/SymFloat.h
#pragma once #include <c10/core/SymBool.h> #include <c10/core/SymNodeImpl.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/intrusive_ptr.h> #include <limits> namespace c10 { // NB: this is actually double precision; we're using the Python naming here class C10_API SymFloat { pub...
3,175
27.872727
79
h
null
pytorch-main/c10/core/SymInt.h
#pragma once #include <c10/core/SymBool.h> #include <c10/core/SymNodeImpl.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/Optional.h> #include <numeric> #include <type_traits> namespace c10 { class SymFloat; // SymInt represents either a regular int64_t, or a symbolic integer /...
11,961
33.373563
95
h
null
pytorch-main/c10/core/SymIntArrayRef.h
#pragma once #include <c10/core/SymInt.h> #include <c10/util/ArrayRef.h> #include <c10/util/Exception.h> #include <c10/util/Optional.h> namespace c10 { using SymIntArrayRef = ArrayRef<SymInt>; inline at::IntArrayRef asIntArrayRefUnchecked(c10::SymIntArrayRef ar) { return IntArrayRef(reinterpret_cast<const int64_t*...
2,137
28.694444
80
h
null
pytorch-main/c10/core/SymNodeImpl.h
#pragma once #include <c10/macros/Export.h> #include <c10/util/ArrayRef.h> #include <c10/util/Exception.h> #include <c10/util/Optional.h> #include <c10/util/intrusive_ptr.h> namespace c10 { class SymNodeImpl; using SymNode = c10::intrusive_ptr<SymNodeImpl>; // When you add a method, you also need to edit // torch/c...
4,720
25.227778
71
h
null
pytorch-main/c10/core/UndefinedTensorImpl.h
#pragma once #include <c10/core/TensorImpl.h> namespace c10 { struct C10_API UndefinedTensorImpl final : public TensorImpl { public: // Without this, we get: // error: identifier "at::UndefinedTensorImpl::_singleton" is undefined in // device code // (ostensibly because the constexpr tricks MSVC into tryi...
964
24.394737
78
h
null
pytorch-main/c10/core/WrapDimMinimal.h
#pragma once #include <c10/core/SymInt.h> namespace c10 { namespace detail { // This template can only be specialized at int64_t and c10::SymInt; // you'll get linker errors otherwise template <typename T> C10_API T maybe_wrap_dim_slow(T dim, T dim_post_expr, bool wrap_scalar); } // namespace detail template <typen...
1,260
27.022222
80
h
null
pytorch-main/c10/core/thread_pool.h
#pragma once #include <atomic> #include <condition_variable> #include <functional> #include <mutex> #include <queue> #include <thread> #include <utility> #include <c10/util/numa.h> #include <c10/util/thread_name.h> C10_CLANG_DIAGNOSTIC_PUSH() #if C10_CLANG_HAS_WARNING("-Wshorten-64-to-32") C10_CLANG_DIAGNOSTIC_IGNOR...
3,122
23.209302
74
h
null
pytorch-main/c10/core/impl/DeviceGuardImplInterface.h
#pragma once #include <c10/core/Device.h> #include <c10/core/DeviceType.h> #include <c10/core/Stream.h> #include <c10/util/Exception.h> // Just for C10_ANONYMOUS_VARIABLE #include <c10/util/Registry.h> #include <atomic> namespace c10 { // Forward declaration class DataPtr; /** * Flags defining the behavior of ev...
12,187
36.045593
80
h
null
pytorch-main/c10/core/impl/FakeGuardImpl.h
#pragma once #include <c10/core/impl/DeviceGuardImplInterface.h> #include <array> namespace c10 { namespace impl { // FakeGuardImpl is hardcoded to have eight devices. Not for // any good reason, just to simplify code. constexpr DeviceIndex kFakeGuardImplMaxDevices = 8; /** * A fake implementation of DeviceGuard...
3,237
28.981481
79
h
null
pytorch-main/c10/core/impl/GPUTrace.h
#pragma once #include <c10/core/impl/PyInterpreter.h> namespace c10 { namespace impl { struct C10_API GPUTrace { // On the x86 architecture the atomic operations are lock-less. static std::atomic<const PyInterpreter*> gpuTraceState; // When PyTorch migrates to C++20, this should be changed to an atomic flag. ...
889
27.709677
80
h
null
pytorch-main/c10/core/impl/HermeticPyObjectTLS.h
#pragma once #include <c10/macros/Export.h> #include <atomic> namespace c10 { namespace impl { // This TLS controls whether or not we permanently associate PyObject // with Tensor the first time it is allocated. When hermetic PyObject // TLS is enabled (state is true), we DO NOT save PyObjects to Tensor, // meaning...
2,471
38.870968
79
h
null
pytorch-main/c10/core/impl/InlineDeviceGuard.h
#pragma once // This file provides implementations of InlineDeviceGuard and // InlineOptionalDeviceGuard. #include <c10/core/Device.h> #include <c10/core/impl/DeviceGuardImplInterface.h> #include <c10/core/impl/VirtualGuardImpl.h> #include <c10/util/C++17.h> #include <c10/util/Optional.h> namespace c10 { namespace i...
15,715
35.37963
80
h
null
pytorch-main/c10/core/impl/InlineEvent.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/core/Stream.h> #include <c10/core/impl/DeviceGuardImplInterface.h> #include <c10/util/Exception.h> namespace c10 { namespace impl { template <typename T> struct InlineEvent final { InlineEvent() = delete; InlineEvent( const DeviceType _device_type...
2,930
25.405405
75
h
null
pytorch-main/c10/core/impl/InlineStreamGuard.h
#pragma once #include <c10/core/impl/InlineDeviceGuard.h> #include <c10/util/ArrayRef.h> #include <c10/util/irange.h> namespace c10 { namespace impl { /** * A StreamGuard is an RAII class that changes the current device * to the device corresponding to some stream, and changes the * default stream on that device ...
9,629
36.470817
80
h
null
pytorch-main/c10/core/impl/LocalDispatchKeySet.h
#pragma once #include <c10/core/DispatchKeySet.h> #include <c10/macros/Export.h> // TLS management for DispatchKeySet (the "local" DispatchKeySet(s)) // // This manages two thread-local DispatchKeySets: // // - The included type set, which adds a tensor type for consideration // in dispatch. (For example, you mi...
5,916
36.929487
80
h
null
pytorch-main/c10/core/impl/PyInterpreter.h
#pragma once #include <c10/core/Device.h> #include <c10/core/Layout.h> #include <c10/core/MemoryFormat.h> #include <c10/core/SymIntArrayRef.h> #include <c10/macros/Export.h> #include <c10/util/ArrayRef.h> #include <c10/util/intrusive_ptr.h> #include <c10/util/python_stub.h> #include <string> #include <vector> // Forw...
10,530
43.434599
80
h
null
pytorch-main/c10/core/impl/PyObjectSlot.h
#pragma once #include <c10/core/impl/HermeticPyObjectTLS.h> #include <c10/core/impl/PyInterpreter.h> #include <c10/util/Optional.h> #include <c10/util/python_stub.h> #include <atomic> namespace c10 { namespace impl { struct C10_API PyObjectSlot { public: PyObjectSlot(); void destroy_pyobj_if_needed(); // A...
7,301
41.208092
80
h
null
pytorch-main/c10/core/impl/PythonDispatcherTLS.h
#pragma once #include <c10/core/impl/PyInterpreter.h> #include <c10/macros/Export.h> namespace c10 { namespace impl { struct C10_API PythonDispatcherTLS { static void set_state(PyInterpreter* state); static PyInterpreter* get_state(); static void reset_state(); }; struct C10_API DisablePythonDispatcher { Di...
574
20.296296
70
h
null
pytorch-main/c10/core/impl/SizesAndStrides.h
#pragma once #include <algorithm> #include <cstdint> #include <c10/macros/Macros.h> #include <c10/util/ArrayRef.h> #include <c10/util/SmallVector.h> #define C10_SIZES_AND_STRIDES_MAX_INLINE_SIZE 5 namespace c10 { namespace impl { // Packed container for TensorImpl sizes and strides. // This design improves on the ...
7,934
24.679612
78
h
null
pytorch-main/c10/core/impl/TorchDispatchModeTLS.h
#pragma once #include <c10/core/SafePyObject.h> #include <c10/macros/Export.h> namespace c10 { namespace impl { struct C10_API TorchDispatchModeTLS { static void push_onto_stack(std::shared_ptr<SafePyObject> mode); static const std::shared_ptr<SafePyObject> pop_stack(); static const std::shared_ptr<SafePyObjec...
636
23.5
72
h
null
pytorch-main/c10/core/impl/VirtualGuardImpl.h
#pragma once #include <c10/core/impl/DeviceGuardImplInterface.h> namespace c10 { namespace impl { /** * An implementation of DeviceGuardImplInterface which delegates * to virtual dispatch on the DeviceGuardImpl registry. */ class VirtualGuardImpl final : public DeviceGuardImplInterface { public: VirtualGuardIm...
2,535
27.177778
80
h
null
pytorch-main/c10/core/impl/cow/context.h
#pragma once #include <c10/macros/Export.h> #include <c10/util/UniqueVoidPtr.h> #include <atomic> #include <cstdint> #include <memory> #include <shared_mutex> #include <variant> namespace c10::impl::cow { /// The c10::DataPtr context for copy-on-write storage. class C10_API Context { public: /// Creates an insta...
1,709
28.482759
77
h
null
pytorch-main/c10/cuda/CUDAAlgorithm.h
#ifdef THRUST_DEVICE_LOWER_BOUND_WORKS #include <thrust/binary_search.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> #include <thrust/functional.h> #endif namespace c10 { namespace cuda { #ifdef THRUST_DEVICE_LOWER_BOUND_WORKS template <typename Iter, typename Scalar> __forceinline__ __device...
1,066
30.382353
130
h
null
pytorch-main/c10/cuda/CUDACachingAllocator.h
#pragma once #include <c10/core/Allocator.h> #include <c10/core/StorageImpl.h> #include <c10/cuda/CUDAGraphsC10Utils.h> #include <c10/cuda/CUDAMacros.h> #include <c10/cuda/CUDAStream.h> #include <c10/util/Registry.h> #include <array> #include <mutex> #include <set> #include <unordered_set> namespace c10 { // Cachin...
13,193
30.117925
80
h
null
pytorch-main/c10/cuda/CUDADeviceAssertion.h
#pragma once #include <c10/cuda/CUDAException.h> #include <c10/macros/Macros.h> namespace c10 { namespace cuda { #ifdef TORCH_USE_CUDA_DSA // Copy string from `src` to `dst` static __device__ void dstrcpy(char* dst, const char* src) { int i = 0; // Copy string from source to destination, ensuring that it // is...
4,096
40.383838
79
h
null
pytorch-main/c10/cuda/CUDADeviceAssertionHost.h
#pragma once #include <c10/cuda/CUDAMacros.h> #include <memory> #include <mutex> #include <string> #include <vector> #ifdef USE_CUDA #define TORCH_USE_CUDA_DSA #endif /// Number of assertion failure messages we can store. If this is too small /// threads will fail silently. constexpr int C10_CUDA_DSA_ASSERTION_COUN...
6,394
39.220126
80
h
null
pytorch-main/c10/cuda/CUDAException.h
#pragma once #include <c10/cuda/CUDADeviceAssertionHost.h> #include <c10/cuda/CUDAMacros.h> #include <c10/cuda/CUDAMiscFunctions.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/util/irange.h> #include <cuda.h> // Note [CHECK macro] // ~~~~~~~~~~~~~~~~~~ // This is a macro so that AT_ER...
4,577
43.446602
80
h
null
pytorch-main/c10/cuda/CUDAFunctions.h
#pragma once // This header provides C++ wrappers around commonly used CUDA API functions. // The benefit of using C++ here is that we can raise an exception in the // event of an error, rather than explicitly pass around error codes. This // leads to more natural APIs. // // The naming convention used here matches t...
3,848
31.344538
80
h
null
pytorch-main/c10/cuda/CUDAGraphsC10Utils.h
#pragma once #include <c10/cuda/CUDAStream.h> #include <utility> // CUDA Graphs utils used by c10 and aten. // aten/cuda/CUDAGraphsUtils.cuh adds utils used by aten only. namespace c10 { namespace cuda { using CaptureId_t = unsigned long long; // first is set if the instance is created by CUDAGraph::capture_begin....
2,979
31.043011
80
h
null
pytorch-main/c10/cuda/CUDAGuard.h
#pragma once #include <c10/core/DeviceType.h> #include <c10/core/impl/InlineDeviceGuard.h> #include <c10/core/impl/InlineStreamGuard.h> #include <c10/cuda/CUDAMacros.h> #include <c10/cuda/impl/CUDAGuardImpl.h> #include <cstddef> namespace c10 { namespace cuda { // This code is kind of boilerplatey. See Note [Whith...
11,212
35.643791
80
h
null
pytorch-main/c10/cuda/CUDAMacros.h
#pragma once #ifndef C10_USING_CUSTOM_GENERATED_MACROS // We have not yet modified the AMD HIP build to generate this file so // we add an extra option to specifically ignore it. #ifndef C10_CUDA_NO_CMAKE_CONFIGURE_FILE #include <c10/cuda/impl/cuda_cmake_macros.h> #endif // C10_CUDA_NO_CMAKE_CONFIGURE_FILE #endif /...
1,193
25.533333
77
h
null
pytorch-main/c10/cuda/CUDAMathCompat.h
#pragma once /* This file defines math functions compatible across different gpu * platforms (currently CUDA and HIP). */ #if defined(__CUDACC__) || defined(__HIPCC__) #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #ifdef __HIPCC__ #define __MATH_FUNCTIONS_DECL__ inline C10_DEVICE #else /* __HIPCC_...
3,603
21.955414
75
h
null
pytorch-main/c10/cuda/CUDAStream.h
#pragma once #include <cstdint> #include <utility> #include <cuda_runtime_api.h> #include <c10/core/DeviceGuard.h> #include <c10/core/Stream.h> #include <c10/cuda/CUDAFunctions.h> #include <c10/util/Exception.h> /* * Stream pool note. * * A CUDAStream is an abstraction of an actual cuStream on the GPU. CUDAStrea...
9,494
34.561798
80
h
null
pytorch-main/c10/cuda/driver_api.h
#pragma once #include <cuda.h> #define NVML_NO_UNVERSIONED_FUNC_DEFS #include <nvml.h> #define C10_CUDA_DRIVER_CHECK(EXPR) \ do { \ CUresult __err = EXPR; \ ...
1,973
38.48
76
h
null
pytorch-main/c10/cuda/impl/CUDAGuardImpl.h
#pragma once #include <c10/core/DeviceGuard.h> #include <c10/core/impl/DeviceGuardImplInterface.h> #include <c10/core/impl/GPUTrace.h> #include <c10/macros/Macros.h> #include <c10/util/Exception.h> #include <c10/cuda/CUDACachingAllocator.h> #include <c10/cuda/CUDAException.h> #include <c10/cuda/CUDAFunctions.h> #incl...
6,831
31.226415
80
h
null
pytorch-main/c10/macros/Export.h
#ifndef C10_MACROS_EXPORT_H_ #define C10_MACROS_EXPORT_H_ /* Header file to define the common scaffolding for exported symbols. * * Export is by itself a quite tricky situation to deal with, and if you are * hitting this file, make sure you start with the background here: * - Linux: https://gcc.gnu.org/wiki/Visibi...
5,684
35.677419
80
h
null
pytorch-main/c10/macros/Macros.h
#ifndef C10_MACROS_MACROS_H_ #define C10_MACROS_MACROS_H_ #include <cassert> /* Main entry for c10/macros. * * In your code, include c10/macros/Macros.h directly, instead of individual * files in this folder. */ // For build systems that do not directly depend on CMake and directly build // from the source direct...
20,133
35.147217
122
h
null
pytorch-main/c10/mobile/CPUCachingAllocator.h
#pragma once #include <mutex> #include <c10/util/SmallVector.h> #include <c10/util/flat_hash_map.h> /* * CPUCachingAllocator: * DISCLAIMER: * This is subject to change (beta) and only supported on mobile builds. * If code snippet such as in 'Usage pattern' is used outside of mobile * build you will not...
4,115
38.2
80
h
null
pytorch-main/c10/mobile/CPUProfilingAllocator.h
#pragma once #include <c10/util/flat_hash_map.h> #include <memory> #include <vector> namespace c10 { /* * Given a sequence of allocations in a thread, AllocationPlan records * 1. size of each allocation * 2. Lifetime of each allocation. * 3. allocation offsets: Memory offset for each allocation in a single blob ...
4,667
30.12
79
h
null
pytorch-main/c10/test/util/complex_math_test_common.h
// Warning: this file is included twice in // aten/src/ATen/test/cuda_complex_math_test.cu #include <c10/util/complex.h> #include <gtest/gtest.h> #ifndef PI #define PI 3.141592653589793238463 #endif #ifndef tol #define tol 1e-6 #endif // Exponential functions C10_DEFINE_TEST(TestExponential, IPi) { // exp(i*pi) ...
21,964
31.881737
78
h
null
pytorch-main/c10/test/util/complex_test_common.h
#include <c10/macros/Macros.h> #include <c10/util/complex.h> #include <c10/util/hash.h> #include <gtest/gtest.h> #include <sstream> #include <tuple> #include <type_traits> #include <unordered_map> #if (defined(__CUDACC__) || defined(__HIPCC__)) #define MAYBE_GLOBAL __global__ #else #define MAYBE_GLOBAL #endif #define...
20,546
30.179059
80
h
null
pytorch-main/c10/util/AlignOf.h
//===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===-------------------------------------------------------...
4,844
26.685714
80
h
null
pytorch-main/c10/util/ArrayRef.h
//===--- ArrayRef.h - Array Reference Wrapper -------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===-------------------------------------------------------...
10,671
27.61126
105
h
null
pytorch-main/c10/util/BFloat16-inl.h
#pragma once #include <c10/macros/Macros.h> #include <c10/util/bit_cast.h> #include <limits> C10_CLANG_DIAGNOSTIC_PUSH() #if C10_CLANG_HAS_WARNING("-Wimplicit-int-float-conversion") C10_CLANG_DIAGNOSTIC_IGNORE("-Wimplicit-int-float-conversion") #endif #if defined(SYCL_EXT_ONEAPI_BFLOAT16_MATH_FUNCTIONS) #if defined...
10,329
29.02907
79
h
null
pytorch-main/c10/util/BFloat16-math.h
#pragma once #include <c10/util/BFloat16.h> #include <c10/util/Half.h> #include <c10/util/math_compat.h> C10_CLANG_DIAGNOSTIC_PUSH() #if C10_CLANG_HAS_WARNING("-Wimplicit-float-conversion") C10_CLANG_DIAGNOSTIC_IGNORE("-Wimplicit-float-conversion") #endif namespace std { template <typename T> struct is_reduced_floa...
7,888
26.778169
72
h
null
pytorch-main/c10/util/BFloat16.h
#pragma once // Defines the bloat16 type (brain floating-point). This representation uses // 1 bit for the sign, 8 bits for the exponent and 7 bits for the mantissa. #include <c10/macros/Macros.h> #include <cmath> #include <cstring> #if defined(__CUDACC__) && !defined(USE_ROCM) #include <cuda_bf16.h> #endif #if def...
2,801
23.155172
79
h