• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.nn.crashtest.app;
18 
19 import android.content.Intent;
20 
21 import com.android.nn.benchmark.app.AcceleratorSpecificTestSupport;
22 import com.android.nn.benchmark.core.NnApiDelegationFailure;
23 import com.android.nn.crashtest.core.test.RunModelsInMultipleProcesses;
24 
25 import org.junit.runner.RunWith;
26 import org.junit.runners.Parameterized;
27 import org.junit.runners.Parameterized.Parameters;
28 
29 import java.time.Duration;
30 import java.util.Arrays;
31 import java.util.List;
32 
33 @RunWith(Parameterized.class)
34 public class NNMultipleProcessInferenceTest extends NNMultipleProcessTest {
NNMultipleProcessInferenceTest(int processCount, int threadCount, Duration duration, int failureRatePercent, String acceleratorName)35     public NNMultipleProcessInferenceTest(int processCount, int threadCount, Duration duration,
36             int failureRatePercent, String acceleratorName) {
37         super(processCount, threadCount, duration, failureRatePercent, acceleratorName);
38     }
39 
40     @Override
getRunModelsInMultipleProcessesConfigIntent()41     protected Intent getRunModelsInMultipleProcessesConfigIntent() {
42         try {
43             Intent result = new Intent();
44             RunModelsInMultipleProcesses
45                     .intentInitializer(mTestName.getMethodName(),
46                             findModelForLivenessTest().get().mModelName,
47                             mProcessCount, mThreadCount, mDuration,
48                             mAcceleratorName, /*justCompileModel=*/false,
49                             mFailureRatePercent)
50                     .addIntentParams(result);
51             return result;
52         } catch (NnApiDelegationFailure nnApiDelegationFailure) {
53             throw new RuntimeException(
54                     "Cannot initialize test, failure looking for supported models, please check "
55                             + "the driver status",
56                     nnApiDelegationFailure);
57         }
58     }
59 
60     @Parameters(name = "{0} processes, {1} threads for {2} on accelerator({4}) with early "
61             + "termination rate({3}%)")
62     public static List<Object[]>
testConfiguration()63     testConfiguration() {
64         return AcceleratorSpecificTestSupport.perAcceleratorTestConfig(
65                 Arrays.asList(new Object[]{6, 10, Duration.ofMinutes(30), 0},
66                         new Object[]{6, 10, Duration.ofMinutes(20), 80}));
67     }
68 }