Skip to content

Commit 4efaea1

Browse files
add note
1 parent f767c3e commit 4efaea1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

onnxscript/rewriter/ort_fusions/cos_sin_cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def _compute_dynamic_freqs(self, op, inv_freq, position_ids, dtype):
9696

9797
# If we do not compute max_pos_id using ONNX ops, use inv_freq and position_ids
9898
# to compute angles and cos/sin values
99+
# Note: The one is added to max_pos_id as position_ids are 0-indexed
100+
# and the range of position ids should be [0, max_pos_id], max_pos_id inclusive.
99101
inv_freq_values = inv_freq.const_value.numpy().reshape(1, -1)
100102
pos_id_range = np.arange(max_pos_id + 1, dtype=np.float32).reshape(-1, 1)
101103
angles = np.matmul(pos_id_range, inv_freq_values)

0 commit comments

Comments
 (0)