# Offsets on mps kernel indexing

**URL:** <https://dev-discuss.pytorch.org/t/offsets-on-mps-kernel-indexing/1426>\
**Category:** Uncategorized\
**Created:** [August 8, 2023, 6:58pm UTC](https://dev-discuss.pytorch.org/t/offsets-on-mps-kernel-indexing/1426 "2023-08-08T18:58:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunppsg](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/arunppsg/32/1146_2.png) [@arunppsg](https://dev-discuss.pytorch.org/u/arunppsg)\
**Post date:** [August 8, 2023, 6:58pm UTC](https://dev-discuss.pytorch.org/t/offsets-on-mps-kernel-indexing/1426/1 "2023-08-08T18:58:11Z")

</div>

I am trying to understand kernel indexing for MPS backend in pytorch. I have two questions:

1. Though `kernel_index_offsets` recieves `num_offsets` argument, it is not using it. Am I overlooking something here?

> <https://github.com/pytorch/pytorch/blob/2764ead4296541b324ae0e8e2b6200eec0e90c4e/aten/src/ATen/mps/IndexKernels.h#L211-L225>

1. Why is `nOffsets` assigned 3 in the following line:

> <https://github.com/pytorch/pytorch/blob/2764ead4296541b324ae0e8e2b6200eec0e90c4e/aten/src/ATen/native/mps/operations/BinaryKernel.mm#L179-L179>

Apologies if this question is out of place here. I am interested in contributing to pytorch (in this [General MPS op coverage tracking issue · Issue #77764 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/77764)) and working towards getting an understanding of the codebase.

---

<div class="post-metadata">

**Author:** ![qqaatw](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/qqaatw/32/1352_2.png) [@qqaatw](https://dev-discuss.pytorch.org/u/qqaatw)\
**Post date:** [August 13, 2023, 7:28am UTC](https://dev-discuss.pytorch.org/t/offsets-on-mps-kernel-indexing/1426/2 "2023-08-13T07:28:39Z")

</div>

Hi,

For your questions:

1. Yes it is indeed not being used as this kernel assumes the number of offsets being 3 (you can see the data type of `data_offsets`, which is `uint3`).

2. The kernel was originally designed for handling binary operations, i.e. binary inputs, so the offsets represent `input(self)`, `other`, and `output`, respectively.
