Commit bb97938d by Andrew Adams Committed by Tianqi Chen

Halide -> HalideIR (#698)

parent 75cee522
Subproject commit d91cf97d5d6cd2b47ec408bb08e978b88cbf6ab7
Subproject commit aadbf02d6bd7a545edbf6652494a7b07a97a06c1
......@@ -16,31 +16,31 @@
namespace tvm {
using Halide::Type;
using Halide::Float;
using Halide::Bool;
using Halide::Int;
using Halide::UInt;
using Halide::Handle;
using Halide::ExprHash;
using Halide::ExprEqual;
using HalideIR::Type;
using HalideIR::Float;
using HalideIR::Bool;
using HalideIR::Int;
using HalideIR::UInt;
using HalideIR::Handle;
using HalideIR::ExprHash;
using HalideIR::ExprEqual;
using Halide::Expr;
using Halide::VarExpr;
using Halide::IR::RangeNode;
using Halide::IR::FunctionRef;
using Halide::IR::FunctionBaseNode;
using Halide::Internal::Stmt;
using Halide::Internal::IRPrinter;
using Halide::Internal::Variable;
using HalideIR::Expr;
using HalideIR::VarExpr;
using HalideIR::IR::RangeNode;
using HalideIR::IR::FunctionRef;
using HalideIR::IR::FunctionBaseNode;
using HalideIR::Internal::Stmt;
using HalideIR::Internal::IRPrinter;
using HalideIR::Internal::Variable;
using Halide::Internal::make_const;
using Halide::Internal::make_zero;
using Halide::Internal::as_const_int;
using Halide::Internal::as_const_uint;
using Halide::Internal::const_true;
using Halide::Internal::const_false;
using Halide::Internal::is_no_op;
using HalideIR::Internal::make_const;
using HalideIR::Internal::make_zero;
using HalideIR::Internal::as_const_int;
using HalideIR::Internal::as_const_uint;
using HalideIR::Internal::const_true;
using HalideIR::Internal::const_false;
using HalideIR::Internal::is_no_op;
inline Type TVMShapeIndexType() {
if (std::is_signed<tvm_index_t>::value) {
......@@ -51,7 +51,7 @@ inline Type TVMShapeIndexType() {
}
inline Type TVMType2Type(TVMType t) {
return Type(static_cast<halide_type_code_t>(t.code), t.bits, t.lanes);
return Type(static_cast<halideir_type_code_t>(t.code), t.bits, t.lanes);
}
inline TVMType Type2TVMType(Type t) {
......@@ -71,7 +71,7 @@ inline int GetVectorBytes(Type dtype) {
}
/*! \brief a named variable in TVM */
class Var : public Halide::VarExpr {
class Var : public HalideIR::VarExpr {
public:
explicit Var(const std::string& name_hint = "v",
Type t = Int(32)) : VarExpr(name_hint, t) {}
......@@ -94,7 +94,7 @@ class Var : public Halide::VarExpr {
class IterVarNode;
/*!
* \brief same as Halide::IR::Range
* \brief same as HalideIR::IR::Range
* except it provide an constructor with (begin, end)
*
* \note Traditional Halide's Range have a constructor with
......@@ -102,11 +102,11 @@ class IterVarNode;
* We decided to correct it by removing the constructor in HalideIR,
* and add it back in TVM's range.
*/
class Range : public Halide::IR::Range {
class Range : public HalideIR::IR::Range {
public:
/*! \brief constructor */
Range() {}
explicit Range(std::shared_ptr<Node> n) : Halide::IR::Range(n) {}
explicit Range(std::shared_ptr<Node> n) : HalideIR::IR::Range(n) {}
/*!
* \brief constructor by begin and end
* \param begin The begin of the range.
......
......@@ -16,11 +16,11 @@
namespace tvm {
namespace ir {
using Halide::Internal::ExprNode;
using Halide::Internal::StmtNode;
using Halide::Internal::IRNodeType;
using Halide::Internal::ForType;
using Halide::DeviceAPI;
using HalideIR::Internal::ExprNode;
using HalideIR::Internal::StmtNode;
using HalideIR::Internal::IRNodeType;
using HalideIR::Internal::ForType;
using HalideIR::DeviceAPI;
// Node container for CommReducer
struct CommReducerNode;
......@@ -433,50 +433,50 @@ enum TVMStructFieldKind : int {
} // namespace intrinsic
// Reuse IR node defintiion from HalideIR
using Halide::Internal::IntImm;
using Halide::Internal::UIntImm;
using Halide::Internal::FloatImm;
using Halide::Internal::StringImm;
using Halide::Internal::Cast;
using Halide::Internal::Add;
using Halide::Internal::Sub;
using Halide::Internal::Mul;
using Halide::Internal::Div;
using Halide::Internal::Mod;
using Halide::Internal::Min;
using Halide::Internal::Max;
using Halide::Internal::EQ;
using Halide::Internal::NE;
using Halide::Internal::LT;
using Halide::Internal::LE;
using Halide::Internal::GT;
using Halide::Internal::GE;
using Halide::Internal::And;
using Halide::Internal::Or;
using Halide::Internal::Not;
using Halide::Internal::Select;
using Halide::Internal::Load;
using Halide::Internal::Ramp;
using Halide::Internal::Broadcast;
using Halide::Internal::Call;
using Halide::Internal::Let;
using Halide::Internal::LetStmt;
using Halide::Internal::AttrStmt;
using Halide::Internal::AssertStmt;
using Halide::Internal::ProducerConsumer;
using Halide::Internal::For;
using Halide::Internal::Store;
using Halide::Internal::Provide;
using Halide::Internal::Allocate;
using Halide::Internal::Free;
using Halide::Internal::Realize;
using Halide::Internal::Prefetch;
using Halide::Internal::Block;
using Halide::Internal::IfThenElse;
using Halide::Internal::Evaluate;
using Halide::Internal::Shuffle;
using HalideIR::Internal::IntImm;
using HalideIR::Internal::UIntImm;
using HalideIR::Internal::FloatImm;
using HalideIR::Internal::StringImm;
using HalideIR::Internal::Cast;
using HalideIR::Internal::Add;
using HalideIR::Internal::Sub;
using HalideIR::Internal::Mul;
using HalideIR::Internal::Div;
using HalideIR::Internal::Mod;
using HalideIR::Internal::Min;
using HalideIR::Internal::Max;
using HalideIR::Internal::EQ;
using HalideIR::Internal::NE;
using HalideIR::Internal::LT;
using HalideIR::Internal::LE;
using HalideIR::Internal::GT;
using HalideIR::Internal::GE;
using HalideIR::Internal::And;
using HalideIR::Internal::Or;
using HalideIR::Internal::Not;
using HalideIR::Internal::Select;
using HalideIR::Internal::Load;
using HalideIR::Internal::Ramp;
using HalideIR::Internal::Broadcast;
using HalideIR::Internal::Call;
using HalideIR::Internal::Let;
using HalideIR::Internal::LetStmt;
using HalideIR::Internal::AttrStmt;
using HalideIR::Internal::AssertStmt;
using HalideIR::Internal::ProducerConsumer;
using HalideIR::Internal::For;
using HalideIR::Internal::Store;
using HalideIR::Internal::Provide;
using HalideIR::Internal::Allocate;
using HalideIR::Internal::Free;
using HalideIR::Internal::Realize;
using HalideIR::Internal::Prefetch;
using HalideIR::Internal::Block;
using HalideIR::Internal::IfThenElse;
using HalideIR::Internal::Evaluate;
using HalideIR::Internal::Shuffle;
// ir functions
using Halide::Internal::is_const_power_of_two_integer;
using HalideIR::Internal::is_const_power_of_two_integer;
} // namespace ir
} // namespace tvm
......
......@@ -12,14 +12,14 @@
namespace tvm {
using Halide::likely;
using Halide::likely_if_innermost;
using HalideIR::likely;
using HalideIR::likely_if_innermost;
// functions
using Halide::cast;
using Halide::min;
using Halide::max;
using Halide::abs;
using Halide::select;
using HalideIR::cast;
using HalideIR::min;
using HalideIR::max;
using HalideIR::abs;
using HalideIR::select;
/*!
* \brief sum of of source expression over axis
......
......@@ -104,7 +104,7 @@ inline TNodeRef TVMArgValue::AsNodeRef() const {
return TNodeRef(sptr);
}
inline TVMArgValue::operator Halide::Expr() const {
inline TVMArgValue::operator HalideIR::Expr() const {
if (type_code_ == kNull) return Expr();
if (type_code_ == kDLInt) {
return Expr(static_cast<int>(value_.v_int64));
......@@ -184,20 +184,20 @@ inline void TVMArgsSetter::operator()(size_t i, const NodeRef& other) const { /
}
// type related stuffs
inline TVMRetValue& TVMRetValue::operator=(const Halide::Type& t) {
inline TVMRetValue& TVMRetValue::operator=(const HalideIR::Type& t) {
return this->operator=(Type2TVMType(t));
}
inline TVMRetValue::operator Halide::Type() const {
inline TVMRetValue::operator HalideIR::Type() const {
return TVMType2Type(operator TVMType());
}
inline TVMArgValue::operator Halide::Type() const {
inline TVMArgValue::operator HalideIR::Type() const {
return TVMType2Type(operator TVMType());
}
inline void TVMArgsSetter::operator()(
size_t i, const Halide::Type& t) const {
size_t i, const HalideIR::Type& t) const {
this->operator()(i, Type2TVMType(t));
}
} // namespace runtime
......
......@@ -17,7 +17,7 @@
#include "./c_runtime_api.h"
#include "./module.h"
namespace Halide {
namespace HalideIR {
// Forward declare type for extensions
// The header works fine without depending on this.
struct Type;
......@@ -351,8 +351,8 @@ class TVMArgValue : public TVMPODValue_ {
typename = typename std::enable_if<
std::is_class<TNodeRef>::value>::type>
inline bool IsNodeType() const;
inline operator Halide::Type() const;
inline operator Halide::Expr() const;
inline operator HalideIR::Type() const;
inline operator HalideIR::Expr() const;
// get internal node ptr, if it is node
inline std::shared_ptr<Node>& node_sptr();
};
......@@ -531,8 +531,8 @@ class TVMRetValue : public TVMPODValue_ {
inline TVMRetValue& operator=(const NodeRef& other);
inline TVMRetValue& operator=(const std::shared_ptr<Node>& other);
// type related
inline operator Halide::Type() const;
inline TVMRetValue& operator=(const Halide::Type& other);
inline operator HalideIR::Type() const;
inline TVMRetValue& operator=(const HalideIR::Type& other);
private:
template<typename T>
......@@ -800,7 +800,7 @@ class TVMArgsSetter {
inline void operator()(size_t i, const T& value) const;
// NodeRef related extenstions: in tvm/packed_func_ext.h
inline void operator()(size_t i, const NodeRef& other) const; // NOLINT(*)
inline void operator()(size_t i, const Halide::Type& t) const;
inline void operator()(size_t i, const HalideIR::Type& t) const;
private:
/*! \brief The values fields */
......
......@@ -23,7 +23,7 @@ class TensorNode;
// internal node container for Operation
class OperationNode;
using Halide::IR::FunctionRef;
using HalideIR::IR::FunctionRef;
/*!
* \brief Tensor structure representing a possible input,
......
......@@ -27,7 +27,7 @@ TVM_REGISTER_API("make.For")
args[1],
args[2],
static_cast<ForType>(args[3].operator int()),
static_cast<Halide::DeviceAPI>(args[4].operator int()),
static_cast<HalideIR::DeviceAPI>(args[4].operator int()),
args[5]);
});
......
......@@ -16,7 +16,7 @@ namespace tvm {
namespace arith {
using namespace ir;
using Halide::Internal::Interval;
using HalideIR::Internal::Interval;
// a visitor to find the path to the target variable
// from a expression.
......
......@@ -626,7 +626,7 @@ Expr CanonicalSimplify(Expr expr, Map<Var, Range> vrange) {
template<typename T>
T Simplify_(T a, Map<Var, Range> vrange) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
Scope<Interval> rscope;
for (auto kv : vrange) {
Range r = kv.second;
......@@ -635,7 +635,7 @@ T Simplify_(T a, Map<Var, Range> vrange) {
Interval(r->min,
simplify(r->min + r->extent - make_const(r->min.type(), 1))));
}
return Halide::Internal::simplify(a, true, rscope);
return HalideIR::Internal::simplify(a, true, rscope);
}
......
......@@ -14,9 +14,9 @@
namespace tvm {
namespace arith {
using Halide::Internal::add_would_overflow;
using Halide::Internal::sub_would_overflow;
using Halide::Internal::mul_would_overflow;
using HalideIR::Internal::add_would_overflow;
using HalideIR::Internal::sub_would_overflow;
using HalideIR::Internal::mul_would_overflow;
/*!
* \brief Compute the expression with the given binary op.
......@@ -133,12 +133,12 @@ inline Expr ComputeExpr<ir::Mod>(Expr a, Expr b) {
template<>
inline Expr ComputeExpr<ir::Max>(Expr a, Expr b) {
return Halide::Internal::Interval::make_max(a, b);
return HalideIR::Internal::Interval::make_max(a, b);
}
template<>
inline Expr ComputeExpr<ir::Min>(Expr a, Expr b) {
return Halide::Internal::Interval::make_min(a, b);
return HalideIR::Internal::Interval::make_min(a, b);
}
template<typename Op>
......
......@@ -15,7 +15,7 @@
namespace tvm {
namespace arith {
using Halide::Internal::Interval;
using HalideIR::Internal::Interval;
using namespace ir;
inline IntSet IntSet::cover_interval() const {
......
......@@ -13,7 +13,7 @@
namespace tvm {
namespace arith {
using Halide::Internal::Interval;
using HalideIR::Internal::Interval;
/*! \brief Set of continuous interval */
struct IntervalSet : public IntSetNode {
......
......@@ -10,7 +10,7 @@
namespace tvm {
using Halide::IR::RangeNode;
using HalideIR::IR::RangeNode;
Range::Range(Expr begin, Expr end)
: Range(std::make_shared<RangeNode>(
......@@ -19,7 +19,7 @@ Range::Range(Expr begin, Expr end)
}
Range Range::make_by_min_extent(Expr min, Expr extent) {
return Range(std::make_shared<Halide::IR::RangeNode>(min, extent));
return Range(std::make_shared<HalideIR::IR::RangeNode>(min, extent));
}
IterVar IterVarNode::make(Range dom, Var var,
......@@ -67,7 +67,7 @@ TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
});
TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
.set_dispatch<RangeNode>([](const Halide::IR::RangeNode *op, IRPrinter *p) {
.set_dispatch<RangeNode>([](const HalideIR::IR::RangeNode *op, IRPrinter *p) {
p->stream << "range(min=" << op->min << ", ext=" << op->extent << ')';
});
......
......@@ -11,7 +11,7 @@
#include <memory>
#include "../pass/ir_util.h"
namespace Halide {
namespace HalideIR {
namespace Internal {
using tvm::ir::CommReducerNode;
......@@ -43,7 +43,7 @@ TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
<< ")";
});
} // namespace Internal
} // namespace Halide
} // namespace HalideIR
namespace tvm {
namespace ir {
......
......@@ -25,7 +25,7 @@ inline std::string Type2String(const Type& t) {
inline Type String2Type(std::string s) {
std::istringstream is(s);
halide_type_code_t code = Type::Int;
halideir_type_code_t code = Type::Int;
if (s.substr(0, 3) == "int") {
code = Type::Int; s = s.substr(3);
} else if (s.substr(0, 4) == "uint") {
......
......@@ -16,7 +16,7 @@ Expr Tensor::operator()(Array<Var> indices) const {
}
Expr Tensor::operator()(Array<Expr> indices) const {
using Halide::Internal::Call;
using HalideIR::Internal::Call;
CHECK_EQ(ndim(), indices.size())
<< "Tensor dimension mismatch in read"
<< "ndim = " << ndim() << ", indices.size=" << indices.size();
......
......@@ -228,7 +228,7 @@ Stmt ComputeOpNode::BuildRealize(
const std::unordered_map<IterVar, Range>& realize_map,
const Stmt& realize_body) const {
CHECK_EQ(stage->op.get(), this);
Halide::Internal::Region bounds;
HalideIR::Internal::Region bounds;
for (IterVar iv : this->axis) {
bounds.push_back(realize_map.at(iv));
}
......
......@@ -113,7 +113,7 @@ Stmt ExternOpNode::BuildRealize(
Stmt realize_body = body;
for (int k = 0; k < num_outputs(); ++k) {
Tensor t = stage->op.output(k);
Halide::Internal::Region bounds;
HalideIR::Internal::Region bounds;
for (size_t i = 0; i < t->shape.size(); ++i) {
bounds.push_back(
Range::make_by_min_extent(
......
......@@ -238,7 +238,7 @@ Stmt ScanOpNode::BuildRealize(
for (size_t i = 0; i < update.size(); ++i) {
Tensor t = stage->op.output(i);
CHECK_EQ(static_cast<size_t>(t->value_index), i);
Halide::Internal::Region bounds;
HalideIR::Internal::Region bounds;
bounds.push_back(tdom);
for (size_t k = 1; k < this->update[i]->shape.size(); ++k, ++sp_idx) {
IterVar sp_ax = this->spatial_axis_[sp_idx];
......
......@@ -15,7 +15,7 @@ namespace ir {
using arith::IntSet;
using arith::DomainTouched;
using Halide::Internal::Region;
using HalideIR::Internal::Region;
class PrefetchInjector : public IRMutator {
public:
......
......@@ -328,8 +328,8 @@ class IRDeepCompare :
return order_;
}
int CompareRegion(const Halide::Internal::Region& lhs,
const Halide::Internal::Region& rhs) {
int CompareRegion(const HalideIR::Internal::Region& lhs,
const HalideIR::Internal::Region& rhs) {
if (order_ != 0) return order_;
if (CompareValue(lhs.size(), rhs.size()) != 0) return order_;
for (size_t i = 0; i < lhs.size(); ++i) {
......
......@@ -206,7 +206,7 @@ Stmt IRMutator::Mutate_(const Provide* op, const Stmt& s) {
Stmt IRMutator::Mutate_(const Realize* op, const Stmt& s) {
IRMutator* m = this;
Halide::Internal::Region new_bounds;
HalideIR::Internal::Region new_bounds;
bool bounds_changed = false;
// Mutate the bounds
......@@ -236,7 +236,7 @@ Stmt IRMutator::Mutate_(const Realize* op, const Stmt& s) {
Stmt IRMutator::Mutate_(const Prefetch* op, const Stmt& s) {
IRMutator* m = this;
Halide::Internal::Region new_bounds;
HalideIR::Internal::Region new_bounds;
bool bounds_changed = false;
// Mutate the bounds
......
......@@ -22,7 +22,7 @@
namespace tvm {
namespace ir {
using Halide::Internal::Region;
using HalideIR::Internal::Region;
using runtime::StorageScope;
using runtime::ThreadScope;
using intrinsic::tvm_address_of;
......
......@@ -407,7 +407,7 @@ void PassUpBoundCheck(const Stage& s,
const Map<IterVar, Range>& dom_map,
std::unordered_map<IterVar, bool>* p_state) {
auto& state = *p_state;
using Halide::Internal::can_prove;
using HalideIR::Internal::can_prove;
for (size_t i = s->relations.size(); i != 0; --i) {
IterVarRelation rel = s->relations[i - 1];
if (rel.as<SplitNode>()) {
......
......@@ -4,8 +4,8 @@
namespace {
using namespace tvm::ir;
using namespace Halide::Internal;
using namespace Halide;
using namespace HalideIR::Internal;
using namespace HalideIR;
// replace variable to constant
class IRVar2Const : public IRMutator {
......@@ -38,7 +38,7 @@ TVM_STATIC_IR_FUNCTOR(IRVar2Const, vtable_expr)
} // namespace
TEST(IRMutator, Basic) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
using namespace tvm;
Var x("x"), y;
auto z = x + y;
......
......@@ -4,7 +4,7 @@
#include <arithmetic/Simplify.h>
TEST(IRSIMPLIFY, Basic) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
simplify_test();
}
......
......@@ -5,7 +5,7 @@
TEST(IRSSA, Convert) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
using namespace tvm;
Var x("x"), y;
Expr let = Let::make(x, 1, x + 1);
......@@ -17,7 +17,7 @@ TEST(IRSSA, Convert) {
}
TEST(IRSSA, Basic) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
using namespace tvm;
Var x("x"), y;
auto z = Evaluate::make(x + y);
......
......@@ -5,7 +5,7 @@
#include <tvm/ir_pass.h>
TEST(IRVisitor, CountVar) {
using namespace Halide::Internal;
using namespace HalideIR::Internal;
using namespace tvm;
int n_var = 0;
Var x("x"), y;
......
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