File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import torch
2+ from executorch .backends .xnnpack .partition .xnnpack_partitioner import XnnpackPartitioner
3+ from executorch .exir import to_edge_transform_and_lower
4+ from executorch .extension .pybindings .portable_lib import (
5+ _load_for_executorch_from_buffer ,
6+ )
7+
8+
9+ class Model (torch .nn .Module ):
10+ def forward (self , x , y ):
11+ return torch .add (x , y , alpha = 10 )
12+
13+
14+ inputs = (
15+ torch .randn (10 ),
16+ torch .randn (10 ),
17+ )
18+ model = Model ()
19+
20+ ep = torch .export .export (model , inputs )
21+ lowered = to_edge_transform_and_lower (
22+ ep ,
23+ partitioner = [XnnpackPartitioner ()],
24+ ).to_executorch ()
25+
26+ et_model = _load_for_executorch_from_buffer (lowered .buffer )
27+
28+ eager_output = model (* inputs )
29+ et_output = et_model ([* inputs ])[0 ]
30+
31+ print (f"Eager: { eager_output } " )
32+ print (f"ET: { et_output } " )
33+ print (f"Error: { et_output - eager_output } " )
You can’t perform that action at this time.
0 commit comments