MCPcopy Create free account
hub / github.com/CHENGY12/PLOT / patch_device

Function patch_device

plot-pp/clip/clip.py:136–148  ·  view source on GitHub ↗
(module)

Source from the content-addressed store, hash-verified

134 device_node = [n for n in device_holder.graph.findAllNodes("prim::Constant") if "Device" in repr(n)][-1]
135
136 def patch_device(module):
137 try:
138 graphs = [module.graph] if hasattr(module, "graph") else []
139 except RuntimeError:
140 graphs = []
141
142 if hasattr(module, "forward1"):
143 graphs.append(module.forward1.graph)
144
145 for graph in graphs:
146 for node in graph.findAllNodes("prim::Constant"):
147 if "value" in node.attributeNames() and str(node["value"]).startswith("cuda"):
148 node.copyAttributes(device_node)
149
150 model.apply(patch_device)
151 patch_device(model.encode_image)

Callers 1

loadFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected