diff --git a/dlib/cmake b/dlib/cmake index 33c2edfc3..f851a4ee5 100644 --- a/dlib/cmake +++ b/dlib/cmake @@ -78,6 +78,8 @@ elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visu message(STATUS "Enabling SSE2 instructions") add_definitions(-DDLIB_HAVE_SSE2) endif() + # DNN module produces long type names for NN definitions - disable this warning for MSVC + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4503") endif() diff --git a/dlib/dnn/layers.h b/dlib/dnn/layers.h index 355c0c044..d427b58ba 100644 --- a/dlib/dnn/layers.h +++ b/dlib/dnn/layers.h @@ -1985,44 +1985,34 @@ namespace dlib // ---------------------------------------------------------------------------------------- namespace impl{ - // helper classes for layer concat processing - template class... TAG_TYPES> - struct concat_helper_impl { - }; - template class TAG_TYPE> - struct concat_helper_impl{ - constexpr static size_t tag_count() {return 1;} - static void list_tags(std::ostream& out) - { - out << tag_id::id; - } - - template - static void resize_out(resizable_tensor& out, const SUBNET& sub, long sum_k) - { - auto& t = layer(sub).get_output(); - out.set_size(t.num_samples(), t.k() + sum_k, t.nr(), t.nc()); - } - template - static void concat(tensor& out, const SUBNET& sub, size_t k_offset) - { - auto& t = layer(sub).get_output(); - tt::copy_tensor(out, k_offset, t, 0, t.k()); - } - template - static void split(const tensor& input, SUBNET& sub, size_t k_offset) - { - auto& t = layer(sub).get_gradient_input(); - tt::copy_tensor(t, 0, input, k_offset, t.k()); - } - }; +// // helper classes for layer concat processing +// template class... TAG_TYPES> +// struct concat_helper_impl { +// // this specialization will be used only by MSVC +// constexpr static size_t tag_count() {return 0;} +// static void list_tags(std::ostream& out) +// { +// } +// template +// static void resize_out(resizable_tensor&, const SUBNET&, long) +// { +// } +// template +// static void concat(tensor&, const SUBNET&, size_t) +// { +// } +// template +// static void split(const tensor&, SUBNET&, size_t) +// { +// } +// }; template class TAG_TYPE, template class... TAG_TYPES> - struct concat_helper_impl{ + struct concat_helper_impl{ constexpr static size_t tag_count() {return 1 + concat_helper_impl::tag_count();} - static void list_tags(std::ostream& out) - { - out << tag_id::id << ","; + static void list_tags(std::ostream& out) + { + out << tag_id::id << (tag_count() > 1 ? "," : ""); concat_helper_impl::list_tags(out); } @@ -2049,6 +2039,33 @@ namespace dlib concat_helper_impl::split(input, sub, k_offset); } }; + template class TAG_TYPE> + struct concat_helper_impl{ + constexpr static size_t tag_count() {return 1;} + static void list_tags(std::ostream& out) + { + out << tag_id::id; + } + + template + static void resize_out(resizable_tensor& out, const SUBNET& sub, long sum_k) + { + auto& t = layer(sub).get_output(); + out.set_size(t.num_samples(), t.k() + sum_k, t.nr(), t.nc()); + } + template + static void concat(tensor& out, const SUBNET& sub, size_t k_offset) + { + auto& t = layer(sub).get_output(); + tt::copy_tensor(out, k_offset, t, 0, t.k()); + } + template + static void split(const tensor& input, SUBNET& sub, size_t k_offset) + { + auto& t = layer(sub).get_gradient_input(); + tt::copy_tensor(t, 0, input, k_offset, t.k()); + } + }; } // concat layer template<