提交 59b40ecb 编写于 作者: D dzhwinter

revert parameter with []byte

上级 7386b06c
......@@ -5,6 +5,7 @@ package pserver
#cgo pkg-config: protobuf
#cgo CFLAGS: -I ../../
#cgo LDFLAGS: ../../build/paddle/optimizer/libpaddle_optimizer.a ../../build/proto/libpaddle_proto.a ../../third_party/install/glog/lib/libglog.a ../../third_party/install/gtest/lib/libgtest.a ../../third_party/install/gflags/lib/libgflags.a ../../third_party/install/openblas/lib/libopenblas.a -I/usr/local/lib/ -lprotobuf
#cgo LDFLAGS: /Users/dzh/.go/src/github.com/PaddlePaddle/Paddle/build/lib/libdep.a
#include "paddle/optimizer/optimizer.h"
*/
import "C"
......
......@@ -28,8 +28,7 @@ const (
type Parameter struct {
Name string
ElementType ElementType
Content *byte
Length int
Content []byte
}
// ParameterWithConfig contains the parameter and the configuration.
......@@ -47,15 +46,13 @@ type Service struct {
mu sync.Mutex
// injection from parameter to optimizer
optMap map[string]*optimizer
paramMap map[string]Parameter
optMap map[string]*optimizer
}
// NewService creates a new service.
func NewService() *Service {
s := &Service{}
s.optMap = make(map[string]*optimizer)
s.paramMap = make(map[string]Parameter)
s.initialized = make(chan struct{})
return s
}
......@@ -76,7 +73,6 @@ func (s *Service) InitParam(paramWithConfigs ParameterWithConfig, dummy *int) er
// TODO(helin): check if paramWithConfigs.Param.Content is
// properly memory aligned, if not, make copy to a memory
// aligned region.
s.paramMap[paramWithConfigs.Param.Name] = paramWithConfigs.Param
s.optMap[paramWithConfigs.Param.Name] = newOptimizer(paramWithConfigs)
return nil
}
......@@ -106,13 +102,9 @@ func (s *Service) SendGrad(g Gradient, dummy *int) error {
s.mu.Lock()
defer s.mu.Unlock()
p, ok := s.paramMap[g.Name]
if !ok {
return fmt.Errorf("parameter: %s does not exist", g.Name)
}
o, ok := s.optMap[g.Name]
if !ok {
return fmt.Errorf("optimizer: %s does not exist", g.Name)
return fmt.Errorf("parameter: %s does not exist", g.Name)
}
return o.UpdateParameter(p, g)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册