MCPcopy Create free account
hub / github.com/apache/tvm / np_float2np_bf16

Function np_float2np_bf16

tests/python/codegen/test_target_codegen_cuda.py:118–123  ·  view source on GitHub ↗

Convert a numpy array of float to a numpy array of bf16 in uint16

(arr)

Source from the content-addressed store, hash-verified

116 num_thread = 8
117
118 def np_float2np_bf16(arr):
119 """Convert a numpy array of float to a numpy array
120 of bf16 in uint16"""
121 orig = arr.view("<u4")
122 bias = np.bitwise_and(np.right_shift(orig, 16), 1) + 0x7FFF
123 return np.right_shift(orig + bias, 16).astype("uint16")
124
125 def np_bf162np_float(arr):
126 """Convert a numpy array of bf16 (uint16) to a numpy array

Callers 1

check_cudaFunction · 0.85

Calls 2

viewMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…