-
#include "tensorstore/tensorstore.h"
-
template <typename ElementType = void,
DimensionIndex Rank = dynamic_rank,
ReadWriteMode Mode = ReadWriteMode::dynamic>
class tensorstore::TensorStore; Open handle to an asynchronous multi-dimensional array.
A TensorStore object combines:
A shared handle to an underlying TensorStore driver;
An index transform applied on top of the TensorStore driver;
A ReadWriteMode that constrains the permitted operations.
The free functions
Read
,Write
,Copy
,Resize
, andResolveBounds
may be used to perform operations on a TensorStore.Indexing may be performed using the
DimExpression
facilities. For example:TensorStore<int32_t, 3> store = ...; Result<TensorStore<int32_t, 2>> sub_store = store | Dims(0).IndexSlice(5);
Typically a
TensorStore
object is obtained by callingtensorstore::Open
.- Template Parameters:¶
- typename ElementType = void¶
Compile-time element type constraint. May be
void
to indicate that the element type is determined at run time. Must be unqualified (i.e. must not beconst T
).- DimensionIndex Rank = dynamic_rank¶
Compile-time rank constraint. May be
dynamic_rank
to indicate that the rank is determined at run time.- ReadWriteMode Mode = ReadWriteMode::dynamic¶
Compile-time read/write mode constraint. May be
ReadWriteMode::dynamic
to indicate that the read-write mode is determined at run time.
Types¶
- using Element = ElementType;
Element type.
- using RankType = StaticOrDynamicRank<Rank>;
Static or dynamic rank type representation.
Data members¶
- constexpr const DimensionIndex static_rank = Rank;
Compile-time rank, or
dynamic_rank
if the rank is determined at run time.
- constexpr const ReadWriteMode static_mode = Mode;
Compile-time read-write mode, or
ReadWriteMode::dynamic
if the mode is determined at run time.
Constructors¶
- TensorStore();
Constructs an invalid
TensorStore
.
- TensorStore(TensorStore<SourceElement, SourceRank, SourceMode> other);
Constructs from a compatible existing TensorStore.
-
explicit TensorStore(
unchecked_t,
TensorStore<SourceElement, SourceRank, SourceMode> other); Unchecked conversion from an existing TensorStore.
Methods¶
-
TensorStore&
operator=(TensorStore<SourceElement, SourceRank, SourceMode> other); Assigns from an existing implicitly compatible
TensorStore
.
- ReadWriteMode read_write_mode() const;
Returns the read-write mode.
- bool valid() const noexcept;
Returns
true
if this is a valid handle to a TensorStore.
- IndexDomainView<Rank> domain() const;
Returns the domain.
- const Transaction& transaction() const;
Returns the associated transaction.
- Result<Spec> spec(SpecRequestOptions&& options) const;
- Result<Spec> spec(Option&&... option) const;
Returns a Spec that may be used to open/recreate this TensorStore.
- Result<ChunkLayout> chunk_layout() const;
Returns the storage layout of this TensorStore, which can be used to determine efficient read/write access patterns.
- Result<SharedArray<const Element>> fill_value() const;
Returns the fill value.
- Result<DimensionUnitsVector> dimension_units() const;
Returns the dimension units.
- Result<TensorStore<>> base() const;
Returns the underlying TensorStore, if this is an adapter.
-
PipelineResultType<const TensorStore&, Func>
operator|(Func&& func) const&; - PipelineResultType<TensorStore&&, Func> operator|(Func&& func) &&;
“Pipeline” operator.
Friend functions¶
- friend auto ApplyIndexTransform(Expr&& expr, TensorStore store);
Applies a function that operates on an IndexTransform to a TensorStore.
-
friend Result<TensorStore>
ApplyTensorStoreTransaction(TensorStore store,
Transaction transaction); Changes to a new transaction.
Related Types¶
- enum tensorstore::SourceDataReferenceRestriction;
Specifies restrictions on how references to the source array/source TensorStore may be used by write operations.
- enum class tensorstore::ReadWriteMode;
Specifies whether reading and/or writing is permitted.
-
using tensorstore::TensorReader<Element, Rank> =
TensorStore<Element, Rank, ReadWriteMode::read>; Read-only
TensorStore
alias.
-
using tensorstore::TensorWriter<Element, Rank> =
TensorStore<Element, Rank, ReadWriteMode::write>; Write-only
TensorStore
alias.
Related Functions¶
-
Result<TensorStore<Element, Rank>>
tensorstore::ModeCast(TensorStore<Element, Rank, ExistingMode> store,
ReadWriteMode new_mode); Changes the
ReadWriteMode
ofstore
to the specifiednew_mode
.
-
WriteFutures tensorstore::Write(SourceArray&& source,
Target&& target,
WriteOptions options); -
WriteFutures tensorstore::Write(SourceArray&& source,
Target&& target,
Option&&... option);
-
WriteFutures tensorstore::Copy(Source&& source,
Target&& target,
CopyOptions options); -
WriteFutures tensorstore::Copy(Source&& source,
Target&& target,
Option&&... option); Copies from
source
TensorStore
totarget
TensorStore
.
-
auto tensorstore::Cast(
TensorStore<ElementType, Rank, Mode> store,
StaticDataType<TargetElementType> target_dtype = {}); -
Result<TensorStore<void,
Rank,
(Mode == ReadWriteMode::read_write
? ReadWriteMode::dynamic
: Mode)>>
tensorstore::Cast(TensorStore<ElementType, Rank, Mode> store,
DataType target_dtype); Returns a view of a
TensorStore
with a converted data type.
-
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec spec, TransactionalOpenOptions&& options); -
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(Spec spec, Option&&... option); -
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_spec, Option&&... option); -
Future<TensorStore<Element, Rank, Mode>>
tensorstore::Open(J json_spec, TransactionalOpenOptions&& options); Opens a TensorStore from a Spec.
I/O¶
-
Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult store,
ResolveBoundsOptions options); -
Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult store, Option&&... option); Returns a new
TensorStore
that is equivalent tostore
but has implicit bounds resolved if possible, and explicit bounds checked.
-
Future<UnwrapResultType<StoreResult>> tensorstore::Resize(
StoreResult store,
span<const Index, UnwrapResultType<StoreResult>::static_rank>
inclusive_min,
span<const Index, UnwrapResultType<StoreResult>::static_rank>
exclusive_max,
ResizeOptions options); -
Future<UnwrapResultType<StoreResult>> tensorstore::Resize(
StoreResult store,
span<const Index, UnwrapResultType<StoreResult>::static_rank>
inclusive_min,
span<const Index, UnwrapResultType<StoreResult>::static_rank>
exclusive_max,
Option&&... option); Resizes a
TensorStore
to have the specifiedinclusive_min
andexclusive_max
bounds.
-
Future<void> tensorstore::Read(SourceTensorstore&& source,
TargetArray&& target,
ReadOptions options); -
Future<void> tensorstore::Read(SourceTensorstore&& source,
TargetArray&& target,
Option&&... option);
-
Future<
SharedArray<typename UnwrapResultType<SourceTensorstore>::Element,
UnwrapResultType<SourceTensorstore>::static_rank,
OriginKind>>
tensorstore::Read(SourceTensorstore&& source,
ReadIntoNewArrayOptions options); -
Future<
SharedArray<typename UnwrapResultType<SourceTensorstore>::Element,
UnwrapResultType<SourceTensorstore>::static_rank,
OriginKind>>
tensorstore::Read(SourceTensorstore&& source, Option&&... option); Copies from a
source
TensorStore
to a newly-allocated targetArray
.
-
Future<ArrayStorageStatistics> tensorstore::GetStorageStatistics(
const StoreResult& store,
GetArrayStorageStatisticsOptions options); -
Future<ArrayStorageStatistics>
tensorstore::GetStorageStatistics(const StoreResult& store,
Option&&... option); Retrieves statistics of the data stored within the given array region.