/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
c10
/
util
/
/usr/local/lib64/python3.6/site-packages/torch/include/c10/util
mkdir
upload
Name
Size
Mode
Actions
accumulate.h
4205
0644
edit
dl
rm
AlignOf.h
4835
0644
edit
dl
rm
Array.h
11354
0644
edit
dl
rm
ArrayRef.h
9058
0644
edit
dl
rm
Backtrace.h
364
0644
edit
dl
rm
BFloat16-inl.h
9222
0644
edit
dl
rm
BFloat16-math.h
5217
0644
edit
dl
rm
BFloat16.h
2372
0644
edit
dl
rm
Bitset.h
3414
0644
edit
dl
rm
C++17.h
13329
0644
edit
dl
rm
complex.h
17542
0644
edit
dl
rm
complex_math.h
10902
0644
edit
dl
rm
complex_utils.h
958
0644
edit
dl
rm
ConstexprCrc.h
6633
0644
edit
dl
rm
copysign.h
866
0644
edit
dl
rm
DeadlockDetection.h
1920
0644
edit
dl
rm
Deprecated.h
3579
0644
edit
dl
rm
either.h
6423
0644
edit
dl
rm
env.h
835
0644
edit
dl
rm
Exception.h
24723
0644
edit
dl
rm
ExclusivelyOwned.h
4759
0644
edit
dl
rm
Flags.h
10056
0644
edit
dl
rm
flat_hash_map.h
61655
0644
edit
dl
rm
FunctionRef.h
2301
0644
edit
dl
rm
Half-inl.h
8674
0644
edit
dl
rm
Half.h
18965
0644
edit
dl
rm
hash.h
5084
0644
edit
dl
rm
IdWrapper.h
2348
0644
edit
dl
rm
intrusive_ptr.h
35563
0644
edit
dl
rm
in_place.h
350
0644
edit
dl
rm
irange.h
2679
0644
edit
dl
rm
LeftRight.h
6016
0644
edit
dl
rm
llvmMathExtras.h
29168
0644
edit
dl
rm
Logging.h
11256
0644
edit
dl
rm
logging_is_google_glog.h
2031
0644
edit
dl
rm
logging_is_not_google_glog.h
8271
0644
edit
dl
rm
MathConstants.h
858
0644
edit
dl
rm
math_compat.h
7296
0644
edit
dl
rm
MaybeOwned.h
6689
0644
edit
dl
rm
Metaprogramming.h
15288
0644
edit
dl
rm
numa.h
696
0644
edit
dl
rm
Optional.h
35592
0644
edit
dl
rm
order_preserving_flat_hash_map.h
65482
0644
edit
dl
rm
overloaded.h
709
0644
edit
dl
rm
python_stub.h
56
0644
edit
dl
rm
qint8.h
472
0644
edit
dl
rm
qint32.h
319
0644
edit
dl
rm
quint4x2.h
366
0644
edit
dl
rm
quint8.h
320
0644
edit
dl
rm
Registry.h
12242
0644
edit
dl
rm
reverse_iterator.h
8796
0644
edit
dl
rm
ScopeExit.h
1345
0644
edit
dl
rm
signal_handler.h
3154
0644
edit
dl
rm
SmallBuffer.h
1243
0644
edit
dl
rm
SmallVector.h
34456
0644
edit
dl
rm
sparse_bitset.h
26511
0644
edit
dl
rm
StringUtil.h
4538
0644
edit
dl
rm
string_utils.h
3989
0644
edit
dl
rm
string_view.h
20189
0644
edit
dl
rm
tempfile.h
6029
0644
edit
dl
rm
ThreadLocal.h
3883
0644
edit
dl
rm
ThreadLocalDebugInfo.h
2603
0644
edit
dl
rm
thread_name.h
148
0644
edit
dl
rm
Type.h
607
0644
edit
dl
rm
TypeCast.h
6972
0644
edit
dl
rm
typeid.h
18793
0644
edit
dl
rm
TypeIndex.h
5251
0644
edit
dl
rm
TypeList.h
16901
0644
edit
dl
rm
TypeTraits.h
5368
0644
edit
dl
rm
Unicode.h
295
0644
edit
dl
rm
UniqueVoidPtr.h
4117
0644
edit
dl
rm
Unroll.h
667
0644
edit
dl
rm
variant.h
95182
0644
edit
dl
rm
win32-headers.h
858
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/c10/util/ExclusivelyOwned.h
(4759B)
#pragma once #include <c10/util/in_place.h> namespace c10 { // See example implementations in TensorBody.h and intrusive_ptr.h. // Synopsis: // // repr_type -- type to use to store an owned T in ExclusivelyOwned. // // pointer_type -- pointer-esque type to return from // ExclusivelyOwned's get() and operator*() methods. // // const_pointer_type -- similar to pointer_type, used for the const methods. // // static repr_type nullRepr() -- return a null instance of repr_type. // // template <class... Args> // static repr_type createInPlace(Args&&... args) -- used by the in-place // ExclusivelyOwned constructor. // // static repr_type moveToRepr(T&& x) -- move the given x into an // instance of repr_type. used by the ExclusivelyOwned(T&&) // constructor. // // static void destroyOwned(repr_type x) -- free memory for a // known-exclusively-owned instance of x. Replaces calling repr_type's // destructor. Being able to implement this more efficiently than // repr_type's destructor is the main reason to use ExclusivelyOwned // for a type. // // static T take(repr_type&) -- move out of the given repr_type into an owned T. // // static pointer_type getImpl(const repr_type&) -- return a pointer // to the given repr_type. May take repr_type by value if that is more // efficient. template <typename T> struct ExclusivelyOwnedTraits; /// ExclusivelyOwned is a smart-pointer-like wrapper around an /// exclusively-owned instance of some type T that normally has /// mandatory reference counting (currently Tensor or /// c10::intrusive_ptr). If you have an isolated piece of code that /// knows that it has sole ownership of an object of one of these /// types (i.e., because you created it directly or using a factory /// function) and that object will not escape from that isolated piece /// of code, then moving the object into an ExclusivelyOwned will /// avoid an atomic reference count decrement at destruction time. /// /// If you directly create the Tensor/intrusive_ptr in the first /// place, you can use the in_place constructor of ExclusivelyOwned to /// additionally avoid doing any stores to initialize the refcount & /// weakcount. (Do note, however, that in this case you should /// probably just use std::unique_ptr instead of intrusive_ptr if applicable.) template <typename T> class ExclusivelyOwned { using EOT = ExclusivelyOwnedTraits<T>; union { char dummy_; typename ExclusivelyOwnedTraits<T>::repr_type repr_; }; public: ExclusivelyOwned() : repr_(EOT::nullRepr()) {} explicit ExclusivelyOwned(T&& t) : repr_(EOT::moveToRepr(std::move(t))) {} template <class... Args> explicit ExclusivelyOwned(in_place_t, Args&&... args) : repr_(EOT::createInPlace(std::forward<Args>(args)...)) {} ExclusivelyOwned(const ExclusivelyOwned&) = delete; ExclusivelyOwned(ExclusivelyOwned&& rhs) noexcept : repr_(std::move(rhs.repr_)) { rhs.repr_ = EOT::nullRepr(); } ExclusivelyOwned& operator=(const ExclusivelyOwned&) = delete; ExclusivelyOwned& operator=(ExclusivelyOwned&& rhs) noexcept { EOT::destroyOwned(repr_); repr_ = std::move(rhs.repr_); rhs.repr_ = EOT::nullRepr(); return *this; } ExclusivelyOwned& operator=(T&& rhs) noexcept { EOT::destroyOwned(repr_); repr_ = EOT::moveToRepr(std::move(rhs)); return *this; } ~ExclusivelyOwned() { EOT::destroyOwned(repr_); // Don't bother to call the destructor of repr_, since we already // did specialized destruction for the exclusively-owned case in // destroyOwned! } // We don't provide this because it would require us to be able to // differentiate an owned-but-empty T from a lack of T. This is // particularly problematic for Tensor, which wants to use an // undefined Tensor as its null state. explicit operator bool() const noexcept = delete; operator T() && { return take(); } // NOTE: the equivalent operation on MaybeOwned is a moving // operator*. For ExclusivelyOwned, take() and operator*() may well // have different return types (e.g., for intrusive_ptr, take() // returns c10::intrusive_ptr<T> whereas operator* returns T&), so // they are different functions. T take() && { return EOT::take(repr_); } typename EOT::const_pointer_type operator->() const { return get(); } typename EOT::const_pointer_type get() const { return EOT::getImpl(repr_); } typename EOT::pointer_type operator->() { return get(); } typename EOT::pointer_type get() { return EOT::getImpl(repr_); } std::remove_pointer_t<typename EOT::const_pointer_type>& operator*() const { return *get(); } std::remove_pointer_t<typename EOT::pointer_type>& operator*() { return *get(); } }; } // namespace c10
Save
cmd:
run