From a2fabcc1144c480d0f972026194693b80ca6c397 Mon Sep 17 00:00:00 2001 From: dongzhihong Date: Wed, 28 Jun 2017 00:57:52 +0800 Subject: [PATCH] "fix client test" --- go/pserver/client_test.go | 9 +++++++-- go/pserver/optimizer.go | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go/pserver/client_test.go b/go/pserver/client_test.go index d0371a26a13..d746bf3f269 100644 --- a/go/pserver/client_test.go +++ b/go/pserver/client_test.go @@ -1,6 +1,7 @@ package pserver_test import ( + "io/ioutil" "net" "net/http" "net/rpc" @@ -71,18 +72,22 @@ func TestClientFull(t *testing.T) { } const numParameter = 100 + config, err := ioutil.ReadFile("./cclient/test/testdata/optimizer.pb.txt") + if err != nil { + t.Fatalf("read optimizer proto failed") + } for i := 0; i < numParameter; i++ { var p pserver.Parameter p.Name = "p_" + strconv.Itoa(i) p.ElementType = pserver.Float32 p.Content = make([]byte, (i+1)*100) - err := c.InitParam(pserver.ParameterWithConfig{Param: p}) + err := c.InitParam(pserver.ParameterWithConfig{Param: p, Config: config}) if err != nil { t.Fatal(err) } } - err := c.FinishInitParams() + err = c.FinishInitParams() if err != nil { t.Fatal(err) } diff --git a/go/pserver/optimizer.go b/go/pserver/optimizer.go index 5575fab3c0a..9cb2801f30d 100644 --- a/go/pserver/optimizer.go +++ b/go/pserver/optimizer.go @@ -61,6 +61,7 @@ func (o *optimizer) UpdateParameter(g Gradient) error { return fmt.Errorf("Name: %s, parameter and gradient element type not match, parameter: %v, gradient: %v", g.Name, o.ElementType, g.ElementType) } + fmt.Println(g) r := C.paddle_update_parameter(o.opt, C.paddle_element_type(g.ElementType), unsafe.Pointer(&g.Content[0]), C.int(len(g.Content))) if r != 0 { return fmt.Errorf("optimizer update returned error code: %d", r) -- GitLab