Download code/hamer/kernels/eltwise/writer.cpp from changh95/hamer-p150: direct link, hf CLI and curl.
- Browser
- Download file 961 Bytes
-
https://huggingface.co/changh95/hamer-p150/resolve/main/code/hamer/kernels/eltwise/writer.cpp
- Command line
-
hf download hf://changh95/hamer-p150/code/hamer/kernels/eltwise/writer.cpp
-
curl -L -o writer.cpp https://huggingface.co/changh95/hamer-p150/resolve/main/code/hamer/kernels/eltwise/writer.cpp
961 Bytes
| // SPDX-FileCopyrightText: © 2026 Tenstorrent Inc. | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // Unary eltwise writer: cb 16 -> destination pages [start, start+n), one tile at a time. | |
| // compile-time: TensorAccessorArgs(dst). runtime: dst_addr, start, n | |
| void kernel_main() { | |
| const uint32_t dst_addr = get_arg_val<uint32_t>(0); | |
| const uint32_t start = get_arg_val<uint32_t>(1); | |
| const uint32_t n = get_arg_val<uint32_t>(2); | |
| constexpr auto dst_args = TensorAccessorArgs<0>(); | |
| constexpr uint32_t cb = 16; | |
| const uint32_t page = get_local_cb_interface(cb).fifo_page_size; | |
| const auto dst = TensorAccessor(dst_args, dst_addr, page); | |
| for (uint32_t i = 0; i < n; ++i) { | |
| cb_wait_front(cb, 1); | |
| noc_async_write(get_read_ptr(cb), dst.get_noc_addr(start + i), page); | |
| noc_async_writes_flushed(); | |
| cb_pop_front(cb, 1); | |
| } | |
| noc_async_write_barrier(); | |
| } | |