stack
Driver¶
The stack
driver specifies a TensorStore backed by a sequence of layered
drivers, where each underlying layer describes it’s bounds via a transform.
The TensorStore for a stack driver has staic bounds, which may be derived from the underlying
layers
Reading is supported if the
layers
TensorStore supports reading.Writing is supported if the
layers
TensorStore supports writing.
The layers may overlap, with the subsequent layers overriding values from earlier layers in the stack.
The underlying stack
TensorStore layers
are
opened on demand by each operation.
- json driver/stack : object¶
- Extends:¶
TensorStore
— Specifies a TensorStore to open/create.
- Required members:¶
-
driver :
"stack"
¶
- layers : array of TensorStore¶
Array of layered tensorstore drivers.
The stack driver maps each nested driver in
layers
to the position described by the layer transform. All layers must have the samedtype
as well as compatible domains.
-
driver :
- Optional members:¶
-
-
rank : integer[
0
,32
]¶ Specifies the rank of the TensorStore.
If
transform
is also specified, the input rank must match. Otherwise, the rank constraint applies to the driver directly.
- transform : IndexTransform¶
Specifies a transform.
- schema : Schema¶
Specifies constraints on the schema.
When opening an existing array, specifies constraints on the existing schema; opening will fail if the constraints do not match. Any soft constraints specified in the
chunk_layout
are ignored. When creating a new array, a suitable schema will be selected automatically based on the specified schema constraints in combination with any driver-specific constraints.
-
data_copy_concurrency : ContextResource =
"data_copy_concurrency"
¶ Specifies or references a previously defined
Context.data_copy_concurrency
. It is normally more convenient to specify a defaultdata_copy_concurrency
in thecontext
.
-
rank : integer[
Example
{ "driver": "stack", "layers": [ {"driver": "array", "array": [1, 2, 3], "dtype": "int32"}, { "driver": "array", "array": [4, 5, 6], "dtype": "int32", "transform": { "input_inclusive_min": 3, "output": {"input_dimension": 0, "offset": -3} } }] }
Example¶
Example of layer driver
>>> ts.open({
... 'driver':
... 'stack',
... 'layers': [
... {
... 'driver': 'array',
... 'dtype': 'int32',
... 'array': [1, 2, 3, 4],
... },
... {
... 'driver': 'array',
... 'dtype': 'int32',
... 'array': [1, 2, 3, 4],
... 'transform': {
... 'input_inclusive_min': [4],
... 'input_exclusive_max': [8],
... 'output': [{
... 'input_dimension': 0,
... 'offset': -4
... }]
... },
... },
... ]
... }).result().schema.dtype
dtype("int32")
TensorStore Schema¶
Only the following TensorStore schema constraints are useful to the stack
driver. They will be propagated and will cause errors when incompatible with
the layer stack.
Schema.rank
Sets the rank of the TensorStore and constrains the rank of each of thelayers
Schema.dtype
Sets the dtype of the TensorStore and constrains the dtype of each of thelayers
Schema.domain
Sets the domain of the TensorStore. Thestack
driver computes an effective domain as the hull of each layer’s effective domain, as derived from the layer schema and transform. For each dimension bound which is implicit and unbounded (as when thedomain
is omitted), the bounds for that dimension are taken from the effective domain.Schema.dimension_units
Sets the dimension units of the TensorStore. Thestack
driver will set any unset dimension units from the individual layers as long as they are in common.
Scheama options that are not allowed: