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

Model ()

Public functions

FindSignature (absl::string_view signature_key) const
Expected < SimpleSignature >
Returns the SimpleSignature object for the given signature key.
GetInputTensorType (size_t signature_index, size_t input_index) const
Expected < RankedTensorType >
Returns the tensor type for the n-th input tensor.
GetInputTensorType (size_t signature_index, absl::string_view input_name) const
Expected < RankedTensorType >
Returns the tensor type for the given input tensor name.
GetInputTensorType (absl::string_view signature_key, absl::string_view input_name) const
Expected < RankedTensorType >
Returns the tensor type for the given input tensor name.
GetInputTensorType (absl::string_view input_name) const
Expected < RankedTensorType >
Gets the input tensor type of the default signature for a given input name.
GetNumSignatures () const
size_t
GetOutputTensorType (size_t signature_index, size_t output_index) const
Expected < RankedTensorType >
Returns the tensor type for the n-th output tensor.
GetOutputTensorType (size_t signature_index, absl::string_view output_name) const
Expected < RankedTensorType >
Returns the tensor type for the given output tensor name.
GetOutputTensorType (absl::string_view signature_key, absl::string_view output_name) const
Expected < RankedTensorType >
Returns the tensor type for the given output tensor name.
GetOutputTensorType (absl::string_view output_name) const
Expected < RankedTensorType >
Gets the output tensor type of the default signature for a given output name.
GetSignature (size_t signature_index) const
Expected < SimpleSignature >
Returns the signature at the given index.
GetSignatureIndex (absl::string_view signature_key) const
Expected < size_t >
Returns the signature index for the given signature key.
GetSignatureInputNames (size_t signature_index) const
Expected < std::vector< absl::string_view > >
Returns the list of input names defined in the signature.
Expected < std::vector< absl::string_view > >
Returns the list of input names defined in the signature.
GetSignatureInputNames (absl::string_view signature_key) const
Expected < std::vector< absl::string_view > >
Returns the list of input names defined in the signature.
GetSignatureKeys () const
Expected < std::vector< absl::string_view > >
Returns the list of signature key names defined in the signature.
GetSignatureOutputNames (size_t signature_index) const
Expected < std::vector< absl::string_view > >
Returns the list of output names defined in the signature.
Expected < std::vector< absl::string_view > >
Returns the list of output names defined in the signature.
GetSignatureOutputNames (absl::string_view signature_key) const
Expected < std::vector< absl::string_view > >
Returns the list of output names defined in the signature.
GetSignatures () const
Expected < std::vector< SimpleSignature > >
Returns the list of signatures defined in the model.
Metadata (const std::string & metadata_key) const
Expected < absl::Span< const uint8_t > >

Public static functions

CreateFromBuffer ( BufferRef < uint8_t > buffer)
Creates a model from a buffer.
CreateFromFile (const std::string & filename)
CreateFromNonOwnedHandle (LiteRtModel model)
CreateFromOwnedHandle (LiteRtModel model)
absl::string_view

Protected functions

Model (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.

  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
)
Details
Parameters
owned
Indicates if the created TensorBuffer object should take ownership of the provided tensor_buffer handle.
Design a Mobile Site
View Site in Mobile | Classic
Share by: