forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hexagon] Add support for on-device unit testing using gtest (apache#…
…11145) * link gtest to tvm runtime * first test running! * HexagonBuffer tests running in sim * move to new tests directory * use USE_HEXAGON_SDK * add python frontend for Hexagon unit tests * clean up after rebase * isolate cmake changes to Hexagon * add gtest init with arguments * add hexagon sources only if building for Hexagon; remove workaround * format & lint * fix Hexagon build error * remove x86 implementation and win32 code * check if hexagon gtest path exists before linking * make USE_HEXAGON_GTEST an optional cmake param * turn on Hexagon gtest in Hexagon CI * Hexagon unit tests should fail if run without proper gtest linkage * add tvm option; move Hexagon tests to test/cpp-runtime/hexagon * add libinfo * trigger ci
- Loading branch information
Showing
11 changed files
with
159 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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