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

Function patch_device

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

Source from the content-addressed store, hash-verified

146 device_node = [n for n in device_holder.graph.findAllNodes("prim::Constant") if "Device" in repr(n)][-1]
147
148 def patch_device(module):
149 try:
150 graphs = [module.graph] if hasattr(module, "graph") else []
151 except RuntimeError:
152 graphs = []
153
154 if hasattr(module, "forward1"):
155 graphs.append(module.forward1.graph)
156
157 for graph in graphs:
158 for node in graph.findAllNodes("prim::Constant"):
159 if "value" in node.attributeNames() and str(node["value"]).startswith("cuda"):
160 node.copyAttributes(device_node)
161
162 model.apply(patch_device)
163 patch_device(model.encode_image)

Callers 1

loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected