Layout constructor

Layout({
  1. Iterable<int>? shape,
  2. Iterable<int>? strides,
  3. int? offset,
})

Implementation

factory Layout({Iterable<int>? shape, Iterable<int>? strides, int? offset}) {
  final shape_ = utils.toIndices(shape ?? const <int>[]);
  final strides_ = strides == null
      ? utils.toStrides(shape: shape_)
      : utils.toIndices(strides);
  return Layout.internal(
    rank: shape_.length,
    length: shape_.product(),
    shape: shape_,
    strides: strides_,
    offset: offset ?? 0,
    isContiguous: shape_.isEmpty ||
        strides == null ||
        utils.isContiguous(shape: shape_, strides: strides_),
  );
}