Skip to content

Commit

Permalink
Use unity build in OSS tests (neoml-lib#653)
Browse files Browse the repository at this point in the history
* Compilation works!!!!

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Fix randomziation tests

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Fix name conflict

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Try internal build

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Enable distributed tests only for Windows and Linux

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Revert "Enable distributed tests only for Windows and Linux"

This reverts commit 00966ec.

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Switch to updated NeoMLTest

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>

* Switch to actual NeoMLTest version

Signed-off-by: Valeriy Fedyunin <valery.fedyunin@abbyy.com>
  • Loading branch information
Valeriy Fedyunin committed Jun 22, 2022
1 parent 5854899 commit 0ce77e9
Show file tree
Hide file tree
Showing 44 changed files with 710 additions and 1,393 deletions.
3 changes: 2 additions & 1 deletion NeoML/test/desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ add_executable(${PROJECT_NAME}
)

set_target_properties( ${PROJECT_NAME} PROPERTIES
UNITY_BUILD_MODE GROUP
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE ${NeoML_UNITY_BUILD_BATCH_SIZE}
)

configure_target(${PROJECT_NAME})
Expand Down
6 changes: 6 additions & 0 deletions NeoML/test/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ target_sources(${PROJECT_NAME} INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestParams.h
${CMAKE_CURRENT_SOURCE_DIR}/TestParams.cpp
${CMAKE_CURRENT_SOURCE_DIR}/MlTestCommon.h
${CMAKE_CURRENT_SOURCE_DIR}/ClusteringTest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DnnLayersSerializationTest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DnnSerializationTest.cpp
Expand All @@ -27,4 +28,9 @@ target_sources(${PROJECT_NAME} INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/DnnDistributedTest.cpp
)

set_target_properties( ${PROJECT_NAME} PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE ${NeoML_UNITY_BUILD_BATCH_SIZE}
)

target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
12 changes: 1 addition & 11 deletions NeoML/test/src/FloatVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#pragma hdrstop

#include <TestFixture.h>
#include <MlTestCommon.h>

using namespace NeoML;
using namespace NeoMLTest;
Expand All @@ -27,17 +28,6 @@ class CFloatVectorTest : public CNeoMLTestFixture {
static void DeinitTestFixture() {}
};

static CSparseFloatVector generateRandomVector( CRandom& rand, int maxLength = 100,
float minValue = -100., float maxValue = 100. )
{
CSparseFloatVector res;
for( int i = 0; i < maxLength; ++i ) {
int index = rand.UniformInt( 0, maxLength - 1 ) ;
res.SetAt( index, static_cast<float>( rand.Uniform( minValue, maxValue ) ) );
}
return res;
}

TEST_F( CFloatVectorTest, DotProduct )
{
const int maxLength = 100;
Expand Down
31 changes: 31 additions & 0 deletions NeoML/test/src/MlTestCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Copyright © 2017-2022 ABBYY Production LLC
Licensed 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.
--------------------------------------------------------------------------------------------------------------*/

#pragma once

namespace NeoMLTest {

inline CSparseFloatVector generateRandomVector( CRandom& rand, int maxLength = 100,
float minValue = -100., float maxValue = 100. )
{
CSparseFloatVector res;
for( int i = 0; i < maxLength; ++i ) {
int index = rand.UniformInt( 0, maxLength - 1 ) ;
res.SetAt( index, static_cast<float>( rand.Uniform( minValue, maxValue ) ) );
}
return res;
}

} // namespace NeoMLTest
12 changes: 1 addition & 11 deletions NeoML/test/src/SparseFloatMatrixTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#pragma hdrstop

#include <TestFixture.h>
#include <MlTestCommon.h>

using namespace NeoML;
using namespace NeoMLTest;
Expand All @@ -27,17 +28,6 @@ class CSparseFloatMatrixTest : public CNeoMLTestFixture {
static void DeinitTestFixture() {}
};

static CSparseFloatVector generateRandomVector( CRandom& rand, int maxLength = 100,
float minValue = -100., float maxValue = 100. )
{
CSparseFloatVector res;
for( int i = 0; i < maxLength; ++i ) {
int index = rand.UniformInt( 0, maxLength - 1 ) ;
res.SetAt( index, static_cast<float>( rand.Uniform( minValue, maxValue ) ) );
}
return res;
}

TEST_F( CSparseFloatMatrixTest, AddRow )
{
const int maxLength = 100;
Expand Down
4 changes: 2 additions & 2 deletions NeoML/test/src/TestFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace {
#endif

static constexpr CharType TestDataPath[] = { '-','-','T','e','s','t','D','a','t','a','P','a','t','h','=' };
static constexpr CharType MathEngine[] = { '-','-','M','a','t','h','E','n','g','i','n','e','=' };
static constexpr CharType MathEngineArg[] = { '-','-','M','a','t','h','E','n','g','i','n','e','=' };
static constexpr CharType ThreadCount[] = { '-','-','T','h','r','e','a','d','C','o','u','n','t','=' };

static constexpr CharType Cpu[] = { 'c', 'p', 'u' };
Expand All @@ -77,7 +77,7 @@ namespace {
template <typename T>
TMathEngineType GetMathEngineType( int argc, T* argv[] )
{
auto value = ArgValue( argc, argv, MathEngine );
auto value = ArgValue( argc, argv, MathEngineArg );
if( !value ) {
return MET_Undefined;
}
Expand Down
3 changes: 2 additions & 1 deletion NeoMathEngine/test/FullTestDesktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ add_executable(${PROJECT_NAME}
)

set_target_properties( ${PROJECT_NAME} PROPERTIES
UNITY_BUILD_MODE GROUP
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE ${NeoML_UNITY_BUILD_BATCH_SIZE}
)

if(MSVC)
Expand Down
4 changes: 3 additions & 1 deletion NeoMathEngine/test/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
project(CommonTestTools)

add_library(${PROJECT_NAME}
MeTestCommon.h
TestFixture.cpp
TestFixture.h
TestParams.cpp
TestParams.h
)

set_target_properties( ${PROJECT_NAME} PROPERTIES
UNITY_BUILD_MODE GROUP
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE ${NeoML_UNITY_BUILD_BATCH_SIZE}
)

configure_target(${PROJECT_NAME})
Expand Down
Loading

0 comments on commit 0ce77e9

Please sign in to comment.