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