Documentation
¶
Index ¶
- type Session
- func (s *Session) Destroy() error
- func (s *Session) GetFeatureExtractionPipeline(name string) (*pipelines.FeatureExtractionPipeline, error)
- func (s *Session) GetStats() []string
- func (s *Session) GetTextClassificationPipeline(name string) (*pipelines.TextClassificationPipeline, error)
- func (s *Session) GetTokenClassificationPipeline(name string) (*pipelines.TokenClassificationPipeline, error)
- func (s *Session) NewFeatureExtractionPipeline(modelPath string, name string) (*pipelines.FeatureExtractionPipeline, error)
- func (s *Session) NewTextClassificationPipeline(modelPath string, name string, opts ...pipelines.TextClassificationOption) (*pipelines.TextClassificationPipeline, error)
- func (s *Session) NewTokenClassificationPipeline(modelPath string, name string, opts ...pipelines.TokenClassificationOption) (*pipelines.TokenClassificationPipeline, error)
- type SessionOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session allows for the creation of new pipelines and holds the pipeline already created.
func NewSession ¶
func NewSession(options ...SessionOption) (*Session, error)
NewSession is the main entrypoint to hugot and is used to create a new hugot session object. ortLibraryPath should be the path to onnxruntime.so. If it's the empty string, hugot will try to load the library from the default location (/usr/lib/onnxruntime.so). A new session must be destroyed when it's not needed anymore to avoid memory leaks. See the Destroy method. Note moreover that there can be at most one hugot session active (i.e., the Session object is a singleton), otherwise NewSession will return an error.
func (*Session) Destroy ¶
Destroy deletes the hugot session and onnxruntime environment and all initialized pipelines, freeing memory. A hugot session should be destroyed when not neeeded anymore, preferably with a defer() call.
func (*Session) GetFeatureExtractionPipeline ¶
func (s *Session) GetFeatureExtractionPipeline(name string) (*pipelines.FeatureExtractionPipeline, error)
GetFeatureExtractionPipeline returns a feature extraction pipeline by name. If the name does not exist, it will return an error.
func (*Session) GetStats ¶
GetStats returns runtime statistics for all initialized pipelines for profiling purposes. We currently record for each pipeline: the total runtime of the tokenization step the number of batch calls to the tokenization step the average time per tokenization batch call the total runtime of the inference (i.e. onnxruntime) step the number of batch calls to the onnxruntime inference the average time per onnxruntime inference batch call
func (*Session) GetTextClassificationPipeline ¶
func (s *Session) GetTextClassificationPipeline(name string) (*pipelines.TextClassificationPipeline, error)
GetTextClassificationPipeline returns a text classification pipeline by name. If the name does not exist, it will return an error.
func (*Session) GetTokenClassificationPipeline ¶
func (s *Session) GetTokenClassificationPipeline(name string) (*pipelines.TokenClassificationPipeline, error)
GetTokenClassificationPipeline returns a token classification pipeline by name. If the name does not exist, it will return an error.
func (*Session) NewFeatureExtractionPipeline ¶
func (s *Session) NewFeatureExtractionPipeline(modelPath string, name string) (*pipelines.FeatureExtractionPipeline, error)
NewFeatureExtractionPipeline creates and returns a new feature extraction pipeline object. modelPath should be the path to a folder with the onnx exported transformer model. Name is an identifier for the pipeline (see GetFeatureExtractionPipeline).
func (*Session) NewTextClassificationPipeline ¶
func (s *Session) NewTextClassificationPipeline(modelPath string, name string, opts ...pipelines.TextClassificationOption) (*pipelines.TextClassificationPipeline, error)
NewTextClassificationPipeline creates and returns a new text classification pipeline object. modelPath should be the path to a folder with the onnx exported transformer model. Name is an identifier for the pipeline (see GetTextClassificationPipeline).
func (*Session) NewTokenClassificationPipeline ¶
func (s *Session) NewTokenClassificationPipeline(modelPath string, name string, opts ...pipelines.TokenClassificationOption) (*pipelines.TokenClassificationPipeline, error)
NewTokenClassificationPipeline creates and returns a new token classification pipeline object. modelPath should be the path to a folder with the onnx exported transformer model. Name is an identifier for the pipeline (see GetTokenClassificationPipeline).
type SessionOption ¶ added in v0.0.5
type SessionOption func() error
func WithOnnxLibraryPath ¶ added in v0.0.5
func WithOnnxLibraryPath(ortLibraryPath string) SessionOption