File tree 1 file changed +9
-1
lines changed
extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 20
20
import java .io .IOException ;
21
21
import java .util .ArrayList ;
22
22
import java .util .Arrays ;
23
+ import java .util .Collections ;
23
24
import java .util .List ;
24
25
import java .util .stream .Collectors ;
25
26
import org .pytorch .executorch .Module ;
@@ -80,11 +81,18 @@ protected void onPostExecute(Void aVoid) {
80
81
final List <BenchmarkMetric > results = new ArrayList <>();
81
82
// The list of metrics we have atm includes:
82
83
// Avg inference latency after N iterations
84
+ // Currently the result has large variance from outliers, so only use
85
+ // 80% samples in the middle (trimmean 0.2)
86
+ Collections .sort (stats .latency );
87
+ int resultSize = stats .latency .size ();
88
+ List <Double > usedLatencyResults =
89
+ stats .latency .subList (resultSize / 10 , resultSize * 9 / 10 );
90
+
83
91
results .add (
84
92
new BenchmarkMetric (
85
93
benchmarkModel ,
86
94
"avg_inference_latency(ms)" ,
87
- stats . latency .stream ().mapToDouble (l -> l ).average ().orElse (0.0f ),
95
+ usedLatencyResults .stream ().mapToDouble (l -> l ).average ().orElse (0.0f ),
88
96
0.0f ));
89
97
// Model load time
90
98
results .add (
You can’t perform that action at this time.
0 commit comments