Interpreter
public final class InterpreterA TensorFlow Lite interpreter that performs inference from a given model.
- 
                  
                  The configuration options for the Interpreter.DeclarationSwift public let options: Options?
- 
                  
                  The total number of input Tensors associated with the model.DeclarationSwift public var inputTensorCount: Int { get }
- 
                  
                  The total number of output Tensors associated with the model.DeclarationSwift public var outputTensorCount: Int { get }
- 
                  
                  Creates a new instance with the given values. Throws An error if the model could not be loaded or the interpreter could not be created.DeclarationParametersmodelPathThe local file path to a TensorFlow Lite model. optionsConfigurations for the Interpreter. The default isnilindicating that theInterpreterwill determine the configuration options.delegateArrayofDelegates for theInterpreterto use to perform graph operations. The default isnil.
- 
                  
                  Invokes the interpreter to perform inference from the loaded graph. Throws An error if the model was not ready because the tensors were not allocated.DeclarationSwift public func invoke() throws
- 
                  
                  Returns the output Tensorat the given index.Throws An error if the index is invalid, tensors haven’t been allocated, or interpreter has not been invoked for models that dynamically compute output tensors based on the values of its input tensors.DeclarationSwift public func output(at index: Int) throws -> TensorParametersindexThe index for the output Tensor.Return ValueThe output Tensorat the given index.
- 
                  
                  Resizes the input Tensorat the given index to the specifiedTensor.Shape.Note After resizing an input tensor, the client must explicitly callallocateTensors()before attempting to access the resized tensor data or invoking the interpreter to perform inference.Throws An error if the input tensor at the given index could not be resized.DeclarationSwift public func resizeInput(at index: Int, to shape: Tensor.Shape) throws
- 
                  
                  Copies the given data to the input Tensorat the given index.Throws An error if thedata.countdoes not match the input tensor’sdata.countor if the given index is invalid.DeclarationSwift @discardableResult public func copy(_ data: Data, toInputAt index: Int) throws -> TensorParametersdataThe data to be copied to the input Tensor‘s data buffer.indexThe index for the input Tensor.Return ValueThe input Tensorwith the copied data.
- 
                  
                  Allocates memory for all input Tensors based on theirTensor.Shapes.Note This is a relatively expensive operation and should only be called after creating the interpreter and resizing any input tensors.Throws An error if memory could not be allocated for the input tensors.DeclarationSwift public func allocateTensors() throws
- 
                  
                  Options for configuring the Interpreter.DeclarationSwift public struct Options : Equatable, Hashable