For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
sliced_add
def sliced_add[dtype: DType, //, target: StringSlice[ImmStaticOrigin]](c: TileTensor[dtype, Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[dtype, Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[dtype, Storage=b.Storage, address_space=b.address_space, linear_idx_type=b.linear_idx_type], lora_end_idx: TileTensor[DType.int64, Storage=lora_end_idx.Storage, address_space=lora_end_idx.address_space, linear_idx_type=lora_end_idx.linear_idx_type], ctx: DeviceContext)
Adds tensors a and b element-wise for rows < lora_end_idx, otherwise copies a.
This is used for LoRA where only some sequences have LoRA applied. For rows in [0, lora_end_idx): c = a + b For rows in [lora_end_idx, batch_seq_len): c = a
Args:
- βc (
TileTensor[dtype, Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output tensor. - βa (
TileTensor[dtype, Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type]): First input tensor. - βb (
TileTensor[dtype, Storage=b.Storage, address_space=b.address_space, linear_idx_type=b.linear_idx_type]): Second input tensor. - βlora_end_idx (
TileTensor[DType.int64, Storage=lora_end_idx.Storage, address_space=lora_end_idx.address_space, linear_idx_type=lora_end_idx.linear_idx_type]): Scalar tensor with end index of LoRA token portion (rows to apply add). - βctx (
DeviceContext): Device context for GPU operations.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!