Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
AD1024 committed Aug 17, 2022
1 parent 57e42ac commit f3ff3d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion taichi/codegen/llvm/codegen_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ void TaskCodeGenLLVM::visit(BinaryOpStmt *stmt) {
llvm_val[stmt] =
builder->CreateShl(llvm_val[stmt->lhs], llvm_val[stmt->rhs]);
} else if (op == BinaryOpType::bit_sar) {
if (is_signed(stmt->lhs->element_type()) || is_signed_tensor(stmt->lhs->ret_type)) {
if (is_signed(stmt->lhs->element_type()) ||
is_signed_tensor(stmt->lhs->ret_type)) {
llvm_val[stmt] =
builder->CreateAShr(llvm_val[stmt->lhs], llvm_val[stmt->rhs]);
} else {
Expand Down
13 changes: 7 additions & 6 deletions taichi/ir/type_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ TI_DLL_EXPORT int data_type_size(DataType t);

TI_DLL_EXPORT std::string data_type_format(DataType dt);

#define DEFINE_TENSOR_CHECK(func_name) inline bool func_name##_tensor(DataType dt) { \
if (auto tensor_type = dt->cast<TensorType>()) { \
return func_name(tensor_type->get_element_type()); \
} \
return false; \
}
#define DEFINE_TENSOR_CHECK(func_name) \
inline bool func_name##_tensor(DataType dt) { \
if (auto tensor_type = dt->cast<TensorType>()) { \
return func_name(tensor_type->get_element_type()); \
} \
return false; \
}

inline int data_type_bits(DataType t) {
return data_type_size(t) * 8;
Expand Down
3 changes: 2 additions & 1 deletion taichi/transforms/type_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ class TypeCheck : public IRVisitor {
DataType cast_dtype;
if (is_tensor) {
auto tensor_type = stmt->operand->ret_type->cast<TensorType>();
cast_dtype = TypeFactory::create_tensor_type(tensor_type->get_shape(), config_.default_fp);
cast_dtype = TypeFactory::create_tensor_type(tensor_type->get_shape(),
config_.default_fp);
} else {
cast_dtype = config_.default_fp;
}
Expand Down

0 comments on commit f3ff3d2

Please sign in to comment.