File tree 3 files changed +17
-13
lines changed
3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -252,11 +252,7 @@ void Executable::SaveConstantSection(dmlc::Stream* strm) {
252
252
}
253
253
254
254
// Save the const to device mapping.
255
- std::vector<size_t > const_device_type;
256
- for (auto dev_type : this ->const_device_type ) {
257
- const_device_type.push_back (static_cast <size_t >(dev_type));
258
- }
259
- strm->Write (const_device_type);
255
+ strm->Write (this ->const_device_type );
260
256
}
261
257
262
258
void Executable::SavePrimitiveOpNames (dmlc::Stream* strm) {
@@ -525,12 +521,10 @@ void Executable::LoadConstantSection(dmlc::Stream* strm) {
525
521
}
526
522
527
523
// Load the const to device mapping.
528
- std::vector<size_t > const_device_type;
524
+ std::vector<Index > const_device_type;
529
525
STREAM_CHECK (strm->Read (&const_device_type), " constant" );
530
526
ICHECK_EQ (size, const_device_type.size ());
531
- for (auto dev : const_device_type) {
532
- this ->const_device_type .push_back (static_cast <Index>(dev));
533
- }
527
+ this ->const_device_type = const_device_type;
534
528
}
535
529
536
530
void Executable::LoadPrimitiveOpNames (dmlc::Stream* strm) {
Original file line number Diff line number Diff line change 24
24
#ifndef TVM_RUNTIME_VM_SERIALIZE_UTILS_H_
25
25
#define TVM_RUNTIME_VM_SERIALIZE_UTILS_H_
26
26
27
- #include < dmlc/common.h>
28
27
#include < dmlc/memory_io.h>
29
28
#include < tvm/runtime/vm/executable.h>
30
29
31
30
#include < functional>
32
31
#include < string>
33
32
#include < vector>
34
33
34
+ #include " ../../support/utils.h"
35
+
35
36
namespace tvm {
36
37
namespace runtime {
37
38
namespace vm {
@@ -40,9 +41,9 @@ namespace vm {
40
41
constexpr uint64_t kTVMVMBytecodeMagic = 0xD225DE2F4214151D ;
41
42
42
43
template <typename T>
43
- static inline size_t VectorHash (size_t key, const std::vector<T>& values) {
44
+ static inline uint64_t VectorHash (uint64_t key, const std::vector<T>& values) {
44
45
for (const auto & it : values) {
45
- key = dmlc ::HashCombine (key, it);
46
+ key = support ::HashCombine (key, it);
46
47
}
47
48
return key;
48
49
}
@@ -122,7 +123,7 @@ struct VMInstructionSerializer {
122
123
* instruction.
123
124
*/
124
125
Index Hash () const {
125
- size_t key = static_cast <size_t >(opcode);
126
+ uint64_t key = static_cast <uint64_t >(opcode);
126
127
key = VectorHash (key, fields);
127
128
return key;
128
129
}
Original file line number Diff line number Diff line change @@ -162,6 +162,15 @@ inline size_t HashCombine(size_t key, size_t value) {
162
162
return key ^ (value + 0x9e3779b9 + (key << 6 ) + (key >> 2 ));
163
163
}
164
164
165
+ /* !
166
+ * \brief hash an object and combines uint64_t key with previous keys
167
+ */
168
+ template <typename T>
169
+ inline uint64_t HashCombine (uint64_t key, const T& value) {
170
+ std::hash<T> hash_func;
171
+ return key ^ (hash_func (value) + 0x9e3779b9 + (key << 6 ) + (key >> 2 ));
172
+ }
173
+
165
174
} // namespace support
166
175
} // namespace tvm
167
176
#endif // TVM_SUPPORT_UTILS_H_
You can’t perform that action at this time.
0 commit comments