Skip to content

Commit

Permalink
Add test machines under mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Jun 7, 2024
1 parent 73d0d5f commit 78fedee
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/macos-arm-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: macos-arm-unit-tests
on: [push]
jobs:
build:
runs-on: mac-mini-m2
steps:
- uses: actions/checkout@v2
- name: configure & build
run: |
cd lib && ./configure --enable-mps && cd ..
make -j 16 -C lib
make -j 16 -C bin
make -j 16 -C test
make -j 16 -C test/int/nnc
- name: tests
run: |
make -C test test
- name: integration tests
run: |
make -C test/int/nnc test
2 changes: 2 additions & 0 deletions test/int/nnc/graph.vgg.d.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static ccv_nnc_graph_t* ccv_nnc_simple_graph(ccv_convnet_t* convnet, ccv_nnc_ten
return vgg;
}

#ifdef HAVE_LIBPNG
TEST_CASE("run vgg-d graph with nnc")
{
ccv_convnet_t* convnet = ccv_convnet_read(0, "../../../samples/image-net-2012-vgg-d.sqlite3");
Expand Down Expand Up @@ -119,5 +120,6 @@ TEST_CASE("run vgg-d graph with nnc")
ccv_array_free(tensors);
ccv_convnet_free(convnet);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/int/nnc/symbolic.graph.vgg.d.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static ccv_nnc_symbolic_graph_t* ccv_nnc_simple_symbolic_graph(ccv_convnet_t* co
return symbolic_vgg;
}

#ifdef HAVE_LIBPNG
TEST_CASE("run vgg-d graph from its symbolic representation")
{
ccv_convnet_t* convnet = ccv_convnet_read(0, "../../../samples/image-net-2012-vgg-d.sqlite3");
Expand Down Expand Up @@ -162,5 +163,6 @@ TEST_CASE("run vgg-d graph from its symbolic representation")
ccfree(bias_symbols);
ccv_convnet_free(convnet);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/int/nnc/upsample.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TEST_SETUP()
ccv_nnc_init();
}

#ifdef HAVE_LIBPNG
TEST_CASE("upsample bilinear NHWC in float")
{
GUARD_ELSE_RETURN(ccv_nnc_cmd_ok(CCV_NNC_UPSAMPLE_FORWARD, CCV_NNC_BACKEND_GPU_REF) || ccv_nnc_cmd_ok(CCV_NNC_UPSAMPLE_FORWARD, CCV_NNC_BACKEND_MPS));
Expand Down Expand Up @@ -106,6 +107,7 @@ TEST_CASE("downsample bilinear NCHW in float")
ccv_nnc_tensor_free(hb);
ccv_matrix_free(image);
}
#endif

TEST_CASE("downsample bilinear NHWC in half precision")
{
Expand Down
2 changes: 2 additions & 0 deletions test/unit/basic.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "case.h"
#include "ccv_case.h"

#ifdef HAVE_LIBPNG
TEST_CASE("sobel operation")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -161,5 +162,6 @@ TEST_CASE("dilate operation")
ccv_matrix_free(x);
ccv_matrix_free(y);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/unit/image_processing.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "case.h"
#include "ccv_case.h"

#ifdef HAVE_LIBPNG
TEST_CASE("image saturation")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -31,5 +32,6 @@ TEST_CASE("image contrast")
ccv_matrix_free(b);
ccv_matrix_free(image);
}
#endif

#include "case_main.h"
10 changes: 10 additions & 0 deletions test/unit/io.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ TEST_CASE("read raw memory with no copy mode")
ccv_matrix_free(x);
}

#ifdef HAVE_LIBJPEG
TEST_CASE("read JPEG from memory")
{
ccv_dense_matrix_t* x = 0;
Expand All @@ -352,7 +353,9 @@ TEST_CASE("read JPEG from memory")
ccv_matrix_free(y);
ccv_matrix_free(x);
}
#endif

#ifdef HAVE_LIBPNG
TEST_CASE("read PNG from memory")
{
ccv_dense_matrix_t* x = 0;
Expand All @@ -371,7 +374,9 @@ TEST_CASE("read PNG from memory")
ccv_matrix_free(y);
ccv_matrix_free(x);
}
#endif

#ifdef HAVE_LIBJPEG
TEST_CASE("write JPEG to memory")
{
char sanitized_test_case_name[1024] = "/tmp/";
Expand Down Expand Up @@ -423,7 +428,9 @@ TEST_CASE("write JPEG to memory fail at small memory allocation")
ccfree(data);
ccv_matrix_free(x);
}
#endif

#ifdef HAVE_LIBPNG
TEST_CASE("write PNG to memory")
{
char sanitized_test_case_name[1024] = "/tmp/";
Expand Down Expand Up @@ -475,7 +482,9 @@ TEST_CASE("write PNG to memory fail at small memory allocation")
ccfree(data);
ccv_matrix_free(x);
}
#endif

#ifdef HAVE_LIBPNG
TEST_CASE("write binary to memory")
{
char sanitized_test_case_name[1024] = "/tmp/";
Expand Down Expand Up @@ -527,5 +536,6 @@ TEST_CASE("write binary to memory fail at small memory allocation")
ccfree(data);
ccv_matrix_free(x);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/unit/nnc/compression.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TEST_SETUP()
ccv_nnc_init();
}

