aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Svedberg <Fredrik.Svedberg@arm.com>2020-12-11 13:42:22 +0100
committerpatrik.gustavsson <patrik.gustavsson@arm.com>2020-12-18 12:16:19 +0000
commit5b513886ab120023eb1319d4883b175db8b7de3a (patch)
tree8ed296f6567daac9c1a564ad417f3d14ab1b7186
parent6c74c3bcaa733aa062c15d606726722b19c0dfdb (diff)
downloadethos-u-vela-5b513886ab120023eb1319d4883b175db8b7de3a.tar.gz
[MLBEDSW-297] Setup and run on Microsoft Windows
Various updates to make vela run and produce identical output on Microsoft Windows. * Fixed overflow errors * Fixed compile warnings * Avoid problematic numpy version * Updated README.md Signed-off-by: Fredrik Svedberg <Fredrik.Svedberg@arm.com> Change-Id: Ie48c63a92a00c81b3247d07f05b75d881319ddbb
-rw-r--r--.gitignore3
-rw-r--r--README.md7
-rw-r--r--ethosu/mlw_codec/mlw_codecmodule.c6
-rw-r--r--ethosu/mlw_codec/mlw_encode.c6
-rw-r--r--ethosu/tensor_allocator/search_allocator.cpp2
-rw-r--r--ethosu/tensor_allocator/tensor_allocatormodule.cpp2
-rw-r--r--ethosu/vela/fp_math.py2
-rw-r--r--ethosu/vela/softmax.py2
-rw-r--r--setup.py7
9 files changed, 27 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 2ea50a0d..070ea6c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,8 @@
build/
ethos_u_vela.egg-info/
ethosu/*.so
+output/
+.vscode/
.coverage
__pycache__
+*.pyd
diff --git a/README.md b/README.md
index 12abc610..586885c3 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,8 @@ Vela supports TensorFlow 2.3.0
## Environment
-Vela runs on the Linux operating system.
+Vela runs on the Linux operating system and on Microsoft Windows,
+see note in Installation section below.
## Prerequisites
@@ -51,6 +52,10 @@ source code from
[ML Platform](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ethos-u-vela).
Both methods will automatically install all the required dependencies.
+**Note:** For installing on Microsoft Windows you need to have a C99 and C++11
+capable toolchain installed. The recommended and tested toolchain is Microsoft
+Visual C++ 14.x Build Tools, see <https://wiki.python.org/moin/WindowsCompilers>
+
### PyPi
Install Vela from PyPi using the following command:
diff --git a/ethosu/mlw_codec/mlw_codecmodule.c b/ethosu/mlw_codec/mlw_codecmodule.c
index de945ab3..6dde12dc 100644
--- a/ethosu/mlw_codec/mlw_codecmodule.c
+++ b/ethosu/mlw_codec/mlw_codecmodule.c
@@ -53,7 +53,7 @@ method_encode (PyObject *self, PyObject *args)
return NULL;
/* Unpack the length of the input integer list. */
- int input_length = PyObject_Length (input_list_object);
+ int input_length = (int)PyObject_Length (input_list_object);
if (input_length < 0)
input_length = 0;
@@ -73,7 +73,7 @@ method_encode (PyObject *self, PyObject *args)
item = PyList_GetItem(input_list_object, i);
if (!PyLong_Check(item))
input_buffer[i] = 0;
- input_buffer[i] = PyLong_AsLong(item);
+ input_buffer[i] = (int16_t)PyLong_AsLong(item);
}
/* We don't know the output length required, we guess worst case,
@@ -126,7 +126,7 @@ method_decode(PyObject *self, PyObject *args)
/* Unpack the input buffer and length from the bytearray object. */
uint8_t *input_buffer = (uint8_t *) PyByteArray_AsString(input_bytearray_object);
- int input_length = PyByteArray_Size(input_bytearray_object);
+ int input_length = (int)PyByteArray_Size(input_bytearray_object);
/* We don't know the output length required, we guess, but the guess
* will be too small, the mlw_decode call will do a resize (upwards)
diff --git a/ethosu/mlw_codec/mlw_encode.c b/ethosu/mlw_codec/mlw_encode.c
index 7820106e..04afa3ee 100644
--- a/ethosu/mlw_codec/mlw_encode.c
+++ b/ethosu/mlw_codec/mlw_encode.c
@@ -33,8 +33,12 @@
#define ZERO_RUN_THRES 4
+#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
+#endif
typedef struct palette {
int16_t lut[32];
@@ -258,7 +262,7 @@ static void create_palette( int freq[512],
// Setup the 32 entry palette
int palette_max_val = 0, val, cnt, pal_cnt=0;
for(i=0; i<max_palette_size; i++) {
- cnt = freq64[i]>>16;
+ cnt = (int)(freq64[i]>>16);
val = freq64[i]&0xffff;
if ( cnt==0 )
break;
diff --git a/ethosu/tensor_allocator/search_allocator.cpp b/ethosu/tensor_allocator/search_allocator.cpp
index ce5c46de..c7c418a0 100644
--- a/ethosu/tensor_allocator/search_allocator.cpp
+++ b/ethosu/tensor_allocator/search_allocator.cpp
@@ -31,7 +31,7 @@ SearchAllocator::SearchAllocator(const std::vector<LiveRange> &live_ranges, uint
uint32_t max_end_time = 0;
for (size_t i = 0; i < lrs.size(); ++i) {
auto &lr = lrs[i];
- lr.id = i;
+ lr.id = static_cast<int>(i);
max_end_time = std::max(max_end_time, lr.end_time);
}
lrs_at_time.resize(max_end_time + 1);
diff --git a/ethosu/tensor_allocator/tensor_allocatormodule.cpp b/ethosu/tensor_allocator/tensor_allocatormodule.cpp
index 79ee95ad..02488add 100644
--- a/ethosu/tensor_allocator/tensor_allocatormodule.cpp
+++ b/ethosu/tensor_allocator/tensor_allocatormodule.cpp
@@ -53,7 +53,7 @@ static PyObject *method_allocate (PyObject *self, PyObject *args)
}
/* Unpack the length of the input integer list. */
- int input_length = PyObject_Length (input_list_object);
+ int input_length = static_cast<int>(PyObject_Length (input_list_object));
if (input_length < 0) {
input_length = 0;
}
diff --git a/ethosu/vela/fp_math.py b/ethosu/vela/fp_math.py
index 66375611..5228f031 100644
--- a/ethosu/vela/fp_math.py
+++ b/ethosu/vela/fp_math.py
@@ -41,7 +41,7 @@ def saturating_rounding_mul(a, b):
if a == b and a == np.iinfo(np.int32).min:
return np.int32(np.iinfo(np.int32).max)
divider = 1 << 31
- ab = a * b
+ ab = np.int64(a) * np.int64(b)
if ab >= 0:
nudge = 1 << 30
return (ab + nudge) // divider
diff --git a/ethosu/vela/softmax.py b/ethosu/vela/softmax.py
index 1bdab740..8b061297 100644
--- a/ethosu/vela/softmax.py
+++ b/ethosu/vela/softmax.py
@@ -520,7 +520,7 @@ class SoftMax:
[1, 1, 1, 512],
DataType.int32,
self.ONE_OVER_ONE_PLUS_X_LUT,
- np.int32,
+ np.uint32,
TensorPurpose.LUT,
)
)
diff --git a/setup.py b/setup.py
index 805062b0..bb2e8a09 100644
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,12 @@ setup(
keywords=["ethos-u", "vela compiler", "tflite", "npu"],
packages=find_namespace_packages(include=["ethosu.*"]),
python_requires="~=3.6", # We support only 3.6+
- install_requires=["flatbuffers==1.11.0", "numpy>=1.16.6", "lxml>=4.5.1"],
+ install_requires=[
+ "flatbuffers==1.11.0",
+ "numpy>=1.16.6",
+ "numpy>=1.16.6,<1.19.4 ; platform_system=='Windows'",
+ "lxml>=4.5.1",
+ ],
entry_points={"console_scripts": ["vela = ethosu.vela.vela:main"]},
ext_modules=[mlw_module, tensor_allocator_module],
setup_requires=["setuptools_scm"],