diff --git a/CMakeLists.txt b/CMakeLists.txt index a2e4ee32c83..c75b52555f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,8 +215,7 @@ set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -DDALI_DEBUG=0") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g3") set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -g -lineinfo") -# Use -std=c++14 (and not gnu++14) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_C_STANDARD 11) diff --git a/dali/kernels/test/tuple_test.cc b/dali/core/tuple_test.cc similarity index 93% rename from dali/kernels/test/tuple_test.cc rename to dali/core/tuple_test.cc index adce67fa537..963600167be 100644 --- a/dali/kernels/test/tuple_test.cc +++ b/dali/core/tuple_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,9 +13,8 @@ // limitations under the License. #include -#include "dali/kernels/kernel.h" -#include "dali/kernels/type_tag.h" -#include "dali/core/static_switch.h" +#include +#include "dali/core/tuple_helpers.h" namespace dali { namespace kernels { diff --git a/dali/kernels/test/util_test.cc b/dali/core/util_test.cc similarity index 100% rename from dali/kernels/test/util_test.cc rename to dali/core/util_test.cc diff --git a/dali/core/utils_test.cu b/dali/core/utils_test.cu index afbc2022c45..9da68cb6c4d 100644 --- a/dali/core/utils_test.cu +++ b/dali/core/utils_test.cu @@ -33,14 +33,14 @@ DEVICE_TEST(CoreUtilsDev, Volume, 1, 1) { DEVICE_TEST(CoreUtilsDev, Size, 1, 1) { int a0[] = { 42 }; - DEV_EXPECT_EQ(size(a0), 1u); + DEV_EXPECT_EQ(dali::size(a0), 1u); int a1[] = { 2, 3, 4 }; - DEV_EXPECT_EQ(size(a1), 3u); + DEV_EXPECT_EQ(dali::size(a1), 3u); SmallVector v; v.resize(10); DEV_EXPECT_EQ(v.size(), 10u); - DEV_EXPECT_EQ(size(v), 10u); + DEV_EXPECT_EQ(dali::size(v), 10u); } DEFINE_TEST_KERNEL(CoreUtilsDev, Span, span data) { diff --git a/dali/kernels/context.h b/dali/kernels/context.h index c39c37b1104..1ad57649049 100644 --- a/dali/kernels/context.h +++ b/dali/kernels/context.h @@ -135,15 +135,16 @@ class Scratchpad { template >> if_array_like ToGPU(cudaStream_t stream, const Collection &c) { - T *ptr = AllocateGPU(size(c)); - CUDA_CALL(cudaMemcpyAsync(ptr, &c[0], size(c) * sizeof(T), cudaMemcpyHostToDevice, stream)); + auto n = dali::size(c); + T *ptr = AllocateGPU(n); + CUDA_CALL(cudaMemcpyAsync(ptr, &c[0], n * sizeof(T), cudaMemcpyHostToDevice, stream)); return ptr; } template >> if_iterable ToHost(const Collection &c) { - T *ptr = AllocateHost(size(c)); + T *ptr = AllocateHost(dali::size(c)); std::copy(begin(c), end(c), ptr); return ptr; } @@ -151,7 +152,7 @@ class Scratchpad { template >> if_iterable ToPinned(const Collection &c) { - T *ptr = AllocatePinned(size(c)); + T *ptr = AllocatePinned(dali::size(c)); std::copy(begin(c), end(c), ptr); return ptr; } @@ -159,7 +160,7 @@ class Scratchpad { template >> if_iterable ToManaged(const Collection &c) { - T *ptr = AllocateManaged(size(c)); + T *ptr = AllocateManaged(dali::size(c)); std::copy(begin(c), end(c), ptr); return ptr; } diff --git a/dali/kernels/reduce/reduce_drop_dims.h b/dali/kernels/reduce/reduce_drop_dims.h index 7093b769c04..4eb2be279db 100644 --- a/dali/kernels/reduce/reduce_drop_dims.h +++ b/dali/kernels/reduce/reduce_drop_dims.h @@ -136,7 +136,7 @@ struct DropDims { template static int simplify(int64_t *out_shape, unsigned &out_mask, const Indices &in_shape, uint64_t axis_mask) { - int dims = size(in_shape); + int dims = dali::size(in_shape); int d = 0; out_shape[0] = in_shape[0]; bool prev = axis_mask & 1; @@ -169,7 +169,7 @@ struct DropDims { template DropDims(const Indices &in_shape, uint64_t reduced_axes) { memset(this, 0, sizeof(*this)); - if (size(in_shape) == 0) { + if (dali::size(in_shape) == 0) { start = -1; return; } diff --git a/dali/kernels/scratch_copy_impl.h b/dali/kernels/scratch_copy_impl.h index c856c74bb3d..1bbdb0a566d 100644 --- a/dali/kernels/scratch_copy_impl.h +++ b/dali/kernels/scratch_copy_impl.h @@ -34,9 +34,9 @@ inline void copy_to_buffer(char *buffer, const size_t *offsets) {} */ template void copy_to_buffer(char *buffer, - const size_t *offsets, - const Collection &c, - const Collections &... tail) { + const size_t *offsets, + const Collection &c, + const Collections &... tail) { using T = std::remove_cv_t>; std::copy(dali::begin(c), dali::end(c), reinterpret_cast(buffer + offsets[0])); copy_to_buffer(buffer, offsets+1, tail...); @@ -54,12 +54,12 @@ inline void GetCollectionOffsets(size_t base, size_t *offsets) { *offsets = base */ template void GetCollectionOffsets(size_t base, size_t *offsets, - const Collection &c, - const Collections &...tail) { + const Collection &c, + const Collections &...tail) { using T = std::remove_cv_t>; base = align_up(base, alignof(T)); *offsets = base; - base += size(c) * sizeof(T); + base += dali::size(c) * sizeof(T); GetCollectionOffsets(base, offsets + 1, tail...); } diff --git a/dali/kernels/test/scratch_copy_test.cc b/dali/kernels/test/scratch_copy_test.cc index b7e428f1169..c621295e8af 100644 --- a/dali/kernels/test/scratch_copy_test.cc +++ b/dali/kernels/test/scratch_copy_test.cc @@ -23,7 +23,7 @@ namespace dali { namespace kernels { template > -constexpr auto size_bytes(const C &c) { return size(c) * sizeof(element_t); } +constexpr auto size_bytes(const C &c) { return dali::size(c) * sizeof(element_t); } TEST(Scratchpad, ToContiguous) { ScratchpadEstimator se; diff --git a/dali/operators/geometry/mt_transform_attr.h b/dali/operators/geometry/mt_transform_attr.h index a64a1e2152f..926849ea559 100644 --- a/dali/operators/geometry/mt_transform_attr.h +++ b/dali/operators/geometry/mt_transform_attr.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2020-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ class DLL_PUBLIC MTTransformAttr { /** @brief Fill the diagonal with a scalar value, put zeros elsewhere */ template void MakeDiagonalMatrix(Container &&mtx, float value) { - assert(static_cast(size(mtx)) == input_pt_dim_ * output_pt_dim_); + assert(static_cast(dali::size(mtx)) == input_pt_dim_ * output_pt_dim_); for (int i = 0, k = 0; i < output_pt_dim_; i++) for (int j = 0; j < input_pt_dim_; j++, k++) mtx[k] = (i == j ? value : 0); @@ -114,7 +114,7 @@ class DLL_PUBLIC MTTransformAttr { template void Repeat(OutRange &&out, InRange &&in, int times) { - ssize_t n = size(in); + ssize_t n = dali::size(in); resize_if_possible(out, n * times); for (ssize_t i = 0, k = 0; i < times; i++) for (ssize_t j = 0; j < n; j++, k++) diff --git a/dali/operators/segmentation/random_object_bbox.cc b/dali/operators/segmentation/random_object_bbox.cc index 0cf4ba7164a..1a494c26122 100644 --- a/dali/operators/segmentation/random_object_bbox.cc +++ b/dali/operators/segmentation/random_object_bbox.cc @@ -241,8 +241,8 @@ void StoreBox(const OutListCPU &out1, const OutListCPU &out2, RandomObjectBBox::OutputFormat format, int sample_idx, Lo &&start, Hi &&end) { - assert(size(start) == size(end)); - int ndim = size(start); + assert(dali::size(start) == dali::size(end)); + int ndim = dali::size(start); switch (format) { case RandomObjectBBox::Out_Box: for (int i = 0; i < ndim; i++) { diff --git a/dali/pipeline/data/buffer.h b/dali/pipeline/data/buffer.h index f88482cf148..401ba44f061 100644 --- a/dali/pipeline/data/buffer.h +++ b/dali/pipeline/data/buffer.h @@ -324,7 +324,7 @@ class DLL_PUBLIC Buffer { return shrink_threshold_; } - static constexpr double kMaxGrowthFactor = 4; + DLL_PUBLIC static constexpr double kMaxGrowthFactor = 4; protected: // Helper to resize the underlying allocation @@ -413,7 +413,7 @@ DLL_PUBLIC double Buffer::shrink_threshold_ = std::is_same::value ? 0.5 : 0; template -DLL_PUBLIC constexpr double Buffer::kMaxGrowthFactor; +constexpr double Buffer::kMaxGrowthFactor; // Macro so we don't have to list these in all diff --git a/include/dali/core/random.h b/include/dali/core/random.h index 2a7f63d8204..6acc6d39601 100644 --- a/include/dali/core/random.h +++ b/include/dali/core/random.h @@ -1,4 +1,4 @@ -// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2020-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ void random_permutation(Collection &out, RNG &rng) { */ template void random_derangement(Collection &out, RNG &rng) { - int N = size(out); + int N = dali::size(out); std::iota(dali::begin(out), dali::end(out), 0); for (int i = 0; i < N-1; i++) { std::uniform_int_distribution dist(i+1, N-1); @@ -76,7 +76,7 @@ random_sequence(Collection &out, T lo, T hi, RNG &rng) { */ template void random_sequence_no_fixed_points(Collection &out, int lo, int hi, RNG &rng) { - int N = size(out); + int N = dali::size(out); std::uniform_int_distribution dist1(lo, hi-1); int i = 0; // when index is below lo, no fixed points possible diff --git a/include/dali/core/tensor_shape.h b/include/dali/core/tensor_shape.h index 0b239c526b8..b0edc3a9b48 100644 --- a/include/dali/core/tensor_shape.h +++ b/include/dali/core/tensor_shape.h @@ -1363,14 +1363,14 @@ template void collapse_dims(TensorListShape &result, const TensorListShape &shape, std::initializer_list> dim_groups) { - collapse_dims(result, shape, make_span(dim_groups.begin(), size(dim_groups))); + collapse_dims(result, shape, make_span(dim_groups.begin(), dali::size(dim_groups))); } template TensorListShape collapse_dims(const TensorListShape &shape, std::initializer_list> dim_groups) { TensorListShape result; - collapse_dims(result, shape, make_span(dim_groups.begin(), size(dim_groups))); + collapse_dims(result, shape, make_span(dim_groups.begin(), dali::size(dim_groups))); return result; } diff --git a/include/dali/core/tensor_view.h b/include/dali/core/tensor_view.h index ba4ce3cc463..f5785326fbc 100644 --- a/include/dali/core/tensor_view.h +++ b/include/dali/core/tensor_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2017-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,8 +38,8 @@ struct check_implicit_conversion { template bool ContainsCoords(const Shape &shape, const Position &pos) { - const int shape_dim = size(shape); - const int pos_dim = size(pos); + const int shape_dim = dali::size(shape); + const int pos_dim = dali::size(pos); if (pos_dim > shape_dim) { return false; } @@ -60,8 +60,8 @@ template DALI_HOST_DEV if_array_like CalcOffset(const Shape &shape, const Position &pos) { ptrdiff_t ofs = pos[0]; - const int pos_dim = size(pos); - const int shape_dim = size(shape); + const int pos_dim = dali::size(pos); + const int shape_dim = dali::size(shape); int i; for (i = 1; i < pos_dim; i++) { ofs *= shape[i]; diff --git a/include/dali/core/tuple_helpers.h b/include/dali/core/tuple_helpers.h index 95fb16b69d5..8c4e1114fab 100644 --- a/include/dali/core/tuple_helpers.h +++ b/include/dali/core/tuple_helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2018-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -155,8 +155,8 @@ constexpr auto apply(F &&f, std::tuple &&args) template constexpr auto apply_all(F &&f, Args&&... args) - ->decltype(apply(f, std::tuple_cat(as_tuple(args)...))) { - return apply(f, std::tuple_cat(as_tuple(args)...)); + ->decltype(dali::detail::apply(f, std::tuple_cat(as_tuple(args)...))) { + return dali::detail::apply(f, std::tuple_cat(as_tuple(args)...)); } template diff --git a/include/dali/core/util.h b/include/dali/core/util.h index 80cbc0c955a..0d9cf114059 100644 --- a/include/dali/core/util.h +++ b/include/dali/core/util.h @@ -217,7 +217,7 @@ using if_indexable = if_istype()[0]), T>; template using if_array_like = if_indexable())), T>>; + if_istype())), T>>; template using is_integer_iterator = std::is_integral< diff --git a/third_party/libcudacxx b/third_party/libcudacxx index adf4d157ada..03e17c25869 160000 --- a/third_party/libcudacxx +++ b/third_party/libcudacxx @@ -1 +1 @@ -Subproject commit adf4d157ada537ef500553b695f32bb10a2a11e4 +Subproject commit 03e17c25869a2a2a4203e5cde129c833438e2047