Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docker/Dockerfile.ci_adreno
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.

# CI docker GPU env
FROM tlcpack/ci-gpu:20220908-060034-62bdc91b1

COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear

# Android SDK
COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh
RUN bash /install/ubuntu_install_androidsdk.sh
ENV ANDROID_HOME=/opt/android-sdk-linux
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147
ENV PATH /opt/android-sdk-linux/platform-tools:$PATH
13 changes: 11 additions & 2 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function parse_error() {
break_joined_flag='if (( ${#1} == 2 )); then shift; else set -- -"${1#-i}" "${@:2}"; fi'

DOCKER_ENV=( )
DOCKER_FLAGS=( )

while (( $# )); do
case "$1" in
Expand All @@ -184,6 +185,11 @@ while (( $# )); do
shift
;;

--net)
DOCKER_FLAGS+=( --net "$2" )
shift 2
;;

--mount)
if [[ -n "$2" ]]; then
MOUNT_DIRS+=("$2")
Expand Down Expand Up @@ -212,6 +218,11 @@ while (( $# )); do
shift 2
;;

--volume)
DOCKER_FLAGS+=( --volume "$2" )
shift 2
;;

--dry-run)
DRY_RUN=true
shift
Expand Down Expand Up @@ -284,7 +295,6 @@ fi

source "$(dirname $0)/dev_common.sh" || exit 2

DOCKER_FLAGS=( )
DOCKER_MOUNT=( )
DOCKER_DEVICES=( )

Expand Down Expand Up @@ -460,7 +470,6 @@ echo ""

echo Running \'${COMMAND[@]+"${COMMAND[@]}"}\' inside ${DOCKER_IMAGE_NAME}...


DOCKER_CMD=(${DOCKER_BINARY} run
${DOCKER_FLAGS[@]+"${DOCKER_FLAGS[@]}"}
${DOCKER_ENV[@]+"${DOCKER_ENV[@]}"}
Expand Down
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_cmake_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ wget https://cmake.org/files/v${v}/cmake-${version}.tar.gz
tar xvf cmake-${version}.tar.gz
cd cmake-${version}
./bootstrap
make -j"$(nproc)"
make -j$(nproc)
make install
cd ..
rm -rf cmake-${version} cmake-${version}.tar.gz
13 changes: 11 additions & 2 deletions python/tvm/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,8 @@ def _any_gpu_exists():
"OpenCL",
cmake_flag="USE_OPENCL",
target_kind_enabled="opencl",
target_kind_hardware="opencl",
parent_features="gpu",
target_kind_hardware="opencl" if "RPC_TARGET" not in os.environ else None,
parent_features="gpu" if "RPC_TARGET" not in os.environ else None,
)

# Mark a test as requiring the rocm runtime
Expand Down Expand Up @@ -933,6 +933,15 @@ def _any_gpu_exists():
parent_features="gpu",
)

# Mark a test as requiring OpenCLML support in build.
requires_openclml = Feature(
"OpenCLML",
"CLML",
cmake_flag="USE_CLML",
target_kind_enabled="opencl",
)


# Mark a test as requiring microTVM to run
requires_micro = Feature("micro", "MicroTVM", cmake_flag="USE_MICRO")

Expand Down
26 changes: 26 additions & 0 deletions tests/python/contrib/test_clml/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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 sys
import tvm
import pytest
from test_clml.infrastructure import Device


@pytest.fixture(scope="session")
def device():
return Device()
43 changes: 3 additions & 40 deletions tests/python/contrib/test_clml/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class Device:
"""

connection_type = "tracker"
host = "localhost"
port = 9150
host = os.getenv("TVM_TRACKER_HOST", "localhost")
port = int(os.getenv("TVM_TRACKER_PORT", 9090))
target = "opencl"
target_host = "llvm -mtriple=aarch64-linux-gnu"
device_key = "android"
cross_compile = "aarch64-linux-android-g++"
cross_compile = os.getenv("TVM_NDK_CC", "aarch64-linux-android-g++")

def __init__(self):
"""Keep remote device for lifetime of object."""
Expand All @@ -100,43 +100,6 @@ def _get_remote(cls):

return device

@classmethod
def load(cls, file_name):
"""Load test config

Load the test configuration by looking for file_name relative
to the test_clml directory.
"""
location = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
config_file = os.path.join(location, file_name)
if not os.path.exists(config_file):
warnings.warn("Config file doesn't exist, resuming CLML tests with default config.")
return
with open(config_file, mode="r") as config:
test_config = json.load(config)

cls.connection_type = test_config["connection_type"]
cls.host = test_config["host"]
cls.port = test_config["port"]
cls.target = test_config["target"]
cls.target_host = test_config["target_host"]
cls.device_key = test_config.get("device_key") or ""
cls.cross_compile = test_config.get("cross_compile") or ""


def skip_runtime_test():
"""Skip test if it requires the runtime and it's not present."""
# CLML codegen not present.
if not tvm.get_global_func("relay.ext.clml", True):
print("Skip because CLML codegen is not available.")
return True

# Remote device is in use or CLML runtime not present
# Note: Ensure that the device config has been loaded before this check
if not Device.connection_type != "local" and not clml.is_clml_runtime_enabled():
print("Skip because runtime isn't present or a remote device isn't being used.")
return True


def skip_codegen_test():
"""Skip test if it requires the CLML codegen and it's not present."""
Expand Down
52 changes: 14 additions & 38 deletions tests/python/contrib/test_clml/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# under the License.
"""OpenCL ML network tests."""

import tvm
import numpy as np
import pytest
from tvm import testing
from tvm import relay

import tvm
from test_clml.infrastructure import skip_runtime_test, build_and_run, Device
from tvm.relay import testing
from tvm.contrib import utils
from test_clml.infrastructure import build_and_run, Device
import pytest


def _build_and_run_network(mod, params, inputs, data, device, atol, rtol, tvm_log=""):
Expand Down Expand Up @@ -59,15 +59,9 @@ def get_bottom_top_model(model, layer_name):
return mod, params, ref_output


def test_mobilenet():
Device.load("test_config.json")

if skip_runtime_test():
return

device = Device()
dtype = "float16"

@pytest.mark.parametrize("dtype", ["float16"])
@tvm.testing.requires_openclml
def test_mobilenet(device, dtype):
def get_model():
from tensorflow.keras.applications import MobileNet
import tensorflow as tf
Expand Down Expand Up @@ -107,15 +101,9 @@ def get_model():
tvm.testing.assert_allclose(opencl_sort[:10], clml_sort[:10], rtol=1e-5, atol=1e-5)


def test_inception_v3():
Device.load("test_config.json")

if skip_runtime_test():
return

device = Device()
dtype = "float16"

@pytest.mark.parametrize("dtype", ["float16"])
@tvm.testing.requires_openclml
def test_inception_v3(device, dtype):
def get_model():
from tensorflow.keras.applications import InceptionV3
import tensorflow as tf
Expand Down Expand Up @@ -150,15 +138,9 @@ def get_model():
tvm.testing.assert_allclose(opencl_sort[:5], clml_sort[:5], rtol=1e-5, atol=1e-5)


def test_resnet50v2():
Device.load("test_config.json")

if skip_runtime_test():
return

device = Device()
dtype = "float16"

@pytest.mark.parametrize("dtype", ["float16"])
@tvm.testing.requires_openclml
def test_resnet50v2(device, dtype):
def get_model():
from tensorflow.keras.applications import ResNet50V2
import tensorflow as tf
Expand Down Expand Up @@ -202,9 +184,3 @@ def get_model():
clml_sort = np.argsort(outputs[0].asnumpy()).flatten()

tvm.testing.assert_allclose(opencl_sort[:10], clml_sort[:10], rtol=1e-5, atol=1e-5)


if __name__ == "__main__":
test_mobilenet()
test_resnet50v2()
test_inception_v3()
Loading