pkg: add support for utensor as a package
This commit is contained in:
parent
421d174f60
commit
087246ea0f
16
pkg/utensor/Makefile
Normal file
16
pkg/utensor/Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
PKG_NAME=utensor
|
||||||
|
PKG_URL=https://github.com/uTensor/uTensor
|
||||||
|
PKG_VERSION=b22aa5cbc1ef1b3dd42a899b393a9b999afd1305
|
||||||
|
PKG_LICENSE=Apache2.0
|
||||||
|
|
||||||
|
PKG_BASEDIR = $(PKG_BUILDDIR)/src/uTensor
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
all:
|
||||||
|
"$(MAKE)" -C $(PKG_BASEDIR)/core -f $(CURDIR)/Makefile.$(PKG_NAME)
|
||||||
|
"$(MAKE)" -C $(PKG_BASEDIR)/util -f $(CURDIR)/Makefile.$(PKG_NAME).util
|
||||||
|
"$(MAKE)" -C $(PKG_BASEDIR)/ops -f $(CURDIR)/Makefile.$(PKG_NAME).ops
|
||||||
|
|
||||||
|
|
||||||
|
include $(RIOTBASE)/pkg/pkg.mk
|
||||||
4
pkg/utensor/Makefile.dep
Normal file
4
pkg/utensor/Makefile.dep
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FEATURES_REQUIRED += cpp
|
||||||
|
|
||||||
|
USEMODULE += utensor-ops
|
||||||
|
USEMODULE += utensor-util
|
||||||
17
pkg/utensor/Makefile.include
Normal file
17
pkg/utensor/Makefile.include
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor/src
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor/src/uTensor
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor/src/uTensor/core
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor/src/uTensor/ops
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/utensor/src/uTensor/util
|
||||||
|
|
||||||
|
CXXEXFLAGS += -Wno-sign-compare
|
||||||
|
|
||||||
|
ifeq (llvm,$(TOOLCHAIN))
|
||||||
|
CXXEXFLAGS += -Wno-unused-variable
|
||||||
|
CXXEXFLAGS += -Wno-shift-count-negative
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (native,$(BOARD))
|
||||||
|
CXXEXFLAGS += -std=c++11
|
||||||
|
endif
|
||||||
5
pkg/utensor/Makefile.utensor
Normal file
5
pkg/utensor/Makefile.utensor
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MODULE = utensor
|
||||||
|
|
||||||
|
CXXEXFLAGS += -Wno-unused-parameter
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
3
pkg/utensor/Makefile.utensor.ops
Normal file
3
pkg/utensor/Makefile.utensor.ops
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MODULE = utensor-ops
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
5
pkg/utensor/Makefile.utensor.util
Normal file
5
pkg/utensor/Makefile.utensor.util
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MODULE = utensor-util
|
||||||
|
|
||||||
|
CXXEXFLAGS += -Wno-c++14-binary-literal
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
7
pkg/utensor/doc.txt
Normal file
7
pkg/utensor/doc.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* @defgroup pkg_utensor uTensor
|
||||||
|
* @ingroup pkg
|
||||||
|
* @brief Provides a package for AI inference based on TensorFlow
|
||||||
|
*
|
||||||
|
* @see https://github.com/uTensor/uTensor
|
||||||
|
*/
|
||||||
51
pkg/utensor/patches/0001-fix-integer-format.patch
Normal file
51
pkg/utensor/patches/0001-fix-integer-format.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 737ff6e1e4f3411a557b3f7436ed94461c67249e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
Date: Sat, 23 Nov 2019 13:09:31 +0100
|
||||||
|
Subject: [PATCH] Fix wrong integer format in print
|
||||||
|
|
||||||
|
---
|
||||||
|
src/uTensor/core/context.cpp | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/uTensor/core/context.cpp b/src/uTensor/core/context.cpp
|
||||||
|
index 112308e..96020f5 100644
|
||||||
|
--- a/src/uTensor/core/context.cpp
|
||||||
|
+++ b/src/uTensor/core/context.cpp
|
||||||
|
@@ -3,7 +3,7 @@
|
||||||
|
S_TENSOR Context::add(Tensor* t, TName _name, uint8_t init_count) {
|
||||||
|
if(t == nullptr) { ERR_EXIT("null pointer tensor"); }
|
||||||
|
if(rTable.find(_name) != rTable.end()) {
|
||||||
|
- ERR_EXIT("tensor with name \"%d\" address already exist in rTable", t->getName().get_value());
|
||||||
|
+ ERR_EXIT("tensor with name \"%d\" address already exist in rTable", static_cast<unsigned>(t->getName().get_value()));
|
||||||
|
}
|
||||||
|
|
||||||
|
t->setName(_name);
|
||||||
|
@@ -23,7 +23,7 @@ S_TENSOR Context::add(Tensor* t, TName _name, uint8_t init_count) {
|
||||||
|
}
|
||||||
|
|
||||||
|
S_TENSOR Context::get(TName const &t_name) {
|
||||||
|
- if(rTable.find(t_name) == rTable.end()) ERR_EXIT("No tensor with name: %d", t_name.get_value());
|
||||||
|
+ if(rTable.find(t_name) == rTable.end()) ERR_EXIT("No tensor with name: %d", static_cast<unsigned>(t_name.get_value()));
|
||||||
|
return rTable[t_name].ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -64,14 +64,14 @@ void Context::push(Operator* op, TNameList &in_names, TNameList &out_names) {
|
||||||
|
//error checking in the Op class
|
||||||
|
S_TList _inputs;
|
||||||
|
for(auto in:in_names) {
|
||||||
|
- if(rTable.find(in) == rTable.end()) { ERR_EXIT("Tensor \"%d\" not found", in.get_value()); }
|
||||||
|
+ if(rTable.find(in) == rTable.end()) { ERR_EXIT("Tensor \"%d\" not found", static_cast<unsigned>(in.get_value())); }
|
||||||
|
Ref_Record r = rTable[in];
|
||||||
|
_inputs.push_back(r.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
S_TList _outputs;
|
||||||
|
for(auto out:out_names) {
|
||||||
|
- if(rTable.find(out) == rTable.end()) { ERR_EXIT("Tensor \"%d\" not found", out.get_value()); }
|
||||||
|
+ if(rTable.find(out) == rTable.end()) { ERR_EXIT("Tensor \"%d\" not found", static_cast<unsigned>(out.get_value())); }
|
||||||
|
Ref_Record r = rTable[out];
|
||||||
|
_outputs.push_back(r.ptr);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
46
pkg/utensor/patches/0002-fix-mbed-specific-code.patch
Normal file
46
pkg/utensor/patches/0002-fix-mbed-specific-code.patch
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
From 3a6aa2c894923f3d4a5aff0ea09e71f7c68dbde7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
Date: Sat, 23 Nov 2019 13:11:00 +0100
|
||||||
|
Subject: [PATCH] Fix mbed specific code
|
||||||
|
|
||||||
|
---
|
||||||
|
src/uTensor/util/uTensor_util.cpp | 4 ++--
|
||||||
|
src/uTensor/util/uTensor_util.hpp | 2 --
|
||||||
|
2 files changed, 2 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/uTensor/util/uTensor_util.cpp b/src/uTensor/util/uTensor_util.cpp
|
||||||
|
index 4d1dd48..32c50df 100644
|
||||||
|
--- a/src/uTensor/util/uTensor_util.cpp
|
||||||
|
+++ b/src/uTensor/util/uTensor_util.cpp
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
#include "src/uTensor/util/uTensor_util.hpp"
|
||||||
|
-#if !(defined(TARGET_MBED) || defined(ARDUINO))
|
||||||
|
+#ifdef BOARD_NATIVE
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
|
@@ -45,7 +45,7 @@ uint32_t ntoh32(uint32_t val) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#ifdef ARDUINO
|
||||||
|
+#ifndef BOARD_NATIVE
|
||||||
|
void int_env() {
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
diff --git a/src/uTensor/util/uTensor_util.hpp b/src/uTensor/util/uTensor_util.hpp
|
||||||
|
index 25ebcf3..5390ed8 100644
|
||||||
|
--- a/src/uTensor/util/uTensor_util.hpp
|
||||||
|
+++ b/src/uTensor/util/uTensor_util.hpp
|
||||||
|
@@ -106,8 +106,6 @@ void printVector(std::vector<uint32_t> vec);
|
||||||
|
#undef min
|
||||||
|
#undef round
|
||||||
|
#undef abs
|
||||||
|
-#else
|
||||||
|
- #include "mbed.h"
|
||||||
|
#endif
|
||||||
|
//# error "Unknown compiler"
|
||||||
|
// little endian to big endian
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
55
pkg/utensor/patches/0003-fix-variadic-macro.patch
Normal file
55
pkg/utensor/patches/0003-fix-variadic-macro.patch
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
From f68167af0e950ac5330ba5586758ebdc77cb66a1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
Date: Mon, 25 Nov 2019 16:18:30 +0100
|
||||||
|
Subject: [PATCH] util: fix variadic macros
|
||||||
|
|
||||||
|
---
|
||||||
|
src/uTensor/util/uTensor_util.hpp | 12 ++++++------
|
||||||
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/uTensor/util/uTensor_util.hpp b/src/uTensor/util/uTensor_util.hpp
|
||||||
|
index 9fff08b..31206a3 100644
|
||||||
|
--- a/src/uTensor/util/uTensor_util.hpp
|
||||||
|
+++ b/src/uTensor/util/uTensor_util.hpp
|
||||||
|
@@ -28,9 +28,9 @@ void return_error(int ret_val);
|
||||||
|
return_error(FUNC); \
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define DEBUG(MSG, ...) \
|
||||||
|
+#define DEBUG(...) \
|
||||||
|
{ \
|
||||||
|
- printf(MSG, ##__VA_ARGS__); \
|
||||||
|
+ printf(__VA_ARGS__); \
|
||||||
|
fflush(stdout); \
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -44,16 +44,16 @@ enum Padding {
|
||||||
|
// }
|
||||||
|
|
||||||
|
#define ON_ERR(FUNC, MSG) FUNC
|
||||||
|
-#define DEBUG(MSG, ...)
|
||||||
|
+#define DEBUG(...)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void utensor_exit(void);
|
||||||
|
|
||||||
|
-#define ERR_EXIT(MSG, ...) \
|
||||||
|
+#define ERR_EXIT(...) \
|
||||||
|
{ \
|
||||||
|
printf("[Error] %s:%d @%s ", __FILE__, __LINE__, __func__); \
|
||||||
|
- printf(MSG, ##__VA_ARGS__); \
|
||||||
|
+ printf(__VA_ARGS__); \
|
||||||
|
fflush(stdout); \
|
||||||
|
utensor_exit(); \
|
||||||
|
}
|
||||||
|
@@ -130,4 +130,4 @@ uint16_t ntoh16(uint16_t val);
|
||||||
|
uint32_t ntoh32(uint32_t val);
|
||||||
|
|
||||||
|
void init_env();
|
||||||
|
-#endif
|
||||||
|
\ No newline at end of file
|
||||||
|
+#endif
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user