From f5c5f28efb7c99f0440fcd476851c7701786fd00 Mon Sep 17 00:00:00 2001 From: zhangyang0701 Date: Thu, 21 Mar 2019 17:18:03 +0800 Subject: [PATCH] add version interface for FPGA track --- src/fpga/common/fpga_common.cpp | 12 ++++++++++++ src/fpga/common/fpga_common.h | 4 ++++ src/io/paddle_inference_api.h | 2 ++ test/fpga/test_marker_api.cpp | 9 ++++++--- test/fpga/test_rfcn_api.cpp | 11 +++++++++-- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/fpga/common/fpga_common.cpp b/src/fpga/common/fpga_common.cpp index ad238c51ef..06b0b365bd 100644 --- a/src/fpga/common/fpga_common.cpp +++ b/src/fpga/common/fpga_common.cpp @@ -197,5 +197,17 @@ uint64_t vaddr_to_paddr(void *address) { return 0; #endif } + +uint32_t paddle_mobile_version() { + uint32_t v_master = 34; + uint32_t v_slave = 34; + + uint32_t first = 1, second = 2, fourth_master = 1, fourth_slave = 2; + uint32_t master = first << 24 | second << 16 | v_master << 8 | fourth_master; + uint32_t slave = first << 24 | second << 16 | v_slave << 8 | fourth_slave; + + return slave; +} + } // namespace fpga } // namespace paddle_mobile diff --git a/src/fpga/common/fpga_common.h b/src/fpga/common/fpga_common.h index fc3ca28cc9..bc882bed5e 100644 --- a/src/fpga/common/fpga_common.h +++ b/src/fpga/common/fpga_common.h @@ -30,6 +30,7 @@ limitations under the License. */ namespace paddle_mobile { namespace fpga { + enum DataType { DATA_TYPE_INT8 = 2, DATA_TYPE_FP32 = 1, @@ -275,5 +276,8 @@ uint64_t vaddr_to_paddr(void* address); void expand_conv_arg(ConvArgs* arg); void expand_EW_arg(EWAddArgs* arg); inline int32_t convertmantissa(int32_t i); + +uint32_t paddle_mobile_version(); + } // namespace fpga } // namespace paddle_mobile diff --git a/src/io/paddle_inference_api.h b/src/io/paddle_inference_api.h index 36435e07e6..e8c2c1daaa 100644 --- a/src/io/paddle_inference_api.h +++ b/src/io/paddle_inference_api.h @@ -30,10 +30,12 @@ limitations under the License. */ namespace paddle_mobile { #ifdef PADDLE_MOBILE_FPGA + namespace fpga { int open_device(); void* fpga_malloc(size_t size); void fpga_free(void* ptr); +uint32_t paddle_mobile_version(); } // namespace fpga #endif diff --git a/test/fpga/test_marker_api.cpp b/test/fpga/test_marker_api.cpp index 2b25f8f6d1..48038e7b8f 100644 --- a/test/fpga/test_marker_api.cpp +++ b/test/fpga/test_marker_api.cpp @@ -139,6 +139,9 @@ PaddleMobileConfig GetConfig1() { int main() { open_device(); + timeval start11, end11; + long dif_sec, dif_usec; // NOLINT + PaddleMobileConfig config = GetConfig(); auto predictor = CreatePaddlePredictorPredict_From_To(0, -1); gettimeofday(&end11, NULL); @@ -189,8 +190,9 @@ int main() { std::cout << "Output number is " << v.size() << std::endl; for (int fetchNum = 0; fetchNum < v.size(); fetchNum++) { std::string dumpName = "marker_api_fetch_" + std::to_string(fetchNum); - dump_stride(dumpName, v[fetchNum]); + // dump_stride(dumpName, v[fetchNum]); } + fpga_free(img); PaddleMobileConfig config1 = GetConfig1(); auto predictor1 = @@ -233,6 +235,7 @@ int main() { std::string dumpName = "marker2_api_fetch_" + std::to_string(fetchNum); dump_stride(dumpName, v1[fetchNum]); } + fpga_free(img1); } return 0; } diff --git a/test/fpga/test_rfcn_api.cpp b/test/fpga/test_rfcn_api.cpp index a52be938de..c62eeda992 100644 --- a/test/fpga/test_rfcn_api.cpp +++ b/test/fpga/test_rfcn_api.cpp @@ -16,6 +16,7 @@ limitations under the License. */ #define PADDLE_MOBILE_FPGA #endif #include +#include #include #include "../../src/io/paddle_inference_api.h" @@ -69,7 +70,7 @@ PaddleMobileConfig GetConfig1() { int main() { open_device(); - +#if 0 PaddleMobileConfig config1 = GetConfig1(); auto predictor1 = CreatePaddlePredictorFetchPaddleTensors(&v1); // Old data in v will be cleared std::cout << "Output number is " << v1.size() << std::endl; std::cout << "out[0] length " << v1[0].data.length() << std::endl; - + fpga_free(img1); +#endif //////////////////////////// PaddleMobileConfig config = GetConfig(); @@ -160,6 +162,11 @@ int main() { } } std::cout << "Finish getting vector values" << std::endl; + fpga_free(img); + + auto version = fpga::paddle_mobile_version(); + + std::cout << "0X0" << std::hex << version << std::endl; return 0; } -- GitLab