Skip to content
Open
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ exclude: |
projects/hipdnn/.*\.bin$|
# Generated hipDNN FlatBuffers headers
projects/hipdnn/flatbuffers_sdk/include/hipdnn_flatbuffers_sdk/data_objects/.*_generated\.h|
# Reference data
projects/hipdnn/hipdnn_reference_data/.*|
# Reference data (auto-generated)
dnn-providers/integration-tests/hipdnn_reference_data/.*|
# Generated files (see rocrand/tools/ _generator.cpp files)
projects/rocrand/library/.*constants\.(cpp|h)|
projects/rocrand/library/.*precomputed\.(cpp|h)
Expand Down
5 changes: 5 additions & 0 deletions dnn-providers/integration-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ fetch_gtest_dependency()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Copy golden reference data into the build tree so tests can find it at
# <exe_dir>/../lib/hipdnn_reference_data/
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/hipdnn_reference_data/"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably mention this only copies at configure time.

DESTINATION "${CMAKE_BINARY_DIR}/lib/hipdnn_reference_data")

set(INTEGRATION_TESTS_EXE hipdnn_integration_tests)

add_executable(${INTEGRATION_TESTS_EXE}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bin binary
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

#include <hipdnn_data_sdk/logging/Logger.hpp>
#include <hipdnn_test_sdk/utilities/CpuFpReferenceValidation.hpp>
#include <hipdnn_test_sdk/utilities/cpu_graph_executor/CpuReferenceGraphExecutor.hpp>

#include <hipdnn_test_sdk/utilities/FileUtilities.hpp>
#include <hipdnn_test_sdk/utilities/LoadGraphAndTensors.hpp>
#include <hipdnn_test_sdk/utilities/TestUtilities.hpp>
#include <hipdnn_test_sdk/utilities/cpu_graph_executor/CpuReferenceGraphExecutor.hpp>

namespace hipdnn_test_sdk::utilities
namespace hipdnn_integration_tests
{

class TestGoldenReferenceCpu : public ::testing::TestWithParam<std::filesystem::path>
Expand Down Expand Up @@ -46,9 +47,8 @@ class TestGoldenReferenceCpu : public ::testing::TestWithParam<std::filesystem::
SKIP_IF_WINDOWS();

auto tensorMap = _graphAndTensors.hostBufferMap();
EXPECT_EQ(tensorMap.size(), 6);

CpuReferenceGraphExecutor().execute(
hipdnn_test_sdk::utilities::CpuReferenceGraphExecutor().execute(
_graphAndTensors.graphBuffer.data(), _graphAndTensors.graphBuffer.size(), tensorMap);

EXPECT_TRUE(_graphAndTensors.validateTensors(
Expand All @@ -58,10 +58,11 @@ class TestGoldenReferenceCpu : public ::testing::TestWithParam<std::filesystem::

inline auto getGoldenReferenceParams(const std::filesystem::path& subDirectory)
{
return testing::ValuesIn(filesInDirectoryWithExtReturnEmptyPathOnThrow(
hipdnn_data_sdk::utilities::getCurrentExecutableDirectory() / "../lib/hipdnn_reference_data"
/ subDirectory,
".json"));
return testing::ValuesIn(
hipdnn_test_sdk::utilities::filesInDirectoryWithExtReturnEmptyPathOnThrow(
hipdnn_data_sdk::utilities::getCurrentExecutableDirectory()
/ "../lib/hipdnn_reference_data" / subDirectory,
".json"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

target_sources(${INTEGRATION_TESTS_EXE}
PRIVATE
IntegrationGoldenRefBatchnormFwdInference.cpp
IntegrationGpuBatchnormBackward.cpp
IntegrationGpuBatchnormBackwardActivation.cpp
IntegrationGpuBatchnormForwardInference.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT

#ifndef HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB

#include <gtest/gtest.h>

#include <hipdnn_data_sdk/types.hpp>
#include <hipdnn_test_sdk/utilities/TestTolerances.hpp>

#include "harness/GoldenReferenceCpu.hpp"

using namespace hipdnn_integration_tests;
using namespace hipdnn_data_sdk::types;
using namespace hipdnn_test_sdk::utilities;

template <class T>
class TestCpuBatchnormFwdInferenceGoldenReference : public TestGoldenReferenceCpu
{
public:
void testSuite()
{
return goldenReferenceTestSuite(batchnorm::getToleranceInference<T>(),
batchnorm::getToleranceInference<T>());
}
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32
: public TestCpuBatchnormFwdInferenceGoldenReference<float>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16
: public TestCpuBatchnormFwdInferenceGoldenReference<half>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16
: public TestCpuBatchnormFwdInferenceGoldenReference<bfloat16>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32
: public TestCpuBatchnormFwdInferenceGoldenReference<float>
{
};

// Nchw Fp32------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32,
getGoldenReferenceParams("BatchnormFwdInference/nchw/fp32"));

// Nchw Fp16------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16,
getGoldenReferenceParams("BatchnormFwdInference/nchw/fp16"));

// Nchw Bfp16------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16,
getGoldenReferenceParams("BatchnormFwdInference/nchw/bfp16"));

// Ncdhw Fp32------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32,
getGoldenReferenceParams("BatchnormFwdInference/ncdhw/fp32"));

#endif // HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB
18 changes: 12 additions & 6 deletions projects/hipdnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,18 @@ set(HIPDNN_TEST_REFERENCE_DIR "${CMAKE_BINARY_DIR}/lib/hipdnn_reference_data"
set(HIPDNN_TEST_REFERENCE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}"
CACHE INTERNAL "Install directory for test reference data"
)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/hipdnn_reference_data/"
DESTINATION ${HIPDNN_TEST_REFERENCE_DIR}
) # Copies only on calls to cmake
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/hipdnn_reference_data"
DESTINATION ${HIPDNN_TEST_REFERENCE_INSTALL_DIR}
)
set(_hipdnn_ref_data_src
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this belong here anymore? should it just be in the integration-tests project?

"${CMAKE_SOURCE_DIR}/dnn-providers/integration-tests/hipdnn_reference_data")
if(EXISTS "${_hipdnn_ref_data_src}")
file(COPY "${_hipdnn_ref_data_src}/"
DESTINATION ${HIPDNN_TEST_REFERENCE_DIR}
)
endif()
if(EXISTS "${HIPDNN_TEST_REFERENCE_DIR}")
install(DIRECTORY "${HIPDNN_TEST_REFERENCE_DIR}"
DESTINATION ${HIPDNN_TEST_REFERENCE_INSTALL_DIR}
)
endif()

# Migrate HIP_DNN_BUILD_BACKEND -> HIPDNN_BUILD_BACKEND
if(DEFINED HIP_DNN_BUILD_BACKEND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,12 @@
#include <hipdnn_test_sdk/utilities/cpu_graph_executor/CpuReferenceGraphExecutor.hpp>
#include <hipdnn_test_sdk/utilities/detail/CpuFpReferenceUtilities.hpp>

#ifndef HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB
#include "GoldenReferenceCpu.hpp"
#endif

using namespace hipdnn_test_sdk::utilities;
using namespace hipdnn_flatbuffers_sdk::data_objects;
using namespace hipdnn_data_sdk::utilities;
using namespace hipdnn_data_sdk::types;
using hipdnn_test_sdk::detail::safeTestTypeCast;

#ifndef HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB

template <class T>
class TestCpuBatchnormFwdInferenceGoldenReference : public TestGoldenReferenceCpu
{
public:
void testSuite()
{
return goldenReferenceTestSuite(batchnorm::getToleranceInference<T>(),
batchnorm::getToleranceInference<T>());
}
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32
: public TestCpuBatchnormFwdInferenceGoldenReference<float>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16
: public TestCpuBatchnormFwdInferenceGoldenReference<half>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16
: public TestCpuBatchnormFwdInferenceGoldenReference<bfloat16>
{
};

class TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32
: public TestCpuBatchnormFwdInferenceGoldenReference<float>
{
};

// Nchw Fp32------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp32,
getGoldenReferenceParams("BatchnormFwdInference/nchw/fp32"));

// Nchw Fp16------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwFp16,
getGoldenReferenceParams("BatchnormFwdInference/nchw/fp16"));

// Nchw Bfp16------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNchwBfp16,
getGoldenReferenceParams("BatchnormFwdInference/nchw/bfp16"));

// Ncdhw Fp32------------
TEST_P(TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32, Correctness)
{
testSuite();
}

INSTANTIATE_TEST_SUITE_P(,
TestCpuBatchnormFwdInferenceGoldenReferenceNcdhwFp32,
getGoldenReferenceParams("BatchnormFwdInference/ncdhw/fp32"));

#endif // HIPDNN_FLATBUFFERS_SDK_SKIP_JSON_LIB

//--------------------------

template <typename T1, typename T2>
Expand Down
Loading