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

Function MakeLayout

tensorflow/compiler/tf2xla/shape_util.cc:50–69  ·  view source on GitHub ↗

Populate the output layout unless the minor_to_major array contains all -1 value, in which case the layout is considered missing and the API returns false.

Source from the content-addressed store, hash-verified

48// value, in which case the layout is considered missing and the API returns
49// false.
50xla::StatusOr<bool> MakeLayout(absl::Span<const int64> minor_to_major,
51 xla::Layout* layout) {
52 if (std::all_of(minor_to_major.begin(), minor_to_major.end(),
53 [](int64 dim) { return dim == -1; })) {
54 return false;
55 }
56 std::vector<bool> dim_present(minor_to_major.size(), false);
57 for (auto dim : minor_to_major) {
58 if (dim < 0 || dim >= minor_to_major.size()) {
59 return errors::InvalidArgument("Layout dimension out of range: dim=", dim,
60 " rank=", minor_to_major.size());
61 }
62 if (dim_present[dim]) {
63 return errors::InvalidArgument("Repeated layout dimension: dim=", dim);
64 }
65 dim_present[dim] = true;
66 }
67 *layout = xla::LayoutUtil::MakeLayout(minor_to_major);
68 return true;
69}
70
71Status AssignLayout(
72 absl::Span<const int64> minor_to_major,

Callers 15

TEST_FFunction · 0.70
ResolveConstantMethod · 0.70
TESTFunction · 0.50
LiteralUtilTestMethod · 0.50
TYPED_TESTFunction · 0.50
ReshapeSliceMethod · 0.50
TESTFunction · 0.50
MakeDescendingLayoutMethod · 0.50
MakeShapeWithLayoutMethod · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50

Calls 4

InvalidArgumentFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by 15

TEST_FFunction · 0.56
TESTFunction · 0.40
LiteralUtilTestMethod · 0.40
TYPED_TESTFunction · 0.40
TESTFunction · 0.40
MakeShapeWithLayoutMethod · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_PFunction · 0.40
TESTFunction · 0.40
ExpectLayoutIsMethod · 0.40