tflite:: impl:: FlatBufferModel
Summary
Constructors and Destructors |
|
---|---|
FlatBufferModel(const FlatBufferModel &)
|
|
~FlatBufferModel()
|
Public static functions |
|
---|---|
BuildFromAllocation(std::unique_ptr< Allocation > allocation, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Builds a model directly from an allocation.
|
BuildFromBuffer(const char *caller_owned_buffer, size_t buffer_size, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Builds a model based on a pre-loaded flatbuffer.
|
BuildFromFile(const char *filename, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Builds a model based on a file.
|
BuildFromModel(const tflite::Model *caller_owned_model_spec, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Builds a model directly from a flatbuffer pointer Caller retains ownership of the buffer and should keep it alive until the returned object is destroyed.
|
ReadAllMetadata(const ::tflite::Model *model)
|
std::map< std::string, std::string >
|
VerifyAndBuildFromAllocation(std::unique_ptr< Allocation > allocation, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Verifies whether the content of the allocation is legit, then builds a model based on the provided allocation.
|
VerifyAndBuildFromBuffer(const char *caller_owned_buffer, size_t buffer_size, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Verifies whether the content of the buffer is legit, then builds a model based on the pre-loaded flatbuffer.
|
VerifyAndBuildFromFile(const char *filename, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter)
|
std::unique_ptr< FlatBufferModel >
Verifies whether the content of the file is legit, then builds a model based on the file.
|
Public functions |
|
---|---|
CheckModelIdentifier() const
|
bool
Returns true if the model identifier is correct (otherwise false and reports an error).
|
GetMinimumRuntime() const
|
std::string
|
GetModel() const
|
const tflite::Model *
|
ReadAllMetadata() const
|
std::map< std::string, std::string >
|
allocation() const
|
const Allocation *
|
error_reporter() const
|
|
initialized() const
|
bool
|
operator->() const
|
const tflite::Model *
|
operator=(const FlatBufferModel &)=delete
|
FlatBufferModel &
|
Public static functions
BuildFromAllocation
std::unique_ptr< FlatBufferModel > BuildFromAllocation( std::unique_ptr< Allocation > allocation, ErrorReporter *error_reporter )
Builds a model directly from an allocation.
Ownership of the allocation is passed to the model, but the caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure (e.g., the allocation is invalid).
BuildFromBuffer
std::unique_ptr< FlatBufferModel > BuildFromBuffer( const char *caller_owned_buffer, size_t buffer_size, ErrorReporter *error_reporter )
Builds a model based on a pre-loaded flatbuffer.
Caller retains ownership of the buffer and should keep it alive until the returned object is destroyed. Caller also retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure. NOTE: this does NOT validate the buffer so it should NOT be called on invalid/untrusted input. Use VerifyAndBuildFromBuffer in that case
BuildFromFile
std::unique_ptr< FlatBufferModel > BuildFromFile( const char *filename, ErrorReporter *error_reporter )
Builds a model based on a file.
Caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure.
BuildFromModel
std::unique_ptr< FlatBufferModel > BuildFromModel( const tflite::Model *caller_owned_model_spec, ErrorReporter *error_reporter )
Builds a model directly from a flatbuffer pointer Caller retains ownership of the buffer and should keep it alive until the returned object is destroyed.
Caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure.
ReadAllMetadata
std::map< std::string, std::string > ReadAllMetadata( const ::tflite::Model *model )
VerifyAndBuildFromAllocation
std::unique_ptr< FlatBufferModel > VerifyAndBuildFromAllocation( std::unique_ptr< Allocation > allocation, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter )
Verifies whether the content of the allocation is legit, then builds a model based on the provided allocation.
The extra_verifier argument is an additional optional verifier for the buffer. By default, we always check with tflite::VerifyModelBuffer. If extra_verifier is supplied, the buffer is checked against the extra_verifier after the check against tflite::VerifyModelBuilder. Ownership of the allocation is passed to the model, but the caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure.
VerifyAndBuildFromBuffer
std::unique_ptr< FlatBufferModel > VerifyAndBuildFromBuffer( const char *caller_owned_buffer, size_t buffer_size, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter )
Verifies whether the content of the buffer is legit, then builds a model based on the pre-loaded flatbuffer.
The extra_verifier argument is an additional optional verifier for the buffer. By default, we always check with tflite::VerifyModelBuffer. If extra_verifier is supplied, the buffer is checked against the extra_verifier after the check against tflite::VerifyModelBuilder. The caller retains ownership of the buffer and should keep it alive until the returned object is destroyed. Caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure.
VerifyAndBuildFromFile
std::unique_ptr< FlatBufferModel > VerifyAndBuildFromFile( const char *filename, TfLiteVerifier *extra_verifier, ErrorReporter *error_reporter )
Verifies whether the content of the file is legit, then builds a model based on the file.
The extra_verifier argument is an additional optional verifier for the file contents. By default, we always check with tflite::VerifyModelBuffer. If extra_verifier is supplied, the file contents is also checked against the extra_verifier after the check against tflite::VerifyModelBuilder. Caller retains ownership of error_reporter
and must ensure its lifetime is longer than the FlatBufferModel instance. Returns a nullptr in case of failure.
Public functions
CheckModelIdentifier
bool CheckModelIdentifier() const
Returns true if the model identifier is correct (otherwise false and reports an error).
FlatBufferModel
FlatBufferModel( const FlatBufferModel & )=delete
GetMinimumRuntime
std::string GetMinimumRuntime() const
GetModel
const tflite::Model * GetModel() const
ReadAllMetadata
std::map< std::string, std::string > ReadAllMetadata() const
allocation
const Allocation * allocation() const
error_reporter
ErrorReporter * error_reporter() const
initialized
bool initialized() const
operator->
const tflite::Model * operator->() const
operator=
FlatBufferModel & operator=( const FlatBufferModel & )=delete
~FlatBufferModel
~FlatBufferModel()