MCPcopy
hub / github.com/city96/ComfyUI-GGUF / get_orig_shape

Function get_orig_shape

loader.py:16–24  ·  view source on GitHub ↗
(reader, tensor_name)

Source from the content-addressed store, hash-verified

14VIS_TYPE_LIST = {"clip-vision", "mmproj"}
15
16def get_orig_shape(reader, tensor_name):
17 field_key = f"comfy.gguf.orig_shape.{tensor_name}"
18 field = reader.get_field(field_key)
19 if field is None:
20 return None
21 # Has original shape metadata, so we try to decode it.
22 if len(field.types) != 2 or field.types[0] != gguf.GGUFValueType.ARRAY or field.types[1] != gguf.GGUFValueType.INT32:
23 raise TypeError(f"Bad original shape metadata for {field_key}: Expected ARRAY of INT32, got {field.types}")
24 return torch.Size(tuple(int(field.parts[part_idx][0]) for part_idx in field.data))
25
26def get_field(reader, field_name, field_type):
27 field = reader.get_field(field_name)

Callers 1

gguf_sd_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected