VECTOR_T Class — pytorch Architecture
Architecture documentation for the VECTOR_T class in pack_block_sparse.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/quantized/cpu/qnnpack/include/pack_block_sparse.h lines 28–76
template <typename T>
struct OwnedOrBorrowedVector {
using VECTOR_T =
#ifndef _WIN32
std::vector<T, AlignedAllocator<T, 16>>;
#else
std::vector<T>;
#endif
// Only one of owned_vec_data_ or borrowed_tuple_data_ will be meaningfully
// populated.
// A union could potentially be used here to reduce memory usage.
// std::variant is not used here because it causes internal build errors
// due to incompatibility.
VECTOR_T owned_vec_data_;
std::tuple<T*, uint32_t> borrowed_tuple_data_;
bool owned;
VECTOR_T& vector() {
assert(owned);
return owned_vec_data_;
}
uint32_t size() const {
if (owned) {
return owned_vec_data_.size();
} else {
return std::get<1>(borrowed_tuple_data_);
}
}
const T* data() const {
if (owned) {
return owned_vec_data_.data();
} else {
return std::get<0>(borrowed_tuple_data_);
}
}
const T& operator[](int i) const {
return data()[i];
}
OwnedOrBorrowedVector() : owned(true) {}
OwnedOrBorrowedVector(T* data_ptr, const uint32_t size)
: borrowed_tuple_data_(std::tuple<T*, uint32_t>(data_ptr, size)),
owned(false) {}
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free