diff --git a/go/pserver/optimizer.go b/go/pserver/optimizer.go index df2219aa84d9fec4545a8bb59b8d4fc8dfc086a1..40748d03c1da2115ffb11b2f465a7a5d688d6271 100644 --- a/go/pserver/optimizer.go +++ b/go/pserver/optimizer.go @@ -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" diff --git a/go/pserver/service.go b/go/pserver/service.go index c721388b6a7fc6922dfa3f9a5d3370a1285108a9..32449f66b7e841314756a4a306603f23f2c94d15 100644 --- a/go/pserver/service.go +++ b/go/pserver/service.go @@ -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)