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

revert parameter with []byte

上级 7386b06c
...@@ -5,6 +5,7 @@ package pserver ...@@ -5,6 +5,7 @@ package pserver
#cgo pkg-config: protobuf #cgo pkg-config: protobuf
#cgo CFLAGS: -I ../../ #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: ../../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" #include "paddle/optimizer/optimizer.h"
*/ */
import "C" import "C"
......
...@@ -28,8 +28,7 @@ const ( ...@@ -28,8 +28,7 @@ const (
type Parameter struct { type Parameter struct {
Name string Name string
ElementType ElementType ElementType ElementType
Content *byte Content []byte
Length int
} }
// ParameterWithConfig contains the parameter and the configuration. // ParameterWithConfig contains the parameter and the configuration.
...@@ -47,15 +46,13 @@ type Service struct { ...@@ -47,15 +46,13 @@ type Service struct {
mu sync.Mutex mu sync.Mutex
// injection from parameter to optimizer // injection from parameter to optimizer
optMap map[string]*optimizer optMap map[string]*optimizer
paramMap map[string]Parameter
} }
// NewService creates a new service. // NewService creates a new service.
func NewService() *Service { func NewService() *Service {
s := &Service{} s := &Service{}
s.optMap = make(map[string]*optimizer) s.optMap = make(map[string]*optimizer)
s.paramMap = make(map[string]Parameter)
s.initialized = make(chan struct{}) s.initialized = make(chan struct{})
return s return s
} }
...@@ -76,7 +73,6 @@ func (s *Service) InitParam(paramWithConfigs ParameterWithConfig, dummy *int) er ...@@ -76,7 +73,6 @@ func (s *Service) InitParam(paramWithConfigs ParameterWithConfig, dummy *int) er
// TODO(helin): check if paramWithConfigs.Param.Content is // TODO(helin): check if paramWithConfigs.Param.Content is
// properly memory aligned, if not, make copy to a memory // properly memory aligned, if not, make copy to a memory
// aligned region. // aligned region.
s.paramMap[paramWithConfigs.Param.Name] = paramWithConfigs.Param
s.optMap[paramWithConfigs.Param.Name] = newOptimizer(paramWithConfigs) s.optMap[paramWithConfigs.Param.Name] = newOptimizer(paramWithConfigs)
return nil return nil
} }
...@@ -106,13 +102,9 @@ func (s *Service) SendGrad(g Gradient, dummy *int) error { ...@@ -106,13 +102,9 @@ func (s *Service) SendGrad(g Gradient, dummy *int) error {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() 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] o, ok := s.optMap[g.Name]
if !ok { 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) return o.UpdateParameter(p, g)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册