# InferenceOutput.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/adservices/ondevicepersonalization/InferenceOutput.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                           ||
| ↳ | [android.adservices.ondevicepersonalization.InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) |

A builder for[InferenceOutput](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput)

## Summary

|                                                                 Public constructors                                                                  ||
|---------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                      Public methods                                                                                                                                                                                                                                                                                                                                                                                                      ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | [addDataOutput](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#addDataOutput(kotlin.Int,%20kotlin.Any))`(`key:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `value:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`)` <br />                                                                                                                                                                                                                                                                                                           |
| [InferenceOutput](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput)                  | [build](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#build())`()` Builds the instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | [setData](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#setData(kotlin.ByteArray))`(`value:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`)` A byte array that holds input data.                                                                                                                                                                                                                                                                                                                                                                          |
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | [setDataOutputs](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#setDataOutputs(kotlin.collections.MutableMap))`(`value:` `[MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!,` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!>`)` Note: use[InferenceOutput.Builder.setData(byte[])](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#setData(kotlin.ByteArray))instead. |

## Public constructors

### Builder

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

```
Builder()
```

## Public methods

### addDataOutput

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

```
fun addDataOutput(
    key: Int, 
    value: Any
): InferenceOutput.Builder
```

|                                                   Parameters                                                    ||
|---------|--------------------------------------------------------------------------------------------------------|
| `value` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html):This value cannot be`null`. |

|                                                                                   Return                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | This value cannot be`null`. |

**See Also**

- [#setDataOutputs](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#setDataOutputs(kotlin.collections.MutableMap))  

### build

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

```
fun build(): InferenceOutput
```

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

|                                                                          Return                                                                           ||
|------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [InferenceOutput](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput) | This value cannot be`null`. |

### setData

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

```
fun setData(value: ByteArray): InferenceOutput.Builder
```

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 a serialized Map that is mapped to outputs of runForMultipleInputsOutputs: https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/InterpreterApi#parameters_9

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

|                                                          Parameters                                                          ||
|---------|---------------------------------------------------------------------------------------------------------------------|
| `value` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html):This value cannot be`null`. |

|                                                                                   Return                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | This value cannot be`null`. |

### setDataOutputs

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

```
fun setDataOutputs(value: MutableMap<Int!, Any!>): InferenceOutput.Builder
```

Note: use[InferenceOutput.Builder.setData(byte[])](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#setData(kotlin.ByteArray))instead.

A map mapping output indices to multidimensional arrays of output.

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

|                                                                                                                                              Parameters                                                                                                                                               ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `value` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!,[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!\>:This value cannot be`null`. |

|                                                                                   Return                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [InferenceOutput.Builder](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/InferenceOutput.Builder#) | This value cannot be`null`. |