-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Hexagon] Add support for on-device unit testing using gtest #11145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
csullivan
merged 20 commits into
apache:main
from
adstraw:straw-link-gtest-to-tvm-runtime
May 3, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cd11d02
link gtest to tvm runtime
adstraw 31fc623
first test running!
adstraw 79c2110
HexagonBuffer tests running in sim
adstraw 8a2ff6d
move to new tests directory
adstraw a85c333
use USE_HEXAGON_SDK
adstraw b4db712
add python frontend for Hexagon unit tests
adstraw 8ec34af
clean up after rebase
adstraw 4eb97fd
isolate cmake changes to Hexagon
adstraw 262dc73
add gtest init with arguments
adstraw b6b0c4b
add hexagon sources only if building for Hexagon; remove workaround
adstraw 273a2dd
format & lint
adstraw 8916768
fix Hexagon build error
adstraw 39c2275
remove x86 implementation and win32 code
adstraw d1f1784
check if hexagon gtest path exists before linking
adstraw 32e6dd2
make USE_HEXAGON_GTEST an optional cmake param
adstraw f12efd7
turn on Hexagon gtest in Hexagon CI
adstraw fa19d82
Hexagon unit tests should fail if run without proper gtest linkage
adstraw e6222e8
add tvm option; move Hexagon tests to test/cpp-runtime/hexagon
adstraw 816f3be
add libinfo
adstraw 3946e23
trigger ci
adstraw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,9 +84,6 @@ if(NOT USE_HEXAGON) | |
| if(BUILD_FOR_HOST) | ||
| list(APPEND COMPILER_SRCS src/target/opt/build_hexagon_off.cc) | ||
| endif() | ||
| list(APPEND RUNTIME_SRCS src/runtime/hexagon/hexagon_buffer.cc) | ||
| list(APPEND RUNTIME_SRCS src/runtime/hexagon/hexagon_common.cc) | ||
| list(APPEND RUNTIME_SRCS src/runtime/hexagon/hexagon_user_dma.cc) | ||
| return() | ||
| endif() | ||
|
|
||
|
|
@@ -119,14 +116,23 @@ function(add_hexagon_wrapper_paths) | |
| link_directories("${HEXAGON_TOOLCHAIN}/lib/iss") | ||
| endfunction() | ||
|
|
||
|
|
||
| # Common sources for TVM runtime with Hexagon support | ||
| file_glob_append(RUNTIME_HEXAGON_SRCS | ||
| "${TVMRT_SOURCE_DIR}/hexagon/*.cc" | ||
| ) | ||
|
|
||
| if(BUILD_FOR_HEXAGON OR USE_HEXAGON_RPC) | ||
| # Common sources for TVM runtime with Hexagon support | ||
| file_glob_append(RUNTIME_HEXAGON_SRCS | ||
| "${TVMRT_SOURCE_DIR}/hexagon/*.cc" | ||
| ) | ||
| else() | ||
| file_glob_append(RUNTIME_HEXAGON_SRCS | ||
| "${TVMRT_SOURCE_DIR}/hexagon/hexagon_module.cc" | ||
| ) | ||
| endif() | ||
|
Comment on lines
+119
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nevermind. It was an error on my side. Sorry for the noise. |
||
|
|
||
| if(BUILD_FOR_HEXAGON) | ||
| if(DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTEST}) | ||
| file_glob_append(RUNTIME_HEXAGON_SRCS | ||
| "${CMAKE_SOURCE_DIR}/tests/cpp-runtime/hexagon/*.cc" | ||
| ) | ||
| endif() | ||
| get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}" | ||
| SDK_INCLUDE SDK_INCLUDE_DIRS | ||
| QURT_INCLUDE QURT_INCLUDE_DIRS | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * 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 <gtest/gtest.h> | ||
| #include <tvm/runtime/packed_func.h> | ||
| #include <tvm/runtime/registry.h> | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "../src/support/utils.h" | ||
|
|
||
| namespace tvm { | ||
| namespace runtime { | ||
| namespace hexagon { | ||
|
|
||
| TVM_REGISTER_GLOBAL("hexagon.run_all_tests").set_body([](TVMArgs args, TVMRetValue* rv) { | ||
| // gtest args are passed into this packed func as a singular string | ||
| // split gtest args using <space> delimiter and build argument vector | ||
| std::vector<std::string> parsed_args = tvm::support::Split(args[0], ' '); | ||
| std::vector<char*> argv; | ||
|
|
||
| // add executable name | ||
| argv.push_back(const_cast<char*>("hexagon_run_all_tests")); | ||
|
|
||
| // add parsed arguments | ||
| for (int i = 0; i < parsed_args.size(); ++i) { | ||
| argv.push_back(const_cast<char*>(parsed_args[i].data())); | ||
| } | ||
|
|
||
| // end of parsed arguments | ||
| argv.push_back(nullptr); | ||
|
|
||
| // set argument count | ||
| int argc = argv.size() - 1; | ||
|
|
||
| // initialize gtest with arguments and run | ||
| ::testing::InitGoogleTest(&argc, argv.data()); | ||
| *rv = RUN_ALL_TESTS(); | ||
| }); | ||
|
|
||
| } // namespace hexagon | ||
| } // namespace runtime | ||
| } // namespace tvm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # 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 pytest | ||
| import numpy as np | ||
| from tvm.contrib.hexagon.build import HexagonLauncher | ||
| from .conftest import requires_hexagon_toolchain | ||
|
|
||
|
|
||
| @requires_hexagon_toolchain | ||
| def test_cache_read_write_2d(hexagon_session): | ||
| # arguments to pass to gtest | ||
| # e.g. | ||
| # 1) to run all tests use: | ||
| # gtest_args = "" | ||
| # 2) to run all tests with "foo" in their name twice use: | ||
| # gtest_args = "--gtest_repeat=2 --gtest_filter=*foo*" | ||
| gtest_args = "" | ||
| try: | ||
| func = hexagon_session._rpc.get_function("hexagon.run_all_tests") | ||
| result = func(gtest_args) | ||
| except: | ||
| print( | ||
| "This test requires the USE_HEXAGON_GTEST cmake flag to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest" | ||
| ) | ||
| result = 1 | ||
|
|
||
| np.testing.assert_equal(result, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.