MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / __call__

Method __call__

examples/community/run_tensorrt_controlnet.py:105–131  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

103 self.output_names = output_names
104
105 def __call__(self, **kwargs):
106 context = self.context
107 stream = self.stream
108 bindings = self.bindings
109
110 host_inputs = self.host_inputs
111 cuda_inputs = self.cuda_inputs
112 host_outputs = self.host_outputs
113 cuda_outputs = self.cuda_outputs
114
115 for idx, input_name in enumerate(self.input_names):
116 _input = kwargs[input_name]
117 np.copyto(host_inputs[idx], _input)
118 # transfer input data to the GPU
119 cuda.memcpy_htod_async(cuda_inputs[idx], host_inputs[idx], stream)
120
121 context.execute_async_v2(bindings=bindings, stream_handle=stream.handle)
122
123 result = {}
124 for idx, output_name in enumerate(self.output_names):
125 # transfer predictions back from the GPU
126 cuda.memcpy_dtoh_async(host_outputs[idx], cuda_outputs[idx], stream)
127 result[output_name] = host_outputs[idx]
128
129 stream.synchronize()
130
131 return result
132
133
134EXAMPLE_DOC_STRING = """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected