Skip to content

Commit

Permalink
[REFACTOR] util => utils for consistency in the project. (apache#6684)
Browse files Browse the repository at this point in the history
* [REFACTOR] util => utils for consistency in the project.

* Update CMake
  • Loading branch information
tqchen authored and Trevor Morris committed Dec 2, 2020
1 parent 549043c commit ce50cbd
Show file tree
Hide file tree
Showing 154 changed files with 228 additions and 228 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Expand Up @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.2)
project(tvm C CXX)

# Utility functions
include(cmake/util/Util.cmake)
include(cmake/util/FindCUDA.cmake)
include(cmake/util/FindOpenCL.cmake)
include(cmake/util/FindVulkan.cmake)
include(cmake/util/FindLLVM.cmake)
include(cmake/util/FindROCM.cmake)
include(cmake/util/FindEthosN.cmake)
include(cmake/utils/Utils.cmake)
include(cmake/utils/FindCUDA.cmake)
include(cmake/utils/FindOpenCL.cmake)
include(cmake/utils/FindVulkan.cmake)
include(cmake/utils/FindLLVM.cmake)
include(cmake/utils/FindROCM.cmake)
include(cmake/utils/FindEthosN.cmake)

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
Expand Down
2 changes: 1 addition & 1 deletion apps/android_camera/app/src/main/jni/tvm_runtime.h
Expand Up @@ -40,7 +40,7 @@
#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/dso_library.cc"
#include "../src/runtime/file_util.cc"
#include "../src/runtime/file_utils.cc"
#include "../src/runtime/graph/graph_runtime.cc"
#include "../src/runtime/library_module.cc"
#include "../src/runtime/module.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/android_deploy/app/src/main/jni/tvm_runtime.h
Expand Up @@ -28,7 +28,7 @@
#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/dso_library.cc"
#include "../src/runtime/file_util.cc"
#include "../src/runtime/file_utils.cc"
#include "../src/runtime/graph/graph_runtime.cc"
#include "../src/runtime/library_module.cc"
#include "../src/runtime/module.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/android_rpc/app/src/main/jni/tvm_runtime.h
Expand Up @@ -40,7 +40,7 @@
#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/dso_library.cc"
#include "../src/runtime/file_util.cc"
#include "../src/runtime/file_utils.cc"
#include "../src/runtime/graph/graph_runtime.cc"
#include "../src/runtime/graph/graph_runtime_factory.cc"
#include "../src/runtime/library_module.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/bundle_deploy/runtime.cc
Expand Up @@ -24,7 +24,7 @@

#include "../../src/runtime/c_runtime_api.cc"
#include "../../src/runtime/cpu_device_api.cc"
#include "../../src/runtime/file_util.cc"
#include "../../src/runtime/file_utils.cc"
#include "../../src/runtime/graph/graph_runtime.cc"
#include "../../src/runtime/library_module.cc"
#include "../../src/runtime/module.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/cpp_rpc/main.cc
Expand Up @@ -35,7 +35,7 @@
#include <vector>

#include "../../src/support/socket.h"
#include "../../src/support/util.h"
#include "../../src/support/utils.h"
#include "rpc_server.h"

#if defined(_WIN32)
Expand Down
4 changes: 2 additions & 2 deletions apps/cpp_rpc/rpc_env.cc
Expand Up @@ -40,8 +40,8 @@ int mkdir(const char* path, int /* ignored */) { return _mkdir(path); }
#include <string>
#include <vector>

#include "../../src/runtime/file_util.h"
#include "../../src/support/util.h"
#include "../../src/runtime/file_utils.h"
#include "../../src/support/utils.h"
#include "rpc_env.h"

