# litert::Model


`#include <litert_model.h>`

A C++ wrapper for `LiteRtModel`, representing a LiteRT model.

## Summary

\\internal

### Inheritance

Inherits from: internal::BaseHandle\< LiteRtModel \>

| ### Constructors and Destructors ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1aeae198c0a977d33c1ea856a4f2df1b6b()` ||

| ### Public functions ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1afb808102acdbcfcfc7fb0cce4254e694(absl::string_view signature_key) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< SimpleSignature >` Returns the `SimpleSignature` object for the given signature key. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1afffb424fa4dcee10480153765ec32c50(size_t signature_index, size_t input_index) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the n-th input tensor. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1ad02321052628831c39f0f0bb2dfdfcb8(size_t signature_index, absl::string_view input_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the given input tensor name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a4fa8d294c51dfcc76dc41ff56ea13c6c(absl::string_view signature_key, absl::string_view input_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the given input tensor name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a56cbeb50f2ab3899c63ede5c1b12c291(absl::string_view input_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Gets the input tensor type of the default signature for a given input name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a45d89cabfa27bb4fbf52f400290b535b() const ` | `size_t` |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a0809b139a8956cfb90f267220fd86acf(size_t signature_index, size_t output_index) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the n-th output tensor. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1ae90a953980534019eb8e907d3944cba4(size_t signature_index, absl::string_view output_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the given output tensor name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1ac15d08cc4d7939b27429fdd19032bb97(absl::string_view signature_key, absl::string_view output_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Returns the tensor type for the given output tensor name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a7fad01117c2fb3567716348c57b0ccbc(absl::string_view output_name) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< RankedTensorType >` Gets the output tensor type of the default signature for a given output name. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a7bf20b60e8e02732922c50869d541731(size_t signature_index) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< SimpleSignature >` Returns the signature at the given index. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a8d0a21581b6acfd4ce81a80b54ec118e(absl::string_view signature_key) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< size_t >` Returns the signature index for the given signature key. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a82029ccdca325cb3da2e84219a30a6a6(size_t signature_index) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of input names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a960d6d54c42c467f37aed5508e598736() const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of input names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a3f045705a709b7583ff63cc381bf133b(absl::string_view signature_key) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of input names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1ae1582999ae8d1292a651a9effa355c92() const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of signature key names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1af896d8a95b8464b736dc682d078f6acf(size_t signature_index) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of output names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a8fae66d0306c0170b2b4c17758fbe1d9() const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of output names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1aa738033f41be75fb217da8f052bbd97e(absl::string_view signature_key) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< absl::string_view > >` Returns the list of output names defined in the signature. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a600eeba3ffd840cd9470c574e00da3eb() const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< std::vector< SimpleSignature > >` Returns the list of signatures defined in the model. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a6f79989ca2215855744b95d326a4bd6e(const std::string & metadata_key) const ` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< absl::Span< const uint8_t > >` |

| ### Public static functions ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a69ede5eb89e3795ffbbd01f751db6a51(https://developers.google.com/edge/api/litert/c/classlitert/1-1-buffer-ref#classlitert_1_1_buffer_ref< uint8_t > buffer)` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model >` Creates a model from a buffer. |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a7b3f09614e2631ed28da4972d27e4d5b(const std::string & filename)` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-expected#classlitert_1_1_expected< https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model >` |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a7ff06de46d792f166256a61218f9022c(LiteRtModel model)` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model` |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a893c0f3c1e81ccb7e803782b07b063d1(LiteRtModel model)` | `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model` |
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1a17b21ce2de4e4e3919d0fea24a505f77()` | `absl::string_view` |

| ### Protected functions ||
|---|---|
| `https://developers.google.com/edge/api/litert/c/classlitert/1-1-model#classlitert_1_1_model_1ac7ce40b95c3e25026ec388779315cc50(LiteRtModel model, OwnHandle owned)` |   |

## Public functions

### FindSignature

```
Expected< SimpleSignature > FindSignature(
  absl::string_view signature_key
) const 
```
Returns the `SimpleSignature` object for the given signature key.

Returns the default signature if the signature key is empty.

### GetInputTensorType

```
Expected< RankedTensorType > GetInputTensorType(
  size_t signature_index,
  size_t input_index
) const 
```
Returns the tensor type for the n-th input tensor.

### GetInputTensorType

