MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / unpack_tensor_to_dict

Function unpack_tensor_to_dict

bitsandbytes/utils.py:183–197  ·  view source on GitHub ↗

Unpack a torch tensor into a Python dictionary. Parameters: - tensor_data: The torch tensor containing the packed data. Returns: A Python dictionary containing the unpacked data.

(tensor_data)

Source from the content-addressed store, hash-verified

181
182
183def unpack_tensor_to_dict(tensor_data):
184 """
185 Unpack a torch tensor into a Python dictionary.
186
187 Parameters:
188 - tensor_data: The torch tensor containing the packed data.
189
190 Returns:
191 A Python dictionary containing the unpacked data.
192 """
193 json_bytes = bytes(tensor_data.cpu().numpy())
194 json_str = json_bytes.decode("utf-8")
195 unpacked_dict = json.loads(json_str)
196
197 return unpacked_dict
198
199
200LINEAR_8BIT_WEIGHTS_FORMAT_MAPPING = {"row": 0, "col32": 1, "col_turing": 2, "col_ampere": 3}

Callers 1

from_dictMethod · 0.90

Calls 1

cpuMethod · 0.45

Tested by

no test coverage detected