Unverified Commit 33a2d9e1 authored by Hongzhi (Steve), Chen's avatar Hongzhi (Steve), Chen Committed by GitHub
Browse files

[Misc] clang-format auto fix. (#4812)



* [Misc] clang-format auto fix.

* manual
Co-authored-by: default avatarSteve <ubuntu@ip-172-31-34-29.ap-northeast-1.compute.internal>
parent 360e6cb4
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include <dgl/array.h> #include <dgl/array.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <time.h> #include <time.h>
#include <random> #include <random>
#include "./common.h" #include "./common.h"
using namespace dgl; using namespace dgl;
...@@ -87,10 +89,10 @@ void CheckResult(T* exp, T* out, T* out_intel_kernel, int dim) { ...@@ -87,10 +89,10 @@ void CheckResult(T* exp, T* out, T* out_intel_kernel, int dim) {
template <class ElemWiseUpd> template <class ElemWiseUpd>
ElemWiseUpd* generic_ElemWiseUpd() { ElemWiseUpd* generic_ElemWiseUpd() {
static std::unique_ptr<ElemWiseUpd> asm_kernel_ptr( static std::unique_ptr<ElemWiseUpd> asm_kernel_ptr(
(dgl::IntelKernel<>::IsEnabled()) ? new ElemWiseUpd() : nullptr); (dgl::IntelKernel<>::IsEnabled()) ? new ElemWiseUpd() : nullptr);
ElemWiseUpd* cpu_spec = (asm_kernel_ptr && asm_kernel_ptr->applicable()) ElemWiseUpd* cpu_spec = (asm_kernel_ptr && asm_kernel_ptr->applicable())
? asm_kernel_ptr.get() ? asm_kernel_ptr.get()
: nullptr; : nullptr;
return cpu_spec; return cpu_spec;
} }
...@@ -113,7 +115,7 @@ void _TestSpmmCopyLhs() { ...@@ -113,7 +115,7 @@ void _TestSpmmCopyLhs() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::CopyLhs<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::CopyLhs<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
...@@ -149,7 +151,7 @@ void _TestSpmmCopyRhs() { ...@@ -149,7 +151,7 @@ void _TestSpmmCopyRhs() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::CopyRhs<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::CopyRhs<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
...@@ -186,7 +188,7 @@ void _TestSpmmAdd() { ...@@ -186,7 +188,7 @@ void _TestSpmmAdd() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Add<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Add<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
...@@ -223,7 +225,7 @@ void _TestSpmmSub() { ...@@ -223,7 +225,7 @@ void _TestSpmmSub() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Sub<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Sub<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
...@@ -260,7 +262,7 @@ void _TestSpmmMul() { ...@@ -260,7 +262,7 @@ void _TestSpmmMul() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Mul<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Mul<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
...@@ -297,7 +299,7 @@ void _TestSpmmDiv() { ...@@ -297,7 +299,7 @@ void _TestSpmmDiv() {
// Calculation of output using intel path - 'out_intel_kernel' // Calculation of output using intel path - 'out_intel_kernel'
auto* cpu_spec = auto* cpu_spec =
generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Div<IDX>>>(); generic_ElemWiseUpd<dgl::ElemWiseAddUpdate<ns_op::Div<IDX>>>();
if (cpu_spec) { if (cpu_spec) {
IDX out_intel_kernel[dim]; IDX out_intel_kernel[dim];
GenerateZeroData(out_intel_kernel, dim); GenerateZeroData(out_intel_kernel, dim);
......
...@@ -3,16 +3,18 @@ ...@@ -3,16 +3,18 @@
* \file test_unit_graph.cc * \file test_unit_graph.cc
* \brief Test UnitGraph * \brief Test UnitGraph
*/ */
#include "../../src/graph/unit_graph.h"
#include "./../src/graph/heterograph.h"
#include "./common.h"
#include <dgl/array.h> #include <dgl/array.h>
#include <dgl/immutable_graph.h> #include <dgl/immutable_graph.h>
#include <dgl/runtime/device_api.h> #include <dgl/runtime/device_api.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "../../src/graph/unit_graph.h"
#include "./../src/graph/heterograph.h"
#include "./common.h"
using namespace dgl; using namespace dgl;
using namespace dgl::runtime; using namespace dgl::runtime;
...@@ -24,18 +26,13 @@ aten::CSRMatrix CSR1(DGLContext ctx) { ...@@ -24,18 +26,13 @@ aten::CSRMatrix CSR1(DGLContext ctx) {
* [0, 1, 0], * [0, 1, 0],
* [1, 0, 1]] * [1, 0, 1]]
*/ */
IdArray g_indptr = IdArray g_indptr = aten::VecToIdArray(
aten::VecToIdArray(std::vector<IdType>({0, 1, 3, 4, 6}), sizeof(IdType)*8, CTX); std::vector<IdType>({0, 1, 3, 4, 6}), sizeof(IdType) * 8, CTX);
IdArray g_indices = IdArray g_indices = aten::VecToIdArray(
aten::VecToIdArray(std::vector<IdType>({2, 0, 2, 1, 0, 2}), sizeof(IdType)*8, CTX); std::vector<IdType>({2, 0, 2, 1, 0, 2}), sizeof(IdType) * 8, CTX);
const aten::CSRMatrix &csr_a = aten::CSRMatrix( const aten::CSRMatrix &csr_a =
4, aten::CSRMatrix(4, 3, g_indptr, g_indices, aten::NullArray(), false);
3,
g_indptr,
g_indices,
aten::NullArray(),
false);
return csr_a; return csr_a;
} }
...@@ -48,18 +45,12 @@ aten::COOMatrix COO1(DGLContext ctx) { ...@@ -48,18 +45,12 @@ aten::COOMatrix COO1(DGLContext ctx) {
* G = [[1, 1, 0], * G = [[1, 1, 0],
* [0, 1, 0]] * [0, 1, 0]]
*/ */
IdArray g_row = IdArray g_row = aten::VecToIdArray(
aten::VecToIdArray(std::vector<IdType>({0, 0, 1}), sizeof(IdType)*8, CTX); std::vector<IdType>({0, 0, 1}), sizeof(IdType) * 8, CTX);
IdArray g_col = IdArray g_col = aten::VecToIdArray(
aten::VecToIdArray(std::vector<IdType>({0, 1, 1}), sizeof(IdType)*8, CTX); std::vector<IdType>({0, 1, 1}), sizeof(IdType) * 8, CTX);
const aten::COOMatrix &coo = aten::COOMatrix( const aten::COOMatrix &coo =
2, aten::COOMatrix(2, 3, g_row, g_col, aten::NullArray(), true, true);
3,
g_row,
g_col,
aten::NullArray(),
true,
true);
return coo; return coo;
} }
...@@ -67,7 +58,8 @@ aten::COOMatrix COO1(DGLContext ctx) { ...@@ -67,7 +58,8 @@ aten::COOMatrix COO1(DGLContext ctx) {
template aten::COOMatrix COO1<int32_t>(DGLContext ctx); template aten::COOMatrix COO1<int32_t>(DGLContext ctx);
template aten::COOMatrix COO1<int64_t>(DGLContext ctx); template aten::COOMatrix COO1<int64_t>(DGLContext ctx);
template <typename IdType> void _TestUnitGraph_InOutDegrees(DGLContext ctx) { template <typename IdType>
void _TestUnitGraph_InOutDegrees(DGLContext ctx) {
/* /*
InDegree(s) is available only if COO or CSC formats permitted. InDegree(s) is available only if COO or CSC formats permitted.
OutDegree(s) is available only if COO or CSR formats permitted. OutDegree(s) is available only if COO or CSR formats permitted.
...@@ -346,8 +338,8 @@ void _TestUnitGraph_Reserve(DGLContext ctx) { ...@@ -346,8 +338,8 @@ void _TestUnitGraph_Reserve(DGLContext ctx) {
} }
template <typename IdType> template <typename IdType>
void _TestUnitGraph_CopyTo(const DGLContext &src_ctx, void _TestUnitGraph_CopyTo(
const DGLContext &dst_ctx) { const DGLContext &src_ctx, const DGLContext &dst_ctx) {
const aten::CSRMatrix &csr = CSR1<IdType>(src_ctx); const aten::CSRMatrix &csr = CSR1<IdType>(src_ctx);
const aten::COOMatrix &coo = COO1<IdType>(src_ctx); const aten::COOMatrix &coo = COO1<IdType>(src_ctx);
......
...@@ -53,7 +53,7 @@ TEST(ZeroCopySerialize, NDArray) { ...@@ -53,7 +53,7 @@ TEST(ZeroCopySerialize, NDArray) {
zc_write_strm.Write(tensor2); zc_write_strm.Write(tensor2);
EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 126) EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 126)
<< "Invalid save"; << "Invalid save";
std::vector<void *> new_ptr_list; std::vector<void *> new_ptr_list;
// Use memcpy to mimic remote machine reconstruction // Use memcpy to mimic remote machine reconstruction
...@@ -103,7 +103,7 @@ TEST(ZeroCopySerialize, SharedMem) { ...@@ -103,7 +103,7 @@ TEST(ZeroCopySerialize, SharedMem) {
std::vector<int64_t> shape{4}; std::vector<int64_t> shape{4};
DGLContext cpu_ctx = {kDGLCPU, 0}; DGLContext cpu_ctx = {kDGLCPU, 0};
auto shared_tensor = auto shared_tensor =
NDArray::EmptyShared("test", shape, dtype, cpu_ctx, true); NDArray::EmptyShared("test", shape, dtype, cpu_ctx, true);
shared_tensor.CopyFrom(tensor1); shared_tensor.CopyFrom(tensor1);
std::string nonzerocopy_blob; std::string nonzerocopy_blob;
...@@ -115,7 +115,7 @@ TEST(ZeroCopySerialize, SharedMem) { ...@@ -115,7 +115,7 @@ TEST(ZeroCopySerialize, SharedMem) {
zc_write_strm.Write(shared_tensor); zc_write_strm.Write(shared_tensor);
EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 51) EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 51)
<< "Invalid save"; << "Invalid save";
NDArray loadtensor1; NDArray loadtensor1;
StreamWithBuffer zc_read_strm = StreamWithBuffer(&zerocopy_blob, false); StreamWithBuffer zc_read_strm = StreamWithBuffer(&zerocopy_blob, false);
...@@ -146,7 +146,7 @@ TEST(ZeroCopySerialize, HeteroGraph) { ...@@ -146,7 +146,7 @@ TEST(ZeroCopySerialize, HeteroGraph) {
zc_write_strm.Write(hrptr); zc_write_strm.Write(hrptr);
EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 745) EXPECT_EQ(nonzerocopy_blob.size() - zerocopy_blob.size(), 745)
<< "Invalid save"; << "Invalid save";
std::vector<void *> new_ptr_list; std::vector<void *> new_ptr_list;
// Use memcpy to mimic remote machine reconstruction // Use memcpy to mimic remote machine reconstruction
......
...@@ -24,6 +24,6 @@ std::shared_ptr<tensorpipe::Context> InitTPContext() { ...@@ -24,6 +24,6 @@ std::shared_ptr<tensorpipe::Context> InitTPContext() {
context->registerChannel(0 /* low priority */, "basic", basicChannel); context->registerChannel(0 /* low priority */, "basic", basicChannel);
return context; return context;
} }
} // namespace } // namespace
#endif #endif
\ No newline at end of file
#include <chrono> #include <chrono>
#include <cstdlib>
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <cstdlib>
#include "rpc_base.h" #include "rpc_base.h"
class RPCClient { class RPCClient {
public: public:
explicit RPCClient(const std::string &ip_config) : ip_config_(ip_config) { explicit RPCClient(const std::string &ip_config) : ip_config_(ip_config) {
ParseIPs(); ParseIPs();
} }
...@@ -23,7 +23,7 @@ public: ...@@ -23,7 +23,7 @@ public:
} }
} }
private: private:
void ParseIPs() { void ParseIPs() {
std::ifstream ifs(ip_config_); std::ifstream ifs(ip_config_);
if (!ifs) { if (!ifs) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "rpc_base.h" #include "rpc_base.h"
class RPCServer { class RPCServer {
public: public:
explicit RPCServer(const std::string &ip, int num_machines) explicit RPCServer(const std::string &ip, int num_machines)
: ip_(ip), num_machines_(num_machines) {} : ip_(ip), num_machines_(num_machines) {}
void run() { void run() {
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
} }
} }
private: private:
void StartServer(int id) { void StartServer(int id) {
dgl::rpc::TPReceiver receiver(InitTPContext()); dgl::rpc::TPReceiver receiver(InitTPContext());
std::string ip_addr = std::string ip_addr =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment