MCPcopy Create free account
hub / github.com/pytorch/executorch / get_program_info

Function get_program_info

backends/qualcomm/utils/utils.py:234–277  ·  view source on GitHub ↗
(program)

Source from the content-addressed store, hash-verified

232 # check if user specifies to use multi_contexts
233 # this is a generic approach in case there exists multiple backends
234 def get_program_info(program):
235 def process_exported_program(prog):
236 max_sf_buf_size, module_map = 0, {}
237 for _, m in prog.graph_module._modules.items():
238 # currently only 1 compile spec is expected in each partition
239 options = flatbuffer_to_option(m.compile_specs[0].value)
240 if (
241 options.backend_options.backend_type
242 == QnnExecuTorchBackendType.kHtpBackend
243 and options.backend_options.htp_options.use_multi_contexts
244 ):
245 qnn_mgr = PyQnnManagerAdaptor.QnnManager(
246 m.compile_specs[0].value, m.processed_bytes
247 )
248 assert (
249 qnn_mgr.InitBackend().value == 0
250 ), "failed to initialize backend"
251 assert (
252 qnn_mgr.InitContextCache().value == 0
253 ), "failed to init context cache"
254 max_sf_buf_size = max(
255 max_sf_buf_size, qnn_mgr.GetSpillFillBufferSize()
256 )
257 module_map[m] = options
258 qnn_mgr.Destroy()
259 return max_sf_buf_size, module_map
260
261 def process_lowered_module(module):
262 qnn_mgr = PyQnnManagerAdaptor.QnnManager(
263 module.compile_specs[0].value, module.processed_bytes
264 )
265 assert qnn_mgr.InitBackend().value == 0, "failed to initialize backend"
266 assert qnn_mgr.InitContextCache().value == 0, "failed to init context cache"
267 spill_fill_size = qnn_mgr.GetSpillFillBufferSize()
268 qnn_mgr.Destroy()
269 return spill_fill_size, {
270 module: flatbuffer_to_option(module.compile_specs[0].value)
271 }
272
273 dispatch = {
274 ExportedProgram: process_exported_program,
275 LoweredBackendModule: process_lowered_module,
276 }
277 return dispatch[type(program)](program)
278
279 def update_program(max_sf_buf_size, module_map):
280 def set_spec(module, options):

Callers 1

update_spill_fill_sizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected