Download code/tt_bevfusion/tt/kernels/epi2t_reader_rm.cpp from changh95/bevfusion-p150: direct link, hf CLI and curl.
- Browser
- Download file 2.44 kB
-
https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_reader_rm.cpp
- Command line
-
hf download hf://changh95/bevfusion-p150/code/tt_bevfusion/tt/kernels/epi2t_reader_rm.cpp
-
curl -L -o epi2t_reader_rm.cpp https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_reader_rm.cpp
2.44 kB
| // SPDX-License-Identifier: Apache-2.0 | |
| // Two-term conv epilogue, ROW_MAJOR form (tt/epi_kernel.py epilogue_2t_rm, OPT_PLAN D9), reader (RISCV_0). The math | |
| // of epi2t_compute.cpp is elementwise, so it runs on any fixed order of 1024 values: a "tile" here is RPC | |
| // consecutive rows of the NP fp32 ROW_MAJOR conv products (RPC * C == 1024), read row page by row page into CBs | |
| // 0 .. NP-1; the writer stores the results in the same order (ROW_MAJOR bf16 rows). No tilize, no reshape. | |
| // CT args: [0] per-core RT-arg count (P3), [1] NP, [2] RPC, [3] row bytes (C * 4), then the TensorAccessorArgs of | |
| // the three inputs (the third repeats the first for NP = 2). Common RT args: [addr_0 .. addr_{NP-1}]. | |
| // Per-core RT args: [c0, n] (chunk range; chunk c = rows c * RPC .. c * RPC + RPC - 1). | |
| constexpr uint32_t NP = get_compile_time_arg_val(1); | |
| constexpr uint32_t RPC = get_compile_time_arg_val(2); | |
| constexpr uint32_t RB = get_compile_time_arg_val(3); | |
| constexpr auto a0_args = TensorAccessorArgs<4>(); | |
| constexpr auto a1_args = TensorAccessorArgs<a0_args.next_compile_time_args_offset()>(); | |
| constexpr auto a2_args = TensorAccessorArgs<a1_args.next_compile_time_args_offset()>(); | |
| void kernel_main() { | |
| const uint32_t c0 = get_arg_val<uint32_t>(0); | |
| const uint32_t n = get_arg_val<uint32_t>(1); | |
| const auto a0 = TensorAccessor(a0_args, get_common_arg_val<uint32_t>(0), RB); | |
| const auto a1 = TensorAccessor(a1_args, get_common_arg_val<uint32_t>(1), RB); | |
| const auto a2 = TensorAccessor(a2_args, NP > 2 ? get_common_arg_val<uint32_t>(2) : 0, RB); | |
| for (uint32_t c = c0; c < c0 + n; ++c) { | |
| const uint32_t r0 = c * RPC; | |
| cb_reserve_back(0, 1); | |
| cb_reserve_back(1, 1); | |
| uint32_t w0 = get_write_ptr(0), w1 = get_write_ptr(1), w2 = 0; | |
| if constexpr (NP > 2) { | |
| cb_reserve_back(2, 1); | |
| w2 = get_write_ptr(2); | |
| } | |
| for (uint32_t j = 0; j < RPC; ++j) { | |
| noc_async_read(a0.get_noc_addr(r0 + j), w0 + j * RB, RB); | |
| noc_async_read(a1.get_noc_addr(r0 + j), w1 + j * RB, RB); | |
| if constexpr (NP > 2) { | |
| noc_async_read(a2.get_noc_addr(r0 + j), w2 + j * RB, RB); | |
| } | |
| } | |
| noc_async_read_barrier(); | |
| cb_push_back(0, 1); | |
| cb_push_back(1, 1); | |
| if constexpr (NP > 2) { | |
| cb_push_back(2, 1); | |
| } | |
| } | |
| } | |