diff --git a/Tests/UnitTests/MathPerformanceTests/MathPerformanceTests.vcxproj b/Tests/UnitTests/MathPerformanceTests/MathPerformanceTests.vcxproj index 476cc8f5f..8253f4665 100644 --- a/Tests/UnitTests/MathPerformanceTests/MathPerformanceTests.vcxproj +++ b/Tests/UnitTests/MathPerformanceTests/MathPerformanceTests.vcxproj @@ -48,8 +48,7 @@ - $(SolutionDir)\Source\Math;$(SolutionDir)Source\Common\Include;%(AdditionalIncludeDirectories) - 4819 + $(SolutionDir)Source\Math;$(SolutionDir)Source\Common\Include;%(AdditionalIncludeDirectories) $(OutDir) diff --git a/Tests/UnitTests/MathPerformanceTests/PerformanceTests.cpp b/Tests/UnitTests/MathPerformanceTests/PerformanceTests.cpp deleted file mode 100644 index 00c0af3ad..000000000 --- a/Tests/UnitTests/MathPerformanceTests/PerformanceTests.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. -// -// Performance unit tests should go here -// - -#include "stdafx.h" -#include "Matrix.h" -#include "CPUMatrix.h" -#include "TensorView.h" -#include "Sequences.h" -#include -#include -#include -#include -#include -#include -#include - -using namespace Microsoft::MSR::CNTK; -using namespace boost::unit_test; - -namespace Microsoft { namespace MSR { namespace CNTK { namespace Test { - -BOOST_AUTO_TEST_SUITE(MathPerformanceTests) - -template -static void OneTensorTest(const char* what, double tolerance, const FN& fn) -{ - cout << "===== Tensor test '" << what << "'\n "; - - // run on GPU and CPU - let resultGPU = fn(0); - let resultCPU = fn(-1); - - // dump top corner of the result to get a feel for the error - resultGPU.GetSOB().Print("GPU result", 0, 7, 0, 9); - resultGPU.GetSOB().TransferToDeviceIfNotThere(-1, true, false, true); - resultCPU.GetSOB().Print("CPU result", 0, 7, 0, 9); - - // compare - let isSame = resultGPU.GetSOB().IsEqualTo(resultCPU.GetSOB(), (ElemType)tolerance); - BOOST_CHECK(isSame); -} - -template -static TensorView CreateTensor(TensorShape shape, int randomSeed, DEVICEID_TYPE deviceId, bool isResult = false) -{ - let numElements = shape.GetNumElements(); - - if (isResult) - cout << " ->"; - cout << " [" << string(shape) << "]"; - if (isResult) - cout << " \t// " << (deviceId < 0 ? "C" : "G") << "PU\n " << flush; - - // random init - mt19937 rng(randomSeed); - uniform_real_distribution nd(-1, 1); - vector init(numElements); - generate(begin(init), end(init), [&] { return nd(rng); }); - - // create storage object (one-column matrix) - let sob = make_shared>(numElements/*rows*/, 1/*cols*/, init.data(), deviceId); - - // create TensorView - return TensorView(sob, shape); -} - -template -static TensorView BroadcastingTest(TensorShape layerShape, TensorShape biasShape, DEVICEID_TYPE deviceId) -{ - int randomSeed = 1; - let input = CreateTensor(layerShape, randomSeed++, deviceId); - auto bias = CreateTensor(biasShape, randomSeed++, deviceId); - - auto result = CreateTensor(layerShape, randomSeed++, deviceId, true); - result.AssignSumOf(input, bias); - return result; -} - -BOOST_AUTO_TEST_CASE(test01) { - OneTensorTest("elementwise addition", 1e-8, [](DEVICEID_TYPE deviceId)->TensorView - { - return BroadcastingTest(TensorShape{ 512, 256 }, TensorShape({ 512, 256 }), deviceId); - }); -} - -BOOST_AUTO_TEST_SUITE_END() - -} -} } } \ No newline at end of file diff --git a/Tests/UnitTests/MathTests/stdafx.h b/Tests/UnitTests/MathTests/stdafx.h index ed3427f35..3b8d26661 100644 --- a/Tests/UnitTests/MathTests/stdafx.h +++ b/Tests/UnitTests/MathTests/stdafx.h @@ -24,6 +24,9 @@ #define BOOST_TEST_DYN_LINK #endif #include +<<<<<<< 2d4e16ed7592851224919859cd2877fcf9585d87 +======= +>>>>>>> Clean Math and MathPerformance test projects #include "constants.h" #include "fixtures.h"