Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 19, 2022
1 parent 073aa72 commit 331a41f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions taichi/codegen/llvm/codegen_llvm_quant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ llvm::Value *CodeGenLLVM::get_exponent_offset(llvm::Value *exponent,
tlctx->get_constant(0));
}

llvm::Value *CodeGenLLVM::quant_int_or_quant_fixed_to_bits(llvm::Value *val, Type *input_type, llvm::Type *output_type) {
llvm::Value *CodeGenLLVM::quant_int_or_quant_fixed_to_bits(
llvm::Value *val,
Type *input_type,
llvm::Type *output_type) {
QuantIntType *qit = nullptr;
if (auto qfxt = input_type->cast<QuantFixedType>()) {
qit = qfxt->get_digits_type()->as<QuantIntType>();
Expand Down Expand Up @@ -295,9 +298,11 @@ void CodeGenLLVM::visit(BitStructStoreStmt *stmt) {
} else {
qit = dtype->as<QuantIntType>();
}
update_mask(mask, qit->get_num_bits(), bit_struct->get_member_bit_offset(ch_id));
update_mask(mask, qit->get_num_bits(),
bit_struct->get_member_bit_offset(ch_id));
}
store_masked(llvm_val[stmt->ptr], physical_type, mask, bit_struct_val, stmt->is_atomic);
store_masked(llvm_val[stmt->ptr], physical_type, mask, bit_struct_val,
stmt->is_atomic);
}
}

Expand All @@ -323,8 +328,7 @@ void CodeGenLLVM::store_quant_floats_with_shared_exponents(
input != stmt->ch_ids.end()) {
floats.push_back(llvm_val[stmt->values[input - stmt->ch_ids.begin()]]);
} else {
floats.push_back(
extract_quant_float(physical_value, bit_struct, user));
floats.push_back(extract_quant_float(physical_value, bit_struct, user));
}
}
// convert to i32 for bit operations
Expand All @@ -339,7 +343,8 @@ void CodeGenLLVM::store_quant_floats_with_shared_exponents(
}
}

auto first_qflt = bit_struct->get_member_type(exponent_users[0])->as<QuantFloatType>();
auto first_qflt =
bit_struct->get_member_type(exponent_users[0])->as<QuantFloatType>();
auto exponent_offset = get_exponent_offset(max_exp_bits, first_qflt);

auto max_exp_bits_to_store =
Expand All @@ -357,8 +362,10 @@ void CodeGenLLVM::store_quant_floats_with_shared_exponents(
} else {
masked_val = builder->CreateOr(masked_val, val);
}
update_mask(mask, bit_struct->get_member_type(i)->as<QuantIntType>()->get_num_bits(),
bit_offset);
update_mask(
mask,
bit_struct->get_member_type(i)->as<QuantIntType>()->get_num_bits(),
bit_offset);

for (int c = 0; c < (int)exponent_users.size(); c++) {
auto user = exponent_users[c];
Expand Down Expand Up @@ -396,8 +403,8 @@ void CodeGenLLVM::store_quant_floats_with_shared_exponents(
update_mask(mask, num_digit_bits, digits_bit_offset);
}
}
store_masked(llvm_val[stmt->ptr], physical_type, mask,
masked_val, stmt->is_atomic);
store_masked(llvm_val[stmt->ptr], physical_type, mask, masked_val,
stmt->is_atomic);
}

llvm::Value *CodeGenLLVM::extract_exponent_from_f32(llvm::Value *f) {
Expand Down

0 comments on commit 331a41f

Please sign in to comment.