inference

package
v1.9.57-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2020 License: GPL-3.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INFER_UNKNOWN  = InferType(0)
	INFER_BY_IH    = InferType(1) // Infer By Input Hash
	INFER_BY_IC    = InferType(2) // Infer By Input Content
	GAS_BY_H       = InferType(3) // Gas By Model Hash
	AVAILABLE_BY_H = InferType(4) // Available by info hash
)
View Source
const (
	RES_OK    = "ok"
	RES_ERROR = "error"
)

infer response types

Variables

This section is empty.

Functions

func DumpToFile added in v1.0.0

func DumpToFile(fname string, data []byte) error

Types

type AvailableWork added in v1.9.51

type AvailableWork struct {
	Type     InferType `json:"type"`
	InfoHash string    `json:"infohash"`
	RawSize  int64     `json:"rawSize"`
}

check Available

type GasWork added in v1.0.0

type GasWork struct {
	Type  InferType `json:"type"`
	Model string    `json:"model"`
}

Infer gas

type ICWork added in v1.0.0

type ICWork struct {
	Type  InferType     `json:"type"`
	Model string        `json:"model"`
	Input hexutil.Bytes `json:"input"`
}

Infer by input content

type IHWork added in v1.0.0

type IHWork struct {
	Type  InferType `json:"type"`
	Model string    `json:"model"`
	Input string    `json:"input"`
}

Infer by input info hash

type InferResult added in v1.0.0

type InferResult struct {
	Data hexutil.Bytes `json:"data"`
	Info string        `json:"info"`
}

type InferType added in v1.0.0

type InferType uint32

infer send types

func RetriveType added in v1.0.0

func RetriveType(input []byte) InferType

type NpyReader added in v1.0.0

type NpyReader struct {

	// The numpy data type of the array
	Dtype string

	// The endianness of the binary data
	Endian binary.ByteOrder

	// The version number of the file format
	Version int

	// The shape of the array as specified in the file.
	Shape []int

	// If true, the data are flattened in column-major order,
	// otherwise they are flattened in row-major order.
	ColumnMajor bool
	// contains filtered or unexported fields
}

NpyReader can read data from a Numpy binary array into a Go slice.

func NewBytesReader added in v1.0.0

func NewBytesReader(buff []byte) (*NpyReader, error)

func NewFileReader added in v1.0.0

func NewFileReader(f string) (*NpyReader, error)

NewFileReader returns a NpyReader that can be used to obtain array data from the given named file. Call one of the GetXXX methods to obtain the data as a Go slice.

func NewReader added in v1.0.0

func NewReader(r io.Reader) (*NpyReader, error)

NewReader returns a NpyReader that can be used to obtain array data as a Go slice. The Go slice has a type matching the dtype in the Numpy file. Call one of the GetXX methods to obtain the slice.

func (*NpyReader) GetBytes added in v1.0.0

func (rdr *NpyReader) GetBytes() ([]byte, error)

func (*NpyReader) GetComplex128 added in v1.9.51

func (rdr *NpyReader) GetComplex128() ([]complex128, error)

GetComplex128 returns the array data as a slice of complex128 values.

func (*NpyReader) GetComplex64 added in v1.9.51

func (rdr *NpyReader) GetComplex64() ([]complex64, error)

GetComplex64 returns the array data as a slice of complex64 values.

func (*NpyReader) GetFloat32 added in v1.0.0

func (rdr *NpyReader) GetFloat32() ([]float32, error)

GetFloat32 returns the array data as a slice of float32 values.

func (*NpyReader) GetFloat64 added in v1.0.0

func (rdr *NpyReader) GetFloat64() ([]float64, error)

GetFloat64 returns the array data as a slice of float64 values.

func (*NpyReader) GetInt16 added in v1.0.0

func (rdr *NpyReader) GetInt16() ([]int16, error)

GetInt16 returns the array data as a slice of int16 values.

func (*NpyReader) GetInt32 added in v1.0.0

func (rdr *NpyReader) GetInt32() ([]int32, error)

GetInt32 returns the array data as a slice of int32 values.

func (*NpyReader) GetInt64 added in v1.0.0

func (rdr *NpyReader) GetInt64() ([]int64, error)

GetInt64 returns the array data as a slice of int64 values.

func (*NpyReader) GetInt8 added in v1.0.0

func (rdr *NpyReader) GetInt8() ([]int8, error)

GetInt8 returns the array data as a slice of int8 values.

func (*NpyReader) GetUint16 added in v1.9.51

