Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi Zhang committed Oct 25, 2024
1 parent 6522327 commit 974ee3a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
23 changes: 17 additions & 6 deletions onnxruntime/test/contrib_ops/matmul_4bits_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,17 @@ void RunTest(int64_t M, int64_t N, int64_t K, int64_t block_size, int64_t accura
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
if (use_float16) {
#ifdef USE_CUDA
execution_providers.push_back(DefaultCudaExecutionProvider());
if (DefaultCudaExecutionProvider() != nullptr) {
execution_providers.push_back(DefaultCudaExecutionProvider());
}
#endif
#ifdef USE_ROCM
execution_providers.push_back(DefaultRocmExecutionProvider());
#endif
#ifdef USE_DML
execution_providers.push_back(DefaultDmlExecutionProvider());
if (DefaultDmlExecutionProvider() != nullptr) {
execution_providers.push_back(DefaultDmlExecutionProvider());
}
#endif

RunTest<MLFloat16>(opts, std::move(execution_providers));
Expand All @@ -506,8 +510,11 @@ void RunTest(int64_t M, int64_t N, int64_t K, int64_t block_size, int64_t accura
} // namespace

TEST(MatMulNBits, Float16Cuda) {
#if defined(USE_CUDA) || defined(USE_ROCM)
#if defined(USE_CUDA) || defined(USE_ROCM) || defined(USE_DML)
auto has_gidx_options = {true, false};
if (DefaultDmlExecutionProvider() != nullptr) {
has_gidx_options = {false};
}
#else
auto has_gidx_options = {false};
#endif
Expand All @@ -518,7 +525,9 @@ TEST(MatMulNBits, Float16Cuda) {
for (auto block_size : {16, 32, 64, 128}) {
for (auto has_gidx : has_gidx_options) {
#ifdef USE_DML
RunTest(M, N, K, block_size, 0, false, true, has_gidx, true, 0.04f);
if (DefaultDmlExecutionProvider() != nullptr) {
RunTest(M, N, K, block_size, 0, false, true, has_gidx, true, 0.04f);
}
#else
RunTest(M, N, K, block_size, 0, false, true, has_gidx);
RunTest(M, N, K, block_size, 0, true, true, has_gidx, false);
Expand All @@ -531,12 +540,15 @@ TEST(MatMulNBits, Float16Cuda) {
}

TEST(MatMulNBits, Float16Large) {
#ifdef USE_DML
#if defined(USE_CUDA) || defined(USE_DML)
// For some reason, the A10 machine that runs these tests during CI has a much bigger error than all retail
// machines we tested on. All consumer-grade machines from Nvidia/AMD/Intel seem to pass these tests with an
// absolute error of 0.08, but the A10 has errors going as high as 0.22. Ultimately, given the large number
// of elements in this test, ULPs should probably be used instead of absolute/relative tolerances.
float abs_error = 0.3f;
if (DefaultDmlExecutionProvider() != nullptr) {
abs_error = 0.05f;
}
#else
float abs_error = 0.05f;
#endif
Expand All @@ -549,7 +561,6 @@ TEST(MatMulNBits, Float16Large) {
}
}
}

#endif // defined(USE_CUDA) || defined(USE_ROCM) || defined(USE_DML)
} // namespace test
} // namespace onnxruntime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ TEST(MatMulIntegerToFloat, HasZeroPoint_HasBias_test_U8S8) {
}

// DML EP supports Float16 output type and Signed A Matrix and Unsigned B Matric for Float32 output
#if defined(USE_DML)
#if defined(USE_DML) && !defined(USE_CUDA)

TEST(MatMulIntegerToFloat, HasZeroPoint_NoBias_test_S8U8) {
RunMatMulIntegerToFloatTest<int8_t, uint8_t, float, true, false>();
Expand Down
16 changes: 16 additions & 0 deletions onnxruntime/test/lora/lora_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ TEST(LoraAdapterTest, Load) {

#ifdef USE_CUDA
TEST(LoraAdapterTest, VerifyCudaDeviceCopy) {
if (DefaultCudaExecutionProvider() == nullptr) {
GTEST_SKIP() << "Skip This Test Due to this EP is null";
}
#ifdef USE_DML
if (DefaultDmlExecutionProvider() == nullptr) {
GTEST_SKIP() << "It should not run with DML EP";
}
#endif
auto cpu_ep = DefaultCpuExecutionProvider();
auto cpu_allocator = cpu_ep->CreatePreferredAllocators()[0];
auto cuda_allocator = DefaultCudaExecutionProvider()->CreatePreferredAllocators()[0];
Expand Down Expand Up @@ -234,6 +242,14 @@ TEST(LoraAdapterTest, VerifyCudaDeviceCopy) {

#ifdef USE_DML
TEST(LoraAdapterTest, VerifyDmlDeviceCopy) {
if (DefaultDmlExecutionProvider() == nullptr) {
GTEST_SKIP() << "Skip This Test Due to this EP is null";
}
#ifdef USE_CUDA
if (DefaultCudaExecutionProvider() == nullptr) {
GTEST_SKIP() << "It should not run with CUDA EP";
}
#endif
auto cpu_ep = DefaultCpuExecutionProvider();
auto cpu_allocator = cpu_ep->CreatePreferredAllocators()[0];

Expand Down
12 changes: 12 additions & 0 deletions onnxruntime/test/providers/cpu/model_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ ::std::vector<::std::basic_string<ORTCHAR_T>> GetParameterStrings() {
// the number of times these are run to reduce the CI time.
provider_names.erase(provider_name_cpu);
#endif

#if defined(USE_CUDA) && defined(USE_DML)
const std::string no_cuda_ep_test = Env::Default().GetEnvironmentVar("NO_CUDA_TEST");
if (no_cuda_ep_test == "1") {
provider_names.erase(provider_name_cuda);
}
const std::string no_dml_ep_test = Env::Default().GetEnvironmentVar("NO_DML_TEST");
if (no_dml_ep_test == "1") {
provider_names.erase(provider_name_dml);
}
#endif

std::vector<std::basic_string<ORTCHAR_T>> v;
// Permanently exclude following tests because ORT support only opset starting from 7,
// Please make no more changes to the list
Expand Down
2 changes: 1 addition & 1 deletion tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs):
executables.append("onnxruntime_global_thread_pools_test")
executables.append("onnxruntime_customopregistration_test")
for exe in executables:
test_output = f"--gtest_filter=*FusedMatMulOpTest* --gtest_output=xml:{cwd}/{exe}.{config}.results.xml"
test_output = f"--gtest_output=xml:{cwd}/{exe}.{config}.results.xml"
run_subprocess([os.path.join(cwd, exe), test_output], cwd=cwd, dll_path=dll_path)
else:
ctest_cmd = [ctest_path, "--build-config", config, "--verbose", "--timeout", args.test_all_timeout]
Expand Down

0 comments on commit 974ee3a

Please sign in to comment.