```
Expected< RankedTensorType > GetInputTensorType(
  size_t signature_index,
  absl::string_view input_name
) const 
```
Returns the tensor type for the given input tensor name.

### GetInputTensorType

```
Expected< RankedTensorType > GetInputTensorType(
  absl::string_view signature_key,
  absl::string_view input_name
) const 
```
Returns the tensor type for the given input tensor name.

### GetInputTensorType

```
Expected< RankedTensorType > GetInputTensorType(
  absl::string_view input_name
) const 
```
Gets the input tensor type of the default signature for a given input name.

### GetNumSignatures

```
size_t GetNumSignatures() const 
```

### GetOutputTensorType

```
Expected< RankedTensorType > GetOutputTensorType(
  size_t signature_index,
  size_t output_index
) const 
```
Returns the tensor type for the n-th output tensor.

### GetOutputTensorType

```
Expected< RankedTensorType > GetOutputTensorType(
  size_t signature_index,
  absl::string_view output_name
) const 
```
Returns the tensor type for the given output tensor name.

### GetOutputTensorType

```
Expected< RankedTensorType > GetOutputTensorType(
  absl::string_view signature_key,
  absl::string_view output_name
) const 
```
Returns the tensor type for the given output tensor name.

### GetOutputTensorType

```
Expected< RankedTensorType > GetOutputTensorType(
  absl::string_view output_name
) const 
```
Gets the output tensor type of the default signature for a given output name.

### GetSignature

```
Expected< SimpleSignature > GetSignature(
  size_t signature_index
) const 
```
Returns the signature at the given index.

### GetSignatureIndex

```
Expected< size_t > GetSignatureIndex(
  absl::string_view signature_key
) const 
```
Returns the signature index for the given signature key.

Returns 0 if the signature key is empty.

### GetSignatureInputNames

```
Expected< std::vector< absl::string_view > > GetSignatureInputNames(
  size_t signature_index
) const 
```
Returns the list of input names defined in the signature.

### GetSignatureInputNames

```
Expected< std::vector< absl::string_view > > GetSignatureInputNames() const 
```
Returns the list of input names defined in the signature.

### GetSignatureInputNames

```
Expected< std::vector< absl::string_view > > GetSignatureInputNames(
  absl::string_view signature_key
) const 
```
Returns the list of input names defined in the signature.

### GetSignatureKeys

```
Expected< std::vector< absl::string_view > > GetSignatureKeys() const 
```
Returns the list of signature key names defined in the signature.

### GetSignatureOutputNames

```
Expected< std::vector< absl::string_view > > GetSignatureOutputNames(
  size_t signature_index
) const 
```
Returns the list of output names defined in the signature.

### GetSignatureOutputNames

```
Expected< std::vector< absl::string_view > > GetSignatureOutputNames() const 
```
Returns the list of output names defined in the signature.

### GetSignatureOutputNames

```
Expected< std::vector< absl::string_view > > GetSignatureOutputNames(
  absl::string_view signature_key
) const 
```
Returns the list of output names defined in the signature.

### GetSignatures

```
Expected< std::vector< SimpleSignature > > GetSignatures() const 
```
Returns the list of signatures defined in the model.

### Metadata

```
Expected< absl::Span< const uint8_t > > Metadata(
  const std::string & metadata_key
) const 
```

### Model

```
 Model()=default
```

## Public static functions

### CreateFromBuffer

```
Expected< Model > CreateFromBuffer(
  BufferRef< uint8_t > buffer
)
```
Creates a model from a buffer.

The caller must ensure that the buffer remains valid for the lifetime of the model.

### CreateFromFile

```
Expected< Model > CreateFromFile(
  const std::string & filename
)
```

### CreateFromNonOwnedHandle

```
Model CreateFromNonOwnedHandle(
  LiteRtModel model
)
```

### CreateFromOwnedHandle

```
Model CreateFromOwnedHandle(
  LiteRtModel model
)
```

### DefaultSignatureKey

```
absl::string_view DefaultSignatureKey()
```

## Protected functions

### Model

```
 Model(
  LiteRtModel model,
  OwnHandle owned
)
```
<br />

Details Parameters `owned` Indicates if the created `https://developers.google.com/edge/api/litert/c/classlitert/1-1-tensor-buffer#classlitert_1_1_tensor_buffer` object should take ownership of the provided `tensor_buffer` handle.