MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / patch_float

Function patch_float

extract_clip/clip.py:172–186  ·  view source on GitHub ↗
(module)

Source from the content-addressed store, hash-verified

170 float_node = float_input.node()
171
172 def patch_float(module):
173 try:
174 graphs = [module.graph] if hasattr(module, "graph") else []
175 except RuntimeError:
176 graphs = []
177
178 if hasattr(module, "forward1"):
179 graphs.append(module.forward1.graph)
180
181 for graph in graphs:
182 for node in graph.findAllNodes("aten::to"):
183 inputs = list(node.inputs())
184 for i in [1, 2]: # dtype can be the second or third argument to aten::to()
185 if inputs[i].node()["value"] == 5:
186 inputs[i].node().copyAttributes(float_node)
187
188 model.apply(patch_float)
189 patch_float(model.encode_image)

Callers 1

loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected