stage/views/mapping.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | #pragma once | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | #include <memory> | ||
| 6 | |||
| 7 | #include <dlpack/dlpack.h> | ||
| 8 | |||
| 9 | #include "chrono_batch_render/device/operation.h" | ||
| 10 | #include "chrono_batch_render/device/stream.h" | ||
| 11 | #include "chrono_batch_render/device/tensor.h" | ||
| 12 | #include "chrono_batch_render/export.h" | ||
| 13 | #include "chrono_batch_render/stage/schema/schema.h" | ||
| 14 | |||
| 15 | namespace chrono::batch_render { | ||
| 16 | |||
| 17 | class ViewState; | ||
| 18 | |||
| 19 | enum class MapAccess : uint8_t { Read, Write, ReadWrite }; | ||
| 20 | |||
| 21 | class CHRONO_BATCH_RENDER_API Mapping { | ||
| 22 | public: | ||
| 23 | 33 | Mapping() = default; | |
| 24 | Mapping(const Mapping&) = delete; | ||
| 25 | Mapping& operator=(const Mapping&) = delete; | ||
| 26 | Mapping(Mapping&& other) noexcept; | ||
| 27 | Mapping& operator=(Mapping&& other) noexcept; | ||
| 28 | ~Mapping(); | ||
| 29 | |||
| 30 | 3 | bool Open() const { | |
| 31 | 3 | return m_open; | |
| 32 | } | ||
| 33 | |||
| 34 | MapAccess Access() const { | ||
| 35 | return m_access; | ||
| 36 | } | ||
| 37 | |||
| 38 | 7 | bool Aliased() const { | |
| 39 | 7 | return m_aliased; | |
| 40 | } | ||
| 41 | |||
| 42 | 23 | const device::Tensor& Values() const { | |
| 43 | 22 | return m_values; | |
| 44 | } | ||
| 45 | |||
| 46 | ✗ | const device::Tensor& Rows() const { | |
| 47 | ✗ | return m_rows; | |
| 48 | } | ||
| 49 | |||
| 50 | 1 | const device::Tensor& Offsets() const { | |
| 51 | 1 | return m_offsets; | |
| 52 | } | ||
| 53 | |||
| 54 | const device::Operation& Ready() const { | ||
| 55 | return m_ready; | ||
| 56 | } | ||
| 57 | |||
| 58 | DLTensor DLPack() const { | ||
| 59 | return m_values.DLPack(); | ||
| 60 | } | ||
| 61 | |||
| 62 | device::Operation Close(Stream producer = Stream::None(), const DLTensor* mask = nullptr); | ||
| 63 | |||
| 64 | private: | ||
| 65 | friend class UntypedAttribute; | ||
| 66 | |||
| 67 | void Release() noexcept; | ||
| 68 | |||
| 69 | std::shared_ptr<ViewState> m_view; | ||
| 70 | ColumnRef m_column; | ||
| 71 | MapAccess m_access = MapAccess::Read; | ||
| 72 | device::Tensor m_values; | ||
| 73 | device::Tensor m_rows; | ||
| 74 | device::Tensor m_offsets; | ||
| 75 | device::Operation m_ready; | ||
| 76 | bool m_aliased = false; | ||
| 77 | bool m_open = false; | ||
| 78 | }; | ||
| 79 | |||
| 80 | } | ||
| 81 |