namespace {
Expand Down
2 changes: 1 addition & 1 deletion apps/howto_deploy/tvm_runtime_pack.cc
Expand Up @@ -39,7 +39,7 @@
*/
#include "../../src/runtime/c_runtime_api.cc"
#include "../../src/runtime/cpu_device_api.cc"
#include "../../src/runtime/file_util.cc"
#include "../../src/runtime/file_utils.cc"
#include "../../src/runtime/library_module.cc"
#include "../../src/runtime/module.cc"
#include "../../src/runtime/ndarray.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/ios_rpc/tvmrpc/TVMRuntime.mm
Expand Up @@ -25,7 +25,7 @@
#include "../../../src/runtime/c_runtime_api.cc"
#include "../../../src/runtime/cpu_device_api.cc"
#include "../../../src/runtime/dso_library.cc"
#include "../../../src/runtime/file_util.cc"
#include "../../../src/runtime/file_utils.cc"
#include "../../../src/runtime/library_module.cc"
#include "../../../src/runtime/metadata_module.cc"
#include "../../../src/runtime/module.cc"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/dev/relay_add_op.rst
Expand Up @@ -231,7 +231,7 @@ Adding a Gradient in C++
Adding a gradient in C++ is similar to adding one in Python, but the
interface for registering is slightly different.

First, make sure ``src/relay/pass/pattern_util.h`` is included. It provides
First, make sure ``src/relay/pass/pattern_utils.h`` is included. It provides
helper functions for creating nodes in the Relay AST. Then, define the
gradient in a similar fashion as in the Python example:

Expand Down
2 changes: 1 addition & 1 deletion golang/src/tvm_runtime_pack.cc
Expand Up @@ -23,7 +23,7 @@
*/
#include "src/runtime/c_runtime_api.cc"
#include "src/runtime/cpu_device_api.cc"
#include "src/runtime/file_util.cc"
#include "src/runtime/file_utils.cc"
#include "src/runtime/library_module.cc"
#include "src/runtime/module.cc"
#include "src/runtime/ndarray.cc"
Expand Down
8 changes: 4 additions & 4 deletions include/tvm/topi/util.h → include/tvm/topi/utils.h
Expand Up @@ -19,10 +19,10 @@

/*!
* \brief Topi utility function
* \file topi/util.h
* \file topi/utils.h
*/
#ifndef TVM_TOPI_UTIL_H_
#define TVM_TOPI_UTIL_H_
#ifndef TVM_TOPI_UTILS_H_
#define TVM_TOPI_UTILS_H_

#include <tvm/ir/expr.h>
#include <tvm/runtime/packed_func.h>
Expand All @@ -44,4 +44,4 @@ inline Array<Integer> ArrayOrInt(TVMArgValue arg) {
}
} // namespace topi
} // namespace tvm
#endif // TVM_TOPI_UTIL_H_
#endif // TVM_TOPI_UTILS_H_
4 changes: 2 additions & 2 deletions python/tvm/te/hybrid/__init__.py
Expand Up @@ -35,7 +35,7 @@

from .module import HybridModule
from .parser import source_to_op
from .util import _pruned_source
from .utils import _pruned_source


