项目文件夹

文件
Minjie Wang 870da747ea [CUDA][Kernel] More CUDA kernels; Standardize the behavior for sorted COO/CSR (#1704)
* add cub; array cumsum

* CSRSliceRows

* fix warning

* operator << for ndarray; CSRSliceRows

* add CSRIsSorted

* add csr_sort

* inplace coosort and outplace csrsort

* WIP: coo is sorted

* mv cuda_utils

* add AllTrue utility

* csr sort

* coo sort

* coo2csr for sorted coo arrays

* CSRToCOO from sorted

* pass tests for the new kernel changes

* cannot use inplace sort

* lint

* try fix msvc error

* Fix g.copy_to and g.asnumbits; ToBlock no longer uses CSC

* stash

* revert some hack

* revert some changes

* address comments

* fix

* fix to_block unittest

* add todo note
2020-06-28 18:37:28 +08:00

54 行
1.7 KiB
C++

/*!
* Copyright (c) 2017 by Contributors
* \file dgl/runtime/serializer.h
* \brief Serializer extension to support DGL data types
* Include this file to enable serialization of DLDataType, DLContext
*/
#ifndef DGL_RUNTIME_SMART_PTR_SERIALIZER_H_
#define DGL_RUNTIME_SMART_PTR_SERIALIZER_H_
#include <dgl/graph_serializer.h>
#include <dmlc/io.h>
#include <dmlc/serializer.h>
#include <memory>
namespace dmlc {
namespace serializer {
//! \cond Doxygen_Suppress
template <typename T>
struct Handler<std::shared_ptr<T>> {
inline static void Write(Stream *strm, const std::shared_ptr<T> &data) {
Handler<T>::Write(strm, *data.get());
}
inline static bool Read(Stream *strm, std::shared_ptr<T> *data) {
// When read, the default initialization behavior of shared_ptr is
// shared_ptr<T>(), which is holding a nullptr. Here we need to manually
// reset to a real object for further loading
if (!(*data)) {
data->reset(dgl::Serializer::new_object<T>());
}
return Handler<T>::Read(strm, data->get());
}
};
template <typename T>
struct Handler<std::unique_ptr<T>> {
inline static void Write(Stream *strm, const std::unique_ptr<T> &data) {
Handler<T>::Write(strm, *data.get());
}
inline static bool Read(Stream *strm, std::unique_ptr<T> *data) {
// When read, the default initialization behavior of unique_ptr is
// unique_ptr<T>(), which is holding a nullptr. Here we need to manually
// reset to a real object for further loading
if (!(*data)) {
data->reset(dgl::Serializer::new_object<T>());
}
return Handler<T>::Read(strm, data->get());
}
};
} // namespace serializer
} // namespace dmlc
#endif // DGL_RUNTIME_SMART_PTR_SERIALIZER_H_