提交 966bf9ae 编写于 作者: Q qiaolongfei

fix the problem in cclient when malloc paddle_parameter

上级 28476f5f
......@@ -42,6 +42,7 @@ import (
"strings"
"sync"
"unsafe"
"fmt"
"github.com/PaddlePaddle/Paddle/go/pserver"
)
......@@ -204,12 +205,14 @@ func paddle_get_params(client C.client, names **C.char, dst **C.paddle_parameter
}
p := ps[i]
param := *(**C.paddle_parameter)(unsafe.Pointer((uintptr(unsafe.Pointer(dst)) + uintptr(i)*unsafe.Sizeof(*dst))))
paramPtr := (**C.paddle_parameter)(unsafe.Pointer((uintptr(unsafe.Pointer(dst)) + uintptr(i)*unsafe.Sizeof(*dst))))
param := *paramPtr
nameReady := false
contentAllocated := false
if unsafe.Pointer(param) == nullPtr {
param = (*C.paddle_parameter)(C.calloc(1, C.size_t(unsafe.Sizeof(*param))))
*paramPtr = (*C.paddle_parameter)(C.calloc(1, C.size_t(unsafe.Sizeof(*param))))
param = *paramPtr
} else {
if unsafe.Pointer(param.name) != nullPtr {
if n := C.GoString(param.name); n != p.Name {
......
......@@ -21,7 +21,7 @@ void print_parameter(paddle_gradient* param) {
for (int i = 0; i < param->content_len; ++i) {
printf("0x%x ", param->content[i]);
}
printf("\n");
printf("\n\n");
}
}
......@@ -33,17 +33,18 @@ retry:
paddle_parameter param;
char name_a[] = "param_a";
char name_b[] = "param_b";
unsigned char content[] = {0x00, 0x00, 0x00};
unsigned char content1[] = {0x01, 0x02, 0x03};
param.element_type = PADDLE_ELEMENT_TYPE_FLOAT32;
param.name = name_a;
param.content = content;
param.content = content1;
param.content_len = 3;
if (paddle_init_param(c, param, NULL, 0) != 0) {
goto retry;
}
unsigned char content2[] = {0x04, 0x05, 0x06};
param.element_type = PADDLE_ELEMENT_TYPE_INT32;
param.name = name_b;
param.content = content;
param.content = content2;
param.content_len = 3;
if (paddle_init_param(c, param, NULL, 0) != 0) {
goto retry;
......
......@@ -29,6 +29,10 @@ type Parameter struct {
Content []byte
}
func (p *Parameter) toString() {
fmt.Println(p.Name, p.ElementType, p.Content)
}
// ParameterWithConfig contains the parameter and the configuration.
type ParameterWithConfig struct {
Param Parameter
......
......@@ -33,8 +33,8 @@ public:
const std::string pserverSpec);
~NewRemoteParameterUpdater() {
LOG(INFO) << "~NewRemoteParameterUpdater in";
releaseNewParameter(newParameters_);
releaseNewParameter(newGradients_);
// releaseNewParameter(newParameters_);
// releaseNewParameter(newGradients_);
if (parameterClient_ >= 0) paddle_pserver_client_release(parameterClient_);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册