diff --git a/apps/cpp_rpc/rpc_env.cc b/apps/cpp_rpc/rpc_env.cc index 44f848dc749e..f7817f5d1d28 100644 --- a/apps/cpp_rpc/rpc_env.cc +++ b/apps/cpp_rpc/rpc_env.cc @@ -164,7 +164,7 @@ void LinuxShared(const std::string output, } cmd += " " + options; std::string err_msg; - auto executed_status = common::Execute(cmd, &err_msg); + auto executed_status = support::Execute(cmd, &err_msg); if (executed_status) { LOG(FATAL) << err_msg; } @@ -195,22 +195,22 @@ void CreateShared(const std::string output, const std::vector &file */ Module Load(std::string *fileIn, const std::string fmt) { std::string file = *fileIn; - if (common::EndsWith(file, ".so")) { + if (support::EndsWith(file, ".so")) { return Module::LoadFromFile(file, fmt); } #if defined(__linux__) || defined(__ANDROID__) std::string file_name = file + ".so"; - if (common::EndsWith(file, ".o")) { + if (support::EndsWith(file, ".o")) { std::vector files; files.push_back(file); CreateShared(file_name, files); - } else if (common::EndsWith(file, ".tar")) { + } else if (support::EndsWith(file, ".tar")) { std::string tmp_dir = "./rpc/tmp/"; mkdir(&tmp_dir[0], 0777); std::string cmd = "tar -C " + tmp_dir + " -zxf " + file; std::string err_msg; - int executed_status = common::Execute(cmd, &err_msg); + int executed_status = support::Execute(cmd, &err_msg); if (executed_status) { LOG(FATAL) << err_msg; } diff --git a/apps/cpp_rpc/rpc_server.cc b/apps/cpp_rpc/rpc_server.cc index b35a63bd67dc..54af956a7be1 100644 --- a/apps/cpp_rpc/rpc_server.cc +++ b/apps/cpp_rpc/rpc_server.cc @@ -122,8 +122,8 @@ class RPCServer { void ListenLoopProc() { TrackerClient tracker(tracker_addr_, key_, custom_addr_); while (true) { - common::TCPSocket conn; - common::SockAddr addr("0.0.0.0", 0); + support::TCPSocket conn; + support::SockAddr addr("0.0.0.0", 0); std::string opts; try { // step 1: setup tracker and report to tracker @@ -221,8 +221,8 @@ class RPCServer { * \param ping_period Timeout for select call waiting */ void AcceptConnection(TrackerClient* tracker, - common::TCPSocket* conn_sock, - common::SockAddr* addr, + support::TCPSocket* conn_sock, + support::SockAddr* addr, std::string* opts, int ping_period = 2) { std::set old_keyset; @@ -233,7 +233,7 @@ class RPCServer { while (true) { tracker->WaitConnectionAndUpdateKey(listen_sock_, my_port_, ping_period, &matchkey); - common::TCPSocket conn = listen_sock_.Accept(addr); + support::TCPSocket conn = listen_sock_.Accept(addr); int code = kRPCMagic; CHECK_EQ(conn.RecvAll(&code, sizeof(code)), sizeof(code)); @@ -289,7 +289,7 @@ class RPCServer { * \param sock The socket information * \param addr The socket address information */ - void ServerLoopProc(common::TCPSocket sock, common::SockAddr addr) { + void ServerLoopProc(support::TCPSocket sock, support::SockAddr addr) { // Server loop auto env = RPCEnv(); RPCServerLoop(sock.sockfd); @@ -308,7 +308,7 @@ class RPCServer { if (opts.find(option) == 0) { cmd = opts.substr(opts.find_last_of(option) + 1); - CHECK(common::IsNumber(cmd)) << "Timeout is not valid"; + CHECK(support::IsNumber(cmd)) << "Timeout is not valid"; return std::stoi(cmd); } return 0; @@ -321,8 +321,8 @@ class RPCServer { std::string tracker_addr_; std::string key_; std::string custom_addr_; - common::TCPSocket listen_sock_; - common::TCPSocket tracker_sock_; + support::TCPSocket listen_sock_; + support::TCPSocket tracker_sock_; }; /*! diff --git a/apps/cpp_rpc/rpc_tracker_client.h b/apps/cpp_rpc/rpc_tracker_client.h index 89424c7511f0..0852bbbf76bf 100644 --- a/apps/cpp_rpc/rpc_tracker_client.h +++ b/apps/cpp_rpc/rpc_tracker_client.h @@ -132,7 +132,7 @@ class TrackerClient { * \param ping_period Select wait time. * \param matchkey Random match key output. */ - void WaitConnectionAndUpdateKey(common::TCPSocket listen_sock, + void WaitConnectionAndUpdateKey(support::TCPSocket listen_sock, int port, int ping_period, std::string *matchkey) { @@ -140,7 +140,7 @@ class TrackerClient { int unmatch_timeout = 4; while (true) { if (!tracker_sock_.IsClosed()) { - common::PollHelper poller; + support::PollHelper poller; poller.WatchRead(listen_sock.sockfd); poller.Poll(ping_period * 1000); if (!poller.CheckRead(listen_sock.sockfd)) { @@ -189,11 +189,11 @@ class TrackerClient { * \param retry_period Number of seconds before we retry again. * \return TCPSocket The socket information if connect is success. */ - common::TCPSocket ConnectWithRetry(int timeout = 60, int retry_period = 5) { + support::TCPSocket ConnectWithRetry(int timeout = 60, int retry_period = 5) { auto tbegin = std::chrono::system_clock::now(); while (true) { - common::SockAddr addr(tracker_addr_); - common::TCPSocket sock; + support::SockAddr addr(tracker_addr_); + support::TCPSocket sock; sock.Create(); LOG(INFO) << "Tracker connecting to " << addr.AsString(); if (sock.Connect(addr)) { @@ -235,7 +235,7 @@ class TrackerClient { std::string tracker_addr_; std::string key_; std::string custom_addr_; - common::TCPSocket tracker_sock_; + support::TCPSocket tracker_sock_; std::set old_keyset_; std::mt19937 gen_; std::uniform_real_distribution dis_; diff --git a/include/tvm/arithmetic.h b/include/tvm/arithmetic.h index 12acfc3d4d7d..a7b12336e663 100644 --- a/include/tvm/arithmetic.h +++ b/include/tvm/arithmetic.h @@ -24,6 +24,8 @@ #ifndef TVM_ARITHMETIC_H_ #define TVM_ARITHMETIC_H_ +#include + #include #include #include diff --git a/include/tvm/buffer.h b/include/tvm/buffer.h index 284e37063ab6..db5334e0649f 100644 --- a/include/tvm/buffer.h +++ b/include/tvm/buffer.h @@ -26,7 +26,6 @@ #include -#include "base.h" #include "expr.h" #include "expr_operator.h" #include "tvm/node/container.h" diff --git a/include/tvm/codegen.h b/include/tvm/codegen.h index 218a7827ba1e..025bc8d6bc28 100644 --- a/include/tvm/codegen.h +++ b/include/tvm/codegen.h @@ -25,7 +25,6 @@ #define TVM_CODEGEN_H_ #include -#include "base.h" #include "expr.h" #include "lowered_func.h" #include "runtime/packed_func.h" diff --git a/include/tvm/data_layout.h b/include/tvm/data_layout.h index d49320c0629e..0f79f9f61e98 100644 --- a/include/tvm/data_layout.h +++ b/include/tvm/data_layout.h @@ -25,7 +25,7 @@ #ifndef TVM_DATA_LAYOUT_H_ #define TVM_DATA_LAYOUT_H_ -#include + #include #include diff --git a/include/tvm/expr.h b/include/tvm/expr.h index 62806c667e61..d3686270a293 100644 --- a/include/tvm/expr.h +++ b/include/tvm/expr.h @@ -29,7 +29,6 @@ #include #include #include -#include "base.h" #include "node/node.h" #include "node/container.h" #include "node/functor.h" diff --git a/include/tvm/ir.h b/include/tvm/ir.h index 553db4e1551f..46645d75f0c2 100644 --- a/include/tvm/ir.h +++ b/include/tvm/ir.h @@ -29,7 +29,6 @@ #include #include #include -#include "base.h" #include "expr.h" #include "runtime/util.h" diff --git a/include/tvm/ir/op.h b/include/tvm/ir/op.h index f3a860371c0c..e281c199fd47 100644 --- a/include/tvm/ir/op.h +++ b/include/tvm/ir/op.h @@ -391,6 +391,14 @@ class OpMap { const GenericOpMap& map_; }; +#define TVM_STRINGIZE_DETAIL(x) #x +#define TVM_STRINGIZE(x) TVM_STRINGIZE_DETAIL(x) +#define TVM_DESCRIBE(...) describe(__VA_ARGS__ "\n\nFrom:" __FILE__ ":" TVM_STRINGIZE(__LINE__)) +/*! + * \brief Macro to include current line as string + */ +#define TVM_ADD_FILELINE "\n\nDefined in " __FILE__ ":L" TVM_STRINGIZE(__LINE__) + // internal macros to make #define TVM_OP_REGISTER_VAR_DEF \ static DMLC_ATTRIBUTE_UNUSED ::tvm::OpRegistry& __make_##Op diff --git a/include/tvm/ir/transform.h b/include/tvm/ir/transform.h index 424472ee7fdc..c606b348f099 100644 --- a/include/tvm/ir/transform.h +++ b/include/tvm/ir/transform.h @@ -56,7 +56,7 @@ #ifndef TVM_IR_TRANSFORM_H_ #define TVM_IR_TRANSFORM_H_ -#include +#include #include #include #include diff --git a/include/tvm/lowered_func.h b/include/tvm/lowered_func.h index 310b454c15d3..2b643d75f08b 100644 --- a/include/tvm/lowered_func.h +++ b/include/tvm/lowered_func.h @@ -27,7 +27,6 @@ #include -#include "base.h" #include "expr.h" #include "tensor.h" #include "tvm/node/container.h" diff --git a/include/tvm/packed_func_ext.h b/include/tvm/packed_func_ext.h index fa532eae36fa..28918954b186 100644 --- a/include/tvm/packed_func_ext.h +++ b/include/tvm/packed_func_ext.h @@ -30,7 +30,6 @@ #include #include -#include "base.h" #include "expr.h" #include "tensor.h" #include "runtime/packed_func.h" diff --git a/include/tvm/schedule.h b/include/tvm/schedule.h index 7e1347536b07..3115b0a5ac7d 100644 --- a/include/tvm/schedule.h +++ b/include/tvm/schedule.h @@ -27,7 +27,6 @@ #include #include -#include "base.h" #include "expr.h" #include "tensor.h" #include "tensor_intrin.h" diff --git a/include/tvm/schedule_pass.h b/include/tvm/schedule_pass.h index 3187e2b17727..af2459bb2c8e 100644 --- a/include/tvm/schedule_pass.h +++ b/include/tvm/schedule_pass.h @@ -28,7 +28,6 @@ #ifndef TVM_SCHEDULE_PASS_H_ #define TVM_SCHEDULE_PASS_H_ -#include "base.h" #include "schedule.h" namespace tvm { diff --git a/include/tvm/logging.h b/include/tvm/support/logging.h similarity index 97% rename from include/tvm/logging.h rename to include/tvm/support/logging.h index 0190d0641d8b..44b990e0d7db 100644 --- a/include/tvm/logging.h +++ b/include/tvm/support/logging.h @@ -18,11 +18,11 @@ */ /*! - * \file tvm/logging.h + * \file tvm/support/logging.h * \brief logging utilities on top of dmlc-core */ -#ifndef TVM_LOGGING_H_ -#define TVM_LOGGING_H_ +#ifndef TVM_SUPPORT_LOGGING_H_ +#define TVM_SUPPORT_LOGGING_H_ // a technique that enables overriding macro names on the number of parameters. This is used // to define other macros below @@ -114,4 +114,4 @@ #define COND_CHECK_2(quit_on_assert, x) COND_CHECK_3(quit_on_assert, x, return false) #define COND_LOG_2(quit_on_assert, x) COND_LOG_3(quit_on_assert, x, return false) -#endif // TVM_LOGGING_H_ +#endif // TVM_SUPPORT_LOGGING_H_ diff --git a/include/tvm/base.h b/include/tvm/support/with.h similarity index 80% rename from include/tvm/base.h rename to include/tvm/support/with.h index 9b3b4cd3e8df..46b091a68f34 100644 --- a/include/tvm/base.h +++ b/include/tvm/support/with.h @@ -18,11 +18,12 @@ */ /*! - * \file tvm/base.h - * \brief Base utilities + * \file tvm/support/with.h + * \brief RAII wrapper function to enter and exit a context object + * similar to python's with syntax. */ -#ifndef TVM_BASE_H_ -#define TVM_BASE_H_ +#ifndef TVM_SUPPORT_WITH_H_ +#define TVM_SUPPORT_WITH_H_ #include #include @@ -73,14 +74,5 @@ class With { ContextType ctx_; }; -#define TVM_STRINGIZE_DETAIL(x) #x -#define TVM_STRINGIZE(x) TVM_STRINGIZE_DETAIL(x) -#define TVM_DESCRIBE(...) describe(__VA_ARGS__ "\n\nFrom:" __FILE__ ":" TVM_STRINGIZE(__LINE__)) -/*! - * \brief Macro to include current line as string - */ -#define TVM_ADD_FILELINE "\n\nDefined in " __FILE__ ":L" TVM_STRINGIZE(__LINE__) - - } // namespace tvm -#endif // TVM_BASE_H_ +#endif // TVM_SUPPORT_WITH_H_ diff --git a/include/tvm/target_info.h b/include/tvm/target_info.h index f7b36a06b9d6..0a42a76a1b2e 100644 --- a/include/tvm/target_info.h +++ b/include/tvm/target_info.h @@ -25,7 +25,6 @@ #define TVM_TARGET_INFO_H_ #include -#include "base.h" #include "expr.h" namespace tvm { diff --git a/include/tvm/tensor.h b/include/tvm/tensor.h index ecadc3552923..9962762d30d9 100644 --- a/include/tvm/tensor.h +++ b/include/tvm/tensor.h @@ -30,7 +30,6 @@ #include #include -#include "base.h" #include "expr.h" #include "expr_operator.h" #include "arithmetic.h" diff --git a/src/README.md b/src/README.md index 599f41dfdc5f..6a7bf514adb2 100644 --- a/src/README.md +++ b/src/README.md @@ -21,7 +21,7 @@ Header files in include are public APIs that share across modules. There can be internal header files within each module that sit in src. ## Modules -- common: Internal common utilities. +- support: Internal support utilities. - runtime: Minimum runtime related codes. - node: base infra for IR/AST nodes that is dialect independent. - api: API function registration. diff --git a/src/codegen/codegen_cuda.cc b/src/codegen/codegen_cuda.cc index d06e9aa2a0ad..b39965edc049 100644 --- a/src/codegen/codegen_cuda.cc +++ b/src/codegen/codegen_cuda.cc @@ -20,7 +20,7 @@ /*! * \file codegen_cuda.cc */ -#include + #include #include #include diff --git a/src/codegen/llvm/llvm_common.cc b/src/codegen/llvm/llvm_common.cc index 64008e622bcd..29e4db3c91da 100644 --- a/src/codegen/llvm/llvm_common.cc +++ b/src/codegen/llvm/llvm_common.cc @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,7 +22,7 @@ */ #ifdef TVM_LLVM_VERSION -#include +#include #include #include #include diff --git a/src/codegen/opt/build_cuda_on.cc b/src/codegen/opt/build_cuda_on.cc index b5f42bfa3f2c..976db0eaf54a 100644 --- a/src/codegen/opt/build_cuda_on.cc +++ b/src/codegen/opt/build_cuda_on.cc @@ -27,7 +27,7 @@ #include #endif #include -#include + #include #include diff --git a/src/lang/expr.cc b/src/lang/expr.cc index 62cbc374a14b..a95bd40a09e1 100644 --- a/src/lang/expr.cc +++ b/src/lang/expr.cc @@ -20,7 +20,7 @@ /*! * \file expr.cc */ -#include + #include #include #include diff --git a/src/lang/expr_operator.cc b/src/lang/expr_operator.cc index 30557672d1ab..5b4f4d1132e1 100644 --- a/src/lang/expr_operator.cc +++ b/src/lang/expr_operator.cc @@ -20,7 +20,7 @@ /*! * \file expr_operator.cc */ -#include + #include #include #include diff --git a/src/lang/ir.cc b/src/lang/ir.cc index b7f3c270429c..274459ec088c 100644 --- a/src/lang/ir.cc +++ b/src/lang/ir.cc @@ -20,7 +20,7 @@ /*! * \file ir.cc */ -#include + #include #include #include diff --git a/src/node/serialization.cc b/src/node/serialization.cc index d45112d0ddcd..647700bfa14b 100644 --- a/src/node/serialization.cc +++ b/src/node/serialization.cc @@ -34,7 +34,7 @@ #include #include -#include "../common/base64.h" +#include "../support/base64.h" namespace tvm { @@ -392,7 +392,7 @@ struct JSONGraph { for (DLTensor* tensor : indexer.tensor_list_) { std::string blob; dmlc::MemoryStringStream mstrm(&blob); - common::Base64OutStream b64strm(&mstrm); + support::Base64OutStream b64strm(&mstrm); runtime::SaveDLTensor(&b64strm, tensor); b64strm.Finish(); g.b64ndarrays.emplace_back(std::move(blob)); @@ -420,7 +420,7 @@ ObjectRef LoadJSON(std::string json_str) { // load in tensors for (const std::string& blob : jgraph.b64ndarrays) { dmlc::MemoryStringStream mstrm(const_cast(&blob)); - common::Base64InStream b64strm(&mstrm); + support::Base64InStream b64strm(&mstrm); b64strm.InitPosition(); runtime::NDArray temp; CHECK(temp.Load(&b64strm)); diff --git a/src/relay/backend/graph_plan_memory.cc b/src/relay/backend/graph_plan_memory.cc index ecb2d59aee6f..de03d977f8a8 100644 --- a/src/relay/backend/graph_plan_memory.cc +++ b/src/relay/backend/graph_plan_memory.cc @@ -25,7 +25,7 @@ #include #include #include -#include "../../common/arena.h" +#include "../../support/arena.h" namespace tvm { namespace relay { @@ -130,7 +130,7 @@ class StorageAllocaBaseVisitor : public ExprVisitor { class StorageAllocaInit : protected StorageAllocaBaseVisitor { public: - explicit StorageAllocaInit(common::Arena* arena) + explicit StorageAllocaInit(support::Arena* arena) : arena_(arena) {} /*! \return The internal token map */ @@ -183,7 +183,7 @@ class StorageAllocaInit : protected StorageAllocaBaseVisitor { private: // allocator - common::Arena* arena_; + support::Arena* arena_; Map node_device_map_; }; @@ -374,7 +374,7 @@ class StorageAllocator : public StorageAllocaBaseVisitor { private: // allocator - common::Arena arena_; + support::Arena arena_; // scale used for rough match size_t match_range_{16}; // free list of storage entry diff --git a/src/relay/backend/vm/compiler.cc b/src/relay/backend/vm/compiler.cc index be0ce5a37ee4..e4a34a3974ae 100644 --- a/src/relay/backend/vm/compiler.cc +++ b/src/relay/backend/vm/compiler.cc @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/relay/backend/vm/compiler.h b/src/relay/backend/vm/compiler.h index 07e704f31d11..df08c7e39cb6 100644 --- a/src/relay/backend/vm/compiler.h +++ b/src/relay/backend/vm/compiler.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/relay/backend/vm/inline_primitives.cc b/src/relay/backend/vm/inline_primitives.cc index 9c1608c41617..6a7962697101 100644 --- a/src/relay/backend/vm/inline_primitives.cc +++ b/src/relay/backend/vm/inline_primitives.cc @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/relay/backend/vm/lambda_lift.cc b/src/relay/backend/vm/lambda_lift.cc index 2527e600518a..955453d187dd 100644 --- a/src/relay/backend/vm/lambda_lift.cc +++ b/src/relay/backend/vm/lambda_lift.cc @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/relay/backend/vm/removed_unused_funcs.cc b/src/relay/backend/vm/removed_unused_funcs.cc index 23bcdc373e26..d535c8d1de83 100644 --- a/src/relay/backend/vm/removed_unused_funcs.cc +++ b/src/relay/backend/vm/removed_unused_funcs.cc @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/relay/ir/pretty_printer.cc b/src/relay/ir/pretty_printer.cc index e2fc57ee6ae3..31f1e71ad7e1 100644 --- a/src/relay/ir/pretty_printer.cc +++ b/src/relay/ir/pretty_printer.cc @@ -887,7 +887,7 @@ class PrettyPrinter : /*! \brief whether the printer is currently in an ADT definition */ bool in_adt_def_; /*! \brief arena for dependency graph */ - common::Arena arena_; + support::Arena arena_; /*! \brief dependency graph of the expr */ DependencyGraph dg_; class AttrPrinter; diff --git a/src/relay/pass/dependency_graph.cc b/src/relay/pass/dependency_graph.cc index 81c205a33c2f..9dab38cd1c6a 100644 --- a/src/relay/pass/dependency_graph.cc +++ b/src/relay/pass/dependency_graph.cc @@ -32,7 +32,7 @@ namespace relay { // Creator of DependencyGraph class DependencyGraph::Creator : private ExprFunctor { public: - explicit Creator(common::Arena* arena) + explicit Creator(support::Arena* arena) : arena_(arena) {} DependencyGraph Create(const Expr& body) { @@ -42,7 +42,7 @@ class DependencyGraph::Creator : private ExprFunctor { private: /*! \brief allocator of all the internal node object */ - common::Arena* arena_; + support::Arena* arena_; // The output. DependencyGraph graph_; // Update the message stored at the node. @@ -175,7 +175,7 @@ class DependencyGraph::Creator : private ExprFunctor { void VisitExpr_(const ConstructorNode* c) final { } }; -DependencyGraph DependencyGraph::Create(common::Arena* arena, const Expr& body) { +DependencyGraph DependencyGraph::Create(support::Arena* arena, const Expr& body) { return Creator(arena).Create(body); } diff --git a/src/relay/pass/dependency_graph.h b/src/relay/pass/dependency_graph.h index d6a4e9588df9..4f33e51c3727 100644 --- a/src/relay/pass/dependency_graph.h +++ b/src/relay/pass/dependency_graph.h @@ -28,13 +28,13 @@ #include #include #include "let_list.h" -#include "../../common/arena.h" +#include "../../support/arena.h" namespace tvm { namespace relay { -using common::LinkNode; -using common::LinkedList; +using support::LinkNode; +using support::LinkedList; /* DependencyGraph track input and output of an Expr. * Additionally, dummy scope is created to model scope. @@ -64,7 +64,7 @@ class DependencyGraph { * \param arena The arena used for data allocation. * \param body The body of the expression to create a graph. */ - static DependencyGraph Create(common::Arena* arena, const Expr& body); + static DependencyGraph Create(support::Arena* arena, const Expr& body); private: class Creator; diff --git a/src/relay/pass/fuse_ops.cc b/src/relay/pass/fuse_ops.cc index e18dbc27d367..e774549ece68 100644 --- a/src/relay/pass/fuse_ops.cc +++ b/src/relay/pass/fuse_ops.cc @@ -30,7 +30,7 @@ #include #include #include "./pattern_util.h" -#include "../../common/arena.h" +#include "../../support/arena.h" namespace tvm { @@ -74,8 +74,8 @@ namespace relay { - CommitFuse: mark all the nodes between source and post-dominator as the same group. - We use an Union-Find data structure to manage the groups. */ -using common::LinkNode; -using common::LinkedList; +using support::LinkNode; +using support::LinkedList; constexpr uint32_t kMaxFusedOps = 256; @@ -139,7 +139,7 @@ class IndexedForwardGraph { * \param arena The arena used for data allocation. * \param body The body of the expression to create a graph. */ - static IndexedForwardGraph Create(common::Arena* arena, const Expr& body); + static IndexedForwardGraph Create(support::Arena* arena, const Expr& body); private: class Creator; @@ -148,7 +148,7 @@ class IndexedForwardGraph { // Creator of post dominator tree of the dataflow class IndexedForwardGraph::Creator : private ExprVisitor { public: - explicit Creator(common::Arena* arena) + explicit Creator(support::Arena* arena) : arena_(arena) {} IndexedForwardGraph Prepare(const Expr& body) { @@ -159,7 +159,7 @@ class IndexedForwardGraph::Creator : private ExprVisitor { private: /*! \brief allocator of all the internal node object */ - common::Arena* arena_; + support::Arena* arena_; // The output. IndexedForwardGraph graph_; // attribute equal comparator @@ -363,7 +363,7 @@ class IndexedForwardGraph::Creator : private ExprVisitor { }; IndexedForwardGraph IndexedForwardGraph::Create( - common::Arena* arena, const Expr& body) { + support::Arena* arena, const Expr& body) { return Creator(arena).Prepare(body); } @@ -396,7 +396,7 @@ class DominatorTree { * \note This algorithm makes use of the fact that graph is DAG, * and runs a single pass algorithm via LCA (Least Common Ancestor) */ - static DominatorTree PostDom(common::Arena* arena, + static DominatorTree PostDom(support::Arena* arena, const IndexedForwardGraph& graph); private: @@ -475,7 +475,7 @@ class DominatorTree { * \param gnode An IndexedForwardGraph Node. * \return The DominatorTree Node. */ - Node* GetNode(common::Arena* arena, IndexedForwardGraph::Node* gnode) { + Node* GetNode(support::Arena* arena, IndexedForwardGraph::Node* gnode) { Node* tnode = arena->make(); tnode->gnode = gnode; if (gnode->extern_ref) { @@ -495,7 +495,7 @@ class DominatorTree { }; -DominatorTree DominatorTree::PostDom(common::Arena* arena, +DominatorTree DominatorTree::PostDom(support::Arena* arena, const IndexedForwardGraph& graph) { DominatorTree tree; tree.nodes.resize(graph.post_dfs_order.size(), nullptr); @@ -512,7 +512,7 @@ DominatorTree DominatorTree::PostDom(common::Arena* arena, */ class GraphPartitioner { public: - explicit GraphPartitioner(common::Arena* arena, int opt_level) + explicit GraphPartitioner(support::Arena* arena, int opt_level) : arena_(arena), opt_level_(opt_level) {} /*! * \brief Group as a union find data structure. @@ -562,7 +562,7 @@ class GraphPartitioner { private: /*! \brief The internal arena for temporary space. */ - common::Arena* arena_; + support::Arena* arena_; /*! \brief optimization level for fuse operation. */ int opt_level_; /*! \brief The internal groups. */ @@ -845,7 +845,7 @@ class FuseMutator : private ExprMutator { } }; /*! \brief Internal arena. */ - common::Arena arena_; + support::Arena arena_; /*! \brief The group assignment map. */ std::unordered_map gmap_; /* \brief Internal group information map. */ diff --git a/src/relay/pass/to_a_normal_form.cc b/src/relay/pass/to_a_normal_form.cc index c08deefd2169..9322e490d6a3 100644 --- a/src/relay/pass/to_a_normal_form.cc +++ b/src/relay/pass/to_a_normal_form.cc @@ -27,9 +27,9 @@ #include #include #include -#include +#include #include "let_list.h" -#include "../../common/arena.h" +#include "../../support/arena.h" #include "pass_util.h" #include "dependency_graph.h" @@ -275,7 +275,7 @@ Expr ToANormalFormAux(const Expr& e) { * * So we calculate all the dependency between nodes. */ - common::Arena arena; + support::Arena arena; DependencyGraph dg = DependencyGraph::Create(&arena, e); /* In order to model new subscopes created by lambda, if else and pattern matching, * we also assign scope to edge as well. diff --git a/src/relay/pass/type_solver.h b/src/relay/pass/type_solver.h index 00a43eceb9a2..6eed5b708be6 100644 --- a/src/relay/pass/type_solver.h +++ b/src/relay/pass/type_solver.h @@ -32,14 +32,14 @@ #include #include #include -#include "../../common/arena.h" +#include "../../support/arena.h" namespace tvm { namespace relay { -using common::LinkNode; -using common::LinkedList; +using support::LinkNode; +using support::LinkedList; /*! * \brief Interface of type solver used in type inference. @@ -171,7 +171,7 @@ class TypeSolver { /*! \brief Internal queue to update the relation */ std::queue update_queue_; /*! \brief allocator of all the internal node obhect*/ - common::Arena arena_; + support::Arena arena_; /*! \brief Reporter that reports back to self */ TypeReporter reporter_; /*! \brief The global representing the current function. */ diff --git a/src/runtime/micro/openocd_low_level_device.cc b/src/runtime/micro/openocd_low_level_device.cc index 5e6685a3a09b..e5c83e590c36 100644 --- a/src/runtime/micro/openocd_low_level_device.cc +++ b/src/runtime/micro/openocd_low_level_device.cc @@ -45,7 +45,7 @@ class OpenOCDLowLevelDevice final : public LowLevelDevice { server_addr_ = server_addr; port_ = port; - socket_.Connect(tvm::common::SockAddr(server_addr_.c_str(), port_)); + socket_.Connect(tvm::support::SockAddr(server_addr_.c_str(), port_)); socket_.cmd_builder() << "halt 0"; socket_.SendCommand(); } diff --git a/src/runtime/micro/tcl_socket.cc b/src/runtime/micro/tcl_socket.cc index 8730ced75770..64dfbf218388 100644 --- a/src/runtime/micro/tcl_socket.cc +++ b/src/runtime/micro/tcl_socket.cc @@ -37,7 +37,7 @@ TclSocket::~TclSocket() { tcp_socket_.Close(); } -void TclSocket::Connect(tvm::common::SockAddr addr) { +void TclSocket::Connect(tvm::support::SockAddr addr) { CHECK(tcp_socket_.Connect(addr)) << "failed to connect"; } diff --git a/src/runtime/micro/tcl_socket.h b/src/runtime/micro/tcl_socket.h index 2123312ff585..0b23e7f1b07f 100644 --- a/src/runtime/micro/tcl_socket.h +++ b/src/runtime/micro/tcl_socket.h @@ -27,7 +27,7 @@ #include #include -#include "../../common/socket.h" +#include "../../support/socket.h" namespace tvm { namespace runtime { @@ -55,7 +55,7 @@ class TclSocket { * \brief open connection with server * \param addr server address */ - void Connect(tvm::common::SockAddr addr); + void Connect(tvm::support::SockAddr addr); /* * \brief send the built command to the server and await a reply @@ -76,7 +76,7 @@ class TclSocket { private: /*! \brief underlying TCP socket being wrapped */ - tvm::common::TCPSocket tcp_socket_; + tvm::support::TCPSocket tcp_socket_; /*! \brief buffer used to receive messages from the socket */ std::vector reply_buf_; /*! \brief string stream used to build current command */ diff --git a/src/runtime/rpc/rpc_session.cc b/src/runtime/rpc/rpc_session.cc index 77d39754b095..6d1c8f03a36b 100644 --- a/src/runtime/rpc/rpc_session.cc +++ b/src/runtime/rpc/rpc_session.cc @@ -36,8 +36,8 @@ #include #include "rpc_session.h" #include "../object_internal.h" -#include "../../common/ring_buffer.h" -#include "../../common/socket.h" +#include "../../support/ring_buffer.h" +#include "../../support/socket.h" namespace tvm { namespace runtime { @@ -73,8 +73,8 @@ struct RPCArgBuffer { // Event handler for RPC events. class RPCSession::EventHandler : public dmlc::Stream { public: - EventHandler(common::RingBuffer* reader, - common::RingBuffer* writer, + EventHandler(support::RingBuffer* reader, + support::RingBuffer* writer, int rpc_sess_table_index, std::string name, std::string* remote_key) @@ -819,9 +819,9 @@ class RPCSession::EventHandler : public dmlc::Stream { // Number of pending bytes requests size_t pending_request_bytes_; // The ring buffer to read data from. - common::RingBuffer* reader_; + support::RingBuffer* reader_; // The ringr buffer to write reply to. - common::RingBuffer* writer_; + support::RingBuffer* writer_; // Session table index. int rpc_sess_table_index_; // Name of session. @@ -1336,7 +1336,7 @@ size_t CallbackChannel::Send(const void* data, size_t size) { bytes.size = size; int64_t n = fsend_(bytes); if (n == -1) { - common::Socket::Error("CallbackChannel::Send"); + support::Socket::Error("CallbackChannel::Send"); } return static_cast(n); } @@ -1344,7 +1344,7 @@ size_t CallbackChannel::Send(const void* data, size_t size) { size_t CallbackChannel::Recv(void* data, size_t size) { TVMRetValue ret = frecv_(size); if (ret.type_code() != kBytes) { - common::Socket::Error("CallbackChannel::Recv"); + support::Socket::Error("CallbackChannel::Recv"); } std::string* bytes = ret.ptr(); memcpy(static_cast(data), bytes->c_str(), bytes->length()); diff --git a/src/runtime/rpc/rpc_session.h b/src/runtime/rpc/rpc_session.h index cc04af80232f..888df8ffde65 100644 --- a/src/runtime/rpc/rpc_session.h +++ b/src/runtime/rpc/rpc_session.h @@ -30,7 +30,7 @@ #include #include #include -#include "../../common/ring_buffer.h" +#include "../../support/ring_buffer.h" namespace tvm { namespace runtime { @@ -270,7 +270,7 @@ class RPCSession { // Internal mutex std::recursive_mutex mutex_; // Internal ring buffer. - common::RingBuffer reader_, writer_; + support::RingBuffer reader_, writer_; // Event handler. std::shared_ptr handler_; // call remote with specified function code. diff --git a/src/runtime/rpc/rpc_socket_impl.cc b/src/runtime/rpc/rpc_socket_impl.cc index cb59e723251b..6b4e341acf91 100644 --- a/src/runtime/rpc/rpc_socket_impl.cc +++ b/src/runtime/rpc/rpc_socket_impl.cc @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,14 +24,14 @@ #include #include #include "rpc_session.h" -#include "../../common/socket.h" +#include "../../support/socket.h" namespace tvm { namespace runtime { class SockChannel final : public RPCChannel { public: - explicit SockChannel(common::TCPSocket sock) + explicit SockChannel(support::TCPSocket sock) : sock_(sock) {} ~SockChannel() { if (!sock_.BadSocket()) { @@ -41,26 +41,26 @@ class SockChannel final : public RPCChannel { size_t Send(const void* data, size_t size) final { ssize_t n = sock_.Send(data, size); if (n == -1) { - common::Socket::Error("SockChannel::Send"); + support::Socket::Error("SockChannel::Send"); } return static_cast(n); } size_t Recv(void* data, size_t size) final { ssize_t n = sock_.Recv(data, size); if (n == -1) { - common::Socket::Error("SockChannel::Recv"); + support::Socket::Error("SockChannel::Recv"); } return static_cast(n); } private: - common::TCPSocket sock_; + support::TCPSocket sock_; }; std::shared_ptr RPCConnect(std::string url, int port, std::string key) { - common::TCPSocket sock; - common::SockAddr addr(url.c_str(), port); + support::TCPSocket sock; + support::SockAddr addr(url.c_str(), port); sock.Create(addr.ss_family()); CHECK(sock.Connect(addr)) << "Connect to " << addr.AsString() << " failed"; @@ -101,8 +101,8 @@ Module RPCClientConnect(std::string url, int port, std::string key) { } void RPCServerLoop(int sockfd) { - common::TCPSocket sock( - static_cast(sockfd)); + support::TCPSocket sock( + static_cast(sockfd)); RPCSession::Create( std::unique_ptr(new SockChannel(sock)), "SockServerLoop", "")->ServerLoop(); diff --git a/src/runtime/vm/object.cc b/src/runtime/vm/object.cc index d7760d53e4df..b7174abc4ba8 100644 --- a/src/runtime/vm/object.cc +++ b/src/runtime/vm/object.cc @@ -21,7 +21,7 @@ * \file src/runtime/vm/object.cc * \brief VM related objects. */ -#include +#include #include #include #include diff --git a/src/runtime/vm/vm.cc b/src/runtime/vm/vm.cc index 49aba7f65eb1..5349a97bd83c 100644 --- a/src/runtime/vm/vm.cc +++ b/src/runtime/vm/vm.cc @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/common/arena.h b/src/support/arena.h similarity index 97% rename from src/common/arena.h rename to src/support/arena.h index 8f9dbc7cd545..744ff4f12188 100644 --- a/src/common/arena.h +++ b/src/support/arena.h @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,14 +23,14 @@ * \brief Arena allocator that allocates * memory chunks and frees them all during destruction time. */ -#ifndef TVM_COMMON_ARENA_H_ -#define TVM_COMMON_ARENA_H_ +#ifndef TVM_SUPPORT_ARENA_H_ +#define TVM_SUPPORT_ARENA_H_ #include #include namespace tvm { -namespace common { +namespace support { const constexpr int kArenaPageSize = 16 << 10; @@ -162,6 +162,6 @@ struct LinkedList { } }; -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_ARENA_H_ +#endif // TVM_SUPPORT_ARENA_H_ diff --git a/src/common/base64.h b/src/support/base64.h similarity index 98% rename from src/common/base64.h rename to src/support/base64.h index 0d2b6a1df073..c85b268fd7b6 100644 --- a/src/common/base64.h +++ b/src/support/base64.h @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,8 +23,8 @@ * \brief data stream support to input and output from/to base64 stream * base64 is easier to store and pass as text format in mapreduce */ -#ifndef TVM_COMMON_BASE64_H_ -#define TVM_COMMON_BASE64_H_ +#ifndef TVM_SUPPORT_BASE64_H_ +#define TVM_SUPPORT_BASE64_H_ #include #include @@ -33,7 +33,7 @@ #include namespace tvm { -namespace common { +namespace support { /*! \brief namespace of base64 decoding and encoding table */ namespace base64 { // decoding table @@ -297,6 +297,6 @@ class Base64OutStream: public dmlc::Stream { } } }; -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_BASE64_H_ +#endif // TVM_SUPPORT_BASE64_H_ diff --git a/src/common/pipe.h b/src/support/pipe.h similarity index 95% rename from src/common/pipe.h rename to src/support/pipe.h index fe3fa235686f..120bbdb95e77 100644 --- a/src/common/pipe.h +++ b/src/support/pipe.h @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,8 +21,8 @@ * \file pipe.h * \brief Platform independent pipe, used for IPC. */ -#ifndef TVM_COMMON_PIPE_H_ -#define TVM_COMMON_PIPE_H_ +#ifndef TVM_SUPPORT_PIPE_H_ +#define TVM_SUPPORT_PIPE_H_ #include #include @@ -37,7 +37,7 @@ #endif namespace tvm { -namespace common { +namespace support { /*! \brief Platform independent pipe */ class Pipe : public dmlc::Stream { @@ -118,7 +118,7 @@ class Pipe : public dmlc::Stream { private: PipeHandle handle_; }; -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_PIPE_H_ +#endif // TVM_SUPPORT_PIPE_H_ diff --git a/src/common/ring_buffer.h b/src/support/ring_buffer.h similarity index 97% rename from src/common/ring_buffer.h rename to src/support/ring_buffer.h index f548acf1846b..7700a967893a 100644 --- a/src/common/ring_buffer.h +++ b/src/support/ring_buffer.h @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,15 +21,15 @@ * \file ring_buffer.h * \brief this file aims to provide a wrapper of sockets */ -#ifndef TVM_COMMON_RING_BUFFER_H_ -#define TVM_COMMON_RING_BUFFER_H_ +#ifndef TVM_SUPPORT_RING_BUFFER_H_ +#define TVM_SUPPORT_RING_BUFFER_H_ #include #include #include namespace tvm { -namespace common { +namespace support { /*! * \brief Ring buffer class for data buffering in IO. * Enables easy usage for sync and async mode. @@ -173,6 +173,6 @@ class RingBuffer { // The internald ata ring. std::vector ring_; }; -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_RING_BUFFER_H_ +#endif // TVM_SUPPORT_RING_BUFFER_H_ diff --git a/src/common/socket.h b/src/support/socket.h similarity index 99% rename from src/common/socket.h rename to src/support/socket.h index e49fb384faf9..aeb4626b5d47 100644 --- a/src/common/socket.h +++ b/src/support/socket.h @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,8 +22,8 @@ * \brief this file aims to provide a wrapper of sockets * \author Tianqi Chen */ -#ifndef TVM_COMMON_SOCKET_H_ -#define TVM_COMMON_SOCKET_H_ +#ifndef TVM_SUPPORT_SOCKET_H_ +#define TVM_SUPPORT_SOCKET_H_ #if defined(_WIN32) #define NOMINMAX @@ -50,7 +50,7 @@ using ssize_t = int; #include #include #include -#include "../common/util.h" +#include "../support/util.h" #if defined(_WIN32) static inline int poll(struct pollfd *pfd, int nfds, @@ -62,7 +62,7 @@ static inline int poll(struct pollfd *pfd, int nfds, #endif // defined(_WIN32) namespace tvm { -namespace common { +namespace support { /*! * \brief Get current host name. * \return The hostname. @@ -648,6 +648,6 @@ struct PollHelper { std::unordered_map fds; }; -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_SOCKET_H_ +#endif // TVM_SUPPORT_SOCKET_H_ diff --git a/src/common/util.h b/src/support/util.h similarity index 96% rename from src/common/util.h rename to src/support/util.h index b1d469c3b4f2..9a477e6f81f2 100644 --- a/src/common/util.h +++ b/src/support/util.h @@ -21,8 +21,8 @@ * \file util.h * \brief Defines some common utility function.. */ -#ifndef TVM_COMMON_UTIL_H_ -#define TVM_COMMON_UTIL_H_ +#ifndef TVM_SUPPORT_UTIL_H_ +#define TVM_SUPPORT_UTIL_H_ #include #ifndef _WIN32 @@ -38,7 +38,7 @@ #include namespace tvm { -namespace common { +namespace support { /*! * \brief TVMPOpen wrapper of popen between windows / unix. * \param command executed command @@ -153,6 +153,6 @@ inline int Execute(std::string cmd, std::string* err_msg) { return 255; } -} // namespace common +} // namespace support } // namespace tvm -#endif // TVM_COMMON_UTIL_H_ +#endif // TVM_SUPPORT_UTIL_H_