Triton 是一種用於並行編程的語言和編譯器。它旨在提供一個基於 Python 的編程環境,以高效編寫自定義 DNN 計算內核,並能夠在現代 GPU 硬件上以最大吞吐量運行。
更多 Triton 中文文檔可訪問 →https://triton.hyper.ai/
triton.language.broadcast_to(input, *shape)
嘗試將給定的張量廣播到新的 shape。
參數:
- input (Block) - 輸入張量。
- shape - 所需的形狀。
shape 可以以 1 個元組或獨立參數被傳入:
# These are equivalent
# 這些是等效的
broadcast_to(x, (32, 32))
broadcast_to(x, 32, 32)
該函數也可作為 tensor 的 1 個成員函數調用,使用 x.broadcast_to(...) 而不是 broadcast_to(x, ...)。