You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -48,17 +40,11 @@ class AdaptiveRKVDiversityCalculator {
48
40
OPENVINO_ASSERT(eviction_size % block_size == 0);
49
41
}
50
42
51
-
/** Divides the input rank-3 tensor into blocks along last two dimensions, performs the addition of the values
52
-
* inside each block and outputs each block sum into corresponding positions in the output tensor downsampled along
53
-
* the same dimensions. The output tensor dimensions are such that the query and key token dimensions are
54
-
* downsampled by `block_size` when compared to the *original* query and key tensors.
55
-
* @param attention_scores_data Pointer to the attention score input.
56
-
* @param attention_score_shape Shape of the attention score input tensor. Expected shape is [num_heads,
57
-
* num_query_tokens / stride, num_key_tokens / stride], where `num_query_tokens` and `num_key_tokens` must be
58
-
* multiples of `block_size`.
59
-
* @param out Pointer to the output tensor data (block sums)
60
-
* @param out_shape Shape of the output tensor data. Expected shape is [num_heads, num_query_tokens / block_size,
61
-
* num_key_tokens / block_size].
43
+
/** Fills the diagonal of each square matrix slice (at ranks 1 and 2, zero-based) of the input rank-3 tensor with
44
+
* a provided value. The operation is done in-place.
45
+
* @param in_out Pointer to the matrix data.
46
+
* @param in_out_shape Shape of the matrix data. Expected shape is [num_heads, token_dim, token_dim].
47
+
* @param val Value to fill in the diagonal positions.
62
48
*/
63
49
voidfill_diagonal_(T* in_out,
64
50
const Shape& in_out_shape,
@@ -77,6 +63,12 @@ class AdaptiveRKVDiversityCalculator {
77
63
}
78
64
}
79
65
66
+
/** For a rank-3 tensor, zeroes out the values that are less than the mean of the values of the corresponding slice at rank 2 (zero-based). Ranks 1 and 2 of the input tensor must be equal. Mean values are computed and provided externally. The operation is done in-place.
67
+
* @param in_out Pointer to the tensor data.
68
+
* @param in_out_shape Shape of the tensor data. Expected shape is [num_heads, token_dim, token_dim].
69
+
* @param means Pointer to the tensor data containing the means of each slice of the `in_out` tensor along its rank 2 (zero-based).
70
+
* @param means_shape Shape of the means tensor. Expected shape is [num_heads, token_dim].
71
+
*/
80
72
voidfill_low_values_with_zeros_(T* in_out,
81
73
const Shape& in_out_shape,
82
74
const T* means,
@@ -102,17 +94,23 @@ class AdaptiveRKVDiversityCalculator {
0 commit comments