• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.benchmark.core;
18 
19 import java.nio.ByteBuffer;
20 
21 /** Input and expected output pair for inference benchmark */
22 public class InferenceInOut {
23     // TODO: Support multiple inputs/outputs
24 
25     // Input can be passed either directly as a byte array or indirectly through
26     // the input creator. This is needed to pass datasets that can not fit into
27     // memory at once.
28     public byte[] mInput;
29     public byte[][] mExpectedOutputs;
30     public int  mExpectedClass;
31     public InputCreatorInterface mInputCreator;
32 
33     public interface InputCreatorInterface {
createInput(ByteBuffer buffer)34         public abstract void createInput(ByteBuffer buffer);
35     }
36 
InferenceInOut(byte[] input, byte[][] expectedOutputs, int expectedClass)37     public InferenceInOut(byte[] input, byte[][] expectedOutputs, int expectedClass) {
38         mInput = input;
39         mExpectedOutputs = expectedOutputs;
40         mExpectedClass = expectedClass;
41         mInputCreator = null;
42     }
InferenceInOut(InputCreatorInterface inputCreator, byte[][] expectedOutputs, int expectedClass)43     public InferenceInOut(InputCreatorInterface inputCreator, byte[][] expectedOutputs,
44                           int expectedClass) {
45         mInput = null;
46         mExpectedOutputs = expectedOutputs;
47         mExpectedClass = expectedClass;
48         mInputCreator = inputCreator;
49     }
50 }
51