MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / StridesForShape

Function StridesForShape

tensorflow/compiler/xla/python/dlpack.cc:151–163  ·  view source on GitHub ↗

Returns the strides for `shape`.

Source from the content-addressed store, hash-verified

149
150// Returns the strides for `shape`.
151std::vector<int64> StridesForShape(const Shape& shape) {
152 std::vector<int64> strides;
153 CHECK(shape.IsArray());
154 CHECK(shape.has_layout());
155
156 strides.resize(shape.dimensions_size());
157 int64 stride = 1;
158 for (int i : shape.layout().minor_to_major()) {
159 strides.at(i) = stride;
160 stride *= shape.dimensions(i);
161 }
162 return strides;
163}
164
165StatusOr<std::vector<int64>> StridesToLayout(absl::Span<int64 const> dims,
166 absl::Span<int64 const> strides) {

Callers 1

Calls 8

has_layoutMethod · 0.80
dimensions_sizeMethod · 0.80
minor_to_majorMethod · 0.80
IsArrayMethod · 0.45
resizeMethod · 0.45
layoutMethod · 0.45
atMethod · 0.45
dimensionsMethod · 0.45

Tested by

no test coverage detected