|
| 1 | +// Copyright 2026 Advanced Micro Devices, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | + |
| 7 | +// RUN: %{TEST_EXE} | iree-opt --verify-roundtrip |
| 8 | +// RUN: %{TEST_EXE} | FileCheck %s --check-prefix=TORCH-CHECK |
| 9 | +// RUN: %{TEST_EXE} stats | FileCheck %s --check-prefix=%{BACKEND}-STATS-CHECK |
| 10 | + |
| 11 | +// clang-format off |
| 12 | +// |
| 13 | +// TORCH-CHECK: module @module { |
| 14 | +// TORCH-CHECK: func.func @main(%[[RESULT0:.+]]: !torch.tensor<[16,256,64,32],f32>, %[[ARG0:.+]]: !torch.vtensor<[16,256,64,32],f32>) attributes {torch.assume_strict_symbolic_shapes} { |
| 15 | +// TORCH-CHECK: %[[PERM0_0:.+]] = torch.constant.int 0 |
| 16 | +// TORCH-CHECK: %[[PERM0_1:.+]] = torch.constant.int 1 |
| 17 | +// TORCH-CHECK: %[[PERM0_2:.+]] = torch.constant.int 2 |
| 18 | +// TORCH-CHECK: %[[PERM0_3:.+]] = torch.constant.int 3 |
| 19 | +// TORCH-CHECK: %[[PERM0_LIST:.+]] = torch.prim.ListConstruct %[[PERM0_0]], %[[PERM0_1]], %[[PERM0_2]], %[[PERM0_3]] : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 20 | +// TORCH-CHECK: %[[PERMUTE0:.+]] = torch.aten.permute %[[ARG0]], %[[PERM0_LIST]] : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 21 | +// TORCH-CHECK: %[[RECIPROCAL:.+]] = torch.aten.reciprocal %[[PERMUTE0]] : !torch.vtensor<[16,256,64,32],f32> -> !torch.vtensor<[16,256,64,32],f32> |
| 22 | +// TORCH-CHECK: %[[PERM_OUT_0:.+]] = torch.constant.int 0 |
| 23 | +// TORCH-CHECK: %[[PERM_OUT_1:.+]] = torch.constant.int 1 |
| 24 | +// TORCH-CHECK: %[[PERM_OUT_2:.+]] = torch.constant.int 2 |
| 25 | +// TORCH-CHECK: %[[PERM_OUT_3:.+]] = torch.constant.int 3 |
| 26 | +// TORCH-CHECK: %[[PERM_OUT_LIST:.+]] = torch.prim.ListConstruct %[[PERM_OUT_0]], %[[PERM_OUT_1]], %[[PERM_OUT_2]], %[[PERM_OUT_3]] : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 27 | +// TORCH-CHECK: %[[PERM_OUT:.+]] = torch.aten.permute %[[RECIPROCAL]], %[[PERM_OUT_LIST]] : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 28 | +// TORCH-CHECK: torch.overwrite.tensor.contents %[[PERM_OUT]] overwrites %[[RESULT0]] : !torch.vtensor<[16,256,64,32],f32>, !torch.tensor<[16,256,64,32],f32> |
| 29 | +// TORCH-CHECK: return |
| 30 | +// TORCH-CHECK: } |
| 31 | +// TORCH-CHECK: } |
| 32 | +// |
| 33 | +// AMDGPU-STATS-CHECK: "transient-memory-size": 0 |
| 34 | +// AMDGPU-STATS-CHECK: "dispatch-count": 1 |
| 35 | +// CPU-STATS-CHECK: "transient-memory-size": 0 |
| 36 | +// CPU-STATS-CHECK: "dispatch-count": 1 |
| 37 | +// |
| 38 | +// clang-format on |
| 39 | + |
| 40 | +#include <fusilli.h> |
| 41 | + |
| 42 | +#include "utils.h" |
| 43 | + |
| 44 | +#include <iostream> |
| 45 | +#include <string> |
| 46 | + |
| 47 | +using namespace fusilli; |
| 48 | + |
| 49 | +int main(int argc, char **argv) { |
| 50 | + std::string mode = (argc > 1) ? argv[1] : "default"; |
| 51 | + |
| 52 | + auto status = testUnaryPointwiseAsmEmitter( |
| 53 | + "pointwise_asm_emitter_reciprocal", "reciprocal", mode, |
| 54 | + PointwiseAttr::Mode::RECIPROCAL, {16, 256, 64, 32}); |
| 55 | + if (isError(status)) { |
| 56 | + std::cerr << "Test failed: " << status << std::endl; |
| 57 | + return 1; |
| 58 | + } |
| 59 | + return 0; |
| 60 | +} |
0 commit comments