Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#inhmethods)

# InferenceInput.Builder

*** ** * ** ***


`
public
static
final

class
InferenceInput.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.adservices.ondevicepersonalization.InferenceInput.Builder |

<br />

*** ** * ** ***


**This class was deprecated
in API level 37.**   

The ODP APIs are deprecated and will not be supported in future Android
releases. There is no direct replacement API available. Developers currently integrated with
these APIs must cease further integration efforts. For comprehensive details regarding this
deprecation and the future roadmap of Privacy Sandbox on Android, please consult the
official Privacy Sandbox developer documentation and announcements:
<https://privacysandbox.google.com>

A builder for `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#Builder(android.adservices.ondevicepersonalization.InferenceInput.Params,%20byte[])(https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Params params, byte[] inputData) ` Creates a new Builder with provided runtime parameters and input data. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#Builder(android.adservices.ondevicepersonalization.InferenceInput.Params,%20java.lang.Object[],%20android.adservices.ondevicepersonalization.InferenceOutput)(https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Params params, https://developer.android.com/reference/java/lang/Object inputData, https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceOutput expectedOutputStructure) ` Note: use `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#Builder(android.adservices.ondevicepersonalization.InferenceInput.Params,%20byte[])` instead. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#build()() ` Builds the instance. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setBatchSize(int)(int value) ` The number of input examples. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setExpectedOutputStructure(android.adservices.ondevicepersonalization.InferenceOutput)(https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceOutput value) ` The empty InferenceOutput representing the expected output structure. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setInputData(byte[])(byte[] value) ` A byte array that holds input data. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setInputData(java.lang.Object[])(https://developer.android.com/reference/java/lang/Object value) ` Note: use `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setInputData(byte[])` instead. |
| ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setParams(android.adservices.ondevicepersonalization.InferenceInput.Params)(https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Params value) ` The configuration that controls runtime interpreter behavior. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public Builder (InferenceInput.Params params, 
                byte[] inputData)
```

Creates a new Builder with provided runtime parameters and input data.

For LiteRT, inputData field is mapped to inputs of runForMultipleInputsOutputs:
https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/InterpreterApi#parameters_9
For example, if a model takes multiple inputs:

    String[] input0 = {"foo", "bar"}; // string tensor shape is [2].
    int[] input1 = new int[]{3, 2, 1}; // int tensor shape is [3].
    Object[] data = {input0, input1, ...};
    byte[] inputData = serializeObject(data);

For Executorch, inputData field is mapped to a serialized EValue array.

<br />

| Parameters ||
|---|---|
| `params` | `InferenceInput.Params`: configuration that controls runtime interpreter behavior. This value cannot be `null`. <br /> |
| `inputData` | `byte`: byte array that holds serialized input data. This value cannot be `null`. <br /> |

### Builder

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (InferenceInput.Params params, 
                Object[] inputData, 
                InferenceOutput expectedOutputStructure)
```

Note: use `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#Builder(android.adservices.ondevicepersonalization.InferenceInput.Params,%20byte[])` instead.

Creates a new Builder for LiteRT model inference input. For LiteRT, inputData field is
mapped to inputs of runForMultipleInputsOutputs:
https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/InterpreterApi#parameters_9
The inputs should be in the same order as inputs \* of the model. \*

For example, if a model takes multiple inputs: \*

    String[] input0 = {"foo", "bar"}; // string tensor shape is [2].
    int[] input1 = new int[]{3, 2, 1}; // int tensor shape is [3].
    Object[] inputData = {input0, input1, ...};

For LiteRT, the inference code will verify whether the expected output structure matches model output signature.

If a model produce string tensors:

    String[] output = new String[3][2];  // Output tensor shape is [3, 2].
    HashMap<Integer, Object> outputs = new HashMap<>();
    outputs.put(0, output);
    expectedOutputStructure = new InferenceOutput.Builder().setDataOutputs(outputs).build();

<br />

<br />

| Parameters ||
|---|---|
| `params` | `InferenceInput.Params`: configuration that controls runtime interpreter behavior. This value cannot be `null`. <br /> |
| `inputData` | `Object`: an array of input data. This value cannot be `null`. <br /> |
| `expectedOutputStructure` | `InferenceOutput`: an empty InferenceOutput representing the expected output structure. This value cannot be `null`. <br /> |

## Public methods

### build

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput build ()
```

Builds the instance. This builder should not be touched after calling this!

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput` | This value cannot be `null`. <br /> |

### setBatchSize

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput.Builder setBatchSize (int value)
```

The number of input examples. Adopter can set this field to run batching inference. The
batch size is 1 by default. The batch size should match the input data size.

<br />

| Parameters ||
|---|---|
| `value` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | This value cannot be `null`. <br /> |

### setExpectedOutputStructure

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput.Builder setExpectedOutputStructure (InferenceOutput value)
```

The empty InferenceOutput representing the expected output structure. It's only required
by LiteRT model. For LiteRT, the inference code will verify whether this expected output
structure matches model output signature.

If a model produce string tensors:

    String[] output = new String[3][2];  // Output tensor shape is [3, 2].
    HashMap<Integer, Object> outputs = new HashMap<>();
    outputs.put(0, output);
    expectedOutputStructure = new InferenceOutput.Builder().setDataOutputs(outputs).build();

<br />

<br />

| Parameters ||
|---|---|
| `value` | `InferenceOutput`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | This value cannot be `null`. <br /> |

### setInputData

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)   
Deprecated in [API level
37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput.Builder setInputData (byte[] value)
```

A byte array that holds input data. The inputs should be in the same order as inputs of
the model.

For LiteRT, this field is mapped to inputs of runForMultipleInputsOutputs:
https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/InterpreterApi#parameters_9

    String[] input0 = {"foo", "bar"}; // string tensor shape is [2].
    int[] input1 = new int[]{3, 2, 1}; // int tensor shape is [3].
    Object[] data = {input0, input1, ...};
    byte[] inputData = serializeObject(data);

For Executorch model, this field is a serialized EValue array.

<br />

| Parameters ||
|---|---|
| `value` | `byte`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | This value cannot be `null`. <br /> |

### setInputData

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput.Builder setInputData (Object... value)
```

Note: use `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder#setInputData(byte[])` instead.

An array of input data. The inputs should be in the same order as inputs of the model.

For example, if a model takes multiple inputs:

    String[] input0 = {"foo", "bar"}; // string tensor shape is [2].
    int[] input1 = new int[]{3, 2, 1}; // int tensor shape is [3].
    Object[] inputData = {input0, input1, ...};

For LiteRT, this field is mapped to inputs of runForMultipleInputsOutputs: https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/InterpreterApi#parameters_9

<br />

<br />

| Parameters ||
|---|---|
| `value` | `Object`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | This value cannot be `null`. <br /> |

### setParams

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public InferenceInput.Builder setParams (InferenceInput.Params value)
```

The configuration that controls runtime interpreter behavior.

<br />

| Parameters ||
|---|---|
| `value` | `InferenceInput.Params`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceInput.Builder` | This value cannot be `null`. <br /> |