Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alifahrri committed Feb 17, 2024
1 parent 4321b48 commit d5139e9
Show file tree
Hide file tree
Showing 88 changed files with 2,345 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ if (NMTOOLS_FUNCTIONAL_TEST_ALL)

src/misc/ct_map.cpp
src/misc/ct_digraph.cpp

src/arange.cpp

src/composition/reduce_add_tanh.cpp
src/composition/multiply_tanh.cpp
src/composition/multiply_add.cpp
src/composition/multiply_add_tanh.cpp
src/composition/add_tanh.cpp
src/composition/reduce_add_divide.cpp
src/composition/divide_subtract.cpp
src/composition/subtract_fabs.cpp
src/composition/subtract_fabs_square.cpp
src/composition/fabs_square.cpp
src/composition/fabs_square_sum.cpp
src/composition/square_sum.cpp
src/composition/square_sum_divide.cpp
src/composition/sum_divide.cpp
src/composition/reduce_maximum_subtract.cpp
src/composition/reduce_maximum_subtract_exp.cpp
src/composition/subtract_exp.cpp
)
endif()

Expand Down
15 changes: 15 additions & 0 deletions tests/functional/src/activations/celu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ TEST_CASE("celu(case2)" * doctest::test_suite("functional::celu"))
ACTIVATIONS_SUBCASE( "case2", fn::celu[alpha], a_f );
ACTIVATIONS_SUBCASE( "case2", fn::celu[alpha], a_h );
ACTIVATIONS_SUBCASE( "case2", fn::celu[alpha], a_d );
}

namespace view = nmtools::view;

TEST_CASE("celu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,celu,case2);
using namespace args;

auto array = view::celu(a,alpha);

auto function = fn::get_function_composition(array);
auto expect = fn::celu[alpha];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/elu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ TEST_CASE("elu(case2)" * doctest::test_suite("functional::elu"))
ACTIVATIONS_SUBCASE( "case2", fn::elu[alpha], a_f );
ACTIVATIONS_SUBCASE( "case2", fn::elu[alpha], a_h );
ACTIVATIONS_SUBCASE( "case2", fn::elu[alpha], a_d );
}

namespace view = nmtools::view;

TEST_CASE("elu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,elu,case2);
using namespace args;

auto array = view::elu(a,alpha);

auto function = fn::get_function_composition(array);
auto expect = fn::elu[alpha];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/hardshrink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ TEST_CASE("hardshrink(case2)" * doctest::test_suite("functional::hardshrink"))
ACTIVATIONS_SUBCASE( "case2", fn::hardshrink[lambda], a_f );
ACTIVATIONS_SUBCASE( "case2", fn::hardshrink[lambda], a_h );
ACTIVATIONS_SUBCASE( "case2", fn::hardshrink[lambda], a_d );
}

namespace view = nmtools::view;

TEST_CASE("hardshrink" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,hardshrink,case2);
using namespace args;

auto array = view::hardshrink(a,lambda);

auto function = fn::get_function_composition(array);
auto expect = fn::hardshrink[lambda];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/hardswish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("hardswish(case1)" * doctest::test_suite("functional::hardswish"))
ACTIVATIONS_SUBCASE( "case1", fn::hardswish, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::hardswish, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::hardswish, a_d );
}

namespace view = nmtools::view;

TEST_CASE("hardswish" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,hardswish,case1);
using namespace args;

auto array = view::hardswish(a);

auto function = fn::get_function_composition(array);
auto expect = fn::hardswish;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/hardtanh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("hardtanh(case1)" * doctest::test_suite("functional::hardtanh"))
ACTIVATIONS_SUBCASE( "case1", fn::hardtanh, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::hardtanh, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::hardtanh, a_d );
}

namespace view = nmtools::view;

TEST_CASE("hardtanh" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,hardtanh,case1);
using namespace args;

auto array = view::hardtanh(a);

auto function = fn::get_function_composition(array);
auto expect = fn::hardtanh[-1.][1.];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/leaky_relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("leaky_relu(case1)" * doctest::test_suite("functional::leaky_relu"))
ACTIVATIONS_SUBCASE( "case1", fn::leaky_relu, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::leaky_relu, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::leaky_relu, a_d );
}

namespace view = nmtools::view;

TEST_CASE("leaky_relu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,leaky_relu,case1);
using namespace args;

auto array = view::leaky_relu(a);

auto function = fn::get_function_composition(array);
auto expect = fn::leaky_relu[0.01];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/log_sigmoid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("log_sigmoid(case1)" * doctest::test_suite("functional::log_sigmoid"))
ACTIVATIONS_SUBCASE( "case1", fn::log_sigmoid, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::log_sigmoid, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::log_sigmoid, a_d );
}

namespace view = nmtools::view;

TEST_CASE("log_sigmoid" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,log_sigmoid,case1);
using namespace args;

auto array = view::log_sigmoid(a);