func (rdr *NpyReader) GetUint16() ([]uint16, error)

GetUint16 returns the array data as a slice of uint16 values.

func (*NpyReader) GetUint32 added in v1.9.51

func (rdr *NpyReader) GetUint32() ([]uint32, error)

GetUint32 returns the array data as a slice of uint32 values.

func (*NpyReader) GetUint64 added in v1.9.51

func (rdr *NpyReader) GetUint64() ([]uint64, error)

GetUint64 returns the array data as a slice of uint64 values.

func (*NpyReader) GetUint8 added in v1.9.51

func (rdr *NpyReader) GetUint8() ([]uint8, error)

GetUint8 returns the array data as a slice of uint8 values.

type NpyWriter added in v1.9.51

type NpyWriter struct {

	// Defaults to little endian, but can be set to
	// binary.BigEndian before writing data
	Endian binary.ByteOrder

	// Defaults to nx1, where n is the length of data.  Can be set
	// to any shape with any number of dimensions.  The shape is
	// not checked for compatibility with the data.
	Shape []int

	// Defaults to false (row major order), can be set to true
	// (column major order) before writing the data.
	ColumnMajor bool

	// Defaults to 1, can be set to 2 before writing the data.
	Version int
	// contains filtered or unexported fields
}

NpyWriter can write data from a Go slice to a Numpy binary array.

func NewFileWriter added in v1.9.51

func NewFileWriter(fname string) (*NpyWriter, error)

NewFileWriter returns a NpyWriter that can be used to write data to a Numpy binary format file. After creation, call one of the WriteXX methods to write array data to the file. The file is automatically closed at the end of that call. Only one array can be written to a file.

func NewWriter added in v1.9.51

func NewWriter(w io.WriteCloser) (*NpyWriter, error)

NewWriter returns a NpyWriter that can be used to write data to an io.WriteCloser, using the Numpy binary format. After creation, call one of the WriteXXX methods to write array data to the writer. The file is automatically closed at the end of that call. Only one slice can be written to the writer.

func (*NpyWriter) WriteComplex128 added in v1.9.51

func (wtr *NpyWriter) WriteComplex128(data []complex128) error

WriteComplex128 writes a slice of complex128 values in npy format.

func (*NpyWriter) WriteComplex64 added in v1.9.51

func (wtr *NpyWriter) WriteComplex64(data []complex64) error

WriteComplex64 writes a slice of complex64 values in npy format.

func (*NpyWriter) WriteFloat32 added in v1.9.51

func (wtr *NpyWriter) WriteFloat32(data []float32) error

WriteFloat32 writes a slice of float32 values in npy format.

func (*NpyWriter) WriteFloat64 added in v1.9.51

func (wtr *NpyWriter) WriteFloat64(data []float64) error

WriteFloat64 writes a slice of float64 values in npy format.

func (*NpyWriter) WriteInt16 added in v1.9.51

func (wtr *NpyWriter) WriteInt16(data []int16) error

WriteInt16 writes a slice of int16 values in npy format.

func (*NpyWriter) WriteInt32 added in v1.9.51

func (wtr *NpyWriter) WriteInt32(data []int32) error

WriteInt32 writes a slice of int32 values in npy format.

func (*NpyWriter) WriteInt64 added in v1.9.51

func (wtr *NpyWriter) WriteInt64(data []int64) error

WriteInt64 writes a slice of int64 values in npy format.

func (*NpyWriter) WriteInt8 added in v1.9.51

func (wtr *NpyWriter) WriteInt8(data []int8) error

WriteInt8 writes a slice of int8 values in npy format.

func (*NpyWriter) WriteUint16 added in v1.9.51

func (wtr *NpyWriter) WriteUint16(data []uint16) error

WriteUint16 writes a slice of uint16 values in npy format.

func (*NpyWriter) WriteUint32 added in v1.9.51

func (wtr *NpyWriter) WriteUint32(data []uint32) error

WriteUint32 writes a slice of uint32 values in npy format.

func (*NpyWriter) WriteUint64 added in v1.9.51

func (wtr *NpyWriter) WriteUint64(data []uint64) error

WriteUint64 writes a slice of uint64 values in npy format.

func (*NpyWriter) WriteUint8 added in v1.9.51

func (wtr *NpyWriter) WriteUint8(data []uint8) error

WriteUint8 writes a slice of uint8 values in npy format.

type Work added in v1.9.51

type Work struct {
	Type InferType `json:"type"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL