Skip to content

Commit

Permalink
#13385: Low-level interface for ttnn.round on Wormhole
Browse files Browse the repository at this point in the history
  • Loading branch information
jdh8 committed Oct 16, 2024
1 parent ddc42a1 commit 7ec2b44
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
#include "llk_math_eltwise_unary_sfpu_signbit.h"
#include "llk_math_eltwise_unary_sfpu_floor.h"
#include "llk_math_eltwise_unary_sfpu_ceil.h"
#include "llk_math_eltwise_unary_sfpu_round.h"
#include "llk_math_eltwise_unary_sfpu_silu.h"
#include "llk_math_eltwise_unary_sfpu_square.h"
#include "llk_math_eltwise_unary_sfpu_tanh.h"
#include "llk_math_eltwise_unary_sfpu_topk.h"
#include "llk_math_eltwise_unary_sfpu_unary_comp.h"
#include "llk_math_eltwise_unary_sfpu_trigonometry.h"
#include "llk_math_eltwise_unary_sfpu_unary_comp.h"
#include "llk_math_eltwise_unary_sfpu_remainder.h"
#include "llk_math_eltwise_unary_sfpu_bitwise_xor.h"
#include "llk_math_eltwise_unary_sfpu_bitwise_not.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "llk_math_eltwise_unary_sfpu_init.h"
#include "llk_math_eltwise_unary_sfpu_params.h"
#include "ckernel_sfpu_round.h"

namespace ckernel {

// New LLK SFPU APIs

template <bool APPROXIMATE>
inline void llk_math_eltwise_unary_sfpu_round_init() {
llk_math_eltwise_unary_sfpu_init<SfpuType::round, APPROXIMATE>();
}

template <bool APPROXIMATE>
inline void llk_math_eltwise_unary_sfpu_round(uint dst_index, int vector_mode = (int)VectorMode::RC) {
llk_math_eltwise_unary_sfpu_params<APPROXIMATE>
(ckernel::sfpu::calculate_round<APPROXIMATE>,
dst_index, vector_mode);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ enum SfpuType {
ceil,
unused,
reshuffle_rows,
cumsum
cumsum,
round,
};
45 changes: 45 additions & 0 deletions tt_metal/include/compute_kernel_api/eltwise_unary/round.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

#pragma once


#include "compute_kernel_api/common_globals.h"
#ifdef TRISC_MATH
#include "llk_math_eltwise_unary_sfpu_round.h"
#define MAIN math_main()
#define MATH(x) x
#else
#define MATH(x)
#endif



namespace ckernel {

/**
* Please refer to documentation for any_init.
*/
ALWI void round_tile_init() {
MATH(( llk_math_eltwise_unary_sfpu_round_init<APPROX>() ));
}

/**
* Performs round operation on each row of a tile.
* in DST register at index tile_index. The DST register buffer must be in
* acquired state via *acquire_dst* call. This call is blocking and is only
* available on the compute engine.
*
* Return value: None
*
* | Argument | Description | Type | Valid Range | Required |
* |-----------------|----------------------------------------------------------------------------|----------|-------------------------------------------------------|----------|
* | idst | The index of the tile in DST register buffer to modify the sign bit of | uint32_t | Must be less than the size of the DST register buffer | True |
*/
ALWI void round_tile(uint32_t idst) {
MATH(( llk_math_eltwise_unary_sfpu_round<APPROX>(idst) ));
}


} // namespace ckernel
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
#include "compute_kernel_api/eltwise_unary/floor.h"
#endif

#if SFPU_OP_ROUND_INCLUDE
#include "compute_kernel_api/eltwise_unary/round.h"
#endif

#if SFPU_OP_LEFT_SHIFT_INCLUDE
#include "compute_kernel_api/eltwise_unary/left_shift.h"
#endif
Expand Down

0 comments on commit 7ec2b44

Please sign in to comment.