auto function = fn::get_function_composition(array);
auto expect = fn::log_sigmoid;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/mish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("mish(case1)" * doctest::test_suite("functional::mish"))
ACTIVATIONS_SUBCASE( "case1", fn::mish, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::mish, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::mish, a_d );
}

namespace view = nmtools::view;

TEST_CASE("mish" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,mish,case1);
using namespace args;

auto array = view::mish(a);

auto function = fn::get_function_composition(array);
auto expect = fn::mish;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/prelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("prelu(case1)" * doctest::test_suite("functional::prelu"))
ACTIVATIONS_SUBCASE( "case1", fn::prelu, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::prelu, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::prelu, a_d );
}

namespace view = nmtools::view;

TEST_CASE("prelu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,prelu,case1);
using namespace args;

auto array = view::prelu(a);

auto function = fn::get_function_composition(array);
auto expect = fn::prelu[0.25];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("relu(case1)" * doctest::test_suite("functional::relu"))
RELU_SUBCASE("case1", fn::relu, a_f);
RELU_SUBCASE("case1", fn::relu, a_h);
RELU_SUBCASE("case1", fn::relu, a_d);
}

namespace view = nmtools::view;

TEST_CASE("relu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,relu,case1);
using namespace args;

auto array = view::relu(a);

auto function = fn::get_function_composition(array);
auto expect = fn::relu;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
16 changes: 16 additions & 0 deletions tests/functional/src/activations/relu6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ TEST_CASE("relu6(case1)" * doctest::test_suite("functional::relu6"))
ACTIVATIONS_SUBCASE( "case1", fn::relu6, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::relu6, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::relu6, a_d );
}


namespace view = nmtools::view;

TEST_CASE("relu6" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,relu6,case1);
using namespace args;

auto array = view::relu6(a);

auto function = fn::get_function_composition(array);
auto expect = fn::relu6;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/selu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("selu(case1)" * doctest::test_suite("functional::selu"))
ACTIVATIONS_SUBCASE( "case1", fn::selu, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::selu, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::selu, a_d );
}

namespace view = nmtools::view;

TEST_CASE("selu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,selu,case1);
using namespace args;

auto array = view::selu(a);

auto function = fn::get_function_composition(array);
auto expect = fn::selu;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/sigmoid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("sigmoid(case1)" * doctest::test_suite("functional::sigmoid"))
ACTIVATIONS_SUBCASE( "case1", fn::sigmoid, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::sigmoid, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::sigmoid, a_d );
}

namespace view = nmtools::view;

TEST_CASE("sigmoid" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,sigmoid,case1);
using namespace args;

auto array = view::sigmoid(a);

auto function = fn::get_function_composition(array);
auto expect = fn::sigmoid;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/silu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("silu(case1)" * doctest::test_suite("functional::silu"))
ACTIVATIONS_SUBCASE( "case1", fn::silu, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::silu, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::silu, a_d );
}

namespace view = nmtools::view;

TEST_CASE("silu" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,silu,case1);
using namespace args;

auto array = view::silu(a);

auto function = fn::get_function_composition(array);
auto expect = fn::silu;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/softplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("softplus(case1)" * doctest::test_suite("functional::softplus"))
ACTIVATIONS_SUBCASE( "case1", fn::softplus, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::softplus, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::softplus, a_d );
}

namespace view = nmtools::view;

TEST_CASE("softplus" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,softplus,case1);
using namespace args;

auto array = view::softplus(a);

auto function = fn::get_function_composition(array);
auto expect = fn::softplus[1.][20.];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/softshrink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("softshrink(case1)" * doctest::test_suite("functional::softshrink"))
ACTIVATIONS_SUBCASE( "case1", fn::softshrink, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::softshrink, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::softshrink, a_d );
}

namespace view = nmtools::view;

TEST_CASE("softshrink" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,softshrink,case1);
using namespace args;

auto array = view::softshrink(a);

auto function = fn::get_function_composition(array);
auto expect = fn::softshrink[0.5];

NMTOOLS_ASSERT_EQUAL( function, expect );
}
15 changes: 15 additions & 0 deletions tests/functional/src/activations/softsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@ TEST_CASE("softsign(case1)" * doctest::test_suite("functional::softsign"))
ACTIVATIONS_SUBCASE( "case1", fn::softsign, a_f );
ACTIVATIONS_SUBCASE( "case1", fn::softsign, a_h );
ACTIVATIONS_SUBCASE( "case1", fn::softsign, a_d );
}

namespace view = nmtools::view;

TEST_CASE("softsign" * doctest::test_suite("functional::get_function_composition"))
{
NMTOOLS_TESTING_DECLARE_NS(activations,softsign,case1);
using namespace args;

auto array = view::softsign(a);

auto function = fn::get_function_composition(array);
auto expect = fn::softsign;

NMTOOLS_ASSERT_EQUAL( function, expect );
}
Loading

0 comments on commit d5139e9

Please sign in to comment.