Download code/tt_bevfusion/tt/kernels/epi2t_reader.cpp from changh95/bevfusion-p150: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_reader.cpp
- Command line
-
hf download hf://changh95/bevfusion-p150/code/tt_bevfusion/tt/kernels/epi2t_reader.cpp
-
curl -L -o epi2t_reader.cpp https://huggingface.co/changh95/bevfusion-p150/resolve/main/code/tt_bevfusion/tt/kernels/epi2t_reader.cpp
2.41 kB
| // SPDX-License-Identifier: Apache-2.0 | |
| // Two-term conv epilogue (tt/epi_kernel.py, OPT_PLAN B1), reader (RISCV_0): for each tile of this core's contiguous | |
| // range, the same tile of the NP fp32 conv products (NP = 2 or 3) into CBs 0 .. NP-1, one read barrier per tile. | |
| // CT args: [0] per-core RT-arg count (P3), [1] NP, [2] CT (output column tiles), [3 + 2i] / [4 + 2i] the column | |
| // tiles / the column-tile offset of input i (i < 3; B1n: two parts may be column halves of one tensor), then the | |
| // TensorAccessorArgs of the three inputs. Output tile t = (r, c) reads tile r * W_i + O_i + c of input i. | |
| // Common RT args: [addr_0 .. addr_{NP-1}]. Per-core RT args: [t0, n] (flattened tile indices). | |
| constexpr uint32_t NP = get_compile_time_arg_val(1); | |
| constexpr uint32_t CT = get_compile_time_arg_val(2); | |
| constexpr uint32_t W0 = get_compile_time_arg_val(3), O0 = get_compile_time_arg_val(4); | |
| constexpr uint32_t W1 = get_compile_time_arg_val(5), O1 = get_compile_time_arg_val(6); | |
| constexpr uint32_t W2 = get_compile_time_arg_val(7), O2 = get_compile_time_arg_val(8); | |
| constexpr auto a0_args = TensorAccessorArgs<9>(); | |
| constexpr auto a1_args = TensorAccessorArgs<a0_args.next_compile_time_args_offset()>(); | |
| constexpr auto a2_args = TensorAccessorArgs<a1_args.next_compile_time_args_offset()>(); | |
| constexpr uint32_t TB = 4096; | |
| void kernel_main() { | |
| const uint32_t t0 = 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), TB); | |
| const auto a1 = TensorAccessor(a1_args, get_common_arg_val<uint32_t>(1), TB); | |
| const auto a2 = TensorAccessor(a2_args, NP > 2 ? get_common_arg_val<uint32_t>(2) : 0, TB); | |
| for (uint32_t t = t0; t < t0 + n; ++t) { | |
| const uint32_t r = t / CT, c = t % CT; | |
| cb_reserve_back(0, 1); | |
| cb_reserve_back(1, 1); | |
| noc_async_read(a0.get_noc_addr(r * W0 + O0 + c), get_write_ptr(0), TB); | |
| noc_async_read(a1.get_noc_addr(r * W1 + O1 + c), get_write_ptr(1), TB); | |
| if constexpr (NP > 2) { | |
| cb_reserve_back(2, 1); | |
| noc_async_read(a2.get_noc_addr(r * W2 + O2 + c), get_write_ptr(2), TB); | |
| } | |
| noc_async_read_barrier(); | |
| cb_push_back(0, 1); | |
| cb_push_back(1, 1); | |
| if constexpr (NP > 2) { | |
| cb_push_back(2, 1); | |
| } | |
| } | |
| } | |