Home / Class/ alignment Class — pytorch Architecture

alignment Class — pytorch Architecture

Architecture documentation for the alignment class in attention.cpp from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/native/transformers/attention.cpp lines 572–586

template<int alignment>
bool aligned_tensor(const at::Tensor& tensor){
  for(const auto i : c10::irange(tensor.dim() - 1)){
    auto stride = tensor.sym_stride(i).maybe_as_int();
    // If the stride is unknown at compilation time, assume it is unaligned
    // and always pad it. This is helpful to avoid unnecessary guards.
    if (!stride)
      return false;

    if((*stride) % alignment != 0){
      return false;
    }
  }
  return tensor.sym_stride(-1) == 1;
}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free