From fa0fd40da5a0aa4c6a8c16e7325375066afb6188 Mon Sep 17 00:00:00 2001 From: zhangyang Date: Thu, 26 Jul 2018 17:41:27 +0800 Subject: [PATCH] add interfaces --- src/fpga/api/fpga_api.cpp | 4 ++++ src/fpga/api/fpga_api.h | 49 ++++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/fpga/api/fpga_api.cpp b/src/fpga/api/fpga_api.cpp index d484d889d8..a913d6e39c 100644 --- a/src/fpga/api/fpga_api.cpp +++ b/src/fpga/api/fpga_api.cpp @@ -58,6 +58,10 @@ void fpga_copy(void *dest, const void *src, size_t num) { memcpy(dest, src, num); } +int ComputeFpgaConv(struct FpgaConvArgs) {} +int ComputeFpgaPool(struct FpgaPoolArgs) {} +int ComputeFpgaEWAdd(struct FpgaEWAddArgs) {} + } // namespace api } // namespace fpga } // namespace mobile diff --git a/src/fpga/api/fpga_api.h b/src/fpga/api/fpga_api.h index 65fb1b5d61..2dfc285af4 100644 --- a/src/fpga/api/fpga_api.h +++ b/src/fpga/api/fpga_api.h @@ -32,24 +32,55 @@ void *fpga_malloc(size_t size); void fpga_free(void *ptr); void fpga_copy(void *dst, const void *src, size_t num); -struct CnnVersionArgs { +struct FpgaVersionArgs { void *buf; }; -struct QuantArgs { +struct MemoryToPhysicalArgs { + const void *src; + uint64_t physical; +}; + +struct MemoryCopyArgs { + void *src; + void *dst; + size_t size; +}; + +struct FpgaQuantArgs { float scale; }; -struct BatchNormalizationArgs { - bool enable; +struct FpgaBNArgs {}; + +struct FpgaConvArgs { + bool enable_BN = false; + bool enable_Relu = false; + struct FpgaBNParam bn_parm; +}; + +struct FpgaPoolArgs { + bool enable_BN = false; + struct FpgaBNParam bn_parm; +}; + +struct FpgaEWAddArgs { // only support X + Y + bool enable_Relu = false; }; -struct ScaleArgs {}; +int ComputeFpgaConv(struct FpgaConvArgs); +int ComputeFpgaPool(struct FpgaPoolArgs); +int ComputeFpgaEWAdd(struct FpgaEWAddArgs); -#define IOCTL_CNN_MAGIC 'CNN' -#define IOCTL_VERSION _IOW(IOCTL_CNN_MAGIC, 1, struct CnnVersionArgs) -#define IOCTL_GET_QUANT _IOW(IOCTL_CNN_MAGIC, 2, struct QuantArgs) -#define IOCTL_SET_QUANT _IOW(IOCTL_CNN_MAGIC, 3, struct QuantArgs) +#define IOCTL_FPGA_MAGIC 'FPGA' +#define IOCTL_VERSION _IOW(IOCTL_FPGA_MAGIC, 1, struct FpgaVersionArgs) +#define IOCTL_GET_QUANT _IOW(IOCTL_FPGA_MAGIC, 2, struct FpgaQuantArgs) +#define IOCTL_SET_QUANT _IOW(IOCTL_FPGA_MAGIC, 3, struct FpgaArgs) +#define IOCTL_MEM_COPY _IOW(IOCTL_FPGA_MAGIC, 11, struct MemoryCopyArgs) +#define IOCTL_MEM_TOPHY _IOW(IOCTL_FPGA_MAGIC, 12, struct MemoryToPhysicalArgs) +#define IOCTL_CONFIG_CONV _IOW(IOCTL_FPGA_MAGIC, 21, struct FpgaConvArgs) +#define IOCTL_CONFIG_POOLING _IOW(IOCTL_FPGA_MAGIC, 22, struct FpgaPoolArgs) +#define IOCTL_CONFIG_EW _IOW(IOCTL_FPGA_MAGIC, 23, struct FpgaEWAddArgs) } // namespace api } // namespace fpga -- GitLab