forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchained_eval_array.hpp
More file actions
73 lines (57 loc) · 1.47 KB
/
Copy pathchained_eval_array.hpp
File metadata and controls
73 lines (57 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include "../array.hpp"
#include "../dtype.hpp"
#include <base/span_cast.hpp>
#include <icm/shape.hpp>
#include <cstdint>
#include <span>
namespace nd {
namespace impl {
class chained_eval_array
{
private:
struct holder {
holder(nd::array owner, icm::shape shape, uint32_t volume)
: owner_(std::move(owner)), first_child_(owner_[0]),
value_(first_child_.data().data(), volume * dtype_bytes(owner_.dtype())), shape_(shape)
{
}
holder(const holder&) = delete;
holder(holder&&) = delete;
holder& operator=(const holder&) = delete;
holder& operator=(holder&&) = delete;
const nd::array owner_;
const nd::array first_child_;
const std::span<const uint8_t> value_;
const icm::shape shape_;
};
public:
chained_eval_array(nd::array owner, icm::shape shape, uint32_t volume)
: holder_(std::make_shared<holder>(std::move(owner), std::move(shape), volume))
{
}
enum dtype dtype() const
{
return holder_->owner_.dtype();
}
std::span<const uint8_t> data() const
{
return holder_->value_;
}
const icm::shape& shape() const
{
return holder_->shape_;
}
const auto& owner() const
{
return holder_;
}
constexpr bool is_dynamic() const noexcept
{
return false;
}
private:
std::shared_ptr<holder> holder_;
};
} // namespace impl
} // namespace nd