client.go 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package pserver

// ElementType is the type of elements of a Parameter.
type ElementType int

// Supported element types
const (
	Int32 ElementType = iota
	UInt32
	Int64
	UInt64
	Float32
	Float64
)

H
Helin Wang 已提交
16
// Parameter is a piece of data to sync with the parameter server.
17 18 19 20 21 22
type Parameter struct {
	Name        string
	ElementType ElementType
	Content     []byte
}

H
Helin Wang 已提交
23
// ParameterWithConfig contains the parameter and the configuration.
24 25
type ParameterWithConfig struct {
	Param  Parameter
H
Helin Wang 已提交
26
	Config []byte // parameter configuration in Proto Buffer format
27 28
}

H
Helin Wang 已提交
29
// Gradient is the gradient of the parameter.
30 31
type Gradient Parameter

H
Helin Wang 已提交
32
// Client is the client to parameter servers.
33 34 35
type Client struct {
}

H
Helin Wang 已提交
36
// NewClient creates a new client.
37 38 39 40
func NewClient(addr string) *Client {
	return &Client{}
}

H
Helin Wang 已提交
41 42 43 44 45 46 47 48 49
// BeginInitParams begins to initialize parameters on parameter
// servers.
//
// BeginInitParams will be called from multiple trainers, only one
// trainer will be selected to initialize the parameters on parameter
// servers. Other trainers will be blocked until the initialization is
// done, and they need to get the initialized parameters from
// parameter servers using GetParams.
func (c *Client) BeginInitParams(pserverConfigProto []byte) (selected bool, err error) {
50 51 52
	return true, nil
}

H
Helin Wang 已提交
53
// InitParam initializes the parameter on parameter servers.
54 55 56 57
func (c *Client) InitParam(paramWithConfigs ParameterWithConfig) error {
	return nil
}

H
Helin Wang 已提交
58 59
// FinishInitParams tells parameter servers client has sent all
// parameters to parameter servers as initialization.
60 61 62 63
func (c *Client) FinishInitParams() error {
	return nil
}

H
Helin Wang 已提交
64 65
// SendGrads sends gradients to parameter servers for updating
// parameters.
66 67 68 69
func (c *Client) SendGrads(grads []Gradient) error {
	return nil
}

H
Helin Wang 已提交
70
// GetParams gets parameters from parameter servers.
71 72 73 74
func (c *Client) GetParams(names []string) ([]Parameter, error) {
	return nil, nil
}

H
Helin Wang 已提交
75 76
// SaveModel indicates parameters to save the parameter to the given
// path.
77 78 79 80
func (c *Client) SaveModel(path string) error {
	return nil
}

H
Helin Wang 已提交
81
// Cleanup cleans up the client states.
82 83
func (c *Client) Cleanup() {
}