API reference¶
Core¶
- class tensorstore::Batch;
Batch
provides a mechanism for defining a batch of asynchronous operations that will potentially be deferred until all references to the batch are released.
- class tensorstore::Transaction;
Shared handle to a transaction.
- class tensorstore::Context;
Immutable collection of lazily-constructed “resources”.
- class tensorstore::Schema;
Collection of constraints for a TensorStore schema.
- class tensorstore::Spec;
Specifies the parameters necessary to open or create a
TensorStore
.
- class tensorstore::TensorStore<ElementType, Rank, Mode>;
Open handle to an asynchronous multi-dimensional array.
Indexing¶
- using tensorstore::Index = int64_t;
Type for representing a coordinate in, or a extent of, a multi-dimensional array.
- using tensorstore::DimensionIndex = ptrdiff_t;
Type for representing a dimension index or rank.
- class tensorstore::IndexInterval;
Represents an interval of index values, with support for +/-inf bounds.
- class tensorstore::OptionallyImplicitIndexInterval : public IndexInterval;
Represents an IndexInterval where the lower/upper bounds may be “implicit”.
-
class tensorstore::IndexDomainDimension<LabelCKind>
: public OptionallyImplicitIndexInterval; Represents an index interval with optionally-implicit bounds and an optionally dimension label.
- using tensorstore::InlineRank = DimensionIndex;
Specifies a fixed compile-time rank, or a run-time rank with an optional inline storage limit.
- struct tensorstore::RankConstraint;
Represents an optional rank value and provides related operations.
- using tensorstore::DimensionSet = SmallBitSet<kMaxRank>;
Represents a set of dimension indices.
- class tensorstore::IndexDomain<Rank, CKind>;
Represents an index domain.
- class tensorstore::IndexTransform<InputRank, OutputRank, CKind>;
Transform from an input index space to an output index space.
-
constexpr bool tensorstore::IsIndexArray<T> =
IsArray<T> &&
std::is_convertible_v<T, SharedArrayView<const Index>>; Bool-valued metafunction that evaluates to
true
ifT
is an array type convertible toSharedArrayView<const Index>
.
- class tensorstore::DimExpression<Op...>;
A
DimExpression
represents an ordered “selection” of dimensions of an index space and a sequence of “operations” to apply to those dimensions.
Alignment¶
- enum class tensorstore::DomainAlignmentOptions;
Specifies options for aligning index domains.
-
Result<IndexTransform<>> tensorstore::AlignDomainTo(
IndexDomainView<> source,
IndexDomainView<> target,
DomainAlignmentOptions options = DomainAlignmentOptions::all); Attempts to align the
source
domain to match thetarget
domain.
-
absl::Status tensorstore::AlignDimensionsTo(
IndexDomainView<> source,
IndexDomainView<> target,
span<DimensionIndex> source_matches,
DomainAlignmentOptions options = DomainAlignmentOptions::all); Same as
AlignDomainTo
, but instead of computing thealignment
transform, simply setssource_matches[i] = j
, ifsource
dimensioni
matches to target dimensionj
, and setssource_matches[i] = -1
ifsource
dimensioni
is unmatched.
-
Result<IndexTransform<>> tensorstore::AlignTransformTo(
IndexTransform<> source_transform,
IndexDomainView<> target,
DomainAlignmentOptions options = DomainAlignmentOptions::all); Returns
ComposeTransforms(source_transform, alignment)
, wherealignment
is the result ofAlignDomainTo(source_transform.domain(), target, options)
.
Data types¶
- class tensorstore::BFloat16;
Storage-only bfloat16 type.
- type tensorstore::Float8e4m3fn;
- type tensorstore::Float8e4m3fnuz;
- type tensorstore::Float8e4m3b11fnuz;
- type tensorstore::Float8e5m2;
- type tensorstore::Float8e5m2fnuz;
Storage-only 8-bit floating-point data types.
- class tensorstore::Int4Padded;
Int4 type padded to int8.
- using tensorstore::dtypes::bool_t = bool;
Boolean value (always represented as 0 or 1).
- using tensorstore::dtypes::char_t = char;
Single ASCII/UTF-8 code unit. Primarily intended to represent fixed-width ASCII fields.
- using tensorstore::dtypes::byte_t = ::std::byte;
Opaque byte value. Intended to represent opaque binary data.
- using tensorstore::dtypes::int4_t = ::tensorstore::Int4Padded;
Signed and unsigned integer types.
-
using tensorstore::dtypes::float8_e4m3fn_t =
::tensorstore::Float8e4m3fn;
-
using tensorstore::dtypes::float8_e4m3fnuz_t =
::tensorstore::Float8e4m3fnuz;
-
using tensorstore::dtypes::float8_e4m3b11fnuz_t =
::tensorstore::Float8e4m3b11fnuz;
- using tensorstore::dtypes::float8_e5m2_t = ::tensorstore::Float8e5m2;
-
using tensorstore::dtypes::float8_e5m2fnuz_t =
::tensorstore::Float8e5m2fnuz;
- using tensorstore::dtypes::bfloat16_t = ::tensorstore::BFloat16;
- using tensorstore::dtypes::float16_t = ::half_float::half;
IEEE 754 binary16 half-precision floating-point data type.
- using tensorstore::dtypes::float32_t = float;
IEEE 754 binary32 single-precision floating-point data type.
- using tensorstore::dtypes::float64_t = double;
IEEE 754 binary64 double-precision floating-point data type.
- using tensorstore::dtypes::complex64_t = ::std::complex<float32_t>;
Complex number based on
float32_t
.
- using tensorstore::dtypes::complex128_t = std::complex<float64_t>;
Complex number based on
float64_t
.
- using tensorstore::dtypes::ustring_t = Utf8String;
Unicode string, represented in memory as UTF-8.
- class tensorstore::DataType;
Run-time representation of a C++ type used as the element type for a multi-dimensional array.
Array¶
- enum class tensorstore::ContainerKind;
Specifies whether an object (e.g. strided layout) is stored by value or view/reference.
- class tensorstore::ByteStridedPointer<T>;
Wrapper type for a raw pointer for which pointer arithmetic operates with a stride of 1 byte, rather than a stride of
sizeof(T)
bytes.
- class tensorstore::StridedLayout<Rank, OriginKind, CKind>;
A
StridedLayout
specifies the layout of a multi-dimensional array in terms of anorigin
vector, ashape
vector, and abyte_strides
vector, all of length equal to therank
of the multi-dimensional array. Theorigin
andshape
vectors specify the domain of the array, and thebyte_strides
vector specifies the offset in bytes between consecutive elements in each dimension.
- class tensorstore::ElementPointer<ElementTagType>;
Pairs an array base pointer (either an
Element*
or anstd::shared_ptr<Element>
) with aDataType
in order to support a dynamic element type determined at run time.
-
class tensorstore::
Array<ElementTagType, Rank, OriginKind, LayoutContainerKind>; Represents a pointer to an in-memory multi-dimensional array with an arbitrary strided layout.
-
class tensorstore::
TransformedArray<ElementTagType, Rank, LayoutCKind>; View through an index transform of an in-memory array.
Transformation¶
- class tensorstore::TransformArrayConstraints;
Specifies constraints on the array returned from
TransformArray
.
-
Result<
SharedArray<const typename Array::Element, InputRank, OriginKind>>
tensorstore::TransformArray(
const Array& array,
const IndexTransform<InputRank, OutputRank, CKind>& transform,
TransformArrayConstraints constraints = skip_repeated_elements); Returns a strided array that represents the result of applying
transform
toarray
.
-
Result<SharedArray<std::remove_const_t<typename Array::Element>,
InputRank,
OriginKind>>
tensorstore::MakeCopy(
const Array& array,
const IndexTransform<InputRank, OutputRank, CKind>& transform,
IterationConstraints constraints = skip_repeated_elements); Equivalent to
TransformArray
, but always returns a newly allocated array with a non-const
element type.
Iteration¶
- enum class tensorstore::RepeatedElementsConstraint;
Specifies whether repeated elements may be skipped.
- enum class tensorstore::UnspecifiedLayoutOrder;
Specifies that the iteration order is unconstrained.
- class tensorstore::LayoutOrderConstraint;
Specifies an order constraint on a strided layout/iteration order, equivalent to an algebraic sum of
ContiguousLayoutOrder
andunspecified_order
.
- class tensorstore::IterationConstraints;
Specifies constraints on how multi-dimensional iteration can be performed.
Key-value storage¶
- class tensorstore::kvstore::Spec;
Combines a driver-specific kvstore spec with a string
path
that serves as a key prefix.
- class tensorstore::kvstore::KvStore;
Combines a
DriverPtr
with a string path that serves as a key prefix, and an optional transaction.
- struct tensorstore::ByteRange;
Specifies a range of bytes within a stored value.
- struct tensorstore::OptionalByteRangeRequest;
Specifies an optional byte range request.
- struct tensorstore::StorageGeneration;
Represents a generation identifier associated with a stored object.
- struct tensorstore::TimestampedStorageGeneration;
Combines a local timestamp with a StorageGeneration indicating the local time for which the generation is known to be current.
- class tensorstore::KeyRange;
Specifies a range of keys according to their unsigned lexicographical order.
Downsampling¶
- enum class tensorstore::DownsampleMethod;
Specifies the method by which downsampling is performed.
-
Result<TensorStore<Element, Rank, ReadWriteMode::read>>
tensorstore::Downsample(
TensorStore<Element, Rank, Mode> store,
std::type_identity_t<span<const Index, Rank>> downsample_factors,
DownsampleMethod downsample_method); Returns a downsampled view of a
TensorStore
.
-
Result<Spec>
tensorstore::Downsample(const Spec& base_spec,
span<const Index> downsample_factors,
DownsampleMethod downsample_method); Returns a downsampled view of a
Spec
.
Utilities¶
- class tensorstore::span<T, Extent>;
Unowned view of a contiguous 1-d array of elements, similar to
std::span
.
- struct tensorstore::Utf8String;
Wrapper around
std::string
to indicate a UTF-8 encoded string.
- class tensorstore::SmallBitSet<N>;
Bit set that fits in a single unsigned integer.
- class tensorstore::MaybeHardConstraintSpan<T> : public span<const T>;
Combines a span (with length assumed to be a valid rank) with a bit vector indicating which values are hard constraints as opposed to soft constraints.
- class tensorstore::MaybeHardConstraintIndex;
Combines an
Index
(which defaults tokImplicit
) with abool
indicating whether the value is a hard constraint as opposed to a default value.
-
constexpr bool
tensorstore::IsCompatibleOptionSequence<Options, Option...> =
((!std::is_same_v<Options, std::remove_cvref_t<Option>> &&
Options::template IsOption<std::remove_cvref_t<Option>>) &&
...); Checks if every
Option
is compatible with the specifiedOptions
type.
Error handling¶
-
TENSORSTORE_RETURN_IF_ERROR(...);
Causes the containing function to return the specified
absl::Status
value if it is an error status.
- TENSORSTORE_CHECK_OK(...);
Logs an error and terminates the program if the specified
absl::Status
is an error status.
-
absl::Status tensorstore::MaybeAnnotateStatus(
absl::Status source,
std::string_view message,
std::source_location loc = std::source_location::current()); -
absl::Status tensorstore::MaybeAnnotateStatus(
absl::Status source,
std::string_view message,
absl::StatusCode new_code,
std::source_location loc = std::source_location::current()); If status is not
absl::StatusCode::kOk
, then annotate the status message.
- class [[nodiscard]] tensorstore::Result<T>;
Result<T>
implements a value-or-error concept providing a discriminated union of a usable value,T
, or anabsl::Status
error describing why the value is not present.Result<void>
is permitted, which becomes a wrapper forabsl::Status
, and which enables use ofResult<T>
in a wide variety of template contexts.
Asynchronous support¶
- type tensorstore::Executor;
Function object that is callable with nullary noexcept functions.
- class [[nodiscard]] tensorstore::AnyFuture;
Generic consumer interface to a one-time channel.
- class [[nodiscard]] tensorstore::Future<T> : public AnyFuture;
“Consumer” interface to a one-time channel.
- class [[nodiscard]] tensorstore::PromiseFuturePair<T>;
Pairs a Promise with a Future.
- struct [[nodiscard]] tensorstore::WriteFutures;
Handle for consuming the result of an asynchronous write operation.
JSON serialization¶
- class tensorstore::IncludeDefaults;
Specifies whether members equal to their default values are included when converting to JSON.
- class tensorstore::JsonSerializationOptions;
Defines options for conversion to/from JSON.
Compile-time data type/rank/mode constraints¶
- enum class tensorstore::CastChecking;
Enum type used as a template parameter to casts to choose between an unchecked cast (that returns the bare value
T
) and a checked cast that returnsResult<T>
.
- struct tensorstore::unchecked_t;
Tag type used as the first parameter of some constructors to request an unchecked conversion (e.g. from dynamic rank to a compile-time rank).
-
constexpr bool
tensorstore::IsStaticCastConstructible<Target, SourceRef>; bool
-valued metafunction that evaluates totrue
if a value of typeSourceRef&&
can be converted to a type ofTarget
usingStaticCast
.
- using tensorstore::StaticCastResultType<Target, SourceRef, Checking>;
Evaluates to the result of casting a value of type
SourceRef&&
toTarget
with a checking mode ofChecking
.
-
StaticCastResultType<Target, SourceRef, Checking>
tensorstore::StaticCast(SourceRef&& source); Type-erasure-aware conversion of
source
to the specifiedTarget
type.
- using tensorstore::RebindRank<SourceRef, TargetRank>;
Evaluates to a type similar to
SourceRef
but with a static rank ofTargetRank
.
-
StaticCastResultType<RebindRank<SourceRef, TargetRank>,
SourceRef,
Checking>
tensorstore::StaticRankCast(SourceRef&& source); Casts
source
to have a static rank ofTargetRank
.
- using tensorstore::RebindDataType<SourceRef, TargetElement>;
Evaluates to a type similar to
SourceRef
but with a static data type ofTargetElement
.
-
StaticCastResultType<RebindDataType<SourceRef, TargetElement>,
SourceRef,
Checking>
tensorstore::StaticDataTypeCast(SourceRef&& source); Casts
source
to have a static data type ofTargetElement
.
-
StaticCastResultType<RebindDataType<SourceRef, TargetElement>,
SourceRef>
tensorstore::ConstDataTypeCast(SourceRef&& source); Casts
source
to a specified target element type which must differ from the existing element type only in const qualification.
- using tensorstore::RebindMode<SourceRef, TargetMode>;
Evaluates to a type similar to
SourceRef
but with aReadWriteMode
ofTargetMode
.
-
StaticCastResultType<RebindMode<SourceRef, TargetMode>,
SourceRef,
Checking>
tensorstore::ModeCast(SourceRef&& source); Casts
source
to have a staticReadWriteMode
ofTargetMode
.
String Utilities¶
- std::string tensorstore::StrCat(const Arg&... arg);
Concatenates the string representation of
arg...
and returns the result.
- void tensorstore::StrAppend(std::string* result, const Arg&... arg);
Appends a string representation of arg… to
*result
.
Index vectors¶
-
constexpr bool
tensorstore::IsCompatibleFullIndexVector<Rank, Indices>; Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::value_type
convertible without narrowing toIndex
and a staticspan::extent
compatible withRank
.
-
constexpr bool
tensorstore::IsImplicitlyCompatibleFullIndexVector<Rank, Indices>; Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::value_type
convertible without narrowing toIndex
and a staticspan::extent
implicitly compatible withRank
.
-
constexpr bool
tensorstore::IsCompatiblePartialIndexVector<Rank, Indices>; Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::value_type
convertible without narrowing toIndex
and a staticspan::extent <= Rank
.
-
constexpr bool
tensorstore::IsCompatibleFullIndexPack<Rank, IndexType...>; Bool-valued metafunction that evaluates to
true
if everyIndexType
is convertible without narrowing toIndex
, andsizeof...(IndexType)
is compatible withRank
.
- constexpr bool tensorstore::IsIndexConvertibleVector<Indices>;
Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::value_type
convertible without narrowing toIndex
.
- constexpr bool tensorstore::IsIndexVector<Indices>;
Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::value_type
ofIndex
.
- constexpr bool tensorstore::IsMutableIndexVector<Indices>;
Bool-valued metafunction that evaluates to
true
ifIndices
isspan
-compatible with aspan::element_type
ofIndex
.
- using tensorstore::SpanStaticExtent<X0, Xs...>;
ptrdiff_t
-valued metafunction with astatic constexpr ptrdiff_t value
member that is equal to the common static extent ofX0, Xs...
ifX0, Xs...
are allspan
-compatible types with the same static extent.