| 186 | } |
| 187 | |
| 188 | void 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 | |
| 222 | XLA_TEST_F(CopyOpTest, CopyConstantR3Layout021_SingleIncompleteTilePerLayer) { |
| 223 | TestCopyConstantLayout021(2, 2, 3); |
nothing calls this directly
no test coverage detected