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

Method TestCopyConstantLayoutR4

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

Source from the content-addressed store, hash-verified

186}
187
188void CopyOpTest::TestCopyConstantLayoutR4(size_t n1, size_t n2, size_t n3,
189 size_t n4,
190 absl::Span<const int64> permutation) {
191 Array4D<int32> a(n1, n2, n3, n4);
192 for (size_t i = 0; i < n1; ++i) {
193 for (size_t j = 0; j < n2; ++j) {
194 for (size_t k = 0; k < n3; ++k) {
195 for (size_t l = 0; l < n4; ++l) {
196 a(i, j, k, l) = i * n4 * n3 * n2 + j * n4 * n3 + k * n4 + l;
197 }
198 }
199 }
200 }
201
202 HloComputation::Builder builder(TestName());
203
204 Literal literal = LiteralUtil::CreateR4FromArray4D(a);
205
206 HloInstruction* constant = builder.AddInstruction(
207 HloInstruction::CreateConstant(std::move(literal)));
208
209 builder.AddInstruction(HloInstruction::CreateUnary(
210 constant->shape(), HloOpcode::kCopy, constant));
211
212 std::unique_ptr<HloComputation> computation = builder.Build();
213
214 auto module = CreateNewVerifiedModule();
215 module->AddEntryComputation(std::move(computation));
216 ForceResultLayout(module.get(), LayoutUtil::MakeLayout(permutation));
217 Literal result = ExecuteAndTransfer(std::move(module), {});
218
219 LiteralTestUtil::ExpectR4EqualArray4D(a, result);
220}
221
222XLA_TEST_F(CopyOpTest, CopyConstantR3Layout021_SingleIncompleteTilePerLayer) {
223 TestCopyConstantLayout021(2, 2, 3);

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