Skip to content

Commit

Permalink
Copyright notices
Browse files Browse the repository at this point in the history
  • Loading branch information
guberti committed Aug 11, 2021
1 parent 237a65e commit 96133bc
Show file tree
Hide file tree
Showing 26 changed files with 283 additions and 34 deletions.
19 changes: 19 additions & 0 deletions apps/microtvm/arduino/example_project/project.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "src/model.h"

void setup() {
Expand Down
19 changes: 19 additions & 0 deletions apps/microtvm/arduino/example_project/src/model.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef TVM_IMPLEMENTATION_ARDUINO
#define TVM_IMPLEMENTATION_ARDUINO

Expand Down
19 changes: 19 additions & 0 deletions apps/microtvm/arduino/example_project/src/model.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef IMPLEMENTATION_H_
#define IMPLEMENTATION_H_

Expand Down
19 changes: 19 additions & 0 deletions apps/microtvm/arduino/host_driven/project.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "src/standalone_crt/include/tvm/runtime/crt/microtvm_rpc_server.h"
#include "src/standalone_crt/include/tvm/runtime/crt/logging.h"
#include "src/model.h"
Expand Down
36 changes: 29 additions & 7 deletions apps/microtvm/arduino/host_driven/src/model.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef TVM_IMPLEMENTATION_ARDUINO
#define TVM_IMPLEMENTATION_ARDUINO

Expand All @@ -10,13 +29,16 @@
// Blink code for debugging purposes
void TVMPlatformAbort(tvm_crt_error_t error) {
for (;;) {
for (int i = 0; i < 4; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
digitalWrite(LED_BUILTIN, LOW);
delay(250);
}
delay(1000);
#ifdef LED_BUILTIN
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
digitalWrite(LED_BUILTIN, LOW);
delay(250);
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
digitalWrite(LED_BUILTIN, LOW);
delay(750);
#endif
}
}

Expand Down
19 changes: 19 additions & 0 deletions apps/microtvm/arduino/host_driven/src/model.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef IMPLEMENTATION_H_
#define IMPLEMENTATION_H_

Expand Down
17 changes: 17 additions & 0 deletions apps/microtvm/arduino/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import collections
import functools
import json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from unittest import mock
from pathlib import Path
import sys
Expand All @@ -13,11 +30,6 @@
class TestGenerateProject:
DEFAULT_OPTIONS = {"arduino_cli_cmd": "arduino-cli", "arduino_board": "nano33ble"}

def test_print_c_array(self):
handler = microtvm_api_server.Handler()
c_arr = handler._print_c_array([1, 32, 32, 3])
assert c_arr == "{1, 32, 32, 3}"

def _set_pathlib_path_exists(self, value):
with mock.patch.object(Path, "exists") as mock_exists:
mock_exists.return_value = value
Expand Down
10 changes: 6 additions & 4 deletions tests/lint/check_file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"cl",
# zephyr config file
"conf",
# arduino sketch file
"ino",
}

# List of file names allowed
Expand Down Expand Up @@ -129,10 +131,10 @@
# pytest config
"pytest.ini",
# microTVM tests
"tests/micro/zephyr/testdata/digit-2.jpg",
"tests/micro/zephyr/testdata/digit-9.jpg",
"tests/micro/zephyr/testdata/mnist-8.onnx",
"tests/micro/zephyr/testdata/ic_sample_fp32_8.npy",
"tests/micro/testdata/digit-2.jpg",
"tests/micro/testdata/digit-9.jpg",
"tests/micro/testdata/mnist-8.onnx",
"tests/micro/testdata/yes_no.tflite",
# microTVM Zephyr runtime
"apps/microtvm/zephyr/template_project/CMakeLists.txt.template",
"apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-arm",
Expand Down
3 changes: 3 additions & 0 deletions tests/lint/rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
.*\.interp
.*\.tokens

# microTVM test data files
testdata

# Generated modules
.*\.egg-info
.*gen_modules
Expand Down
17 changes: 17 additions & 0 deletions tests/micro/arduino/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import datetime
import pathlib

Expand Down
26 changes: 22 additions & 4 deletions tests/micro/arduino/test_arduino_rpc_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import datetime
import os
import pathlib
Expand Down Expand Up @@ -165,17 +182,18 @@ def test_onnx(platform, arduino_cli_cmd, tvm_debug, workspace_dir):
build_config = {"debug": tvm_debug}

# Load test images.
this_dir = os.path.dirname(__file__)
digit_2 = Image.open(f"{this_dir}/testdata/digit-2.jpg").resize((28, 28))
this_dir = pathlib.Path(os.path.dirname(__file__))
testdata_dir = this_dir.parent / "testdata"
digit_2 = Image.open(testdata_dir / "digit-2.jpg").resize((28, 28))
digit_2 = np.asarray(digit_2).astype("float32")
digit_2 = np.expand_dims(digit_2, axis=0)

digit_9 = Image.open(f"{this_dir}/testdata/digit-9.jpg").resize((28, 28))
digit_9 = Image.open(testdata_dir / "digit-9.jpg").resize((28, 28))
digit_9 = np.asarray(digit_9).astype("float32")
digit_9 = np.expand_dims(digit_9, axis=0)

# Load ONNX model and convert to Relay.
onnx_model = onnx.load(f"{this_dir}/testdata/mnist-8.onnx")
onnx_model = onnx.load(testdata_dir / "mnist-8.onnx")
shape = {"Input3": (1, 1, 28, 28)}
relay_mod, params = relay.frontend.from_onnx(onnx_model, shape=shape, freeze_params=True)
relay_mod = relay.transform.DynamicToStatic()(relay_mod)
Expand Down
Loading

0 comments on commit 96133bc

Please sign in to comment.