MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / patch_float

Function patch_float

models/CLIP/clip/clip.py:180–194  ·  view source on GitHub ↗
(module)

Source from the content-addressed store, hash-verified

178 float_node = float_input.node()
179
180 def patch_float(module):
181 try:
182 graphs = [module.graph] if hasattr(module, "graph") else []
183 except RuntimeError:
184 graphs = []
185
186 if hasattr(module, "forward1"):
187 graphs.append(module.forward1.graph)
188
189 for graph in graphs:
190 for node in graph.findAllNodes("aten::to"):
191 inputs = list(node.inputs())
192 for i in [1, 2]: # dtype can be the second or third argument to aten::to()
193 if _node_get(inputs[i].node(), "value") == 5:
194 inputs[i].node().copyAttributes(float_node)
195
196 model.apply(patch_float)
197 patch_float(model.encode_image)

Callers 1

loadFunction · 0.85

Calls 1

_node_getFunction · 0.85

Tested by

no test coverage detected