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

Method forward

examples/apple/coreml/llama/utils.py:79–99  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

77 split.weight = torch.nn.Parameter(split_weights[i])
78
79 def forward(self, x):
80 if len(self.in_split_sizes) == 1:
81 out_chunks = [op(x) for op in self.ops]
82 else:
83 x_splits = x.split(self.in_split_sizes, dim=-1)
84 out_chunks = [
85 torch.sum(
86 torch.stack(
87 [
88 self.ops[self.op_index(in_idx, out_idx)].forward(
89 x_splits[in_idx]
90 )
91 for in_idx in range(len(self.in_split_sizes))
92 ],
93 ),
94 dim=0,
95 )
96 for out_idx in range(len(self.out_split_sizes))
97 ]
98
99 return torch.concat(out_chunks, dim=-1)
100
101
102def replace_linear_with_split_linear(

Callers

nothing calls this directly

Calls 2

op_indexMethod · 0.95
splitMethod · 0.80

Tested by

no test coverage detected