Documentation ¶
Overview ¶
Package menoh provides a wrapper "runner" for Menoh library to execute ONNX model. It consits the following structures.
Runner is a wrapper to manage an ONNX model and run with input variables.
Config is information about ONNX model, required for making a runner.
Tensor represents number array for in/out variable, similar to ONNX's Tensor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ONNXModelPath string // path of ONNX file Backend TypeBackend // backend type, like menoh.TypeMKLDNN BackendConfig string // backend configuration Inputs []InputConfig // list of input configuration Outputs []OutputConfig // list of output configuration }
Config is setup information to build Menoh model.
type FloatTensor ¶
FloatTensor represents float32 Tessor.
func (*FloatTensor) FloatArray ¶
func (t *FloatTensor) FloatArray() ([]float32, error)
FloatArray returns float32 array.
func (*FloatTensor) WriteFloat ¶
func (t *FloatTensor) WriteFloat(i int, f float32) error
WriteFloat puts float value to i-th index of array.
type InputConfig ¶
type InputConfig struct { Name string // layer name Dtype TypeDtype // data type Dims []int32 // list of dimension size }
InputConfig is input variable information to pass to the model.
type ModelData ¶ added in v0.2.0
ModelData is a wrap of menoh.ModelData.
func NewModelDataFromBytes ¶ added in v0.2.0
NewModelDataFromBytes return ModelData from binary data.
func NewModelDataFromPath ¶ added in v0.2.0
NewModelDataFromPath returns ModelData using ONNX file placed on the path.
func NewRawModelData ¶ added in v0.2.0
NewRawModelData return empty ModelData to be setup outer.
type OutputConfig ¶
type OutputConfig struct { Name string // layer name Dtype TypeDtype // data type FromInternal bool // if the output comes from operator variable such as weight, set true }
OutputConfig is output variable information to get from the model.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner setups Menoh model with profiling and executes with input variables. A runner supports to call Run (or RunWithTensor) method repeatedly until stopping.
func NewRunner ¶
NewRunner returns Runner using configuration, the runner setup Menoh model and ready for execution. Require to call Stop function after the process is done.
func NewRunnerWithModelData ¶ added in v0.2.0
NewRunnerWithModelData returns Runner using configuration and ONNX model. The ONNX model is passed on memory, not use conf.ONNXModelPath. Spec of a returned runner is same as NewRunner, see docs of the function.
func (*Runner) Run ¶
Run with the inputs which are set name and tensor as key-value. If nothing to input, set nil.
func (*Runner) RunWithTensor ¶
RunWithTensor inputs the tenser with tne name, and runs.
type Tensor ¶
type Tensor interface { // Size returns array size. Size() int // Shape returns shape of array dimension. Shape() []int32 // FloatArray returns float32 array. Returns an error when the array // cannot cast to the type. It is possible that returned array is copied // or split-off from attached array in Menoh model. When updating values, // WriteFloat method. FloatArray() ([]float32, error) // WriteFloat puts float value to i-th index of array. WriteFloat(int, float32) error // contains filtered or unexported methods }
Tensor is base unit of matrix data to pass Menoh model.
type TypeBackend ¶
type TypeBackend int
TypeBackend is a type of backend, like MKL-DNN.
const (
// TypeMKLDNN is a TypeBackend of MKL-DNN
TypeMKLDNN TypeBackend
)
func (TypeBackend) String ¶
func (t TypeBackend) String() string