[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/LIBQNNPACK PATCH 3/3] Initial port of QNNPACK on Unikraft



This is our initial port of QNNPACK to Unikraft as an external library.
The dependencies are: libcxx, newlib, pthreads,fp16, fxdiv, psimd and
 pthreadpool.
(e.g. ...:$(UK_LIBS)/libunwind:$(UK_LIBS)/compiler-rt:
$(UK_LIBS)/libcxxabi:$(UK_LIBS)/libcxx:$(UK_LIBS)/pthread-embedded:
$(UK_LIBS)/newlib:$(UK_LIBS)/intel_intrinsic:$(UK_LIBS)/fp16:
$(UK_LIBS)/fxdiv:$(UK_LIBS)/psimd:$(UK_LIBS)/pthreadpool:$(UK_LIBS)/qnnpack)

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
 Config.uk         |   9 +++
 Makefile.uk       | 142 ++++++++++++++++++++++++++++++++++++++++++++++
 glue.c            |  15 +++++
 include/cpuinfo.h |   5 ++
 4 files changed, 171 insertions(+)
 create mode 100644 Config.uk
 create mode 100644 Makefile.uk
 create mode 100644 glue.c
 create mode 100644 include/cpuinfo.h

diff --git a/Config.uk b/Config.uk
new file mode 100644
index 0000000..aee021c
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,9 @@
+menuconfig LIBQNNPACK
+    bool "QNNPACK - implementation of quantized neural network operators"
+    select LIBPSIMD
+    select LIBCXX
+    select LIBFXDIV
+    select LIBFP16
+    select LIBINTEL_INTRINSICS
+    select LIBPTHREADPOOL
+    default n
diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..d3704ad
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,142 @@
+
+################################################################################
+# Library registration
+################################################################################
+$(eval $(call addlib_s,libqnnpack,$(CONFIG_LIBQNNPACK)))
+
+################################################################################
+# Sources
+################################################################################
+LIBQNNPACK_VERSION=master
+LIBQNNPACK_URL=https://github.com/pytorch/QNNPACK/archive/master.zip
+LIBQNNPACK_PATCHDIR=$(LIBQNN_BASE)/patches
+
+$(eval $(call fetch,libqnnpack,$(LIBQNNPACK_URL)))
+
+
+################################################################################
+# Helpers
+################################################################################
+LIBQNNPACK_SUBDIR=QNNPACK-$(LIBQNNPACK_VERSION)
+LIBQNNPACK_SRC=$(LIBQNNPACK_ORIGIN)/$(LIBQNNPACK_SUBDIR)
+
+################################################################################
+# Library includes
+################################################################################
+CINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/include
+CINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_BASE)/include
+CINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/deps/clog/include
+CINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/src
+CXXINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/include
+CXXINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/deps/clog/include
+CXXINCLUDES-$(CONFIG_LIBQNNPACK) += -I$(LIBQNNPACK_SRC)/src
+
+################################################################################
+# Global flags
+################################################################################
+# Suppress some warnings to make the build process look neater
+SUPPRESS_FLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-nonnull      
    \
+-Wno-unused-but-set-variable -Wno-unused-label -Wno-char-subscripts            
        \
+-Wno-unused-function -Wno-missing-field-initializers -Wno-uninitialized        
            \
+-Wno-array-bounds -Wno-maybe-uninitialized -Wno-pointer-sign -Wno-unused-value 
\
+-Wno-unused-macros -Wno-parentheses -Wno-implicit-function-declaration         
    \
+-Wno-missing-braces -Wno-endif-labels -Wno-unused-but-set-variable             
        \
+-Wno-implicit-function-declaration -Wno-type-limits -Wno-sign-compare
+LIB_NAME_CFLAGS-y    +=  $(SUPPRESS_FLAGS)
+LIB_NAME_CXXFLAGS-y    +=  $(SUPPRESS_FLAGS)
+
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_BASE)/glue.c
+################################################################################
+# Library sources
+################################################################################
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8rmax/neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8rmax/sse2.c|u8rmax
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8lut/scalar.c|x8lut
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-sse4.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/fp32-psimd.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/fp32-scalar.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-scalar.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/gemmlowp-ssse3.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/q31-ssse3.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/q31-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/fp32-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/gemmlowp-sse2.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/fp32-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/gemmlowp-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-ssse3.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-psimd.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/q31-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/q31-sse4.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/precise-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/gemmlowp-sse4.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/q31-scalar.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/requantization/gemmlowp-scalar.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8lut32norm/scalar.c|u8lut32norm
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/indirection.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/softargmax.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8clamp/neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8clamp/sse2.c|u8clamp
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/operator-delete.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/clamp.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sigmoid.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/4x8c2-xzp-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/2x4c8-sse2.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/4x8-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/6x4-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/8x8-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/4x4c2-sse2.c|q8gemm
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gemm/4x-sumrows-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/max-pooling.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8vadd/neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8vadd/sse2.c|q8vadd
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/convolution.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/leaky-relu.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8dwconv/mp8x25-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8dwconv/up8x9-sse2.c|q8dwconv
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8dwconv/mp8x25-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8dwconv/up8x9-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sdwconv/up4x9-psimd.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sconv/6x8-psimd.c|sconv
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/deconvolution.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/init.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/up8xm-sse2.c|q8gavgpool
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/up8xm-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/mp8x7p7q-sse2.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/up8x7-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/mp8x7p7q-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8gavgpool/up8x7-sse2.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8maxpool/16x9p8q-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8maxpool/sub16-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8maxpool/16x9p8q-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/u8maxpool/sub16-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/average-pooling.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/add.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/global-average-pooling.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/operator-run.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8conv/4x8-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8conv/8x8-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8conv/4x4c2-sse2.c|q8conv
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sgemm/6x8-psimd.c|qgemm
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sgemm/6x8-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/sgemm/5x8-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/channel-shuffle.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x3-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/xm-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x4-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x2-sse2.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x2-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/xm-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x3-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/x8zip/x4-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/fully-connected.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/hgemm/8x8-neonfp16arith.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/mp8x9p8q-sse2.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/up8xm-sse2.c|q8avgpool
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/mp8x9p8q-neon.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/up8xm-neon.c
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/up8x9-sse2.c|q8avgpool
+
+LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/deps/clog/src/clog.c
+#LIBQNNPACK_SRCS-y += $(LIBQNNPACK_SRC)/src/q8avgpool/up8x9-neon.c
diff --git a/glue.c b/glue.c
new file mode 100644
index 0000000..32d995c
--- /dev/null
+++ b/glue.c
@@ -0,0 +1,15 @@
+
+
+int cpuinfo_has_x86_sse2()
+{
+       return 1;
+}
+
+int cpuinfo_initialize()
+{
+       return 1;
+}
+
+void cpuinfo_deinitialize()
+{
+}
diff --git a/include/cpuinfo.h b/include/cpuinfo.h
new file mode 100644
index 0000000..5f358f8
--- /dev/null
+++ b/include/cpuinfo.h
@@ -0,0 +1,5 @@
+#define CPUINFO_ARCH_X86_64 1
+
+int cpuinfo_has_x86_sse2();
+int cpuinfo_initialize();
+void cpuinfo_deinitialize();
-- 
2.21.0

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.