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

Class Model

backends/qualcomm/utils/utils.py:828–852  ·  view source on GitHub ↗

The args of forward() can be thought of as what executorch is accepting as input. The getattr inside the forward() can be thought of as qnn context binary. When we first pass in the input, we need to use the executorch's(nn.module) input order. After

Source from the content-addressed store, hash-verified

826
827 # model architecture mimicking context binary
828 class Model(torch.nn.Module):
829 """
830 The args of forward() can be thought of as what executorch is accepting as input.
831 The getattr inside the forward() can be thought of as qnn context binary.
832 When we first pass in the input, we need to use the executorch's(nn.module) input order.
833 After we get into forward(), we then need to convert input order to qnn's input order.
834 Same as return, when qnn returns the value, we need to reorder them back to executorh's output order.
835 """
836
837 def __init__(self, qnn_in_order, executorch_out_order):
838 super().__init__()
839 self.qnn_in_order = qnn_in_order
840 self.executorch_out_order = executorch_out_order
841
842 def forward(self, *inputs): # executorch
843 if self.qnn_in_order:
844 inputs = tuple(inputs[i] for i in self.qnn_in_order)
845 ret = getattr(
846 getattr(torch.ops, OpContextLoader.namespace), op_name
847 ).default(inputs)
848 return (
849 [ret[idx] for idx in self.executorch_out_order]
850 if self.executorch_out_order
851 else ret
852 )
853
854 inputs = (
855 tuple(tuple(inputs.values())[i] for i in executorch_in_order)

Callers 1

build_graphFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected