triton.extension.buffer.language.to_buffer

目录

triton.extension.buffer.language.to_buffer#

triton.extension.buffer.language.to_buffer(tensor: tl.tensor, space: address_space = 'None', bind_buffer: buffer = 'None', _semantic: None = 'None') → buffer#

Convert a tensor to a buffer.

参数:
  • tensor (tl.tensor) -- the tensor to convert.

  • space (address_space) -- the address space for the buffer (optional).

示例

import triton
import triton.language as tl
import triton.extension.buffer.language as bl
import triton.language.extra.cann.extension as al


@triton.jit
def to_buffer_kernel():
    a = tl.full((32, 2, 4), 0, dtype=tl.int64)
    a_buf = bl.to_buffer(a)
    b = tl.full((32, 2, 4), 0, dtype=tl.int64)
    b_buf = bl.to_buffer(b, al.ascend_address_space.UB)
    c = tl.full((32, 2, 4), 0, dtype=tl.int64)
    c_buf = bl.to_buffer(c, al.ascend_address_space.L1)

特殊说明

  • Address space must be one of UB, L1, L0A, L0B, L0C.

  • When using bind_buffer, tensor and bind_buffer must have identical shapes and element types.

  • A tensor cannot be bound to multiple buffers.