Documentation
¶
Index ¶
- Constants
- func BytesToTensor(dataType string, data []byte, shape []int64) (any, error)
- func Serialize(r *RESTInferenceRequest) ([]byte, error)
- type Configuration
- type Event
- func (e *Event) GetBody() []byte
- func (e *Event) GetContentType() string
- func (e *Event) GetFieldByteSlice(key string) []byte
- func (e *Event) GetFieldInt(key string) (int, error)
- func (e *Event) GetFieldString(key string) string
- func (e *Event) GetHeader(key string) any
- func (e *Event) GetHeaderByteSlice(key string) []byte
- func (e *Event) GetHeaders() map[string]any
- func (e *Event) GetMethod() string
- func (e *Event) GetPath() string
- func (e *Event) GetTimestamp() time.Time
- func (e *Event) GetTriggerInfo() nuclio.TriggerInfoProvider
- func (e *Event) GetURL() string
- type InvalidInputError
- type ModelMetadataResponse
- type ModelReadyResponse
- type RESTInferInputTensor
- type RESTInferOutputTensor
- type RESTInferenceRequest
- type RESTInferenceResponse
- type RESTTensorMetadata
- type ServerLiveResponse
- type ServerMetadataResponse
- type ServerReadyResponse
- type TensorDef
- type TensorMetadataProvider
Constants ¶
const ( DefaultRESTPort = 8080 DefaultGRPCPort = 9000 DefaultModelName = "model" DefaultModelVersion = "1" )
Variables ¶
This section is empty.
Functions ¶
func Serialize ¶
func Serialize(r *RESTInferenceRequest) ([]byte, error)
Types ¶
type Configuration ¶
type Configuration struct {
trigger.Configuration
// Server configuration
RESTPort int `mapstructure:"rest_port"`
GRPCPort int `mapstructure:"grpc_port"`
EnableREST bool `mapstructure:"enable_rest"`
EnableGRPC bool `mapstructure:"enable_grpc"`
// Model configuration
ModelName string `mapstructure:"model_name"`
ModelVersion string `mapstructure:"model_version"`
// Tensor definitions
InputTensors []TensorDef `mapstructure:"input_tensors"`
OutputTensors []TensorDef `mapstructure:"output_tensors"`
}
Configuration for OpenInference trigger
func NewConfiguration ¶
func NewConfiguration(id string, triggerConfiguration *functionconfig.Trigger, runtimeConfiguration *runtime.Configuration) (*Configuration, error)
NewConfiguration creates a new OpenInference trigger configuration
type Event ¶
type Event struct {
nuclio.AbstractEvent
// contains filtered or unexported fields
}
Event wraps an OpenInference inference request
func (*Event) GetContentType ¶
GetContentType returns the content type
func (*Event) GetFieldByteSlice ¶
GetFieldByteSlice returns a field value as a byte slice
func (*Event) GetFieldInt ¶
GetFieldInt returns a field value as an int
func (*Event) GetFieldString ¶
GetFieldString returns a field value as a string
func (*Event) GetHeaderByteSlice ¶
GetHeaderByteSlice returns a header value as a byte slice
func (*Event) GetHeaders ¶
GetHeaders returns all headers
func (*Event) GetTimestamp ¶
GetTimestamp returns the event timestamp
func (*Event) GetTriggerInfo ¶
func (e *Event) GetTriggerInfo() nuclio.TriggerInfoProvider
GetTriggerInfo returns trigger information
type InvalidInputError ¶
type InvalidInputError struct {
Err error
}
InvalidInputError lets a runtime distinguish invalid tensor requests from execution failures.
func (*InvalidInputError) Error ¶
func (e *InvalidInputError) Error() string
func (*InvalidInputError) Unwrap ¶
func (e *InvalidInputError) Unwrap() error
type ModelMetadataResponse ¶
type ModelMetadataResponse struct {
Name string `json:"name"`
Versions []string `json:"versions,omitempty"`
Platform string `json:"platform,omitempty"`
Inputs []RESTTensorMetadata `json:"inputs,omitempty"`
Outputs []RESTTensorMetadata `json:"outputs,omitempty"`
}
type ModelReadyResponse ¶
type ModelReadyResponse struct {
Ready bool `json:"ready"`
}
type RESTInferInputTensor ¶
type RESTInferOutputTensor ¶
type RESTInferenceRequest ¶
type RESTInferenceRequest struct {
ID string `json:"id,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
Inputs []RESTInferInputTensor `json:"inputs"`
Outputs []RESTInferOutputTensor `json:"outputs,omitempty"`
}
type RESTInferenceResponse ¶
type RESTInferenceResponse struct {
ModelName string `json:"model_name"`
ModelVersion string `json:"model_version,omitempty"`
ID string `json:"id,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
Outputs []RESTInferOutputTensor `json:"outputs"`
}
func Deserialize ¶
func Deserialize(data []byte) (*RESTInferenceResponse, error)
type RESTTensorMetadata ¶
type RESTTensorMetadata struct {
Name string `json:"name"`
Datatype string `json:"datatype"`
Shape []int64 `json:"shape"`
// Quantization params for int8/uint8 models, in the v2 `parameters` map.
// Omitted for float models, so their response stays exactly as before.
Parameters map[string]any `json:"parameters,omitempty"`
}
type ServerLiveResponse ¶
type ServerLiveResponse struct {
Live bool `json:"live"`
}
type ServerMetadataResponse ¶
type ServerReadyResponse ¶
type ServerReadyResponse struct {
Ready bool `json:"ready"`
}
type TensorDef ¶
type TensorDef struct {
Name string `mapstructure:"name"`
DataType string `mapstructure:"datatype"`
Shape []int64 `mapstructure:"shape"`
// Affine quantization params, for quantized models (int8/uint8): a client
// receiving int8 cannot map the values back to reals without them. Per-axis
// quantization yields more than one entry, indexed by QuantizedDimension.
Scale []float64 `mapstructure:"scale"`
ZeroPoint []int64 `mapstructure:"zero_point"`
QuantizedDimension int64 `mapstructure:"quantized_dimension"`
}
TensorDef defines the shape and data type of a tensor
type TensorMetadataProvider ¶
type TensorMetadataProvider interface {
ModelTensors() (inputs, outputs []TensorDef)
}
TensorMetadataProvider is implemented by runtimes that know their model's own signature (the TVM runtime reads it from metadata.json). The trigger prefers it over the tensors declared in the function config, so a function does not have to repeat — and risk contradicting — what the model already states. Runtimes that do not implement it keep the previous behaviour.