Skip to content

Track Refactor Items and Update Guide #4647

@tqchen

Description

@tqchen

We are in the process of refactoring recently. Some of them are cleanup of legacy code in the new version, some other prepares code changes for #4617

This thread tracks related infra changes and guides to sync the code with the mainline as suggested by @merrymercy . Please feel free to reply to add more suggestions

DataType to runtime

  • Rationale: DataType is a runtime data structure
  • PRs [REFACTOR][DTYPE] Isolate dtype to runtime #4560
  • Rename all old reference of tvm::Type to DataType
  • ExprNode.type -> ExprNode.dtype, Expr.type() -> Expr.dtype()
  • Move type constructors as static function: Int(bits) -> DataType::Int(bits)

Node Object Unification

IRMutator/Visitor Functor Unification

TVM_REGISTER_API -> TVM_REGISTER_GLOBAL

SeqStmt

tir::Call.name -> op

IRPrinter -> ReprPrinter

set_body_typed

// before
TVM_REGISTER_GLOBAL("add")
.set_body_typed<int(int)>([](int x) { return x + 1; }

// after
TVM_REGISTER_GLOBAL("add")
.set_body_typed([](int x) { return x + 1; }

Node suffix Convention

tvm::Expr -> PrimExpr

Relay Type/Module/Op

Unified IR file Reorg

  • Rationale: reorganize code to fit into the new unified ir proposal

New Subfolders and Namespaces

LoweredFunc

TIR uses IRModule as basic unit of transformation instead of LoweredFunc.

ir_pass.h

  • The IRModule->IRModule transformations are moved to tir/transform.h
  • The IRModule->Analaysis result passes are moved to tir/analysis.h

Simplify

BuildConfig

Runtime Misc

Python

tvm.module -> tvm.runtime.module

API changes wrt to runtime.Module #4837

  • tvm.module.load -> tvm.runtime.load_module
  • tvm.module.enabled -> tvm.runtime.enabled
  • tvm.module.system_lib -> tvm.runtime.system_lib

tvm.ir

API changes wrt to tvm.ir #4862

  • tvm.relay.Module -> tvm.IRModule

tvm.target

API change wrt to tvm.target #4872

tvm.te

API change wrt to #4943

  • tvm.create_schedule -> tvm.te.create_schedule
  • tvm.placeholder -> tvm.te.placeholder
  • tvm.compute -> tvm.te.compute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions