-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Ticket #16174 ### Problem description Subtraction of int32 dtype was not supported on WHB0 and BH. ### What's changed Added necessary APIs, LLKs, and modified codepaths to include sub int32 operation. This operation was done through SFPU. ### Checklist - [x] Post commit CI passes - [x] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [ ] **(For models and ops writers)** Full [new models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml) tests passes - [x] New/Existing tests provide coverage for changes
- Loading branch information
1 parent
0ef76c0
commit 64e4bad
Showing
11 changed files
with
180 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tt_metal/hw/ckernels/blackhole/metal/llk_api/llk_sfpu/ckernel_sfpu_sub_int32.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "ckernel.h" | ||
#include "ckernel_defs.h" | ||
#include "sfpi.h" | ||
|
||
using namespace sfpi; | ||
|
||
namespace ckernel { | ||
namespace sfpu { | ||
|
||
template <bool APPROXIMATION_MODE, bool SIGN_MAGNITUDE_FORMAT, int ITERATIONS = 8> | ||
inline void calculate_sub_int32(const uint dst_offset) { | ||
_sub_int32_<APPROXIMATION_MODE, SIGN_MAGNITUDE_FORMAT, ITERATIONS>(dst_offset); | ||
} | ||
|
||
} // namespace sfpu | ||
} // namespace ckernel |
27 changes: 27 additions & 0 deletions
27
...tal/hw/ckernels/blackhole/metal/llk_api/llk_sfpu/llk_math_eltwise_binary_sfpu_sub_int32.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "llk_math_eltwise_binary_sfpu_init.h" | ||
#include "llk_math_eltwise_binary_sfpu_params.h" | ||
#include "ckernel_sfpu_sub_int32.h" | ||
|
||
namespace ckernel { | ||
|
||
// New LLK SFPU APIs | ||
|
||
template <bool APPROXIMATE> | ||
inline void llk_math_eltwise_binary_sfpu_sub_int32_init() { | ||
llk_math_eltwise_binary_sfpu_init<SfpuType::unused, APPROXIMATE>(); | ||
} | ||
|
||
template <bool APPROXIMATE, bool SIGN_MAGNITUDE_FORMAT> | ||
inline void llk_math_eltwise_binary_sfpu_sub_int32( | ||
uint dst_index0, uint32_t dst_index1, int vector_mode = VectorMode::RC) { | ||
llk_math_eltwise_binary_sfpu_params<APPROXIMATE>( | ||
ckernel::sfpu::calculate_sub_int32<APPROXIMATE, SIGN_MAGNITUDE_FORMAT>, dst_index0, dst_index1, vector_mode); | ||
} | ||
|
||
} // namespace ckernel |
22 changes: 22 additions & 0 deletions
22
tt_metal/hw/ckernels/wormhole_b0/metal/llk_api/llk_sfpu/ckernel_sfpu_sub_int32.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "ckernel.h" | ||
#include "ckernel_defs.h" | ||
#include "sfpi.h" | ||
|
||
using namespace sfpi; | ||
|
||
namespace ckernel { | ||
namespace sfpu { | ||
|
||
template <bool APPROXIMATION_MODE, bool SIGN_MAGNITUDE_FORMAT, int ITERATIONS = 8> | ||
inline void calculate_sub_int32(const uint dst_offset) { | ||
_sub_int32_<APPROXIMATION_MODE, SIGN_MAGNITUDE_FORMAT, ITERATIONS>(dst_offset); | ||
} | ||
|
||
} // namespace sfpu | ||
} // namespace ckernel |
27 changes: 27 additions & 0 deletions
27
...l/hw/ckernels/wormhole_b0/metal/llk_api/llk_sfpu/llk_math_eltwise_binary_sfpu_sub_int32.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "llk_math_eltwise_binary_sfpu_init.h" | ||
#include "llk_math_eltwise_binary_sfpu_params.h" | ||
#include "ckernel_sfpu_sub_int32.h" | ||
|
||
namespace ckernel { | ||
|
||
// New LLK SFPU APIs | ||
|
||
template <bool APPROXIMATE> | ||
inline void llk_math_eltwise_binary_sfpu_sub_int32_init() { | ||
llk_math_eltwise_binary_sfpu_init<SfpuType::unused, APPROXIMATE>(); | ||
} | ||
|
||
template <bool APPROXIMATE, bool SIGN_MAGNITUDE_FORMAT> | ||
inline void llk_math_eltwise_binary_sfpu_sub_int32( | ||
uint dst_index0, uint32_t dst_index1, int vector_mode = VectorMode::RC) { | ||
llk_math_eltwise_binary_sfpu_params<APPROXIMATE>( | ||
ckernel::sfpu::calculate_sub_int32<APPROXIMATE, SIGN_MAGNITUDE_FORMAT>, dst_index0, dst_index1, vector_mode); | ||
} | ||
|
||
} // namespace ckernel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "compute_kernel_api/common_globals.h" | ||
#ifdef TRISC_MATH | ||
#include "llk_math_eltwise_binary_sfpu_sub_int32.h" | ||
#define MAIN math_main() | ||
#define MATH(x) x | ||
#else | ||
#define MATH(x) | ||
#endif | ||
|
||
namespace ckernel { | ||
|
||
// clang-format off | ||
/** | ||
* Performs an elementwise sub operation with the two integer inputs: y = sub(x0,x1) | ||
* Output overwrites first operand in DST. | ||
* | ||
* 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. | ||
* A maximum of 4 tiles from each operand can be loaded into DST at once, for a total of 8 tiles, | ||
* when using 16 bit formats. This gets reduced to 2 tiles from each operand for 32 bit formats. | ||
* | ||
* Return value: None | ||
* | ||
* | Argument | Description | Type | Valid Range | Required | | ||
* |-----------------------|-----------------------------------------------------------------------------|----------|-------------------------------------------------------|----------| | ||
* | idst0 | The index of the tile in DST register buffer to use as first operand | uint32_t | Must be less than the size of the DST register buffer | True | | ||
* | idst1 | The index of the tile in DST register buffer to use as second operand | uint32_t | Must be less than the size of the DST register buffer | True | | ||
* | sign_magnitude_format | Whether the Int32 values are in sign-magnitude format (not 2's complement) | bool | | False | | ||
*/ | ||
// clang-format on | ||
template <bool sign_magnitude_format = false> | ||
ALWI void sub_int32_tile(uint32_t idst0, uint32_t idst1) { | ||
MATH((llk_math_eltwise_binary_sfpu_sub_int32<APPROX, sign_magnitude_format>(idst0, idst1))); | ||
} | ||
|
||
/** | ||
* Please refer to documentation for any_init. | ||
*/ | ||
ALWI void sub_int32_tile_init() { MATH((llk_math_eltwise_binary_sfpu_sub_int32_init<APPROX>())); } | ||
|
||
} // namespace ckernel |
Submodule tt_llk_blackhole
updated
2 files
+1 −0 | common/inc/ckernel_sfpu.h | |
+67 −0 | common/inc/sfpu/ckernel_sfpu_sub_int32.h |
Submodule tt_llk_wormhole_b0
updated
2 files
+1 −0 | common/inc/ckernel_sfpu.h | |
+46 −0 | common/inc/sfpu/ckernel_sfpu_sub_int32.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters