Documentation
¶
Index ¶
- func BuildDataTensorRaw(b *fb.Builder, data []byte, shape []int64, dt uint8) fb.UOffsetT
- func BuildStringTensorRaw(b *fb.Builder, strs []string, shape []int64) fb.UOffsetT
- func BuildTensorContiguous(b *fb.Builder, val interface{}) (fb.UOffsetT, error)
- func BuildTensorNonContiguous(b *fb.Builder, val interface{}) (fb.UOffsetT, error)
- func BuildTensorSafe(b *fb.Builder, val interface{}) (fb.UOffsetT, error)
- func Handler(c *appContext, w http.ResponseWriter, r *http.Request) error
- func ListenAndServe(addr string, handler http.Handler) error
- func MultiRemote(client *http.Client, uri string, ins []interface{}, ...) ([]interface{}, error)
- func NativeTensorToNative(t *NativeTensor) (interface{}, error)
- func Remote(client *http.Client, uri string, in interface{}, inputName, outputName string) (interface{}, error)
- func Serialize(b *fb.Builder, obj fb.UOffsetT) []byte
- func Serve(listen string, cache bool, apply interface{}, inShapes, outShapes [][]int64) error
- func ServeRaw(opts *ServeRawOptions) error
- func ShapeType(val reflect.Value) (shape []int64, num int64, size int64, dt uint8, err error)
- func TensorToNative(t *graphpipefb.Tensor) (interface{}, error)
- type Applier
- type Error
- type GetHandlerFunc
- type NativeIOMetadata
- type NativeMetadataResponse
- type NativeTensor
- type Nt
- type RequestContext
- type ServeRawOptions
- type SimpleApplier
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDataTensorRaw ¶
BuildDataTensorRaw builds a data tensor from a byte slice. Validity is not checked, so passing a data slice that is not shape.numElems * dt.size will result in a tensor that is unusable by the receiver.
func BuildStringTensorRaw ¶
BuildStringTensorRaw builds a string tensor from a string slice.
func BuildTensorContiguous ¶
BuildTensorContiguous builds a flatbuffer tensor from a native go slice or array. Using this on a non-contiguous slice or a jagged slice can result in memory corruption. Note that this returns a flatbuffers offset type so that it can be used as part of building a larger object. The object can be serialized with the Serialize function.
func BuildTensorNonContiguous ¶
BuildTensorNonContiguous builds a flatbuffer tensor from a native go slice. This should be used if the slice is not contiguous in memory. Using this on a jagged slice can result in memory corruption. Note that this returns a flatbuffers offset type so that it can be used as part of building a larger object. The object can be serialized with the Serialize function.
func BuildTensorSafe ¶
BuildTensorSafe builds a flatbuffer tensor from a native go slice or array. This version is safe to use with any array or slice. It will return an error if val contains a jagged slice. Note that this returns a flatbuffers offset type so that it can be used as part of building a larger object. The object can be serialized with the Serialize function.
func Handler ¶
func Handler(c *appContext, w http.ResponseWriter, r *http.Request) error
Handler handles our http requests.
func ListenAndServe ¶
ListenAndServe is like robocop but for servers (listens on a host:port and handles requests).
func MultiRemote ¶
func MultiRemote(client *http.Client, uri string, ins []interface{}, inputNames, outputNames []string) ([]interface{}, error)
MultiRemote is a simple interface for communicating with models that have multiple inputs and outputs. It is recommended that you Specify inputNames and outputNames so that you can control input/output ordering. MultiRemote also performs type introspection for inputs and outputs.
func NativeTensorToNative ¶
func NativeTensorToNative(t *NativeTensor) (interface{}, error)
NativeTensorToNative is a converter between NativeTensors and raw arrays of arrays (of arrays of arrays) of numbers.
func Remote ¶
func Remote(client *http.Client, uri string, in interface{}, inputName, outputName string) (interface{}, error)
Remote is the simple interface for making a remote model request. It performs introspection and automatic type conversion on its inputs and outputs. Optionally, you can specify inputName and outputName; if either of these are missing it is up to the server to infer sane defaults for inputNames and outputNames;
func Serve ¶
Serve offers multiple inputs and outputs and converts tensors into native datatypes based on the shapes passed in to this function plus any additional shapes implied by your apply function. If cache is true, will attempt to cache using cache.db as cacheFile
func ServeRaw ¶
func ServeRaw(opts *ServeRawOptions) error
ServeRaw starts the model server. The listen address and port can be specified with the listen parameter. If cacheFile is not "" then caches will be stored using it. context will be passed back to the handler
func ShapeType ¶
ShapeType returns shape, num, size, and dt for a reflect.Value. The value of size will be -1 (unknown) for a string type
func TensorToNative ¶
func TensorToNative(t *graphpipefb.Tensor) (interface{}, error)
TensorToNative converts a tensor object into a native go slice. It can be cast to a proper type. For example: x := TensorToNative(t).([][]float32)
Types ¶
type Applier ¶
type Applier func(*RequestContext, string, map[string]*NativeTensor, []string) ([]*NativeTensor, error)
Applier is the base signature for server actions.
type GetHandlerFunc ¶
GetHandlerFunc is an indirection to return the handler.
type NativeIOMetadata ¶
NativeIOMetadata holds information describing the format of the model being served.
type NativeMetadataResponse ¶
type NativeMetadataResponse struct { Name string Version string Server string Description string Inputs []NativeIOMetadata Outputs []NativeIOMetadata }
NativeMetadataResponse is the response format used by the server.
type NativeTensor ¶
NativeTensor is an easier to use version of the flatbuffer Tensor.
func MultiRemoteRaw ¶
func MultiRemoteRaw(client *http.Client, uri string, inputs []*NativeTensor, inputNames, outputNames []string) ([]*NativeTensor, error)
MultiRemoteRaw is the actual implementation of the remote model request using NativeTensor objects.
func TensorToNativeTensor ¶
func TensorToNativeTensor(t *graphpipefb.Tensor) *NativeTensor
TensorToNativeTensor is a converter between the flatbuffer Tensor objects and the easier to use NativeTensor objects.
func (*NativeTensor) Build ¶
func (nt *NativeTensor) Build(b *fb.Builder) fb.UOffsetT
Build creates the actual flatbuffer representation.
func (*NativeTensor) InitSimple ¶
func (nt *NativeTensor) InitSimple(val interface{}) error
InitSimple tries to infer your data shape from the value you give it.
func (*NativeTensor) InitWithData ¶
func (nt *NativeTensor) InitWithData(data []byte, shape []int64, dt uint8) error
InitWithData is a more explicit initialization and expects the data to already be in the correct format.
func (*NativeTensor) InitWithStringVals ¶
func (nt *NativeTensor) InitWithStringVals(stringVals []string, shape []int64) error
InitWithStringVals is a more explicit initialization and expects the data to already be in the correct format (for stringvals).
type Nt ¶
type Nt struct {
// contains filtered or unexported fields
}
Nt is a NativeTensor holding struct.
type RequestContext ¶
type RequestContext struct { CleanupFunc func() // contains filtered or unexported fields }
RequestContext attaches our flatbuffers to the request.
func (*RequestContext) BuildTensor ¶
func (ctx *RequestContext) BuildTensor(val interface{}) (fb.UOffsetT, error)
BuildTensor does the heavy lifting to make sure we have a flatbuffer.
func (*RequestContext) IsAlive ¶
func (ctx *RequestContext) IsAlive() bool
IsAlive tells you if it isn't dead.
func (*RequestContext) SetDead ¶
func (ctx *RequestContext) SetDead()
SetDead makes sure it isn't alive.
type ServeRawOptions ¶
type ServeRawOptions struct { Listen string CacheFile string Meta *NativeMetadataResponse DefaultInputs []string DefaultOutputs []string Apply Applier GetHandler GetHandlerFunc }
ServeRawOptions is just a call parameter struct.
func BuildSimpleApply ¶
func BuildSimpleApply(apply interface{}, inShapes, outShapes [][]int64) *ServeRawOptions
BuildSimpleApply is the factory for producing SimpleAppliers
type SimpleApplier ¶
type SimpleApplier func(interface{}) (interface{}, error)
SimpleApplier is the signature for a server action that converts between native types and graphpipe objects.
type StatusError ¶
StatusError is our wrapper around an http error interface.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
graphpipe-tf/internal/github.com/tensorflow/tensorflow/tensorflow/go/core/framework
Package framework is a generated protocol buffer package.
|
Package framework is a generated protocol buffer package. |
graphpipe-tf/internal/github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf
Package protobuf is a generated protocol buffer package.
|
Package protobuf is a generated protocol buffer package. |