|
| 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(%result_: !torch.tensor<[16,256,64,32],f32>, %arg0: !torch.vtensor<[16,256,64,32],f32>) attributes {torch.assume_strict_symbolic_shapes} { |
| 15 | +// TORCH-CHECK: %permute_IN_0_val_0_pointwise_abs = torch.constant.int 0 |
| 16 | +// TORCH-CHECK: %permute_IN_0_val_1_pointwise_abs = torch.constant.int 1 |
| 17 | +// TORCH-CHECK: %permute_IN_0_val_2_pointwise_abs = torch.constant.int 2 |
| 18 | +// TORCH-CHECK: %permute_IN_0_val_3_pointwise_abs = torch.constant.int 3 |
| 19 | +// TORCH-CHECK: %permute_IN_0_pointwise_abs = torch.prim.ListConstruct %permute_IN_0_val_0_pointwise_abs, %permute_IN_0_val_1_pointwise_abs, %permute_IN_0_val_2_pointwise_abs, %permute_IN_0_val_3_pointwise_abs : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 20 | +// TORCH-CHECK: %arg0_pointwise_abs_perm = torch.aten.permute %arg0, %permute_IN_0_pointwise_abs : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 21 | +// TORCH-CHECK: %result_pointwise_abs_perm = torch.aten.abs %arg0_pointwise_abs_perm : !torch.vtensor<[16,256,64,32],f32> -> !torch.vtensor<[16,256,64,32],f32> |
| 22 | +// TORCH-CHECK: %permute_OUT_0_val_0_pointwise_abs = torch.constant.int 0 |
| 23 | +// TORCH-CHECK: %permute_OUT_0_val_1_pointwise_abs = torch.constant.int 1 |
| 24 | +// TORCH-CHECK: %permute_OUT_0_val_2_pointwise_abs = torch.constant.int 2 |
| 25 | +// TORCH-CHECK: %permute_OUT_0_val_3_pointwise_abs = torch.constant.int 3 |
| 26 | +// TORCH-CHECK: %permute_OUT_0_pointwise_abs = torch.prim.ListConstruct %permute_OUT_0_val_0_pointwise_abs, %permute_OUT_0_val_1_pointwise_abs, %permute_OUT_0_val_2_pointwise_abs, %permute_OUT_0_val_3_pointwise_abs : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 27 | +// TORCH-CHECK: %result = torch.aten.permute %result_pointwise_abs_perm, %permute_OUT_0_pointwise_abs : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 28 | +// TORCH-CHECK: torch.overwrite.tensor.contents %result overwrites %result_ : !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_abs", "pointwise_abs", mode, |
| 54 | + PointwiseAttr::Mode::ABS, {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