Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alifahrri committed Jun 29, 2024
1 parent a759ea5 commit a3afe6d
Show file tree
Hide file tree
Showing 54 changed files with 2,518 additions and 1,781 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ pocl
*.ll
llvm.sh
install
amdgpu-*
amdgpu-*
*.dot
56 changes: 28 additions & 28 deletions include/nmtools/testing/data/array/broadcast_to.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[2] = {3,1};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct,1_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct,1_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case1)
{
Expand All @@ -37,10 +37,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[2] = {3,3};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct,3_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct,"3:[3]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct,3_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct,"3:[3]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case2)
{
Expand All @@ -56,10 +56,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[3] = {3,3,1};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct,3_ct,1_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct,"3:[3]"_ct,"1:[1]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct,3_ct,1_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct,"3:[3]"_ct,"1:[1]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case3)
{
Expand All @@ -75,10 +75,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[3] = {3,3,6};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct,3_ct,6_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct,"3:[3]"_ct,"6:[6]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct,3_ct,6_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct,"3:[3]"_ct,"6:[6]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case4)
{
Expand All @@ -94,10 +94,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[1] = {3};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case5)
{
Expand All @@ -113,10 +113,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[3] = {3,6,6};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{3_ct,6_ct,6_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"3:[3]"_ct,"6:[6]"_ct,"6:[6]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{3_ct,6_ct,6_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"3:[3]"_ct,"6:[6]"_ct,"6:[6]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case6)
{
Expand All @@ -132,10 +132,10 @@ NMTOOLS_TESTING_DECLARE_CASE(index, broadcast_to)
inline int bshape[4] = {7,3,3,6};
NMTOOLS_CAST_INDEX_ARRAYS(ashape)
NMTOOLS_CAST_INDEX_ARRAYS(bshape)
inline auto ashape_ct = tuple{3_ct,1_ct};
inline auto bshape_ct = tuple{7_ct,3_ct,3_ct,6_ct};
inline auto ashape_cl = tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = tuple{"7:[7]"_ct,"3:[3]"_ct,"3:[3]"_ct,"6:[6]"_ct};
inline auto ashape_ct = nmtools_tuple{3_ct,1_ct};
inline auto bshape_ct = nmtools_tuple{7_ct,3_ct,3_ct,6_ct};
inline auto ashape_cl = nmtools_tuple{"3:[3]"_ct,"1:[1]"_ct};
inline auto bshape_cl = nmtools_tuple{"7:[7]"_ct,"3:[3]"_ct,"3:[3]"_ct,"6:[6]"_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case7)
{
Expand Down
188 changes: 188 additions & 0 deletions include/nmtools/testing/data/index/alias.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#ifndef NMTOOLS_TESTING_DATA_INDEX_ALIAS_HPP
#define NMTOOLS_TESTING_DATA_INDEX_ALIAS_HPP

#include "nmtools/testing/testing.hpp"

NMTOOLS_TESTING_DECLARE_CASE(index,alias)
{
using namespace literals;

NMTOOLS_TESTING_DECLARE_ARGS(case1)
{
inline int operands[1] = {-1};
inline auto reserved_ids = None;
inline auto operands_ct = nmtools_tuple{meta::ct_v<-1>};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case1)
{
inline int result[1] = {0};
}

NMTOOLS_TESTING_DECLARE_ARGS(case2)
{
inline int operands[1] = {-1};
inline int reserved_ids[3] = {2,0,1};
inline auto operands_ct = nmtools_tuple{meta::ct_v<-1>};
inline auto reserved_ids_ct = nmtools_tuple{2_ct,0_ct,1_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case2)
{
inline int result[1] = {3};
}

NMTOOLS_TESTING_DECLARE_ARGS(case3)
{
inline int operands[3] = {-1,2,-1};
inline int reserved_ids[2] = {3,1};
inline auto operands_ct = nmtools_tuple{meta::ct_v<-1>,2_ct,meta::ct_v<-1>};
inline auto reserved_ids_ct = nmtools_tuple{3_ct,1_ct};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case3)
{
inline int result[3] = {4,2,5};
}

NMTOOLS_TESTING_DECLARE_ARGS(case4)
{
inline int operands[3] = {-1,2,-1};
inline auto reserved_ids = nmtools_tuple{};
}
NMTOOLS_TESTING_DECLARE_EXPECT(case4)
{
inline int operands[3] = {3,2,4};
}
}

NMTOOLS_TESTING_DECLARE_CASE(index,generate_alias)
{
using namespace literals;
using meta::ct_v;

NMTOOLS_TESTING_DECLARE_ARGS(case1)
{
inline int aliases[1] = {0};
inline int base = 256;
inline int prime = 101;
inline auto aliases_ct = nmtools_tuple{0_ct};
inline auto base_ct = 256_ct;
inline auto prime_ct = 101_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case1)
{
inline int result = 0;
}

NMTOOLS_TESTING_DECLARE_ARGS(case2)
{
inline int aliases[2] = {0,-1};
inline int base = 256;
inline int prime = 101;
inline auto aliases_ct = nmtools_tuple{0_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 101_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case2)
{
inline auto result = 100;
}

NMTOOLS_TESTING_DECLARE_ARGS(case3)
{
inline int aliases[3] = {100,0,-1};
inline int base = 256;
inline int prime = 101;
inline auto aliases_ct = nmtools_tuple{100_ct,0_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 101_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case3)
{
inline auto result = 12;
}

NMTOOLS_TESTING_DECLARE_ARGS(case4)
{
inline int aliases[4] = {12,100,0,-1};
inline int base = 256;
inline int prime = 101;
inline auto aliases_ct = nmtools_tuple{12_ct,100_ct,0_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 101_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case4)
{
inline auto result = 72;
}

NMTOOLS_TESTING_DECLARE_ARGS(case5)
{
inline int aliases[5] = {72,12,100,0,-1};
inline int base = 256;
inline int prime = 101;
inline auto aliases_ct = nmtools_tuple{72,12,100,0,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 101_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case5)
{
inline auto result = 19;
}

NMTOOLS_TESTING_DECLARE_ARGS(case6)
{
inline int aliases[7] = {3,0,1,2,3,4,-1};
inline int base = 256;
inline int prime = 503;
inline auto aliases_ct = nmtools_tuple{3_ct,0_ct,1_ct,2_ct,3_ct,4_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 503_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case6)
{
inline auto result = 172;
}

NMTOOLS_TESTING_DECLARE_ARGS(case7)
{
inline int aliases[7] = {2,0,1,2,3,4,-1};
inline int base = 256;
inline int prime = 503;
inline auto aliases_ct = nmtools_tuple{2_ct,0_ct,1_ct,2_ct,3_ct,4_ct,ct_v<-1>};
inline int base_ct = 256_ct;
inline int prime_ct = 503_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case7)
{
inline auto result = 97;
}

NMTOOLS_TESTING_DECLARE_ARGS(case8)
{
inline int aliases[7] = {1,0,1,2,3,4,-1};
inline int base = 256;
inline int prime = 503;
inline auto aliases_ct = nmtools_tuple{1_ct,0_ct,1_ct,2_ct,3_ct,4_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 503_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case8)
{
inline auto result = 22;
}

NMTOOLS_TESTING_DECLARE_ARGS(case9)
{
inline int aliases[7] = {4,0,1,2,3,4,-1};
inline int base = 256;
inline int prime = 503;
inline auto aliases_ct = nmtools_tuple{4_ct,0_ct,1_ct,2_ct,3_ct,4_ct,ct_v<-1>};
inline auto base_ct = 256_ct;
inline auto prime_ct = 503_ct;
}
NMTOOLS_TESTING_DECLARE_EXPECT(case9)
{
inline auto result = 247;
}
}

#endif // NMTOOLS_TESTING_DATA_INDEX_ALIAS_HPP
Loading

0 comments on commit a3afe6d

Please sign in to comment.