Skip to content

Commit

Permalink
Merge pull request #2991 from vespa-engine/arnej/document-unpack-bits
Browse files Browse the repository at this point in the history
add documentation for unpack_bits macro
  • Loading branch information
kkraune authored Nov 15, 2023
2 parents 6eeeafb + 97260b4 commit f98fe98
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions en/reference/ranking-expressions.html
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,42 @@ <h3 id="non-primitive-functions">Non-primitive functions</h3>
<p>The hyperbolic tangent of each element.</p>
</td>
</tr>
<tr>
<th>unpack_bits(t)</th>
<td>
<p id="unpack-bits">unpacks bits from int8 input to 8 times as many floats</p>
<p>The innermost indexed dimension will expand to have 8 times as many cells,
each with a float value of either 0.0 or 1.0 determined by one bit in
the 8-bit input value. Comparable to <code>numpy.unpackbits</code>
which gives the same basic functionality.
A minimal input such as <code>tensor&lt;int8&gt;(x[1]):[9]</code>
would give output <code>tensor&lt;float&gt;(x[8]):[0,0,0,0,1,0,0,1]</code>
(default bit-order is big-endian).
As a very complex example, an input with type <code>tensor&lt;int8&gt;(foo{},x[3],y[11],z{})</code>
will produce output with type <code>tensor&lt;float&gt;(foo{},x[3],y[88],z{})</code>
where "foo", "x" and "z" are unchanged, as "y" is the innermost indexed dimension.
</p>
</td>
</tr>
<tr>
<th>unpack_bits(t, cell_type)</th>
<td>
<p id="unpack-bits-cell-type">unpacks bits from int8 input to 8 times as many values</p>
<p>Same as above, but with optionally different cell_type (could be <code>double</code>
for example, if you will combine the output with other tensors using
double).
</p>
</td>
</tr>
<tr>
<th>unpack_bits(t, cell_type, endian)</th>
<td>
<p id="unpack-bits-cell-type-endian">unpacks bits from int8 input to 8 times as many values</p>
<p>Same as above, but also optionally different endian for the bits; must be
either <code>big</code> (default) or <code>little</code>.
</p>
</td>
</tr>
<tr>
<th>xw_plus_b(x, w, b, dim)</th>
<td>
Expand Down

0 comments on commit f98fe98

Please sign in to comment.