Skip to content

Commit

Permalink
Restructure utility functions (#305)
Browse files Browse the repository at this point in the history
* restructure various array utility: move from array/ to utility/ dir

* rename NMTOOLS_TESTING_OUTPUT_PRECISION to NMTOOLS_TESTING_PRECISION

* move files from utils/ to utility/

* fix example

* fix example

* fix invalid ci yaml

* skip some gcc-79 constexpr tests on ci because uses too much memory

* reduce number of jobs on gcc ci to avoid oom
  • Loading branch information
alifahrri authored Nov 2, 2024
1 parent e1e7bf5 commit cad2eb9
Show file tree
Hide file tree
Showing 503 changed files with 809 additions and 898 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/gcc-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- name: build
run: mkdir -p build/ && cd build/ && cmake .. && make -j2 VERBOSE=1
run: mkdir -p build/ && cd build/ && cmake .. && make -j1 VERBOSE=1
- name: run tests
run: |
build/tests/array/numeric-tests-doctest
Expand All @@ -45,8 +45,8 @@ jobs:
platform: x64
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- build:
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_BUILD_INDEX_TESTS=ON .. && make -j2 VERBOSE=1 numeric-tests-index-doctest
- name: build
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_BUILD_INDEX_TESTS=ON .. && make -j1 VERBOSE=1 numeric-tests-index-doctest
- name: run tests
run: |
build/tests/index/numeric-tests-index-doctest
Expand All @@ -64,7 +64,7 @@ jobs:
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- name: build
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON .. && make -j2 VERBOSE=1
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON .. && make -j1 VERBOSE=1
- name: run tests
run: |
build/tests/array/numeric-tests-doctest
Expand All @@ -82,7 +82,7 @@ jobs:
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- name: build
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON -DNMTOOLS_TESTING_GENERIC_NDARRAY=ON -DNMTOOLS_TESTING_NOSTL=OFF .. && make -j2 VERBOSE=1
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON -DNMTOOLS_TESTING_GENERIC_NDARRAY=ON -DNMTOOLS_TESTING_NOSTL=OFF .. && make -j1 VERBOSE=1
- name: run tests
run: |
build/tests/array/numeric-tests-doctest
Expand All @@ -100,7 +100,7 @@ jobs:
- name: setup doctest
run: bash scripts/download_doctest_header.sh -d include/
- name: build
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON -DNMTOOLS_TESTING_GENERIC_NDARRAY=ON -DNMTOOLS_TESTING_NOSTL=ON .. && make -j2 VERBOSE=1
run: mkdir -p build/ && cd build/ && cmake -DNMTOOLS_BUILD_CONSTEXPR_TESTS=ON -DNMTOOLS_BUILD_META_TESTS=OFF -DNMTOOLS_BUILD_UTL_TESTS=OFF -DNMTOOLS_TEST_ALL=OFF -DNMTOOLS_TEST_ARRAY_EVAL=ON -DNMTOOLS_TESTING_GENERIC_NDARRAY=ON -DNMTOOLS_TESTING_NOSTL=ON .. && make -j1 VERBOSE=1
- name: run tests
run: |
build/tests/array/numeric-tests-doctest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "nmtools/array/random_engine.hpp"

#include "nmtools/array/index/ndenumerate.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/array/utility/jni.hpp"
#include "nmtools/utility/to_string.hpp"
#include "nmtools/platform/jni.hpp"

namespace nm = nmtools;
namespace na = nm::array;
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/manip/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "nmtools/array/view/mutable_flatten.hpp"
#include "nmtools/array/array/flatten.hpp"

#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"
#include "nmtools/utils/apply_to_string.hpp"

#include <Arduino.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/ufuncs/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "nmtools/array/array/sum.hpp"
#include "nmtools/array/array/matmul.hpp"
#include "nmtools/array/array/mean.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <Arduino.h>

Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/manip/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "nmtools/array/view/mutable_flatten.hpp"
#include "nmtools/array/array/flatten.hpp"

#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

namespace nm = nmtools;
namespace view = nm::view;
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/ufuncs/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "nmtools/array/ndarray/fixed.hpp"

#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

namespace nm = nmtools;
namespace na = nm::array;
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/broadcast_to.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/broadcast_to.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/expand_dims.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/expand_dims.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/flatten.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/flatten.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/repeat.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/repeat.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/reshape.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/reshape.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/squeeze.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/squeeze.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/nmtools/array/src/tile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nmtools/array/view/tile.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
5 changes: 2 additions & 3 deletions examples/nmtools/array/src/transpose.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "nmtools/array/view/transpose.hpp"
#include "nmtools/array/utility/cast.hpp"
#include "nmtools/utility/cast.hpp"
#include "nmtools/array/ndarray.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/array/cast.hpp"
#include "nmtools/utility/to_string.hpp"

#include <iostream>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion examples/web/manip/manip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "nmtools/array/array/atleast_1d.hpp"
#include "nmtools/array/array/arange.hpp"

#include "nmtools/array/utility/embind.hpp"
#include "nmtools/platform/embind.hpp"
#include <emscripten/bind.h>

namespace em = emscripten;
Expand Down
2 changes: 1 addition & 1 deletion examples/web/ufuncs/ufuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "nmtools/array/view/ufuncs/clip.hpp"
#include "nmtools/array/array/ufuncs/exp.hpp"

#include "nmtools/array/utility/embind.hpp"
#include "nmtools/platform/embind.hpp"
#include <emscripten/bind.h>

namespace em = emscripten;
Expand Down
20 changes: 0 additions & 20 deletions include/nmtools/array/detail.hpp

This file was deleted.

7 changes: 0 additions & 7 deletions include/nmtools/array/dtypes.hpp

This file was deleted.

6 changes: 0 additions & 6 deletions include/nmtools/array/dynamic.hpp

This file was deleted.

8 changes: 4 additions & 4 deletions include/nmtools/array/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "nmtools/array/ndarray.hpp"

#include "nmtools/utils/isequal.hpp"
#include "nmtools/array/utility/apply_at.hpp"
#include "nmtools/array/utility/apply_resize.hpp"
#include "nmtools/array/shape.hpp"
#include "nmtools/utility/isequal.hpp"
#include "nmtools/utility/at.hpp"
#include "nmtools/utility/apply_resize.hpp"
#include "nmtools/utility/shape.hpp"

namespace nmtools::array
{
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/cuda/evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_CUDA_EVALUATOR_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"
#include "nmtools/array/eval/cuda/context.hpp"
#include "nmtools/array/functional.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/hip/evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_HIP_EVALUATOR_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"
#include "nmtools/array/eval/hip/context.hpp"
#include "nmtools/array/functional.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/opencl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_OPENCL_CONTEXT_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"

#include <CL/cl.h>
// for CL_PLATFORM_ICD_SUFFIX_KHR
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/opencl/evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_OPENCL_EVALUATOR_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"
#include "nmtools/array/eval/opencl/context.hpp"

#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/simd/evaluator/ufunc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_SIMD_EVALUATOR_UFUNC_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"
#include "nmtools/array/eval/simd/index.hpp"
#include "nmtools/array/eval/simd/ufunc.hpp"
#include "nmtools/array/eval/simd/bit_width.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/simd/index/matmul.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "nmtools/meta.hpp"
#include "nmtools/array/index/product.hpp"
#include "nmtools/array/shape.hpp"
#include "nmtools/utility/shape.hpp"
#include "nmtools/array/eval/simd/index/common.hpp"

namespace nmtools::index
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/simd/index/ufunc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "nmtools/meta.hpp"
#include "nmtools/array/index/product.hpp"
#include "nmtools/array/shape.hpp"
#include "nmtools/utility/shape.hpp"
#include "nmtools/array/eval/simd/index/common.hpp"
#include "nmtools/array/index/compute_offset.hpp"
#include "nmtools/array/index/compute_strides.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/nmtools/array/eval/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/eval/kernel_helper.hpp"
#include "nmtools/exception.hpp"
#include "nmtools/utils/to_string.hpp"
#include "nmtools/array/as_static.hpp"
#include "nmtools/utility/to_string.hpp"
#include "nmtools/utility/as_static.hpp"
#include "nmtools/utl/vector.hpp"

#include <sycl/sycl.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/eval/sycl/evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define NMTOOLS_ARRAY_EVAL_SYCL_EVALUATOR_HPP

#include "nmtools/array/eval.hpp"
#include "nmtools/array/data.hpp"
#include "nmtools/utility/data.hpp"
#include "nmtools/array/eval/sycl/context.hpp"
#include "nmtools/array/functional.hpp"

Expand Down
6 changes: 0 additions & 6 deletions include/nmtools/array/fixed.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions include/nmtools/array/functional/compute_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ namespace nmtools::functional
}; // get_compute_graph_t
} // namespace nmtools::functional

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utils/to_string/common_types.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/utility/to_string/common_types.hpp"