#ifdef HAVE_LIBPNG
TEST_CASE("LSSC for natural image")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -43,6 +44,7 @@ TEST_CASE("LSSC for natural image")
ccv_nnc_tensor_free(b16);
ccv_nnc_tensor_free(c16);
}
#endif

TEST_CASE("LSSC should give exact result for 2-value data")
{
Expand Down
2 changes: 2 additions & 0 deletions test/unit/nnc/dataframe.addons.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ TEST_CASE("combine tensors")
ccv_array_free(array);
}

#ifdef HAVE_LIBPNG
TEST_CASE("read image and add random jitter")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -154,6 +155,7 @@ TEST_CASE("read image and add random jitter")
ccv_cnnp_dataframe_iter_free(iter);
ccv_cnnp_dataframe_free(dataframe);
}
#endif

TEST_CASE("execute command from dataframe addons API")
{
Expand Down
2 changes: 2 additions & 0 deletions test/unit/nnc/upsample.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TEST_SETUP()
ccv_nnc_init();
}

#ifdef HAVE_LIBPNG
TEST_CASE("upsample chessbox")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -78,6 +79,7 @@ TEST_CASE("downsample chessbox in NCHW")
ccv_matrix_free(image);
ccv_nnc_tensor_free(bt);
}
#endif

TEST_CASE("upsample nearest")
{
Expand Down
8 changes: 8 additions & 0 deletions test/unit/numeric.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ double gaussian(double x, double y, void* data)
return exp(-(x * x + y * y) / 20) / sqrt(CCV_PI * 20);
}

#ifdef HAVE_LIBPNG
TEST_CASE("Gaussian blur with kernel size even & odd")
{
ccv_dense_matrix_t* image = 0;
Expand Down Expand Up @@ -106,6 +107,7 @@ TEST_CASE("Gaussian blur with kernel size even & odd")
REQUIRE_MATRIX_FILE_EQ(y, "data/street.g101.bin", "should be Gaussian blur of 101x101 (odd) on street.png");
ccv_matrix_free(y);
}
#endif

TEST_CASE("ccv_filter centre point for even number window size, hint: (size - 1) / 2")
{
Expand Down Expand Up @@ -147,6 +149,7 @@ TEST_CASE("ccv_filter centre point for odd number window size, hint: (size - 1)

#include "ccv_internal.h"

#ifdef HAVE_LIBPNG
static void naive_ssd(ccv_dense_matrix_t* image, ccv_dense_matrix_t* template, ccv_dense_matrix_t* out)
{
int thw = template->cols / 2;
Expand Down Expand Up @@ -246,6 +249,7 @@ TEST_CASE("convolution ssd (sum of squared differences) v.s. naive ssd")
ccv_matrix_free(final);
ccv_matrix_free(ref);
}
#endif

// divide & conquer method for distance transform (copied directly from dpm-matlab (voc-release4)

Expand Down Expand Up @@ -305,6 +309,7 @@ void daq_min_distance_transform(ccv_dense_matrix_t* a, ccv_dense_matrix_t** b, d
ccv_matrix_free(dc);
}

#ifdef HAVE_LIBPNG
TEST_CASE("ccv_distance_transform (linear time) v.s. distance transform using divide & conquer (O(nlog(n)))")
{
ccv_dense_matrix_t* geometry = 0;
Expand All @@ -322,6 +327,7 @@ TEST_CASE("ccv_distance_transform (linear time) v.s. distance transform using di
ccv_matrix_free(ref);
ccv_matrix_free(distance);
}
#endif

// dt helper function
void dt_max_helper(float *src, float *dst, int *ptr, int step,
Expand Down Expand Up @@ -377,6 +383,7 @@ void daq_max_distance_transform(ccv_dense_matrix_t* a, ccv_dense_matrix_t** b, d
ccv_matrix_free(dc);
}

#ifdef HAVE_LIBPNG
TEST_CASE("ccv_distance_transform to compute max distance")
{
ccv_dense_matrix_t* geometry = 0;
Expand Down Expand Up @@ -435,5 +442,6 @@ TEST_CASE("ccv_kmeans1d to compute the 1D K-means")
ccfree(indices);
ccv_matrix_free(a);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/unit/transform.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "case.h"
#include "ccv_case.h"

#ifdef HAVE_LIBPNG
TEST_CASE("matrix decimal slice")
{
ccv_dense_matrix_t* image = 0;
Expand All @@ -23,5 +24,6 @@ TEST_CASE("matrix perspective transform")
ccv_matrix_free(image);
ccv_matrix_free(b);
}
#endif

#include "case_main.h"
2 changes: 2 additions & 0 deletions test/unit/util.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ TEST_CASE("loop over sparse matrix dense vector")
ccv_matrix_free(b);
}

#ifdef HAVE_LIBPNG
TEST_CASE("matrix slice")
{
ccv_dense_matrix_t* image = 0;
Expand All @@ -345,6 +346,7 @@ TEST_CASE("matrix slice")
ccv_matrix_free(image);
ccv_matrix_free(b);
}
#endif

TEST_CASE("matrix flatten")
{
Expand Down

0 comments on commit 78fedee

Please sign in to comment.