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

Function ByteStridesForShape

tensorflow/compiler/xla/python/types.cc:183–195  ·  view source on GitHub ↗

Returns the strides for `shape`.

Source from the content-addressed store, hash-verified

181
182// Returns the strides for `shape`.
183std::vector<ssize_t> ByteStridesForShape(const Shape& shape) {
184 std::vector<ssize_t> strides;
185 CHECK(shape.IsArray());
186 CHECK(shape.has_layout());
187
188 strides.resize(shape.dimensions_size());
189 ssize_t stride = ShapeUtil::ByteSizeOfPrimitiveType(shape.element_type());
190 for (int i : shape.layout().minor_to_major()) {
191 strides.at(i) = stride;
192 stride *= shape.dimensions(i);
193 }
194 return strides;
195}
196
197StatusOr<py::object> LiteralToPython(std::shared_ptr<xla::Literal> literal) {
198 xla::Literal& m = *literal;

Callers 2

PyLocalBufferGetBufferFunction · 0.85
LiteralToPythonFunction · 0.85

Calls 10

ByteSizeOfPrimitiveTypeFunction · 0.85
has_layoutMethod · 0.80
dimensions_sizeMethod · 0.80
minor_to_majorMethod · 0.80
IsArrayMethod · 0.45
resizeMethod · 0.45
element_typeMethod · 0.45
layoutMethod · 0.45
atMethod · 0.45
dimensionsMethod · 0.45

Tested by

no test coverage detected