Download code/tt_bevfusion/tt/kernels/epi2t_compute.cpp from changh95/bevfusion-p150: direct link, hf CLI and curl.
- Browser
- Download file 3.25 kB
-
https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_compute.cpp
- Command line
-
hf download hf://changh95/bevfusion-p150/code/tt_bevfusion/tt/kernels/epi2t_compute.cpp
-
curl -L -o epi2t_compute.cpp https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_compute.cpp
3.25 kB
| // SPDX-License-Identifier: Apache-2.0 | |
| // Two-term conv epilogue (tt/epi_kernel.py, OPT_PLAN B1), compute: per tile, the stock op sequence of TwoTermConv | |
| // (C17 Conv2d weight_terms=2 add, the lo-conv add with the fused ReLU, ttaw split_terms) in DEST, with the LLKs and | |
| // the order of the stock programs: | |
| // y = c0 + c1 add_binary_tile<NearestEven> (binary_ng's fp32 SFPU add) | |
| // y = y + c2 (NP == 3) add_binary_tile<NearestEven> | |
| // y = relu(y) (RELU) relu_tile (binary_ng's fused post activation) | |
| // hi = bf16(y) typecast_tile<Float32, Float16_b> (ttnn.typecast; fp32(hi) is exact) | |
| // lo = bf16(y - fp32(hi)) sub_binary_tile<NearestEven>, typecast_tile<Float32, Float16_b> | |
| // CT args: [0] per-core RT-arg count (P3), [1] NP (2 or 3), [2] RELU. Per-core RT args: [n, 0]. | |
| using namespace ckernel; | |
| constexpr uint32_t NP = get_compile_time_arg_val(1); | |
| constexpr uint32_t RELU = get_compile_time_arg_val(2); | |
| constexpr uint32_t cb_hi = 16, cb_lo = 17; | |
| void kernel_main() { | |
| const uint32_t n = get_arg_val<uint32_t>(0); | |
| if (n == 0) { | |
| return; | |
| } | |
| compute_kernel_hw_startup(0, cb_hi); | |
| for (uint32_t t = 0; t < n; ++t) { | |
| cb_wait_front(0, 1); | |
| cb_wait_front(1, 1); | |
| if constexpr (NP > 2) { | |
| cb_wait_front(2, 1); | |
| } | |
| tile_regs_acquire(); | |
| copy_init(0); | |
| copy_tile(0, 0, 0); | |
| copy_init(1); | |
| copy_tile(1, 0, 1); | |
| add_binary_tile_init(); | |
| add_binary_tile<ckernel::DstRoundingMode::NearestEven>(0, 1, 0); | |
| if constexpr (NP > 2) { | |
| copy_init(2); | |
| copy_tile(2, 0, 1); | |
| add_binary_tile_init(); | |
| add_binary_tile<ckernel::DstRoundingMode::NearestEven>(0, 1, 0); | |
| } | |
| if constexpr (RELU) { | |
| relu_tile_init(); | |
| relu_tile(0); | |
| } | |
| copy_dest_values_init(); | |
| copy_dest_values<DataFormat::Float32>(0, 1); | |
| typecast_tile_init<(uint32_t)DataFormat::Float32, (uint32_t)DataFormat::Float16_b>(); | |
| typecast_tile<(uint32_t)DataFormat::Float32, (uint32_t)DataFormat::Float16_b>(0); | |
| sub_binary_tile_init(); | |
| sub_binary_tile<ckernel::DstRoundingMode::NearestEven>(1, 0, 1); | |
| typecast_tile_init<(uint32_t)DataFormat::Float32, (uint32_t)DataFormat::Float16_b>(); | |
| typecast_tile<(uint32_t)DataFormat::Float32, (uint32_t)DataFormat::Float16_b>(1); | |
| cb_reserve_back(cb_hi, 1); | |
| cb_reserve_back(cb_lo, 1); | |
| tile_regs_commit(); | |
| tile_regs_wait(); | |
| pack_tile(0, cb_hi); | |
| pack_tile(1, cb_lo); | |
| tile_regs_release(); | |
| cb_push_back(cb_hi, 1); | |
| cb_push_back(cb_lo, 1); | |
| cb_pop_front(0, 1); | |
| cb_pop_front(1, 1); | |
| if constexpr (NP > 2) { | |
| cb_pop_front(2, 1); | |
| } | |
| } | |
| } | |