MCPcopy Create free account
hub / github.com/activeloopai/deeplake / pointer_array

Class pointer_array

cpp/deeplake_pg/nd_utils.hpp:38–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37template <typename T>
38class pointer_array
39{
40public:
41 struct holder_t
42 {
43 explicit holder_t(T* d, std::size_t size)
44 : data_(d)
45 , shape_(size)
46 {
47 }
48
49 explicit holder_t(T* d, std::size_t size, std::size_t size2)
50 : data_(d)
51 , shape_({size, size2})
52 {
53 }
54
55 T* data_;
56 icm::shape shape_;
57 };
58
59public:
60 explicit pointer_array(T* value, std::size_t size)
61 : value_(std::make_shared<holder_t>(value, size))
62 {
63 }
64
65 explicit pointer_array(T* value, std::size_t size, std::size_t size2)
66 : value_(std::make_shared<holder_t>(value, size, size2))
67 {
68 }
69
70 enum nd::dtype dtype() const
71 {
72 return nd::dtype_enum_v<T>;
73 }
74
75 std::span<const uint8_t> data() const
76 {
77 auto len =
78 value_->shape_.size() == 1 ? value_->shape_.front() : (value_->shape_.front() * value_->shape_.back());
79 return base::span_cast<const uint8_t>(std::span<const T>(value_->data_, value_->data_ + len));
80 }
81
82 const auto& owner() const
83 {
84 return value_;
85 }
86
87 icm::shape shape() const
88 {
89 return value_->shape_;
90 }
91
92 constexpr bool is_dynamic() const noexcept
93 {
94 return false;
95 }

Callers 1

pg_to_nd_typedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected