From 5d3e816717f56fd70ec2f3467db4caeb14ada021 Mon Sep 17 00:00:00 2001 From: peterzhang2029 Date: Wed, 22 Nov 2017 11:50:14 +0800 Subject: [PATCH] bug fix in dense --- .../model_inference/dense/CMakeLists.txt | 2 +- .../dense/{main.c => main.cpp} | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) rename paddle/capi/examples/model_inference/dense/{main.c => main.cpp} (85%) diff --git a/paddle/capi/examples/model_inference/dense/CMakeLists.txt b/paddle/capi/examples/model_inference/dense/CMakeLists.txt index 008a488fd..31759310c 100644 --- a/paddle/capi/examples/model_inference/dense/CMakeLists.txt +++ b/paddle/capi/examples/model_inference/dense/CMakeLists.txt @@ -2,5 +2,5 @@ project(dense) cmake_minimum_required(VERSION 2.8) aux_source_directory(. SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") target_link_libraries(${PROJECT_NAME} -lpaddle_capi_shared) diff --git a/paddle/capi/examples/model_inference/dense/main.c b/paddle/capi/examples/model_inference/dense/main.cpp similarity index 85% rename from paddle/capi/examples/model_inference/dense/main.c rename to paddle/capi/examples/model_inference/dense/main.cpp index 876af2aa7..e761dfe2b 100644 --- a/paddle/capi/examples/model_inference/dense/main.c +++ b/paddle/capi/examples/model_inference/dense/main.cpp @@ -1,13 +1,15 @@ #include #include +#include +#include #include "../common/common.h" #define CONFIG_BIN "./trainer_config.bin" int main() { // Initalize Paddle - char* argv[] = {"--use_gpu=False"}; - CHECK(paddle_init(1, (char**)argv)); + std::string comand[] = {"--use_gpu=False"}; + CHECK(paddle_init(1, (char**)comand)); // Reading config binary file. It is generated by `convert_protobin.sh` long size; @@ -53,17 +55,20 @@ int main() { CHECK(paddle_arguments_get_value(out_args, 0, prob)); - std::std::vector result; - int height; - int width; + std::vector result; + uint64_t height; + uint64_t width; - CHECK(paddle_matrix_get_shape(prob, &height, &width); + CHECK(paddle_matrix_get_shape(prob, &height, &width)); result.resize(height * width); CHECK(paddle_matrix_get_value(prob, result.data())); - printf("Prob: "); + printf("Prob: \n"); for (int i = 0; i < height * width; ++i) { - printf("%.2f ", result[i]); + printf("%.4f ", result[i]); + if ((i + 1) % width == 0){ + printf("\n"); + } } printf("\n"); -- GitLab