def script(pyfunc):
Expand All @@ -51,7 +51,7 @@ def script(pyfunc):
"""
# pylint: disable=import-outside-toplevel, missing-docstring
def wrapped_func(func, *args, **kwargs):
from .util import _is_tvm_arg_types
from .utils import _is_tvm_arg_types

if _is_tvm_arg_types(args):
src = _pruned_source(func)
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/te/hybrid/calls.py
Expand Up @@ -25,7 +25,7 @@
from tvm.tir import call_intrin
from tvm.tir.stmt import For

from .util import _internal_assert
from .utils import _internal_assert

# pylint: disable=redefined-builtin,invalid-name

Expand Down
4 changes: 2 additions & 2 deletions python/tvm/te/hybrid/module.py
Expand Up @@ -24,8 +24,8 @@
import ast

from tvm.contrib import util
from .util import _internal_assert
from .util import _is_tvm_arg_types
from .utils import _internal_assert
from .utils import _is_tvm_arg_types
from .parser import source_to_op


Expand Down
26 changes: 13 additions & 13 deletions python/tvm/te/hybrid/parser.py
Expand Up @@ -37,16 +37,16 @@
from tvm.tir import all as _all
from tvm.tir import any as _any

from .util import _internal_assert
from .utils import _internal_assert
from . import calls
from . import util
from . import utils
from .preprocessor import determine_variable_usage


def concat_list_to_block(lst):
"""Concatenate a list of Python IR nodes to HalideIR Block"""
if not lst:
return util.make_nop()
return utils.make_nop()
n = len(lst)
if n == 1:
return lst[0]
Expand All @@ -55,10 +55,10 @@ def concat_list_to_block(lst):

def visit_list_to_block(visit, lst):
"""Visit and concatenate a list of Python IR nodes to HalideIR Block"""
lst = [visit(stmt) for stmt in lst if not util.is_docstring(stmt)]
lst = [stmt for stmt in lst if not tvm.ir.structural_equal(stmt, util.make_nop())]
lst = [visit(stmt) for stmt in lst if not utils.is_docstring(stmt)]
lst = [stmt for stmt in lst if not tvm.ir.structural_equal(stmt, utils.make_nop())]
if not lst:
return util.make_nop()
return utils.make_nop()
return concat_list_to_block(lst)


Expand Down Expand Up @@ -314,7 +314,7 @@ def visit_Assign(self, node):
)
self.add_symbol(node.targets[i].id, Symbol.GlobalBuffer, rhs.output(i))
rmap[rhs.outputs[i].op] = rhs.output(i)
return util.replace_io(rhs.body, rmap)
return utils.replace_io(rhs.body, rmap)

_internal_assert(len(node.targets) == 1, "So far only one-valued assignment is supported!")
lhs = node.targets[0]
Expand All @@ -339,8 +339,8 @@ def visit_Assign(self, node):
self.add_symbol(lhs, getattr(Symbol, scope.title() + "Buffer"), ph)
if scope == "output":
self.outputs.append(lhs)
return util.make_nop()
if isinstance(rhs, util.halide_imm_types) and ast.Store not in rw:
return utils.make_nop()
if isinstance(rhs, utils.halide_imm_types) and ast.Store not in rw:
self.add_symbol(lhs, Symbol.ConstVar, rhs)
else:
_internal_assert(
Expand All @@ -355,7 +355,7 @@ def visit_Assign(self, node):
if lhs is not None:
buf, args = lhs
return tvm.tir.ProducerStore(buf, rhs, args)
return util.make_nop()
return utils.make_nop()

lhs, args = self.visit(lhs)
_internal_assert(
Expand Down Expand Up @@ -412,7 +412,7 @@ def visit_If(self, node):
return visit_list_to_block(self.visit, node.body)
if node.orelse:
return visit_list_to_block(self.visit, node.orelse)
return util.make_nop()
return utils.make_nop()

if_body = visit_list_to_block(self.visit, node.body)

Expand Down Expand Up @@ -559,7 +559,7 @@ def visit_Return(self, node):
logging.log(logging.CRITICAL, "[Warning] Not all the output buffers returned!")
self.outputs = [self.symbols[i][1] for i in ids]
self.returned = True
return util.make_nop()
return utils.make_nop()

def visit_Tuple(self, node):
return tuple(self.visit(i) for i in node.elts)
Expand All @@ -570,7 +570,7 @@ def visit_Str(self, node):
def visit_Assert(self, node):
test = self.visit(node.test)
mesg = tvm.runtime.convert(self.visit(node.msg))
return tvm.tir.AssertStmt(test, mesg, util.make_nop())
return tvm.tir.AssertStmt(test, mesg, utils.make_nop())


def parse_python(src, args, symbols, closure_vars):
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/te/hybrid/preprocessor.py
Expand Up @@ -19,7 +19,7 @@
import ast
import sys
from .runtime import HYBRID_GLOBALS
from .util import _internal_assert
from .utils import _internal_assert


class PyVariableUsage(ast.NodeVisitor):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/arith/int_constraints.cc
Expand Up @@ -33,7 +33,7 @@
#include <unordered_map>
#include <utility>

#include "../tir/transforms/ir_util.h"
#include "../tir/transforms/ir_utils.h"

namespace tvm {
namespace arith {
Expand Down
2 changes: 1 addition & 1 deletion src/arith/iter_affine_map.cc
Expand Up @@ -27,7 +27,7 @@
#include <tvm/tir/expr_functor.h>
#include <tvm/tir/op.h>

#include "../support/util.h"
#include "../support/utils.h"
#include "const_fold.h"

namespace tvm {
Expand Down
2 changes: 1 addition & 1 deletion src/node/structural_hash.cc
Expand Up @@ -28,7 +28,7 @@
#include <algorithm>
#include <unordered_map>

#include "../support/util.h"
#include "../support/utils.h"

namespace tvm {

Expand Down
2 changes: 1 addition & 1 deletion src/relay/analysis/feature.cc
Expand Up @@ -27,7 +27,7 @@
#include <tvm/relay/expr_functor.h>
#include <tvm/relay/feature.h>

#include "../transforms/pass_util.h"
#include "../transforms/pass_utils.h"

namespace tvm {
namespace relay {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/analysis/mac_count.cc
Expand Up @@ -32,7 +32,7 @@
#include <tvm/relay/op.h>
#include <tvm/relay/op_attr_types.h>

#include "../transforms/pattern_util.h"
#include "../transforms/pattern_utils.h"

namespace tvm {
namespace relay {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/analysis/util.cc
Expand Up @@ -31,7 +31,7 @@
#include <tvm/relay/op_attr_types.h>
#include <tvm/relay/pattern_functor.h>

#include "../transforms/pass_util.h"
#include "../transforms/pass_utils.h"

namespace tvm {
namespace relay {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/backend/compile_engine.cc
Expand Up @@ -45,7 +45,7 @@
#include <utility>
#include <vector>

#include "../transforms/pass_util.h"
#include "../transforms/pass_utils.h"
#include "utils.h"

namespace tvm {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/backend/vm/compiler.cc
Expand Up @@ -46,7 +46,7 @@
#include "../../../target/source/codegen_source_base.h"
#include "../../backend/compile_engine.h"
#include "../../op/op_common.h"
#include "../../transforms/pass_util.h"
#include "../../transforms/pass_utils.h"
#include "../utils.h"
#include "compiler.h"

Expand Down
2 changes: 1 addition & 1 deletion src/relay/backend/vm/compiler.h
Expand Up @@ -44,7 +44,7 @@
#include "../../../runtime/vm/naive_allocator.h"
#include "../../../runtime/vm/profiler/vm.h"
#include "../../backend/compile_engine.h"
#include "../../transforms/pass_util.h"
#include "../../transforms/pass_utils.h"

namespace tvm {
namespace relay {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/annotation/annotation.cc
Expand Up @@ -30,7 +30,7 @@
#include <tvm/tir/expr.h>
#include <tvm/topi/elemwise.h>

#include "../../transforms/infer_layout_util.h"
#include "../../transforms/infer_layout_utils.h"
#include "../type_relations.h"

namespace tvm {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/device_copy.cc
Expand Up @@ -33,7 +33,7 @@
#include <tvm/tir/expr.h>
#include <tvm/topi/elemwise.h>

#include "../transforms/infer_layout_util.h"
#include "../transforms/infer_layout_utils.h"
#include "type_relations.h"

namespace tvm {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/dyn/tensor/transform.cc
Expand Up @@ -36,7 +36,7 @@
#include <utility>
#include <vector>

#include "../../../transforms/infer_layout_util.h"
#include "../../../transforms/infer_layout_utils.h"

namespace tvm {
namespace relay {
Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/memory/memory.cc
Expand Up @@ -29,7 +29,7 @@
#include <tvm/runtime/data_type.h>
#include <tvm/topi/elemwise.h>

#include "../../transforms/infer_layout_util.h"
#include "../../transforms/infer_layout_utils.h"
#include "../op_common.h"
#include "../type_relations.h"

Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/nn/bitserial.cc
Expand Up @@ -26,7 +26,7 @@
#include <tvm/relay/op.h>
#include <tvm/tir/data_layout.h>

#include "../../transforms/infer_layout_util.h"
#include "../../transforms/infer_layout_utils.h"
#include "../op_common.h"

namespace tvm {
Expand Down

0 comments on commit ce50cbd

Please sign in to comment.