Skip to content

Commit

Permalink
Update include and src dir CHECK* to ICHECK* (#6745)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkimball authored Oct 24, 2020
1 parent d50bb03 commit 1831c17
Show file tree
Hide file tree
Showing 429 changed files with 4,251 additions and 4,234 deletions.
4 changes: 2 additions & 2 deletions include/tvm/arith/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ class CanonicalSimplifier {
* arith::Analyzer analyzer;
* {
* With<arith::ConstraintContext> scope(&analyzer, x % 3 == 0);
* CHECK_EQ(analyzer.modular_set(x)->coeff, 3);
* ICHECK_EQ(analyzer.modular_set(x)->coeff, 3);
* }
* // constraint no longer in effect.
* CHECK_NE(analyzer.modular_set(x)->coeff, 3);
* ICHECK_NE(analyzer.modular_set(x)->coeff, 3);
*
* \endcode
*/
Expand Down
8 changes: 4 additions & 4 deletions include/tvm/ir/attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ inline void SetValue<double>(double* ptr, const TVMArgValue& val) {
*ptr = val.operator double();
} else {
ObjectRef expr = val;
CHECK(expr.defined());
ICHECK(expr.defined());
if (const IntImmNode* op = expr.as<IntImmNode>()) {
*ptr = static_cast<double>(op->value);
} else if (const FloatImmNode* op = expr.as<FloatImmNode>()) {
Expand Down Expand Up @@ -664,15 +664,15 @@ class AttrsNode : public BaseAttrsNode {
}

void InitByPackedArgs(const runtime::TVMArgs& args, bool allow_unknown) final {
CHECK_EQ(args.size() % 2, 0);
ICHECK_EQ(args.size() % 2, 0);
const int kLinearSearchBound = 16;
int hit_count = 0;
// applies two stratgies to lookup
if (args.size() < kLinearSearchBound) {
// linear search.
auto ffind = [&args](const char* key, runtime::TVMArgValue* val) {
for (int i = 0; i < args.size(); i += 2) {
CHECK_EQ(args.type_codes[i], kTVMStr);
ICHECK_EQ(args.type_codes[i], kTVMStr);
if (!std::strcmp(key, args.values[i].v_str)) {
*val = args[i + 1];
return true;
Expand All @@ -687,7 +687,7 @@ class AttrsNode : public BaseAttrsNode {
// construct a map then do lookup.
std::unordered_map<std::string, runtime::TVMArgValue> kwargs;
for (int i = 0; i < args.size(); i += 2) {
CHECK_EQ(args.type_codes[i], kTVMStr);
ICHECK_EQ(args.type_codes[i], kTVMStr);
kwargs[args[i].operator std::string()] = args[i + 1];
}
auto ffind = [&kwargs](const char* key, runtime::TVMArgValue* val) {
Expand Down
4 changes: 2 additions & 2 deletions include/tvm/ir/diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class DiagnosticRenderer : public ObjectRef {
void Render(const DiagnosticContext& ctx);

DiagnosticRendererNode* operator->() {
CHECK(get() != nullptr);
ICHECK(get() != nullptr);
return static_cast<DiagnosticRendererNode*>(get_mutable());
}

Expand Down Expand Up @@ -203,7 +203,7 @@ class DiagnosticContext : public ObjectRef {
void Render();

DiagnosticContextNode* operator->() {
CHECK(get() != nullptr);
ICHECK(get() != nullptr);
return static_cast<DiagnosticContextNode*>(get_mutable());
}

Expand Down
4 changes: 2 additions & 2 deletions include/tvm/ir/env_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class EnvFunc : public ObjectRef {
template <typename... Args>
runtime::TVMRetValue operator()(Args&&... args) const {
const EnvFuncNode* n = operator->();
CHECK(n != nullptr);
ICHECK(n != nullptr);
return n->func(std::forward<Args>(args)...);
}
/*!
Expand Down Expand Up @@ -137,7 +137,7 @@ class TypedEnvFunc<R(Args...)> : public ObjectRef {
*/
R operator()(Args... args) const {
const EnvFuncNode* n = operator->();
CHECK(n != nullptr);
ICHECK(n != nullptr);
return runtime::detail::typed_packed_call_dispatcher<R>::run(n->func,
std::forward<Args>(args)...);
}
Expand Down
16 changes: 8 additions & 8 deletions include/tvm/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class Integer : public IntImm {
* \brief convert to int64_t
*/
operator int64_t() const {
CHECK(data_ != nullptr) << " Trying to reference a null Integer";
ICHECK(data_ != nullptr) << " Trying to reference a null Integer";
return (*this)->value;
}
// comparators
Expand Down Expand Up @@ -461,21 +461,21 @@ class Range : public ObjectRef {

// implementataions
inline const Type& RelayExprNode::checked_type() const {
CHECK(checked_type_.defined()) << "internal error: the type checker has "
<< "not populated the checked_type "
<< "field for " << GetRef<RelayExpr>(this);
ICHECK(checked_type_.defined()) << "internal error: the type checker has "
<< "not populated the checked_type "
<< "field for " << GetRef<RelayExpr>(this);
return this->checked_type_;
}

template <typename TTypeNode>
inline const TTypeNode* RelayExprNode::type_as() const {
static_assert(std::is_base_of<TypeNode, TTypeNode>::value,
"TType must be a special case of type");
CHECK(checked_type_.defined())
ICHECK(checked_type_.defined())
<< "Type inference for this Expr has not completed. Try to call infer_type pass.";
const TTypeNode* node = checked_type_.as<TTypeNode>();
CHECK(node != nullptr) << "Expected type to be " << TTypeNode::_type_key << ", but get "
<< checked_type_->GetTypeKey();
ICHECK(node != nullptr) << "Expected type to be " << TTypeNode::_type_key << ", but get "
<< checked_type_->GetTypeKey();
return node;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ struct PackedFuncValueConverter<tvm::Bool> {
}
if (val.type_code() == kTVMArgInt) {
int v = val.operator int();
CHECK(v == 0 || v == 1) << "ValueError: boolean value can only be 0 or 1, but get " << v;
ICHECK(v == 0 || v == 1) << "ValueError: boolean value can only be 0 or 1, but get " << v;
return Bool(static_cast<bool>(v));
}
return val.AsObjectRef<tvm::Bool>();
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/ir/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class IRModule : public ObjectRef {
/*! \return mutable pointers to the node. */
IRModuleNode* operator->() const {
auto* ptr = get_mutable();
CHECK(ptr != nullptr);
ICHECK(ptr != nullptr);
return static_cast<IRModuleNode*>(ptr);
}

Expand Down
6 changes: 3 additions & 3 deletions include/tvm/ir/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class OpNode : public RelayExprNode {
// Internal function to compute if it is primitive op
bool IsPrimitiveOp_() const {
const auto& fn_ty = this->op_type;
CHECK(fn_ty.get() != nullptr);
ICHECK(fn_ty.get() != nullptr);
if (fn_ty->type_constraints.size() != 1) return false;
const TypeRelationNode* rel = fn_ty->type_constraints[0].as<TypeRelationNode>();
if (rel == nullptr) return false;
Expand Down Expand Up @@ -462,7 +462,7 @@ inline OpRegEntry& OpRegEntry::set_support_level(int32_t n) { // NOLINT(*)
template <typename ValueType>
inline OpRegEntry& OpRegEntry::set_attr( // NOLINT(*)
const std::string& attr_name, const ValueType& value, int plevel) {
CHECK_GT(plevel, 0) << "plevel in set_attr must be greater than 0";
ICHECK_GT(plevel, 0) << "plevel in set_attr must be greater than 0";
runtime::TVMRetValue rv;
rv = value;
UpdateAttr(attr_name, rv, plevel);
Expand All @@ -473,7 +473,7 @@ inline OpRegEntry& OpRegEntry::set_attr( // NOLINT(*)

template <typename ValueType>
inline ValueType OpAttrMap<ValueType>::get(const RelayExpr& expr, ValueType def_value) const {
CHECK(expr.defined());
ICHECK(expr.defined());
if (const OpNode* op = expr.as<OpNode>()) {
return this->map_.get(GetRef<Op>(op), def_value);
} else {
Expand Down
8 changes: 4 additions & 4 deletions include/tvm/ir/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ class PassContext : public ObjectRef {
* \return const access pointer.
*/
const PassContextNode* operator->() const {
CHECK(get() != nullptr);
ICHECK(get() != nullptr);
return static_cast<const PassContextNode*>(get());
}
/*!
* \brief mutable accessor.
* \return mutable access pointer.
*/
PassContextNode* operator->() {
CHECK(get() != nullptr);
ICHECK(get() != nullptr);
return static_cast<PassContextNode*>(get_mutable());
}

Expand Down Expand Up @@ -344,7 +344,7 @@ class Pass : public ObjectRef {
*/
IRModule operator()(IRModule mod) const {
const PassNode* node = operator->();
CHECK(node != nullptr);
ICHECK(node != nullptr);
return node->operator()(std::move(mod));
}
/*!
Expand All @@ -357,7 +357,7 @@ class Pass : public ObjectRef {
*/
IRModule operator()(IRModule mod, const PassContext& pass_ctx) const {
const PassNode* node = operator->();
CHECK(node != nullptr);
ICHECK(node != nullptr);
return node->operator()(std::move(mod), pass_ctx);
}

Expand Down
2 changes: 1 addition & 1 deletion include/tvm/ir/type_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TypeFunctor<R(const Type& n, Args...)> {
* \return The result of the call
*/
virtual R VisitType(const Type& n, Args... args) {
CHECK(n.defined());
ICHECK(n.defined());
static FType vtable = InitVTable();
return vtable(n, this, std::forward<Args>(args)...);
}
Expand Down
6 changes: 3 additions & 3 deletions include/tvm/node/attr_registry_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class AttrRegistryMapContainerMap {
* \return the const reference to the content value.
*/
const runtime::TVMRetValue& operator[](const KeyType& key) const {
CHECK(key.defined());
ICHECK(key.defined());
const uint32_t idx = key->AttrRegistryIndex();
CHECK(idx < data_.size() && data_[idx].second != 0)
ICHECK(idx < data_.size() && data_[idx].second != 0)
<< "Attribute " << attr_name_ << " has not been registered for " << key->name;
return data_[idx].first;
}
Expand All @@ -71,7 +71,7 @@ class AttrRegistryMapContainerMap {
*/
template <typename ValueType>
ValueType get(const KeyType& key, ValueType def_value) const {
CHECK(key.defined());
ICHECK(key.defined());
const uint32_t idx = key->AttrRegistryIndex();
if (idx < data_.size() && data_[idx].second != 0) {
return data_[idx].first;
Expand Down
16 changes: 8 additions & 8 deletions include/tvm/node/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class SmallMapNode : public MapNode,
*/
const mapped_type& at(const key_type& key) const {
iterator itr = find(key);
CHECK(itr.index < size_) << "IndexError: key is not in Map";
ICHECK(itr.index < size_) << "IndexError: key is not in Map";
return itr->second;
}
/*!
Expand All @@ -361,7 +361,7 @@ class SmallMapNode : public MapNode,
*/
mapped_type& at(const key_type& key) {
iterator itr = find(key);
CHECK(itr.index < size_) << "IndexError: key is not in Map";
ICHECK(itr.index < size_) << "IndexError: key is not in Map";
return itr->second;
}
/*! \return begin iterator */
Expand Down Expand Up @@ -466,7 +466,7 @@ class SmallMapNode : public MapNode,
}
uint64_t next_size = std::max(map_node->slots_ * 2, uint64_t(kInitSize));
next_size = std::min(next_size, uint64_t(kMaxSize));
CHECK_GT(next_size, map_node->slots_);
ICHECK_GT(next_size, map_node->slots_);
ObjectPtr<Object> new_map = CreateFromRange(next_size, map_node->begin(), map_node->end());
InsertMaybeReHash(kv, &new_map);
*map = std::move(new_map);
Expand Down Expand Up @@ -656,7 +656,7 @@ class DenseMapNode : public MapNode {
*/
mapped_type& At(const key_type& key) const {
ListNode iter = Search(key);
CHECK(!iter.IsNone()) << "IndexError: key is not in Map";
ICHECK(!iter.IsNone()) << "IndexError: key is not in Map";
return iter.Val();
}
/*!
Expand Down Expand Up @@ -823,7 +823,7 @@ class DenseMapNode : public MapNode {
* \return The object created
*/
static ObjectPtr<DenseMapNode> Empty(uint32_t fib_shift, uint64_t n_slots) {
CHECK_GT(n_slots, uint64_t(SmallMapNode::kMaxSize));
ICHECK_GT(n_slots, uint64_t(SmallMapNode::kMaxSize));
ObjectPtr<DenseMapNode> p = make_object<DenseMapNode>();
uint64_t n_blocks = CalcNumBlocks(n_slots - 1);
Block* block = p->data_ = new Block[n_blocks];
Expand Down Expand Up @@ -855,7 +855,7 @@ class DenseMapNode : public MapNode {
for (int j = 0; j < kBlockCap;
++j, ++meta_ptr_from, ++data_ptr_from, ++meta_ptr_to, ++data_ptr_to) {
uint8_t& meta = *meta_ptr_to = *meta_ptr_from;
CHECK(meta != kProtectedSlot);
ICHECK(meta != kProtectedSlot);
if (meta != uint8_t(kEmptySlot)) {
new (data_ptr_to) KVType(*data_ptr_from);
}
Expand All @@ -876,7 +876,7 @@ class DenseMapNode : public MapNode {
iter.Val() = kv.second;
return;
}
CHECK_GT(map_node->slots_, uint64_t(SmallMapNode::kMaxSize));
ICHECK_GT(map_node->slots_, uint64_t(SmallMapNode::kMaxSize));
// Otherwise, start rehash
ObjectPtr<Object> p = Empty(map_node->fib_shift_ - 1, map_node->slots_ * 2 + 2);
// Insert the given `kv` into the new hash map
Expand Down Expand Up @@ -963,7 +963,7 @@ class DenseMapNode : public MapNode {
shift -= 1;
slots <<= 1;
}
CHECK_GT(slots, cap);
ICHECK_GT(slots, cap);
if (slots < cap * 2) {
*fib_shift = shift - 1;
*n_slots = slots << 1;
Expand Down
8 changes: 4 additions & 4 deletions include/tvm/node/functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class NodeFunctor<R(const ObjectRef& n, Args...)> {
* \return The result.
*/
R operator()(const ObjectRef& n, Args... args) const {
CHECK(can_dispatch(n)) << "NodeFunctor calls un-registered function on type "
<< n->GetTypeKey();
ICHECK(can_dispatch(n)) << "NodeFunctor calls un-registered function on type "
<< n->GetTypeKey();
return (*func_[n->type_index()])(n, std::forward<Args>(args)...);
}
/*!
Expand All @@ -108,7 +108,7 @@ class NodeFunctor<R(const ObjectRef& n, Args...)> {
if (func_.size() <= tindex) {
func_.resize(tindex + 1, nullptr);
}
CHECK(func_[tindex] == nullptr) << "Dispatch for " << TNode::_type_key << " is already set";
ICHECK(func_[tindex] == nullptr) << "Dispatch for " << TNode::_type_key << " is already set";
func_[tindex] = f;
return *this;
}
Expand All @@ -121,7 +121,7 @@ class NodeFunctor<R(const ObjectRef& n, Args...)> {
template <typename TNode>
TSelf& clear_dispatch() { // NOLINT(*)
uint32_t tindex = TNode::RuntimeTypeIndex();
CHECK_LT(tindex, func_.size()) << "clear_dispatch: index out of range";
ICHECK_LT(tindex, func_.size()) << "clear_dispatch: index out of range";
func_[tindex] = nullptr;
return *this;
}
Expand Down
4 changes: 2 additions & 2 deletions include/tvm/node/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ReflectionVTable::Registry {
* \return rference to self.
*/
Registry& set_creator(FCreate f) { // NOLINT(*)
CHECK_LT(type_index_, parent_->fcreate_.size());
ICHECK_LT(type_index_, parent_->fcreate_.size());
parent_->fcreate_[type_index_] = f;
return *this;
}
Expand All @@ -218,7 +218,7 @@ class ReflectionVTable::Registry {
* \return rference to self.
*/
Registry& set_repr_bytes(FReprBytes f) { // NOLINT(*)
CHECK_LT(type_index_, parent_->frepr_bytes_.size());
ICHECK_LT(type_index_, parent_->frepr_bytes_.size());
parent_->frepr_bytes_[type_index_] = f;
return *this;
}
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/parser/source_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SourceMap : public ObjectRef {
void Add(const Source& source);

SourceMapNode* operator->() {
CHECK(get() != nullptr);
ICHECK(get() != nullptr);
return static_cast<SourceMapNode*>(get_mutable());
}

Expand Down
20 changes: 10 additions & 10 deletions include/tvm/relay/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ namespace tvm {
*/
namespace relay {

#define RELAY_DEBUG(...) \
{ \
auto fdebug = runtime::Registry::Get("relay.debug"); \
CHECK(fdebug) << "Could not find Relay Python debugger function."; \
(*fdebug)("RELAY_DEBUG", __FILE__, __LINE__, __VA_ARGS__); \
#define RELAY_DEBUG(...) \
{ \
auto fdebug = runtime::Registry::Get("relay.debug"); \
ICHECK(fdebug) << "Could not find Relay Python debugger function."; \
(*fdebug)("RELAY_DEBUG", __FILE__, __LINE__, __VA_ARGS__); \
}

#define RELAY_DEBUG_INTERP(...) \
{ \
auto fdebug = runtime::Registry::Get("relay.debug_interp"); \
CHECK(fdebug) << "Could not find Relay Python debugger function."; \
(*fdebug)("RELAY_DEBUG", __FILE__, __LINE__, __VA_ARGS__); \
#define RELAY_DEBUG_INTERP(...) \
{ \
auto fdebug = runtime::Registry::Get("relay.debug_interp"); \
ICHECK(fdebug) << "Could not find Relay Python debugger function."; \
(*fdebug)("RELAY_DEBUG", __FILE__, __LINE__, __VA_ARGS__); \
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/relay/dataflow_pattern_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DFPatternFunctor<R(const DFPattern& n, Args...)> {
* \return The result of the call
*/
virtual R VisitDFPattern(const DFPattern& n, Args... args) {
CHECK(n.defined());
ICHECK(n.defined());
static FType vtable = InitVTable();
return vtable(n, this, std::forward<Args>(args)...);
}
Expand Down
Loading

0 comments on commit 1831c17

Please sign in to comment.