Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
01b3b08b
"git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "e8b77f0a3ed5ee6cb6b5be05f622cbab8785a451"
Commit
01b3b08b
authored
May 29, 2016
by
Fm
Browse files
Replaced sizeof... with variadic templates
parent
1974e68d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
dlib/dnn/layers.h
dlib/dnn/layers.h
+12
-4
No files found.
dlib/dnn/layers.h
View file @
01b3b08b
...
@@ -1844,6 +1844,7 @@ namespace dlib
...
@@ -1844,6 +1844,7 @@ namespace dlib
};
};
template
<
template
<
typename
>
class
TAG_TYPE
>
template
<
template
<
typename
>
class
TAG_TYPE
>
struct
concat_helper_impl
<
TAG_TYPE
>
{
struct
concat_helper_impl
<
TAG_TYPE
>
{
constexpr
static
size_t
tag_count
()
{
return
1
;}
template
<
typename
SUBNET
>
template
<
typename
SUBNET
>
static
void
resize_out
(
resizable_tensor
&
out
,
const
SUBNET
&
sub
,
long
sum_k
)
static
void
resize_out
(
resizable_tensor
&
out
,
const
SUBNET
&
sub
,
long
sum_k
)
{
{
...
@@ -1865,6 +1866,9 @@ namespace dlib
...
@@ -1865,6 +1866,9 @@ namespace dlib
};
};
template
<
template
<
typename
>
class
TAG_TYPE
,
template
<
typename
>
class
...
TAG_TYPES
>
template
<
template
<
typename
>
class
TAG_TYPE
,
template
<
typename
>
class
...
TAG_TYPES
>
struct
concat_helper_impl
<
TAG_TYPE
,
TAG_TYPES
...
>
{
struct
concat_helper_impl
<
TAG_TYPE
,
TAG_TYPES
...
>
{
constexpr
static
size_t
tag_count
()
{
return
1
+
concat_helper_impl
<
TAG_TYPES
...
>::
tag_count
();}
template
<
typename
SUBNET
>
template
<
typename
SUBNET
>
static
void
resize_out
(
resizable_tensor
&
out
,
const
SUBNET
&
sub
,
long
sum_k
)
static
void
resize_out
(
resizable_tensor
&
out
,
const
SUBNET
&
sub
,
long
sum_k
)
{
{
...
@@ -1896,6 +1900,8 @@ namespace dlib
...
@@ -1896,6 +1900,8 @@ namespace dlib
class
concat_
class
concat_
{
{
public:
public:
constexpr
static
size_t
tag_count
()
{
return
impl
::
concat_helper_impl
<
TAG_TYPES
...
>::
tag_count
();};
template
<
typename
SUBNET
>
template
<
typename
SUBNET
>
void
setup
(
const
SUBNET
&
)
void
setup
(
const
SUBNET
&
)
{
{
...
@@ -1924,7 +1930,8 @@ namespace dlib
...
@@ -1924,7 +1930,8 @@ namespace dlib
friend
void
serialize
(
const
concat_
&
item
,
std
::
ostream
&
out
)
friend
void
serialize
(
const
concat_
&
item
,
std
::
ostream
&
out
)
{
{
serialize
(
"concat_"
,
out
);
serialize
(
"concat_"
,
out
);
serialize
(
sizeof
...(
TAG_TYPES
),
out
);
size_t
count
=
tag_count
();
serialize
(
count
,
out
);
}
}
friend
void
deserialize
(
concat_
&
item
,
std
::
istream
&
in
)
friend
void
deserialize
(
concat_
&
item
,
std
::
istream
&
in
)
...
@@ -1935,15 +1942,16 @@ namespace dlib
...
@@ -1935,15 +1942,16 @@ namespace dlib
throw
serialization_error
(
"Unexpected version '"
+
version
+
"' found while deserializing dlib::concat_."
);
throw
serialization_error
(
"Unexpected version '"
+
version
+
"' found while deserializing dlib::concat_."
);
size_t
count_tags
;
size_t
count_tags
;
deserialize
(
count_tags
,
in
);
deserialize
(
count_tags
,
in
);
if
(
count_tags
!=
sizeof
...(
TAG_TYPES
))
if
(
count_tags
!=
tag_count
(
))
throw
serialization_error
(
"Invalid count of tags "
+
std
::
to_string
(
count_tags
)
+
", expecting "
+
throw
serialization_error
(
"Invalid count of tags "
+
std
::
to_string
(
count_tags
)
+
", expecting "
+
std
::
to_string
(
sizeof
...(
TAG_TYPES
))
+
" found while deserializing dlib::concat_."
);
std
::
to_string
(
tag_count
())
+
" found while deserializing dlib::concat_."
);
}
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
concat_
&
item
)
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
concat_
&
item
)
{
{
out
<<
"concat
\t
("
out
<<
"concat
\t
("
<<
sizeof
...(
TAG_TYPES
)
<<
tag_count
(
)
<<
")"
;
<<
")"
;
return
out
;
return
out
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment