diff --git a/src/fpga/api/fpga_api.cpp b/src/fpga/api/fpga_api.cpp index d484d889d8df8f4171658ae395531b84b0ac0a0d..a913d6e39cddda97b347c0675717c265dfa89d18 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 65fb1b5d611e8c063d196efa8b8d7ccfa0ff91b3..2dfc285af4506c055f6780d7b3d393433c0904a8 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