|
| 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_softplus_fwd = torch.constant.int 0 |
| 16 | +// TORCH-CHECK: %permute_IN_0_val_1_pointwise_softplus_fwd = torch.constant.int 1 |
| 17 | +// TORCH-CHECK: %permute_IN_0_val_2_pointwise_softplus_fwd = torch.constant.int 2 |
| 18 | +// TORCH-CHECK: %permute_IN_0_val_3_pointwise_softplus_fwd = torch.constant.int 3 |
| 19 | +// TORCH-CHECK: %permute_IN_0_pointwise_softplus_fwd = torch.prim.ListConstruct %permute_IN_0_val_0_pointwise_softplus_fwd, %permute_IN_0_val_1_pointwise_softplus_fwd, %permute_IN_0_val_2_pointwise_softplus_fwd, %permute_IN_0_val_3_pointwise_softplus_fwd : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 20 | +// TORCH-CHECK: %arg0_pointwise_softplus_fwd_perm = torch.aten.permute %arg0, %permute_IN_0_pointwise_softplus_fwd : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 21 | +// TORCH-CHECK: %softplus_beta_pointwise_softplus_fwd = torch.constant.float 1.000000e+00 |
| 22 | +// TORCH-CHECK: %softplus_threshold_pointwise_softplus_fwd = torch.constant.float 2.000000e+01 |
| 23 | +// TORCH-CHECK: %result_pointwise_softplus_fwd_perm = torch.aten.softplus %arg0_pointwise_softplus_fwd_perm, %softplus_beta_pointwise_softplus_fwd, %softplus_threshold_pointwise_softplus_fwd : !torch.vtensor<[16,256,64,32],f32>, !torch.float, !torch.float -> !torch.vtensor<[16,256,64,32],f32> |
| 24 | +// TORCH-CHECK: %permute_OUT_0_val_0_pointwise_softplus_fwd = torch.constant.int 0 |
| 25 | +// TORCH-CHECK: %permute_OUT_0_val_1_pointwise_softplus_fwd = torch.constant.int 1 |
| 26 | +// TORCH-CHECK: %permute_OUT_0_val_2_pointwise_softplus_fwd = torch.constant.int 2 |
| 27 | +// TORCH-CHECK: %permute_OUT_0_val_3_pointwise_softplus_fwd = torch.constant.int 3 |
| 28 | +// TORCH-CHECK: %permute_OUT_0_pointwise_softplus_fwd = torch.prim.ListConstruct %permute_OUT_0_val_0_pointwise_softplus_fwd, %permute_OUT_0_val_1_pointwise_softplus_fwd, %permute_OUT_0_val_2_pointwise_softplus_fwd, %permute_OUT_0_val_3_pointwise_softplus_fwd : (!torch.int, !torch.int, !torch.int, !torch.int) -> !torch.list<int> |
| 29 | +// TORCH-CHECK: %result = torch.aten.permute %result_pointwise_softplus_fwd_perm, %permute_OUT_0_pointwise_softplus_fwd : !torch.vtensor<[16,256,64,32],f32>, !torch.list<int> -> !torch.vtensor<[16,256,64,32],f32> |
| 30 | +// TORCH-CHECK: torch.overwrite.tensor.contents %result overwrites %result_ : !torch.vtensor<[16,256,64,32],f32>, !torch.tensor<[16,256,64,32],f32> |
| 31 | +// TORCH-CHECK: return |
| 32 | +// TORCH-CHECK: } |
| 33 | +// TORCH-CHECK: } |
| 34 | +// |
| 35 | +// AMDGPU-STATS-CHECK: "transient-memory-size": 0 |
| 36 | +// AMDGPU-STATS-CHECK: "dispatch-count": 1 |
| 37 | +// CPU-STATS-CHECK: "transient-memory-size": 0 |
| 38 | +// CPU-STATS-CHECK: "dispatch-count": 1 |
| 39 | +// |
| 40 | +// clang-format on |
| 41 | + |
| 42 | +#include <fusilli.h> |
| 43 | + |
| 44 | +#include "pointwise_utils.h" |
| 45 | + |
| 46 | +#include <iostream> |
| 47 | +#include <string> |
| 48 | + |
| 49 | +using namespace fusilli; |
| 50 | + |
| 51 | +int main(int argc, char **argv) { |
| 52 | + std::string mode = (argc > 1) ? argv[1] : "default"; |
| 53 | + |
| 54 | + auto status = testUnaryPointwiseAsmEmitter( |
| 55 | + "pointwise_asm_emitter_softplus_fwd", "pointwise_softplus_fwd", mode, |
| 56 | + PointwiseAttr::Mode::SOFTPLUS_FWD, {16, 256, 64, 32}); |
| 57 | + if (isError(status)) { |
| 58 | + std::cerr << "Test failed: " << status << std::endl; |
| 59 | + return 1; |
| 60 | + } |
| 61 | + return 0; |
| 62 | +} |
0 commit comments