Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
access.hpp
Go to the documentation of this file.
1
7#pragma once
8
11
12#include <concepts>
13#include <cstddef>
14#include <optional>
15#include <type_traits>
16#include <utility>
17
18namespace uni20
19{
28template <class State>
29concept TensorAccessState = std::move_constructible<State> && std::is_nothrow_move_constructible_v<State> &&
30 requires(State& state) {
31 { state.release() } noexcept;
32};
33
34namespace detail
35{
36
37struct immediate_mdspan_access_state
38{
39 void release() noexcept {}
40};
41
43template <ImmediateTensorView Tensor> class borrowed_read_tensor_lease {
44 public:
45 using tensor_type = std::remove_cvref_t<Tensor>;
46 using mdspan_type = std::remove_cvref_t<decltype(std::declval<tensor_type const&>().mdspan())>;
47 using storage_policy = tensor_storage_policy_t<tensor_type>;
48 using extents_type = typename mdspan_type::extents_type;
49 using index_type = typename mdspan_type::index_type;
50
51 explicit borrowed_read_tensor_lease(tensor_type const& tensor) noexcept : tensor_(&tensor) {}
52
53 borrowed_read_tensor_lease(borrowed_read_tensor_lease const&) = delete;
54 borrowed_read_tensor_lease& operator=(borrowed_read_tensor_lease const&) = delete;
55
56 borrowed_read_tensor_lease(borrowed_read_tensor_lease&& other) noexcept
57 : tensor_(std::exchange(other.tensor_, nullptr))
58 {}
59
60 borrowed_read_tensor_lease& operator=(borrowed_read_tensor_lease&& other) noexcept
61 {
62 if (this != &other) tensor_ = std::exchange(other.tensor_, nullptr);
63 return *this;
64 }
65
67 [[nodiscard]] decltype(auto) mdspan() const& { return this->source().mdspan(); }
68
69 void mdspan() && = delete;
70
72 [[nodiscard]] decltype(auto) backend_selector() const { return this->source().backend_selector(); }
73
75 [[nodiscard]] decltype(auto) storage() const
76 requires requires(tensor_type const& tensor) { tensor.storage(); }
77 {
78 return this->source().storage();
79 }
80
82 [[nodiscard]] decltype(auto) extents() const { return this->source().extents(); }
83
85 [[nodiscard]] index_type extent(std::size_t axis) const { return this->source().extent(axis); }
86
88 [[nodiscard]] static constexpr std::size_t rank() noexcept { return mdspan_type::rank(); }
89
92 void release() noexcept { tensor_ = nullptr; }
93
94 private:
95 [[nodiscard]] tensor_type const& source() const
96 {
97 CHECK(tensor_ != nullptr, "cannot use a released borrowed tensor lease");
98 return *tensor_;
99 }
100
101 tensor_type const* tensor_ = nullptr;
102};
103
105template <MutableImmediateTensorView Tensor> class borrowed_write_tensor_lease {
106 public:
107 using tensor_type = std::remove_cvref_t<Tensor>;
108 using mdspan_type = std::remove_cvref_t<decltype(std::declval<tensor_type&>().mdspan())>;
109 using const_mdspan_type = std::remove_cvref_t<decltype(std::declval<tensor_type const&>().mdspan())>;
110 using storage_policy = tensor_storage_policy_t<tensor_type>;
111 using extents_type = typename mdspan_type::extents_type;
112 using index_type = typename mdspan_type::index_type;
113
114 explicit borrowed_write_tensor_lease(tensor_type& tensor) noexcept : tensor_(&tensor) {}
115
116 borrowed_write_tensor_lease(borrowed_write_tensor_lease const&) = delete;
117 borrowed_write_tensor_lease& operator=(borrowed_write_tensor_lease const&) = delete;
118
119 borrowed_write_tensor_lease(borrowed_write_tensor_lease&& other) noexcept
120 : tensor_(std::exchange(other.tensor_, nullptr))
121 {}
122
123 borrowed_write_tensor_lease& operator=(borrowed_write_tensor_lease&& other) noexcept
124 {
125 if (this != &other) tensor_ = std::exchange(other.tensor_, nullptr);
126 return *this;
127 }
128
130 [[nodiscard]] decltype(auto) mdspan() & { return this->source().mdspan(); }
131
133 [[nodiscard]] decltype(auto) mdspan() const& { return std::as_const(this->source()).mdspan(); }
134
135 void mdspan() && = delete;
136
138 [[nodiscard]] decltype(auto) backend_selector() const { return this->source().backend_selector(); }
139
141 [[nodiscard]] decltype(auto) extents() const { return this->source().extents(); }
142
144 [[nodiscard]] index_type extent(std::size_t axis) const { return this->source().extent(axis); }
145
147 [[nodiscard]] static constexpr std::size_t rank() noexcept { return mdspan_type::rank(); }
148
151 void release() noexcept { tensor_ = nullptr; }
152
153 private:
154 [[nodiscard]] tensor_type& source() const
155 {
156 CHECK(tensor_ != nullptr, "cannot use a released borrowed tensor lease");
157 return *tensor_;
158 }
159
160 tensor_type* tensor_ = nullptr;
161};
162
163} // namespace detail
164
171template <MdspanLike Mdspan, TensorAccessState AccessState>
172 requires std::is_const_v<typename Mdspan::element_type> && std::is_nothrow_move_constructible_v<Mdspan>
174 public:
175 using mdspan_type = Mdspan;
176 using access_state_type = AccessState;
177
180 : state_(std::move(state)), mdspan_(std::move(mdspan))
181 {}
182
185
187 : state_(std::move(other.state_)), mdspan_(std::move(other.mdspan_))
188 {
189 other.mdspan_.reset();
190 }
191
193 operator=(read_mdspan_lease&& other) noexcept
194 requires(std::is_nothrow_move_assignable_v<access_state_type> && std::is_nothrow_move_assignable_v<mdspan_type>)
195 {
196 if (this != &other)
197 {
198 this->release();
199 state_ = std::move(other.state_);
200 mdspan_ = std::move(other.mdspan_);
201 other.mdspan_.reset();
202 }
203 return *this;
204 }
205
207
209 [[nodiscard]] mdspan_type& mdspan() &
210 {
211 CHECK(mdspan_.has_value(), "cannot use an inactive mdspan lease");
212 return *mdspan_;
213 }
214
216 [[nodiscard]] mdspan_type const& mdspan() const&
217 {
218 CHECK(mdspan_.has_value(), "cannot use an inactive mdspan lease");
219 return *mdspan_;
220 }
221
222 mdspan_type mdspan() && = delete;
223
226 void release() noexcept
227 {
228 if (!mdspan_) return;
229 mdspan_.reset();
230 state_.release();
231 }
232
233 private:
234 [[no_unique_address]] access_state_type state_;
235 std::optional<mdspan_type> mdspan_;
236};
237
244template <MutableMdspanLike Mdspan, TensorAccessState AccessState>
245 requires std::is_nothrow_move_constructible_v<Mdspan>
247 public:
248 using mdspan_type = Mdspan;
249 using access_state_type = AccessState;
250
253 : state_(std::move(state)), mdspan_(std::move(mdspan))
254 {}
255
258
260 : state_(std::move(other.state_)), mdspan_(std::move(other.mdspan_))
261 {
262 other.mdspan_.reset();
263 }
264
267 requires(std::is_nothrow_move_assignable_v<access_state_type> && std::is_nothrow_move_assignable_v<mdspan_type>)
268 {
269 if (this != &other)
270 {
271 this->release();
272 state_ = std::move(other.state_);
273 mdspan_ = std::move(other.mdspan_);
274 other.mdspan_.reset();
275 }
276 return *this;
277 }
278
280
282 [[nodiscard]] mdspan_type& mdspan() &
283 {
284 CHECK(mdspan_.has_value(), "cannot use an inactive mdspan lease");
285 return *mdspan_;
286 }
287
289 [[nodiscard]] mdspan_type const& mdspan() const&
290 {
291 CHECK(mdspan_.has_value(), "cannot use an inactive mdspan lease");
292 return *mdspan_;
293 }
294
295 mdspan_type mdspan() && = delete;
296
299 void release() noexcept
300 {
301 if (!mdspan_) return;
302 mdspan_.reset();
303 state_.release();
304 }
305
306 private:
307 [[no_unique_address]] access_state_type state_;
308 std::optional<mdspan_type> mdspan_;
309};
310
320template <MdspanLike Mdspan, TensorAccessState AccessState, class BackendSelector, class StoragePolicy>
321 requires std::is_const_v<typename Mdspan::element_type> && std::is_nothrow_move_constructible_v<Mdspan> &&
322 std::is_nothrow_move_constructible_v<BackendSelector>
324 public:
325 using mdspan_type = Mdspan;
326 using access_state_type = AccessState;
327 using backend_selector_type = BackendSelector;
328 using storage_policy = StoragePolicy;
329 using extents_type = typename mdspan_type::extents_type;
330 using index_type = typename mdspan_type::index_type;
331
334 : state_(std::move(state)), mdspan_(std::move(mdspan)), selector_(std::move(selector))
335 {}
336
339
341 : state_(std::move(other.state_)), mdspan_(std::move(other.mdspan_)), selector_(std::move(other.selector_))
342 {
343 other.mdspan_.reset();
344 }
345
347 operator=(read_tensor_lease&& other) noexcept
348 requires(std::is_nothrow_move_assignable_v<access_state_type> && std::is_nothrow_move_assignable_v<mdspan_type> &&
349 std::is_nothrow_move_assignable_v<backend_selector_type>)
350 {
351 if (this != &other)
352 {
353 this->release();
354 state_ = std::move(other.state_);
355 mdspan_ = std::move(other.mdspan_);
356 selector_ = std::move(other.selector_);
357 other.mdspan_.reset();
358 }
359 return *this;
360 }
361
363
365 [[nodiscard]] mdspan_type& mdspan() &
366 {
367 CHECK(mdspan_.has_value(), "cannot resolve mdspan through an inactive tensor lease");
368 return *mdspan_;
369 }
370
372 [[nodiscard]] mdspan_type const& mdspan() const&
373 {
374 CHECK(mdspan_.has_value(), "cannot resolve mdspan through an inactive tensor lease");
375 return *mdspan_;
376 }
377
378 mdspan_type mdspan() && = delete;
379
381 [[nodiscard]] backend_selector_type const& backend_selector() const noexcept { return selector_; }
382
384 [[nodiscard]] decltype(auto) storage() const
385 requires requires(access_state_type const& state) { state.storage(); }
386 {
387 return state_.storage();
388 }
389
391 [[nodiscard]] extents_type const& extents() const { return this->mdspan().extents(); }
392
394 [[nodiscard]] index_type extent(std::size_t axis) const { return this->mdspan().extent(axis); }
395
397 [[nodiscard]] static constexpr std::size_t rank() noexcept { return mdspan_type::rank(); }
398
402 void release() noexcept
403 {
404 if (!mdspan_) return;
405 mdspan_.reset();
406 state_.release();
407 }
408
409 private:
410 [[no_unique_address]] access_state_type state_;
411 std::optional<mdspan_type> mdspan_;
412 [[no_unique_address]] backend_selector_type selector_;
413};
414
424template <MutableMdspanLike MutableMdspan, MdspanLike ConstMdspan, TensorAccessState AccessState, class BackendSelector,
425 class StoragePolicy>
426 requires std::is_const_v<typename ConstMdspan::element_type> &&
427 std::is_nothrow_move_constructible_v<MutableMdspan> &&
428 std::is_nothrow_move_constructible_v<ConstMdspan> &&
429 std::is_nothrow_move_constructible_v<BackendSelector>
431 public:
432 using mdspan_type = MutableMdspan;
433 using const_mdspan_type = ConstMdspan;
434 using access_state_type = AccessState;
435 using backend_selector_type = BackendSelector;
436 using storage_policy = StoragePolicy;
437 using extents_type = typename mdspan_type::extents_type;
438 using index_type = typename mdspan_type::index_type;
439
442 backend_selector_type selector) noexcept
443 : state_(std::move(state)), mdspan_(std::move(mdspan)), const_mdspan_(std::move(const_mdspan)),
444 selector_(std::move(selector))
445 {}
446
449
451 : state_(std::move(other.state_)), mdspan_(std::move(other.mdspan_)),
452 const_mdspan_(std::move(other.const_mdspan_)), selector_(std::move(other.selector_))
453 {
454 other.const_mdspan_.reset();
455 other.mdspan_.reset();
456 }
457
460 requires(std::is_nothrow_move_assignable_v<access_state_type> && std::is_nothrow_move_assignable_v<mdspan_type> &&
461 std::is_nothrow_move_assignable_v<const_mdspan_type> &&
462 std::is_nothrow_move_assignable_v<backend_selector_type>)
463 {
464 if (this != &other)
465 {
466 this->release();
467 state_ = std::move(other.state_);
468 mdspan_ = std::move(other.mdspan_);
469 const_mdspan_ = std::move(other.const_mdspan_);
470 selector_ = std::move(other.selector_);
471 other.const_mdspan_.reset();
472 other.mdspan_.reset();
473 }
474 return *this;
475 }
476
478
480 [[nodiscard]] mdspan_type& mdspan() &
481 {
482 CHECK(mdspan_.has_value(), "cannot resolve mdspan through an inactive tensor lease");
483 return *mdspan_;
484 }
485
487 [[nodiscard]] const_mdspan_type const& mdspan() const&
488 {
489 CHECK(const_mdspan_.has_value(), "cannot resolve mdspan through an inactive tensor lease");
490 return *const_mdspan_;
491 }
492
493 mdspan_type mdspan() && = delete;
494
496 [[nodiscard]] backend_selector_type const& backend_selector() const noexcept { return selector_; }
497
499 [[nodiscard]] extents_type const& extents() const { return this->mdspan().extents(); }
500
502 [[nodiscard]] index_type extent(std::size_t axis) const { return this->mdspan().extent(axis); }
503
505 [[nodiscard]] static constexpr std::size_t rank() noexcept { return mdspan_type::rank(); }
506
510 void release() noexcept
511 {
512 if (!mdspan_) return;
513 const_mdspan_.reset();
514 mdspan_.reset();
515 state_.release();
516 }
517
518 private:
519 [[no_unique_address]] access_state_type state_;
520 std::optional<mdspan_type> mdspan_;
521 std::optional<const_mdspan_type> const_mdspan_;
522 [[no_unique_address]] backend_selector_type selector_;
523};
524
526template <class Lease>
528 std::move_constructible<Lease> && (!std::copy_constructible<Lease>) && requires(Lease& lease) {
529 requires MdspanLike<decltype(lease.mdspan())>;
530 requires std::is_const_v<typename std::remove_cvref_t<decltype(lease.mdspan())>::element_type>;
531 { lease.release() } noexcept;
532 };
533
535template <class Lease>
537 std::move_constructible<Lease> && (!std::copy_constructible<Lease>) && requires(Lease& lease) {
538 requires MutableMdspanLike<decltype(lease.mdspan())>;
539 { lease.release() } noexcept;
540 };
541
543template <class Lease>
545
547template <class Lease>
550
552template <class Lease>
554
556template <class Lease>
559
563template <class Lease>
564concept ReadTensorLease = ImmediateTensorView<Lease> && std::move_constructible<Lease> &&
565 (!std::copy_constructible<Lease>) && requires(Lease& lease) {
566 { lease.release() } noexcept;
567 };
568
570template <class Lease>
572
574template <class Lease>
576
578template <class Lease>
581
583template <class Lease>
585
587template <class Lease>
590
592template <class Lease> class ready_access {
593 public:
594 using lease_type = Lease;
595
596 explicit ready_access(lease_type lease) : lease_(std::move(lease)) {}
597
598 ready_access(ready_access const&) = delete;
602
603 [[nodiscard]] bool await_ready() const noexcept { return true; }
604
605 template <class Task> void await_suspend(Task&&) const noexcept {}
606
607 [[nodiscard]] lease_type await_resume() { return std::move(lease_); }
608
609 private:
610 lease_type lease_;
611};
612
614template <HostAccessibleMdspan Mdspan>
615 requires std::is_const_v<typename std::remove_cvref_t<Mdspan>::element_type>
616[[nodiscard]] auto acquire_host_read_access_sync(Mdspan const& mdspan)
617{
618 using mdspan_type = std::remove_cvref_t<Mdspan>;
619 return read_mdspan_lease<mdspan_type, detail::immediate_mdspan_access_state>{detail::immediate_mdspan_access_state{},
620 mdspan};
621}
622
624template <MutableMdspanLike Mdspan>
625 requires HostAccessibleMdspan<Mdspan>
626[[nodiscard]] auto acquire_host_write_access_sync(Mdspan& mdspan)
627{
628 using mdspan_type = std::remove_cvref_t<Mdspan>;
629 return write_mdspan_lease<mdspan_type, detail::immediate_mdspan_access_state>{detail::immediate_mdspan_access_state{},
630 mdspan};
631}
632
634template <ImmediateTensorView Tensor>
635 requires HostAccessibleMdspan<immediate_tensor_mdspan_t<Tensor>>
636[[nodiscard]] auto acquire_host_read_access_sync(Tensor& tensor)
637{
638 using tensor_type = std::remove_cvref_t<Tensor>;
639 return detail::borrowed_read_tensor_lease<tensor_type>{tensor};
640}
641
643template <MutableImmediateTensorView Tensor>
644 requires HostAccessibleMdspan<mutable_immediate_tensor_mdspan_t<Tensor>>
645[[nodiscard]] auto acquire_host_write_access_sync(Tensor& tensor)
646{
647 using tensor_type = std::remove_cvref_t<Tensor>;
648 return detail::borrowed_write_tensor_lease<tensor_type>{tensor};
649}
650
652template <ImmediateTensorView Tensor>
653 requires HostAccessibleMdspan<immediate_tensor_mdspan_t<Tensor>>
654[[nodiscard]] auto acquire_host_read_access_async(Tensor& tensor)
655{
657}
658
660template <MutableImmediateTensorView Tensor>
661 requires HostAccessibleMdspan<mutable_immediate_tensor_mdspan_t<Tensor>>
662[[nodiscard]] auto acquire_host_write_access_async(Tensor& tensor)
663{
665}
666
667namespace detail
668{
669template <class Mdspec>
670using host_read_mdspan_lease_t = decltype(acquire_host_read_access_sync(std::declval<Mdspec const&>()));
671
672template <class Mdspec>
673using host_write_mdspan_lease_t = decltype(acquire_host_write_access_sync(std::declval<Mdspec&>()));
674} // namespace detail
675
677template <class Mdspec>
679 std::remove_cvref_t<decltype(std::declval<detail::host_read_mdspan_lease_t<Mdspec>&>().mdspan())>;
680
682template <class Mdspec>
684 std::remove_cvref_t<decltype(std::declval<detail::host_write_mdspan_lease_t<Mdspec>&>().mdspan())>;
685
687template <class Mdspec>
688concept HostReadableMdspec = MdspecLike<Mdspec> && requires(Mdspec const& mdspec) {
690};
691
693template <class Mdspec>
694concept HostWritableMdspec = MutableMdspecLike<Mdspec> && requires(Mdspec& mdspec) {
696};
697
698namespace detail
699{
700template <class Tensor>
701using host_read_tensor_lease_t = decltype(acquire_host_read_access_sync(std::declval<Tensor const&>()));
702
703template <class Tensor>
704using host_write_tensor_lease_t = decltype(acquire_host_write_access_sync(std::declval<Tensor&>()));
705} // namespace detail
706
708template <class Tensor>
710 std::remove_cvref_t<decltype(std::declval<detail::host_read_tensor_lease_t<Tensor>&>().mdspan())>;
711
713template <class Tensor>
715 std::remove_cvref_t<decltype(std::declval<detail::host_write_tensor_lease_t<Tensor>&>().mdspan())>;
716
718template <class Tensor>
719concept HostReadableTensor = TensorView<Tensor> && requires(Tensor const& tensor) {
721};
722
724template <class Tensor>
728
729} // namespace uni20
General-purpose owning tensor with immediate or deferred mdspan metadata.
Definition basic_tensor.hpp:109
Move-only RAII lease exposing one resolved read-only mdspan.
Definition access.hpp:173
mdspan_type mdspan() &&=delete
Mdspan mdspan_type
Definition access.hpp:175
mdspan_type & mdspan() &
Return the resolved read-only mdspan.
Definition access.hpp:209
read_mdspan_lease(access_state_type state, mdspan_type mdspan) noexcept
Construct an active read lease.
Definition access.hpp:179
read_mdspan_lease(read_mdspan_lease const &)=delete
read_mdspan_lease & operator=(read_mdspan_lease &&other) noexcept
Definition access.hpp:193
~read_mdspan_lease()
Definition access.hpp:206
read_mdspan_lease & operator=(read_mdspan_lease const &)=delete
mdspan_type const & mdspan() const &
Return the resolved read-only mdspan.
Definition access.hpp:216
void release() noexcept
End the access scope.
Definition access.hpp:226
AccessState access_state_type
Definition access.hpp:176
read_mdspan_lease(read_mdspan_lease &&other) noexcept
Definition access.hpp:186
Move-only RAII lease exposing a read-only ImmediateTensorView.
Definition access.hpp:323
~read_tensor_lease()
Definition access.hpp:362
extents_type const & extents() const
Return the resolved tensor extents.
Definition access.hpp:391
mdspan_type & mdspan() &
Return the resolved read-only mdspan.
Definition access.hpp:365
read_tensor_lease & operator=(read_tensor_lease const &)=delete
index_type extent(std::size_t axis) const
Return one resolved tensor extent.
Definition access.hpp:394
read_tensor_lease(read_tensor_lease &&other) noexcept
Definition access.hpp:340
Mdspan mdspan_type
Definition access.hpp:325
read_tensor_lease & operator=(read_tensor_lease &&other) noexcept
Definition access.hpp:347
mdspan_type const & mdspan() const &
Return the resolved read-only mdspan.
Definition access.hpp:372
backend_selector_type const & backend_selector() const noexcept
Return the backend selector retained from the source tensor view.
Definition access.hpp:381
static constexpr std::size_t rank() noexcept
Return the static tensor rank.
Definition access.hpp:397
mdspan_type mdspan() &&=delete
typename mdspan_type::extents_type extents_type
Definition access.hpp:329
AccessState access_state_type
Definition access.hpp:326
typename mdspan_type::index_type index_type
Definition access.hpp:330
void release() noexcept
End the access scope and make this lease inactive.
Definition access.hpp:402
read_tensor_lease(read_tensor_lease const &)=delete
StoragePolicy storage_policy
Definition access.hpp:328
BackendSelector backend_selector_type
Definition access.hpp:327
read_tensor_lease(access_state_type state, mdspan_type mdspan, backend_selector_type selector) noexcept
Construct an active read lease.
Definition access.hpp:333
decltype(auto) storage() const
Return the storage retained by access state when it exposes one.
Definition access.hpp:384
Always-ready awaitable that transfers one access lease.
Definition access.hpp:592
ready_access(ready_access &&)=default
ready_access & operator=(ready_access const &)=delete
bool await_ready() const noexcept
Definition access.hpp:603
ready_access(lease_type lease)
Definition access.hpp:596
ready_access(ready_access const &)=delete
ready_access & operator=(ready_access &&)=default
void await_suspend(Task &&) const noexcept
Definition access.hpp:605
lease_type await_resume()
Definition access.hpp:607
Lease lease_type
Definition access.hpp:594
Move-only RAII lease exposing one resolved writable mdspan.
Definition access.hpp:246
write_mdspan_lease(write_mdspan_lease &&other) noexcept
Definition access.hpp:259
write_mdspan_lease(access_state_type state, mdspan_type mdspan) noexcept
Construct an active write lease.
Definition access.hpp:252
mdspan_type & mdspan() &
Return the resolved writable mdspan.
Definition access.hpp:282
mdspan_type mdspan() &&=delete
write_mdspan_lease(write_mdspan_lease const &)=delete
~write_mdspan_lease()
Definition access.hpp:279
void release() noexcept
End the access scope.
Definition access.hpp:299
mdspan_type const & mdspan() const &
Return the resolved writable mdspan without changing lease ownership.
Definition access.hpp:289
Mdspan mdspan_type
Definition access.hpp:248
write_mdspan_lease & operator=(write_mdspan_lease &&other) noexcept
Definition access.hpp:266
AccessState access_state_type
Definition access.hpp:249
write_mdspan_lease & operator=(write_mdspan_lease const &)=delete
Move-only RAII lease exposing mutable and const immediate TensorViews.
Definition access.hpp:430
static constexpr std::size_t rank() noexcept
Return the static tensor rank.
Definition access.hpp:505
BackendSelector backend_selector_type
Definition access.hpp:435
MutableMdspan mdspan_type
Definition access.hpp:432
write_tensor_lease & operator=(write_tensor_lease const &)=delete
write_tensor_lease(write_tensor_lease &&other) noexcept
Definition access.hpp:450
extents_type const & extents() const
Return the resolved tensor extents.
Definition access.hpp:499
mdspan_type mdspan() &&=delete
const_mdspan_type const & mdspan() const &
Return the resolved read-only mdspan.
Definition access.hpp:487
ConstMdspan const_mdspan_type
Definition access.hpp:433
index_type extent(std::size_t axis) const
Return one resolved tensor extent.
Definition access.hpp:502
AccessState access_state_type
Definition access.hpp:434
write_tensor_lease(write_tensor_lease const &)=delete
typename mdspan_type::extents_type extents_type
Definition access.hpp:437
backend_selector_type const & backend_selector() const noexcept
Return the backend selector retained from the source tensor view.
Definition access.hpp:496
write_tensor_lease & operator=(write_tensor_lease &&other) noexcept
Definition access.hpp:459
void release() noexcept
End the access scope and make this lease inactive.
Definition access.hpp:510
StoragePolicy storage_policy
Definition access.hpp:436
write_tensor_lease(access_state_type state, mdspan_type mdspan, const_mdspan_type const_mdspan, backend_selector_type selector) noexcept
Construct an active write lease.
Definition access.hpp:441
typename mdspan_type::index_type index_type
Definition access.hpp:438
mdspan_type & mdspan() &
Return the resolved writable mdspan.
Definition access.hpp:480
~write_tensor_lease()
Definition access.hpp:477
Mdspan whose accessor may be evaluated directly by CUDA device code.
Definition mdspan/concepts.hpp:317
Read mdspan lease whose resolved accessor is valid in CUDA code.
Definition access.hpp:553
Read lease whose resolved mdspan is directly CUDA-accessible.
Definition access.hpp:584
Write mdspan lease whose resolved accessor is valid in CUDA code.
Definition access.hpp:557
Write lease whose resolved mutable mdspan is directly CUDA-accessible.
Definition access.hpp:588
Mdspan whose accessor may be evaluated directly by host code.
Definition mdspan/concepts.hpp:311
Read mdspan lease whose resolved accessor is valid in host code.
Definition access.hpp:544
Read lease whose resolved mdspan is directly host-accessible.
Definition access.hpp:575
Mdspec metadata supporting host read acquisition.
Definition access.hpp:688
Tensor view supporting host read acquisition.
Definition access.hpp:719
Mutable mdspec metadata supporting host write acquisition.
Definition access.hpp:694
Mutable tensor view supporting host write acquisition.
Definition access.hpp:725
Write mdspan lease whose resolved accessor is valid in host code.
Definition access.hpp:548
Write lease whose resolved mutable mdspan is directly host-accessible.
Definition access.hpp:579
TensorView whose mdspec is already an mdspan.
Definition tensor/concepts.hpp:100
A readable type implementing the mdspan observers and multidimensional subscript contract.
Definition mdspan/concepts.hpp:291
Mdspan metadata whose data handle is immediate or available through a data descriptor.
Definition mdspan/concepts.hpp:304
MutableTensorView whose writable mdspec is already an mdspan.
Definition tensor/concepts.hpp:138
MdspanLike types whose accessor supports indexed assignment.
Definition mdspan/concepts.hpp:387
MdspecLike types whose eventual storage supports writes.
Definition mdspan/concepts.hpp:398
TensorView whose writable mdspec supports eventual element assignment.
Definition tensor/concepts.hpp:133
Move-only lease exposing a resolved read-only mdspan.
Definition access.hpp:527
ImmediateTensorView that owns a move-only read access lifetime.
Definition access.hpp:564
Movable state retaining one acquired tensor data-handle lifetime.
Definition access.hpp:29
Tensor-level object exposing readable multidimensional metadata and a backend selector.
Definition tensor/concepts.hpp:82
Move-only lease exposing a resolved writable mdspan.
Definition access.hpp:536
MutableImmediateTensorView that owns a move-only write access lifetime.
Definition access.hpp:571
Definition qnum.hpp:403
ReadBuffer< T > && release(ReadBuffer< T > &in)
Adaptor for transferring ReadBuffer ownership into an await expression.
Definition buffers.hpp:227
Definition async/async.hpp:26
auto acquire_host_read_access_async(Tensor &tensor)
Return an immediately-ready host read acquisition.
Definition access.hpp:654
std::remove_cvref_t< decltype(std::declval< detail::host_read_mdspan_lease_t< Mdspec > & >().mdspan())> host_read_mdspan_t
Read-only mdspan type resolved by host descriptor acquisition.
Definition access.hpp:679
std::remove_cvref_t< decltype(std::declval< detail::host_read_tensor_lease_t< Tensor > & >().mdspan())> host_read_tensor_mdspan_t
Read-only mdspan type resolved by host tensor acquisition.
Definition access.hpp:710
auto acquire_host_read_access_sync(Mdspan const &mdspan)
Acquire a directly host-accessible read-only mdspan.
Definition access.hpp:616
std::remove_cvref_t< decltype(std::declval< detail::host_write_mdspan_lease_t< Mdspec > & >().mdspan())> host_write_mdspan_t
Writable mdspan type resolved by host descriptor acquisition.
Definition access.hpp:684
std::ptrdiff_t index_type
Definition types.hpp:19
Tensor(InputTensor const &) -> Tensor< tensor_element_t< InputTensor >, tensor_mdspec_t< InputTensor >::rank(), HostStorage, detail::materialized_layout_t< void, tensor_mdspec_t< InputTensor > >, DefaultAccessorFactory >
Deduce a runtime-extents host tensor that materializes a tensor view.
std::remove_cvref_t< decltype(std::declval< detail::host_write_tensor_lease_t< Tensor > & >().mdspan())> host_write_tensor_mdspan_t
Writable mdspan type resolved by host tensor acquisition.
Definition access.hpp:715
auto acquire_host_write_access_sync(Mdspan &mdspan)
Acquire a directly host-accessible writable mdspan.
Definition access.hpp:626
auto acquire_host_write_access_async(Tensor &tensor)
Return an immediately-ready host write acquisition.
Definition access.hpp:662
Concepts for tensor-level objects that resolve mdspan kernel operands.
#define CHECK(cond,...)
Definition trace.hpp:299