-
#include "tensorstore/chunk_layout.h"
-
template <Usage U>
struct tensorstore::ChunkLayout::ChunkShapeFor
: public ChunkShapeBase; Constrains the chunk shape for the specified usage
U
.Example:
tensorstore::ChunkLayout constraints; // Sets a hard constraint on the chunk size for dimension 0 TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::ReadChunkShape{ {64, 0, 0}, /*hard_constraint=*/true})); EXPECT_THAT(constraints.read_chunk_shape(), ::testing::ElementsAre(64, 0, 0)); EXPECT_EQ(tensorstore::DimensionSet::FromBools({1, 0, 0}), constraints.read_chunk_elements().hard_constraint); // Sets a soft constraint on the chunk size for dimensions 0 and 2. // The constraint on dimension 0 is ignored since the prior hard // constraint takes precedence. TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::ReadChunkShape{ {100, 0, 100}, /*hard_constraint=*/false})); EXPECT_THAT(constraints.read_chunk_shape(), ::testing::ElementsAre(64, 0, 100)); EXPECT_EQ(tensorstore::DimensionSet::FromBools({1, 0, 0}), constraints.read_chunk_elements().hard_constraint); // Sets a hard constraint on the chunk size for dimensions 1 and 2. TENSORSTORE_RETURN_IF_ERROR(constraints.Set( tensorstore::ChunkLayout::ReadChunkShape{ {0, 50, 80}, /*hard_constraint=*/true})); EXPECT_THAT(constraints.read_chunk_shape(), ::testing::ElementsAre(64, 50, 80)); EXPECT_EQ(tensorstore::DimensionSet::FromBools({1, 1, 1}), constraints.read_chunk_elements().hard_constraint);
This type inherits from
tensorstore::span<const Index>
.The chunk size constraint for each dimension is specified as a non-negative integer. The special value of 0 for a given dimension indicates no constraint on that dimension. The special value of
-1
indicates that the size should equal the full extent of the domain, and is always treated as a soft constraint. A rank of 0 indicates no constraints. It is an error to specify negative values other than-1
.