Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
d927cb65
Commit
d927cb65
authored
Aug 22, 2017
by
Eric Junyuan Xie
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hash function for tuple (#141)
parent
97811fa4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
nnvm/include/nnvm/base.h
+1
-0
nnvm/include/nnvm/tuple.h
+30
-0
No files found.
nnvm/include/nnvm/base.h
View file @
d927cb65
...
...
@@ -7,6 +7,7 @@
#define NNVM_BASE_H_
#include <dmlc/base.h>
#include <dmlc/common.h>
#include <dmlc/any.h>
#include <dmlc/memory.h>
#include <dmlc/logging.h>
...
...
nnvm/include/nnvm/tuple.h
View file @
d927cb65
...
...
@@ -581,4 +581,34 @@ inline bool Tuple<ValueType>::Load(TStream *strm) {
}
// namespace nnvm
namespace
std
{
/*! \brief hash function for Tuple. */
template
<
typename
T
>
struct
hash
<
nnvm
::
Tuple
<
T
>
>
{
/*! \brief hash a Tuple into unsigned int */
size_t
operator
()(
const
nnvm
::
Tuple
<
T
>&
val
)
const
{
std
::
hash
<
uint32_t
>
hash_uint
;
size_t
res
=
hash_uint
(
val
.
ndim
());
for
(
uint32_t
i
=
0
;
i
<
val
.
ndim
();
++
i
)
{
res
=
dmlc
::
HashCombine
(
res
,
val
[
i
]);
}
return
res
;
}
};
/*! \brief hash function for TShape. */
template
<>
struct
hash
<
nnvm
::
TShape
>
{
/*! \brief hash a TShape into unsigned int */
size_t
operator
()(
const
nnvm
::
TShape
&
val
)
const
{
std
::
hash
<
uint32_t
>
hash_uint
;
size_t
res
=
hash_uint
(
val
.
ndim
());
for
(
uint32_t
i
=
0
;
i
<
val
.
ndim
();
++
i
)
{
res
=
dmlc
::
HashCombine
(
res
,
val
[
i
]);
}
return
res
;
}
};
}
// namespace std
#endif // NNVM_TUPLE_H_
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