MCPcopy Create free account
hub / github.com/Monalissaa/DisenDiff / patch_device

Function patch_device

clip/clip.py:123–131  ·  view source on GitHub ↗
(module)

Source from the content-addressed store, hash-verified

121 device_node = [n for n in device_holder.graph.findAllNodes("prim::Constant") if "Device" in repr(n)][-1]
122
123 def patch_device(module):
124 graphs = [module.graph] if hasattr(module, "graph") else []
125 if hasattr(module, "forward1"):
126 graphs.append(module.forward1.graph)
127
128 for graph in graphs:
129 for node in graph.findAllNodes("prim::Constant"):
130 if "value" in node.attributeNames() and str(node["value"]).startswith("cuda"):
131 node.copyAttributes(device_node)
132
133 model.apply(patch_device)
134 patch_device(model.encode_image)

Callers 1

loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected