diff --git a/src/fpga/api/fpga_api.cpp b/src/fpga/api/fpga_api.cpp index 706614e9449eb33e70e261b221d8882a9353ddbf..8167d4cf7d1fd343e15754bafc7c77ee6f52a822 100644 --- a/src/fpga/api/fpga_api.cpp +++ b/src/fpga/api/fpga_api.cpp @@ -58,9 +58,9 @@ void fpga_copy(void *dest, const void *src, size_t num) { memcpy(dest, src, num); } -int ComputeFpgaConv(struct FpgaConvArgs args) {} -int ComputeFpgaPool(struct FpgaPoolArgs args) {} -int ComputeFpgaEWAdd(struct FpgaEWAddArgs args) {} +int ComputeFpgaConv(struct ConvArgs args) {} +int ComputeFpgaPool(struct PoolingArgs args) {} +int ComputeFpgaEWAdd(struct EWAddArgs args) {} } // namespace fpga } // namespace paddle_mobile diff --git a/src/fpga/api/fpga_api.h b/src/fpga/api/fpga_api.h index 3db15c6ddc1843a5b6e91b0267ddbc0e606d87f8..4225e887c3dadeddf48b173db72412a5209d989d 100644 --- a/src/fpga/api/fpga_api.h +++ b/src/fpga/api/fpga_api.h @@ -58,7 +58,8 @@ struct KernelArgs { }; struct ImageInputArgs { - void* address; // input featuremap virtual address + void* address; // input featuremap virtual address + float* scale_address; // input scale address; uint32_t channels; uint32_t width; // featuremap width uint32_t height; @@ -73,29 +74,26 @@ struct ImageOutputArgs { struct ConvArgs { bool relu_enabled; - float scale; // input scale; void* bias_address; void* filter_address; uint32_t filter_num; uint32_t group_num; struct BNArgs bn; + struct KernelArgs kernel; struct ImageInputArgs image; // input image; struct ImageOutputArgs output; - struct KernelArgs kernel; }; struct PoolingArgs { - float scale; + struct KernelArgs kernel; struct ImageInputArgs image; // input image; struct ImageOutputArgs output; - struct KernelArgs kernel; }; // elementwise add arguments struct EWAddArgs { bool relu_enabled; - float scale; float const0; // output0 = const0 x input0 + const1 x input1; float const1; @@ -130,11 +128,35 @@ struct FpgaRegReadArgs { #define IOCTL_CONFIG_POOLING _IOW(IOCTL_FPGA_MAGIC, 22, struct PoolingArgs) #define IOCTL_CONFIG_EW _IOW(IOCTL_FPGA_MAGIC, 23, struct EWAddArgs) +enum FPGA_ERR_TYPE { + ERR_IOCTL_CMD = -1, + ERR_TIMEOUT = -2, + ERR_COMPLETION_TIMEOUT = -3, + ERR_INVALID_FPGA_ADDR = -4, + ERR_NOMEM = -5, + ERR_NO_RESERVE_MEM = -6, + ERR_COPY_FROM_USER = -7, + ERR_COPY_TO_USER = -8, + ERR_DEL_TIMER = -9, + ERR_ENABLE_MSI = -10, + ERR_REGISTER_IRQ = -11, + ERR_PCIE_REGISTER = -12, + ERR_PCIE_PROBE = -13, + ERR_REGISTER_BLOCK = -14, + ERR_ALLOC_GENDISK = -15, + ERR_INIT_QUEUE = -16, + ERR_WAIT = -17, + ERR_ECC_ERROR = -31, + ERR_FPGA_FAIL_STOP = -64, + ERR_FPGA_DEBUG_STOP = -113, + DEV_TMP_UNAVAILABLE = -128 +}; + //============================== API ============================= -int ComputeFpgaConv(struct FpgaConvArgs args); -int ComputeFpgaPool(struct FpgaPoolArgs args); -int ComputeFpgaEWAdd(struct FpgaEWAddArgs args); +int ComputeFpgaConv(struct ConvArgs args); +int ComputeFpgaPool(struct PoolingArgs args); +int ComputeFpgaEWAdd(struct EWAddArgs args); } // namespace fpga } // namespace paddle_mobile diff --git a/src/operators/op_param.h b/src/operators/op_param.h index dc790ee348e4070bd2891debe21c6f8e7bcdcdf0..88c1886ad7ade5960d1d8175a1b46e12363ca849 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -262,11 +262,11 @@ class ElementwiseAddParam : OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaEWAddArgs fpga_EW_add_args; + fpga::EWAddArgs fpga_EW_add_args; public: - const fpga::FpgaEWAddArgs &FpgaArgs() const { return fpga_EW_add_args; } - void SetFpgaArgs(const fpga::FpgaEWAddArgs &args) { fpga_EW_add_args = args; } + const fpga::EWAddArgs &FpgaArgs() const { return fpga_EW_add_args; } + void SetFpgaArgs(const fpga::EWAddArgs &args) { fpga_EW_add_args = args; } #endif }; @@ -465,11 +465,11 @@ class PoolParam : public OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaPoolArgs fpga_pool_args; + fpga::PoolingArgs fpga_pool_args; public: - const fpga::FpgaPoolArgs &FpgaArgs() const { return fpga_pool_args; } - void SetFpgaArgs(const fpga::FpgaPoolArgs &args) { fpga_pool_args = args; } + const fpga::PoolingArgs &FpgaArgs() const { return fpga_pool_args; } + void SetFpgaArgs(const fpga::PoolingArgs &args) { fpga_pool_args = args; } #endif }; #endif @@ -933,11 +933,11 @@ class FusionFcParam : public OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaConvArgs fpga_conv_args; + fpga::ConvArgs fpga_conv_args; public: - const fpga::FpgaConvArgs &FpgaArgs() const { return fpga_conv_args; } - void SetFpgaArgs(const fpga::FpgaConvArgs &args) { fpga_conv_args = args; } + const fpga::ConvArgs &FpgaArgs() const { return fpga_conv_args; } + void SetFpgaArgs(const fpga::ConvArgs &args) { fpga_conv_args = args; } #endif }; @@ -991,11 +991,11 @@ class FusionConvAddParam : public OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaConvArgs fpga_conv_args; + fpga::ConvArgs fpga_conv_args; public: - const fpga::FpgaConvArgs &FpgaArgs() const { return fpga_conv_args; } - void SetFpgaArgs(const fpga::FpgaConvArgs &args) { fpga_conv_args = args; } + const fpga::ConvArgs &FpgaArgs() const { return fpga_conv_args; } + void SetFpgaArgs(const fpga::ConvArgs &args) { fpga_conv_args = args; } #endif }; @@ -1096,11 +1096,11 @@ class FusionConvAddBNReluParam : public OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaConvArgs fpga_conv_args; + fpga::ConvArgs fpga_conv_args; public: - const fpga::FpgaConvArgs &FpgaArgs() const { return fpga_conv_args; } - void SetFpgaArgs(const fpga::FpgaConvArgs &args) { fpga_conv_args = args; } + const fpga::ConvArgs &FpgaArgs() const { return fpga_conv_args; } + void SetFpgaArgs(const fpga::ConvArgs &args) { fpga_conv_args = args; } #endif }; #endif @@ -1190,11 +1190,11 @@ class FusionConvAddBNParam : public OpParam { #ifdef PADDLE_MOBILE_FPGA private: - fpga::FpgaConvArgs fpga_conv_args; + fpga::ConvArgs fpga_conv_args; public: - const fpga::FpgaConvArgs &FpgaArgs() const { return fpga_conv_args; } - void SetFpgaArgs(const fpga::FpgaConvArgs &args) { fpga_conv_args = args; } + const fpga::ConvArgs &FpgaArgs() const { return fpga_conv_args; } + void SetFpgaArgs(const fpga::ConvArgs &args) { fpga_conv_args = args; } #endif }; #endif