-
#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, andResolveBoundsmay be used to perform operations on a TensorStore.Indexing may be performed using the
DimExpressionfacilities. For example:TensorStore<int32_t, 3> store = ...; Result<TensorStore<int32_t, 2>> sub_store = store | Dims(0).IndexSlice(5);Typically a
TensorStoreobject is obtained by callingtensorstore::Open.- Template Parameters:¶
- typename ElementType = void¶
Compile-time element type constraint. May be
voidto 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_rankto indicate that the rank is determined at run time.- ReadWriteMode Mode = ReadWriteMode::dynamic¶
Compile-time read/write mode constraint. May be
ReadWriteMode::dynamicto 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_rankif the rank is determined at run time.
- constexpr const ReadWriteMode static_mode = Mode;
Compile-time read-write mode, or
ReadWriteMode::dynamicif 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
trueif 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 class tensorstore::ReadWriteMode;
Specifies whether reading and/or writing is permitted.
- enum tensorstore::SourceDataReferenceRestriction;
Specifies restrictions on how references to the source array/source TensorStore may be used by write operations.
-
using tensorstore::TensorReader<Element, Rank> =
TensorStore<Element, Rank, ReadWriteMode::read>; Read-only
TensorStorealias.
-
using tensorstore::TensorWriter<Element, Rank> =
TensorStore<Element, Rank, ReadWriteMode::write>; Write-only
TensorStorealias.
- using tensorstore::StackOpenOptions = TransactionalOpenOptions;
Related Functions¶
-
Result<TensorStore<Element, Rank>>
tensorstore::ModeCast(TensorStore<Element, Rank, ExistingMode> store,
ReadWriteMode new_mode); Changes the
ReadWriteModeofstoreto 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
sourceTensorStoretotargetTensorStore.
-
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
TensorStorewith 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.
-
auto tensorstore::Overlay(const Layers& layers,
StackOpenOptions&& options); - auto tensorstore::Overlay(const Layers& layers, Option&&... option);
Virtually overlays a sequence of
TensorStoreorSpeclayers within a common domain.
-
auto tensorstore::Stack(const Layers& layers,
DimensionIndex stack_dimension,
StackOpenOptions&& options); -
auto tensorstore::Stack(const Layers& layers,
DimensionIndex stack_dimension,
Option&&... option); Virtually stacks a sequence of
TensorStoreorSpeclayers along a new dimension.
-
auto tensorstore::Concat(const Layers& layers,
DimensionIdentifier concat_dimension,
StackOpenOptions&& options); -
auto tensorstore::Concat(const Layers& layers,
DimensionIdentifier concat_dimension,
Option&&... option); Virtually concatenates a sequence of
TensorStoreorSpeclayers along an existing dimension.
I/O¶
-
Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult store,
ResolveBoundsOptions options); -
Future<UnwrapResultType<StoreResult>>
tensorstore::ResolveBounds(StoreResult store, Option&&... option); Returns a new
TensorStorethat is equivalent tostorebut 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
TensorStoreto have the specifiedinclusive_minandexclusive_maxbounds.
-
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
sourceTensorStoreto 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.
Related Constants¶
- constexpr bool tensorstore::IsJsonSpecLike<T>;
Indicates that
Tmay be passed as a JSON spec totensorstore::Open.
Virtual chunked¶
- class tensorstore::virtual_chunked::ReadParameters;
Parameters available to the read function for computing the content of a chunk.
- type tensorstore::virtual_chunked::ReadFunction;
Type-erased function called to read a single chunk.
-
constexpr bool
tensorstore::virtual_chunked::IsReadFunction<Func, Element, Rank>; Metafunction that evaluates to
trueifFuncmay be used as a “read function” for the specified compile-timeElementtype andRank.
- class tensorstore::virtual_chunked::WriteParameters;
Parameters available to the write function for storing the content of a chunk.
- type tensorstore::virtual_chunked::WriteFunction;
Type-erased function called to write a single chunk.
-
constexpr bool tensorstore::virtual_chunked::
IsWriteFunction<Func, Element, Rank>; Metafunction that evaluates to
trueifFuncmay be used as a “write function” for the specified compile-timeElementtype andRank.
- struct tensorstore::virtual_chunked::OpenOptions : public Schema;
Options to the
VirtualChunkedfunction for creating avirtual_chunkedTensorStore.
-
Result<TensorStore<Element, Rank, ReadWriteMode::read>>
tensorstore::VirtualChunked(ReadFunc read_function,
virtual_chunked::OpenOptions&& options); -
Result<TensorStore<Element, Rank, ReadWriteMode::read>>
tensorstore::VirtualChunked(ReadFunc read_function,
Option&&... option); Creates a read-only TensorStore where the content is read chunk-wise by the specified user-defined function.
-
Result<TensorStore<Element, Rank, ReadWriteMode::read_write>>
tensorstore::VirtualChunked(ReadFunc read_function,
WriteFunc write_function,
virtual_chunked::OpenOptions&& options); -
Result<TensorStore<Element, Rank, ReadWriteMode::read_write>>
tensorstore::VirtualChunked(ReadFunc read_function,
WriteFunc write_function,
Option&&... option); Creates a read-write TensorStore where the content is read and written chunk-wise by the specified user-defined functions.
-
Result<TensorStore<Element, Rank, ReadWriteMode::write>>
tensorstore::VirtualChunkedWriteOnly(
WriteFunc write_function,
virtual_chunked::OpenOptions&& options); -
Result<TensorStore<Element, Rank, ReadWriteMode::write>>
tensorstore::VirtualChunkedWriteOnly(WriteFunc write_function,
Option&&... option); Creates a write-only TensorStore where the content is written chunk-wise by the specified user-defined function.