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

Method TestCopyConstantLayout021

tensorflow/compiler/xla/tests/copy_test.cc:158–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void CopyOpTest::TestCopyConstantLayout021(size_t n1, size_t n2, size_t n3) {
159 Array3D<int32> a(n1, n2, n3);
160 for (size_t i = 0; i < n1; ++i) {
161 for (size_t j = 0; j < n2; ++j) {
162 for (size_t k = 0; k < n3; ++k) {
163 a(i, j, k) = i * n3 * n2 + j * n3 + k;
164 }
165 }
166 }
167
168 HloComputation::Builder builder(TestName());
169
170 Literal literal = LiteralUtil::CreateR3FromArray3D(a);
171
172 HloInstruction* constant = builder.AddInstruction(
173 HloInstruction::CreateConstant(std::move(literal)));
174
175 builder.AddInstruction(HloInstruction::CreateUnary(
176 constant->shape(), HloOpcode::kCopy, constant));
177
178 std::unique_ptr<HloComputation> computation = builder.Build();
179
180 auto module = CreateNewVerifiedModule();
181 module->AddEntryComputation(std::move(computation));
182 ForceResultLayout(module.get(), LayoutUtil::MakeLayout({1, 2, 0}));
183 Literal result = ExecuteAndTransfer(std::move(module), {});
184
185 LiteralTestUtil::ExpectR3EqualArray3D(a, result);
186}
187
188void CopyOpTest::TestCopyConstantLayoutR4(size_t n1, size_t n2, size_t n3,
189 size_t n4,

Callers

nothing calls this directly

Calls 8

aClass · 0.85
TestNameFunction · 0.85
AddEntryComputationMethod · 0.80
MakeLayoutFunction · 0.50
AddInstructionMethod · 0.45
shapeMethod · 0.45
BuildMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected