提交 87dfc12a 编写于 作者: Y Yu Yang

Follow comments

上级 18a3588b
...@@ -59,5 +59,11 @@ int main() { ...@@ -59,5 +59,11 @@ int main() {
} }
printf("\n"); printf("\n");
CHECK(paddle_matrix_destroy(prob));
CHECK(paddle_arguments_destroy(out_args));
CHECK(paddle_matrix_destroy(mat));
CHECK(paddle_arguments_destroy(in_args));
CHECK(paddle_gradient_machine_destroy(machine));
return 0; return 0;
} }
...@@ -4,24 +4,24 @@ ...@@ -4,24 +4,24 @@
#include "../common/common.h" #include "../common/common.h"
#define CONFIG_BIN "./trainer_config.bin" #define CONFIG_BIN "./trainer_config.bin"
#define NUM_THREAD 1000 #define NUM_THREAD 4
#define NUM_ITER 1000 #define NUM_ITER 1000
pthread_mutex_t mutex; pthread_mutex_t mutex;
void* thread_main(void* gm_ptr) { void* thread_main(void* gm_ptr) {
paddle_gradient_machine machine = (paddle_gradient_machine)(gm_ptr); paddle_gradient_machine machine = (paddle_gradient_machine)(gm_ptr);
paddle_arguments in_args = paddle_arguments_create_none();
// Create input matrix.
paddle_matrix mat = paddle_matrix_create(/* sample_num */ 1,
/* size */ 784,
/* useGPU */ false);
paddle_arguments out_args = paddle_arguments_create_none();
paddle_matrix prob = paddle_matrix_create_none();
for (int iter = 0; iter < NUM_ITER; ++iter) { for (int iter = 0; iter < NUM_ITER; ++iter) {
paddle_arguments in_args = paddle_arguments_create_none();
// There is only one input of this network. // There is only one input of this network.
CHECK(paddle_arguments_resize(in_args, 1)); CHECK(paddle_arguments_resize(in_args, 1));
// Create input matrix.
paddle_matrix mat = paddle_matrix_create(/* sample_num */ 1,
/* size */ 784,
/* useGPU */ false);
paddle_real* array; paddle_real* array;
// Get First row. // Get First row.
...@@ -33,12 +33,10 @@ void* thread_main(void* gm_ptr) { ...@@ -33,12 +33,10 @@ void* thread_main(void* gm_ptr) {
CHECK(paddle_arguments_set_value(in_args, 0, mat)); CHECK(paddle_arguments_set_value(in_args, 0, mat));
paddle_arguments out_args = paddle_arguments_create_none();
CHECK(paddle_gradient_machine_forward(machine, CHECK(paddle_gradient_machine_forward(machine,
in_args, in_args,
out_args, out_args,
/* isTrain */ false)); /* isTrain */ false));
paddle_matrix prob = paddle_matrix_create_none();
CHECK(paddle_arguments_value(out_args, 0, prob)); CHECK(paddle_arguments_value(out_args, 0, prob));
...@@ -53,6 +51,10 @@ void* thread_main(void* gm_ptr) { ...@@ -53,6 +51,10 @@ void* thread_main(void* gm_ptr) {
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
} }
CHECK(paddle_matrix_destroy(prob));
CHECK(paddle_arguments_destroy(out_args));
CHECK(paddle_matrix_destroy(mat));
CHECK(paddle_arguments_destroy(in_args));
CHECK(paddle_gradient_machine_destroy(machine)); CHECK(paddle_gradient_machine_destroy(machine));
return NULL; return NULL;
} }
......
...@@ -59,5 +59,12 @@ int main() { ...@@ -59,5 +59,12 @@ int main() {
} }
printf("\n"); printf("\n");
CHECK(paddle_matrix_destroy(prob));
CHECK(paddle_arguments_destroy(out_args));
CHECK(paddle_ivector_destroy(seq_pos));
CHECK(paddle_ivector_destroy(sentence));
CHECK(paddle_arguments_destroy(in_args));
CHECK(paddle_gradient_machine_destroy(machine));
return 0; return 0;
} }
...@@ -60,5 +60,11 @@ int main() { ...@@ -60,5 +60,11 @@ int main() {
} }
printf("\n"); printf("\n");
CHECK(paddle_matrix_destroy(prob));
CHECK(paddle_arguments_destroy(out_args));
CHECK(paddle_matrix_destroy(mat));
CHECK(paddle_arguments_destroy(in_args));
CHECK(paddle_gradient_machine_destroy(machine));
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册