연산 지원 목록¶
torch_ha가 eager 경로에 등록하는 ATen 연산 99개를, 디바이스에서 실제로 어떻게 동작하는지에 따라 나눈
목록입니다. 모델 추론은 현재 torch.compile(backend="legato") 경로로 지원합니다.
해당 커버리지는 이 표가 아니라 legato resolver가 결정합니다.
Compile PyTorch Model with Legato를 참조하십시오.
LPU 등록도 PyTorch 합성(composite) 구현도 없는 연산은 디스패치 에러(NotImplementedError)를 냅니다.
합성 연산(transpose, permute, select, split, matmul 등)은 아래 연산으로 분해됩니다.
연산 §3.3을 보십시오.
표에는 실제로 등록한 변형만 싣습니다. functional·in-place 같은 나머지 변형은 torchgen과 PyTorch 공통 구현이 제공합니다.
1. torch.compile 경로를 위한 연산¶
텐서를 디바이스로 옮기고, view와 slice를 만들고, 값을 읽는 데 필요한 연산입니다. 커널 없이 동작하며, 텐서 레이아웃에 따라 제약이 있습니다.
| 연산 | 용도 |
|---|---|
aten::empty.memory_format |
torch.empty(..., device="lpu:0")로 디바이스 메모리에 텐서를 할당 |
aten::empty_strided |
stride를 지정해 할당. .to("lpu")와 출력 텐서 생성에 내부적으로 쓰임 |
aten::_copy_from |
copy_, .to(), .cpu()의 호스트↔디바이스, 디바이스 간 복사. 같은 디바이스 안의 복사는 조건이 맞으면 디바이스 copy 커널로 |
aten::_copy_from_and_resize |
출력 텐서의 크기를 입력에 맞춘 뒤 복사 |
aten::_to_copy |
.to(device)와 .to(dtype). dtype 변환은 호스트에서 수행 |
aten::clone |
clone()으로 같은 레이아웃(kind)의 새 텐서를 만듦 |
aten::view |
view()로 같은 스토리지를 다른 shape로 봄 |
aten::view.dtype |
view(dtype)로 같은 바이트를 다른 dtype으로 읽음 |
aten::_reshape_alias |
reshape()가 복사 없이 view로 끝날 때 쓰임 |
aten::_unsafe_view |
다른 연산이 결과를 view로 돌려줄 때 내부적으로 쓰임 |
aten::alias |
전체 범위 슬라이스처럼 같은 텐서를 가리키는 view를 만듦 |
aten::as_strided |
as_strided(). transpose 같은 stride view의 기반 |
aten::as_strided_ |
in-place as_strided_()로 텐서의 stride를 바꿈 |
aten::slice.Tensor |
x[a:b] 슬라이싱. 복사하지 않고 부모 스토리지를 가리킴. 디바이스 계산이 그대로 받는 슬라이스는 디바이스 시맨틱 §슬라이싱 |
aten::view_as_complex |
torch.view_as_complex로 실수 쌍을 복소수로 봄 (RoPE) |
aten::view_as_real |
torch.view_as_real로 복소수를 실수 쌍으로 봄 (RoPE) |
aten::set_.source_Storage |
set_(storage)로 텐서를 다른 스토리지에 연결 |
aten::set_.source_Storage_storage_offset |
set_(storage, offset, size, stride). torch.load 등이 사용 |
aten::set_.source_Tensor |
set_(tensor)로 다른 텐서의 스토리지를 공유 |
aten::resize_ |
resize_(). out=으로 받은 출력 버퍼의 크기를 조정 |
aten::_has_compatible_shallow_copy_type |
.data 대입 등에서 두 텐서 타입이 호환되는지 확인 |
aten::fill_.Scalar |
fill_(), torch.full. 1 MiB 이상은 디바이스 memset 커널로, 그 밖에는 호스트에서 채워 복사 |
aten::zero_ |
zero_(), torch.zeros. fill_(0)과 같은 경로 |
aten::arange.start_out |
torch.arange. 호스트에서 수열을 만들어 디바이스로 복사 |
aten::cat.out |
torch.cat. 각 입력을 출력의 해당 구간에 복사 |
aten::_local_scalar_dense |
.item()으로 원소 하나짜리 텐서의 값을 호스트로 읽음 |
2. eager mode 연산 (실험적)¶
bfloat16이고 미리 빌드된 shape일 때만 디바이스 커널로 실행됩니다. 그 밖의 dtype·shape은 NotImplementedError로
실패합니다. 출력을 포함한 모든 피연산자가 연속(contiguous)이어야 하며(mm의 가중치는 연속 가중치를
전치한 w.t()도 받습니다), 비연속 view는 먼저 .contiguous()를 호출하고,
디바이스 계산이 그대로 받지 않는 슬라이스(디바이스 시맨틱 §슬라이싱)는 .clone()을 호출하십시오.
연산 §3.1을 보십시오.
| 연산 | 용도 |
|---|---|
aten::add.out |
+, torch.add. 같은 shape, 행 broadcast, 스칼라 |
aten::sub.out |
-, torch.sub. 같은 shape, 행 broadcast, 스칼라 |
aten::mul.out |
*, torch.mul. 같은 shape, 행 broadcast, 스칼라 |
aten::mm.out |
@, torch.mm. bias 없는 nn.Linear도 여기로 옴 |
3. 등록되었으나 eager 디바이스 커널이 없는 연산¶
아래 두 스텁(multinomial, exponential_)을 제외하면 eager로 호출 시 NotImplementedError가 발생합니다. 모델 계산은 torch.compile 경로를 쓰십시오.
multinomial과 exponential_은 에러 없이 고정값을 돌려줍니다
디바이스 난수 생성이 아직 없어 이 둘은 dry-run용 스텁입니다. multinomial은 0을,
exponential_은 1을 채워 돌려주며 실패하지 않습니다. 실제 샘플링에 쓰지 마십시오.
| 연산 | 용도 |
|---|---|
aten::div.out |
/, torch.div |
aten::div.out_mode |
torch.div(..., rounding_mode="floor" | "trunc") |
aten::neg.out |
단항 -, torch.neg |
aten::pow.Scalar_out |
스칼라 ** 텐서 (예: RoPE의 base ** exp) |
aten::pow.Tensor_Scalar_out |
텐서 ** 스칼라 |
aten::pow.Tensor_Tensor_out |
텐서 ** 텐서 |
aten::floor_divide.out |
//, torch.floor_divide |
aten::remainder.Tensor_out |
%, torch.remainder |
aten::reciprocal.out |
torch.reciprocal, 1.0 / x |
aten::rsqrt.out |
torch.rsqrt. RMSNorm 등에서 쓰임 |
aten::abs.out |
abs(), torch.abs |
aten::clamp.out |
스칼라 경계의 clamp(min, max) |
aten::clamp.Tensor_out |
텐서 경계의 clamp(min, max) |
aten::clamp_min.out |
스칼라 경계의 clamp(min=...) |
aten::clamp_min.Tensor_out |
텐서 경계의 clamp(min=...) |
aten::silu.out |
nn.SiLU, F.silu |
aten::gelu.out |
nn.GELU, F.gelu |
aten::sigmoid.out |
torch.sigmoid, nn.Sigmoid |
aten::tanh.out |
torch.tanh, nn.Tanh |
aten::exp.out |
torch.exp |
aten::log.out |
torch.log |
aten::sin.out |
torch.sin. RoPE에서 쓰임 |
aten::cos.out |
torch.cos. RoPE에서 쓰임 |
aten::floor.out |
torch.floor |
aten::bmm.out |
torch.bmm과 배치 차원이 있는 @ |
aten::addmm.out |
torch.addmm. bias 있는 nn.Linear가 여기로 옴 |
aten::sum.IntList_out |
sum(dim) |
aten::mean.out |
mean(dim) |
aten::amax.out |
amax(dim) |
aten::argmax.out |
argmax(dim). greedy 샘플링에서 쓰임 |
aten::max.dim_max |
max(dim). 값과 인덱스를 함께 돌려줌 |
aten::min.dim_min |
min(dim). 값과 인덱스를 함께 돌려줌 |
aten::cumsum.out |
cumsum(dim) |
aten::_softmax.out |
softmax, F.softmax |
aten::_log_softmax.out |
log_softmax, F.log_softmax |
aten::eq.Scalar_out |
텐서와 스칼라의 == |
aten::eq.Tensor_out |
두 텐서의 == |
aten::lt.Scalar_out |
텐서와 스칼라의 < |
aten::lt.Tensor_out |
두 텐서의 < |
aten::le.Scalar_out |
텐서와 스칼라의 <= |
aten::le.Tensor_out |
두 텐서의 <= |
aten::gt.Scalar_out |
텐서와 스칼라의 > |
aten::gt.Tensor_out |
두 텐서의 > |
aten::ge.Scalar_out |
텐서와 스칼라의 >= |
aten::ge.Tensor_out |
두 텐서의 >= |
aten::bitwise_and.Tensor_out |
&. 마스크 결합에 쓰임 |
aten::bitwise_or.Tensor_out |
|. 마스크 결합에 쓰임 |
aten::bitwise_not.out |
~. 마스크 반전에 쓰임 |
aten::embedding |
nn.Embedding, F.embedding |
aten::index.Tensor |
텐서 인덱스로 읽기 x[idx] |
aten::index_select.out |
index_select(dim, index) |
aten::_index_put_impl_ |
텐서 인덱스로 쓰기 x[idx] = v |
aten::index_copy.out |
index_copy, index_copy_ |
aten::gather.out |
gather(dim, index) |
aten::scatter.src_out |
scatter(dim, index, src), scatter_ |
aten::scatter.value_out |
scatter(dim, index, value), scatter_ |
aten::scatter.reduce_out |
scatter(dim, index, src, reduce=...) |
aten::scatter.value_reduce_out |
scatter(dim, index, value, reduce=...) |
aten::scatter_add.out |
scatter_add, scatter_add_ |
aten::topk.values |
topk(k). top-k 샘플링에서 쓰임 |
aten::sort.values_stable |
sort() |
aten::nonzero.out |
nonzero(). 출력 크기가 데이터에 따라 달라짐 |
aten::where.self_out |
torch.where(cond, a, b) |
aten::masked_fill_.Scalar |
masked_fill_(mask, value). 어텐션 마스크 등에 쓰임 |
aten::flip |
flip(dims) |
aten::triu.out |
triu(). causal 마스크 생성에 쓰임 |
aten::tril.out |
tril(). causal 마스크 생성에 쓰임 |
aten::multinomial.out |
torch.multinomial. 에러 없이 0을 채워 돌려줌 |
aten::exponential_ |
exponential_(). 에러 없이 1을 채워 돌려줌 |