/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
ATen
/
core
/
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/core
mkdir
upload
Name
Size
Mode
Actions
boxing/
-
0755
rm
dispatch/
-
0755
rm
op_registration/
-
0755
rm
alias_info.h
2986
0644
edit
dl
rm
Array.h
768
0644
edit
dl
rm
ATenGeneral.h
45
0644
edit
dl
rm
ATenOpList.h
246
0644
edit
dl
rm
aten_interned_strings.h
25389
0644
edit
dl
rm
Backtrace.h
59
0644
edit
dl
rm
blob.h
5422
0644
edit
dl
rm
builtin_function.h
3649
0644
edit
dl
rm
DeprecatedTypeProperties.h
3773
0644
edit
dl
rm
DeprecatedTypePropertiesRegistry.h
795
0644
edit
dl
rm
Dict.h
13195
0644
edit
dl
rm
Dict_inl.h
7996
0644
edit
dl
rm
Dimname.h
1188
0644
edit
dl
rm
DimVector.h
247
0644
edit
dl
rm
DistributionsHelper.h
12594
0644
edit
dl
rm
Formatting.h
959
0644
edit
dl
rm
function.h
2145
0644
edit
dl
rm
functional.h
1460
0644
edit
dl
rm
function_schema.h
13577
0644
edit
dl
rm
function_schema_inl.h
9319
0644
edit
dl
rm
Generator.h
4935
0644
edit
dl
rm
grad_mode.h
210
0644
edit
dl
rm
interned_strings.h
25332
0644
edit
dl
rm
interned_strings_class.h
770
0644
edit
dl
rm
ivalue.h
38823
0644
edit
dl
rm
ivalue_inl.h
59963
0644
edit
dl
rm
ivalue_to.h
756
0644
edit
dl
rm
jit_type.h
75971
0644
edit
dl
rm
jit_type_base.h
6508
0644
edit
dl
rm
LegacyTypeDispatch.h
4626
0644
edit
dl
rm
List.h
15667
0644
edit
dl
rm
List_inl.h
11012
0644
edit
dl
rm
Macros.h
44
0644
edit
dl
rm
MT19937RNGEngine.h
6410
0644
edit
dl
rm
NamedTensor.h
5050
0644
edit
dl
rm
operator_name.h
3018
0644
edit
dl
rm
PhiloxRNGEngine.h
6496
0644
edit
dl
rm
PythonModeTLS.h
403
0644
edit
dl
rm
qualified_name.h
4358
0644
edit
dl
rm
QuantizerBase.h
2443
0644
edit
dl
rm
Range.h
418
0644
edit
dl
rm
Reduction.h
461
0644
edit
dl
rm
rref_interface.h
1144
0644
edit
dl
rm
Scalar.h
29
0644
edit
dl
rm
ScalarType.h
33
0644
edit
dl
rm
stack.h
6034
0644
edit
dl
rm
Tensor.h
1756
0644
edit
dl
rm
TensorAccessor.h
10296
0644
edit
dl
rm
TensorBase.h
32767
0644
edit
dl
rm
TensorBody.h
247555
0644
edit
dl
rm
TransformationHelper.h
6911
0644
edit
dl
rm
typeid.h
29
0644
edit
dl
rm
UndefinedTensorImpl.h
42
0644
edit
dl
rm
UnsafeFromTH.h
708
0644
edit
dl
rm
VariableHooksInterface.h
3312
0644
edit
dl
rm
Variadic.h
2257
0644
edit
dl
rm
Vitals.h
2305
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/core/blob.h
(5422B)
#pragma once #include <cstddef> #include <sstream> #include <type_traits> #include <typeinfo> #include <vector> #include <c10/util/intrusive_ptr.h> #include <c10/util/typeid.h> #include <c10/macros/Macros.h> namespace caffe2 { class Tensor; /** * @brief Blob is a general container that hosts a typed pointer. * * A Blob hosts a pointer as well as its type, and takes charge of deleting it * properly when the blob is deallocated or re-allocated with a new type. A blob * could contain anything, although the most common case is to contain a Tensor. */ class TORCH_API Blob final : public c10::intrusive_ptr_target { public: /** * Initializes an empty Blob. */ Blob() noexcept : meta_(), pointer_(nullptr), has_ownership_(false) {} ~Blob() { Reset(); } Blob(Blob&& other) noexcept : Blob() { swap(other); } Blob& operator=(Blob&& other) noexcept { Blob(std::move(other)).swap(*this); return *this; } /** * Checks if the content stored in the blob is of type T. */ template <class T> bool IsType() const noexcept { return meta_.Match<T>(); } /** * Returns the meta info of the blob. */ const TypeMeta meta() const noexcept { return meta_; } /** * Returns a printable typename of the blob. */ c10::string_view TypeName() const noexcept { return meta_.name(); } /** * @brief Gets the const reference of the stored object. The code checks if * the stored object is of the desired type. */ // TODO(jerryzh): add a Get(DeviceType) function? template <class T> const T& Get() const { TORCH_INTERNAL_ASSERT( IsType<T>(), "wrong type for the Blob instance. Blob contains ", meta_.name(), " while caller expects ", TypeMeta::TypeName<T>()); // TODO: after we add Get<Tensor>(DeviceType) // and changed all the callsites, we can add // a static assert here to enforce T != Tensor // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) return *static_cast<const T*>(pointer_); } const void* GetRaw() const noexcept { return pointer_; } void* GetRaw() noexcept { return pointer_; } /** * @brief Gets a mutable pointer to the stored object. * * If the current object is not of the right type, a new object is created * and the old object is freed. Note that type T should have a default * constructor. Otherwise, create the object yourself first, and use * Reset(). */ template <class T> T* GetMutable() { static_assert( std::is_default_constructible<T>::value, "GetMutable can't be called with non-default-constructible types. " "Try using specialized methods"); if (IsType<T>()) { return static_cast<T*>(pointer_); } else { // TODO Re-enable logging // VLOG(1) << "Create new mutable object " << TypeMeta::TypeName<T>(); return Reset<T>(new T()); } } template <class T> T* GetMutableOrNull() { if (IsType<T>()) { return static_cast<T*>(pointer_); } else { return nullptr; } } /** * Sets the underlying object to the allocated one. The Blob then takes over * the ownership of the passed in pointer. If there is already an object in * the Blob, the old object is freed. * * This is used when the underlying class T does not have a default ctor, or * complex initializations needs to be done outside the blob. */ template <class T> T* Reset(T* allocated) { free_(); meta_ = TypeMeta::Make<T>(); pointer_ = static_cast<void*>(allocated); has_ownership_ = true; return allocated; } /** * Sets the underlying object to the allocated one, but does not take over * the ownership of the passed in pointer. If there is already an object in * the Blob, the old object is freed. * * Unlike Reset, this does not take over the ownership of the pointer and the * caller is responsible for making sure that the lifetime of the allocated * blob outlasts the lifetime of any access to this blob, until another Reset * call is made or the blob is destructed. */ template <class T> typename std::remove_const<T>::type* ShareExternal( typename std::remove_const<T>::type* allocated) { return static_cast<T*>(ShareExternal( static_cast<void*>(allocated), TypeMeta::Make<typename std::remove_const<T>::type>())); } void* ShareExternal(void* allocated, const TypeMeta meta) { free_(); meta_ = meta; pointer_ = allocated; has_ownership_ = false; return allocated; } /** * Resets the Blob to an empty one. */ void Reset() { free_(); pointer_ = nullptr; meta_ = TypeMeta(); has_ownership_ = false; } /** * @brief Swaps the underlying storage of two blobs. */ void swap(Blob& rhs) { using std::swap; swap(meta_, rhs.meta_); swap(pointer_, rhs.pointer_); swap(has_ownership_, rhs.has_ownership_); } private: void free_() { if (has_ownership_ && pointer_ != nullptr) { (*meta_.deleteFn())(pointer_); } } TypeMeta meta_; void* pointer_; bool has_ownership_; C10_DISABLE_COPY_AND_ASSIGN(Blob); }; inline void swap(Blob& lhs, Blob& rhs) { lhs.swap(rhs); } inline std::ostream& operator<<(std::ostream& out, const Blob& v) { return out << "Blob[" << v.TypeName() << "]"; } } // namespace caffe2
Save
cmd:
run