Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/fusilli/attributes/pointwise_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace fusilli {
/* OP(MIN_OP) */ \
OP(MUL) \
/* OP(NEG) */ \
/* OP(RECIPROCAL) */ \
OP(RECIPROCAL) \
/* OP(RELU_BWD) */ \
OP(RELU_FWD) \
/* OP(RSQRT) */ \
Expand Down Expand Up @@ -139,6 +139,7 @@ inline const std::unordered_map<PointwiseAttr::Mode, int>
{PointwiseAttr::Mode::CMP_NEQ, 2},
{PointwiseAttr::Mode::DIV, 2},
{PointwiseAttr::Mode::MUL, 2},
{PointwiseAttr::Mode::RECIPROCAL, 1},
{PointwiseAttr::Mode::RELU_FWD, 1},
{PointwiseAttr::Mode::SIGMOID_FWD, 1},
{PointwiseAttr::Mode::SUB, 2},
Expand Down
1 change: 1 addition & 0 deletions include/fusilli/support/asm_emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ inline ErrorOr<std::string> PointwiseNode::emitNodePreAsm() const {
FUSILLI_DECLARE_BINARY_TORCH_EMITTER(CMP_NEQ, torch.aten.ne.Tensor)
FUSILLI_DECLARE_BINARY_TORCH_EMITTER(DIV, torch.aten.div.Tensor)
FUSILLI_DECLARE_BINARY_TORCH_EMITTER(MUL, torch.aten.mul.Tensor)
FUSILLI_DECLARE_UNARY_TORCH_EMITTER(RECIPROCAL, torch.aten.reciprocal)
FUSILLI_DECLARE_UNARY_TORCH_EMITTER(RELU_FWD, torch.aten.relu)
FUSILLI_DECLARE_UNARY_TORCH_EMITTER(SIGMOID_FWD, torch.aten.sigmoid)
FUSILLI_DECLARE_UNARY_TORCH_EMITTER(TANH_FWD, torch.aten.tanh)
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ add_fusilli_lit_tests(
lit/test_pointwise_asm_emitter_div.cpp
lit/test_pointwise_asm_emitter_mul.cpp
lit/test_pointwise_asm_emitter_mul_scalar.cpp
lit/test_pointwise_asm_emitter_reciprocal.cpp
lit/test_pointwise_asm_emitter_sigmoid.cpp
lit/test_pointwise_asm_emitter_tanh.cpp
lit/test_pointwise_asm_emitter_sub.cpp
Expand Down
60 changes: 60 additions & 0 deletions tests/lit/test_pointwise_asm_emitter_reciprocal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2026 Advanced Micro Devices, Inc.
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// RUN: %{TEST_EXE} | iree-opt --verify-roundtrip
// RUN: %{TEST_EXE} | FileCheck %s --check-prefix=TORCH-CHECK
// RUN: %{TEST_EXE} stats | FileCheck %s --check-prefix=%{BACKEND}-STATS-CHECK

// clang-format off
//
// TORCH-CHECK: module @module {
// 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} {
// TORCH-CHECK: %[[PERM0_0:.+]] = torch.constant.int 0
// TORCH-CHECK: %[[PERM0_1:.+]] = torch.constant.int 1
// TORCH-CHECK: %[[PERM0_2:.+]] = torch.constant.int 2
// TORCH-CHECK: %[[PERM0_3:.+]] = torch.constant.int 3
// 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>
// 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>
// TORCH-CHECK: %[[RECIPROCAL:.+]] = torch.aten.reciprocal %[[PERMUTE0]] : !torch.vtensor<[16,256,64,32],f32> -> !torch.vtensor<[16,256,64,32],f32>
// TORCH-CHECK: %[[PERM_OUT_0:.+]] = torch.constant.int 0
// TORCH-CHECK: %[[PERM_OUT_1:.+]] = torch.constant.int 1
// TORCH-CHECK: %[[PERM_OUT_2:.+]] = torch.constant.int 2
// TORCH-CHECK: %[[PERM_OUT_3:.+]] = torch.constant.int 3
// 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>
// 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>
// TORCH-CHECK: torch.overwrite.tensor.contents %[[PERM_OUT]] overwrites %[[RESULT0]] : !torch.vtensor<[16,256,64,32],f32>, !torch.tensor<[16,256,64,32],f32>
// TORCH-CHECK: return
// TORCH-CHECK: }
// TORCH-CHECK: }
//
// AMDGPU-STATS-CHECK: "transient-memory-size": 0
// AMDGPU-STATS-CHECK: "dispatch-count": 1
// CPU-STATS-CHECK: "transient-memory-size": 0
// CPU-STATS-CHECK: "dispatch-count": 1
//
// clang-format on

#include <fusilli.h>

#include "utils.h"

#include <iostream>
#include <string>

using namespace fusilli;

int main(int argc, char **argv) {
std::string mode = (argc > 1) ? argv[1] : "default";

auto status = testUnaryPointwiseAsmEmitter(
"pointwise_asm_emitter_reciprocal", "reciprocal", mode,
PointwiseAttr::Mode::RECIPROCAL, {16, 256, 64, 32});
if (isError(status)) {
std::cerr << "Test failed: " << status << std::endl;
return 1;
}
return 0;
}
Loading