#if NMTOOLS_HAS_STRING

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/functional/expand.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NMTOOLS_ARRAY_FUNCTIONAL_EXPAND_HPP
#define NMTOOLS_ARRAY_FUNCTIONAL_EXPAND_HPP

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/view/expand.hpp"

Expand Down
4 changes: 2 additions & 2 deletions include/nmtools/array/functional/functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "nmtools/utility/ct_map.hpp"
#include "nmtools/utility/ct_digraph.hpp"
#include "nmtools/utility/tuple_slice.hpp"
#include "nmtools/utils/isequal/isequal.hpp"
#include "nmtools/utils/isclose/isclose.hpp"
#include "nmtools/utility/isequal/isequal.hpp"
#include "nmtools/utility/isclose/isclose.hpp"
#include "nmtools/utility/fwd.hpp"
#include "nmtools/utility/unwrap.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/functional/indexing.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NMTOOLS_ARRAY_FUNCTIONAL_INDEXING_HPP
#define NMTOOLS_ARRAY_FUNCTIONAL_INDEXING_HPP

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/view/indexing.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/functional/ufunc/accumulate.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_ACCUMULATE_HPP
#define NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_ACCUMULATE_HPP

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/view/ufunc.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/functional/ufunc/outer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_OUTER_HPP
#define NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_OUTER_HPP

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/view/ufunc.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/nmtools/array/functional/ufunc/reduce.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_REDUCE_HPP
#define NMTOOLS_ARRAY_FUNCTIONAL_UFUNC_REDUCE_HPP

#include "nmtools/utils/to_string/to_string.hpp"
#include "nmtools/utility/to_string/to_string.hpp"
#include "nmtools/array/functional/functor.hpp"
#include "nmtools/array/view/ufunc.hpp"

Expand Down
Loading

0 comments on commit cad2eb9

Please sign in to comment.