Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Remove data_type_short_name (use data_type_name instead) #2110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/taichi/lang/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def visit_FunctionDef(self, node):
array_dim = self.arg_features[i][1]
import numpy as np
array_dt = to_taichi_type(array_dt)
dt_expr = 'ti.' + ti.core.data_type_short_name(array_dt)
dt_expr = 'ti.' + ti.core.data_type_name(array_dt)
dt = self.parse_expr(dt_expr)
arg_init.value.args[0] = dt
arg_init.value.args[1] = self.parse_expr(
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/cc/cc_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TLANG_NAMESPACE_BEGIN
namespace cccp {

inline std::string cc_data_type_name(DataType dt) {
return "Ti_" + data_type_short_name(dt);
return "Ti_" + data_type_name(dt);
}

inline std::string cc_atomic_op_type_symbol(AtomicOpType op) {
Expand Down
12 changes: 6 additions & 6 deletions taichi/backends/cc/codegen_cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,18 @@ class CCTransformer : public IRVisitor {
cc_data_type_name(stmt->element_type().ptr_removed()) + " *",
stmt->raw_name());
emit("{} = ti_ctx->args[{}].ptr_{};", var, stmt->arg_id,
data_type_short_name(stmt->element_type().ptr_removed()));
data_type_name(stmt->element_type().ptr_removed()));
} else {
auto var =
define_var(cc_data_type_name(stmt->element_type()), stmt->raw_name());
emit("{} = ti_ctx->args[{}].val_{};", var, stmt->arg_id,
data_type_short_name(stmt->element_type()));
data_type_name(stmt->element_type()));
}
}

void visit(KernelReturnStmt *stmt) override {
emit("ti_ctx->args[0].val_{} = {};",
data_type_short_name(stmt->element_type()), stmt->value->raw_name());
emit("ti_ctx->args[0].val_{} = {};", data_type_name(stmt->element_type()),
stmt->value->raw_name());
}

void visit(ConstStmt *stmt) override {
Expand Down Expand Up @@ -332,7 +332,7 @@ class CCTransformer : public IRVisitor {
} else if (bin->op_type == BinaryOpType::truediv) {
emit("{} = ({}) {} / {};", var, dt_name, lhs_name, rhs_name);
} else if (bin->op_type == BinaryOpType::floordiv) {
auto lhs_dt_name = data_type_short_name(bin->lhs->element_type());
auto lhs_dt_name = data_type_name(bin->lhs->element_type());
if (is_integral(bin->lhs->element_type()) &&
is_integral(bin->rhs->element_type())) {
emit("{} = Ti_floordiv_{}({}, {});", var, lhs_dt_name, lhs_name,
Expand Down Expand Up @@ -528,7 +528,7 @@ class CCTransformer : public IRVisitor {

void visit(RandStmt *stmt) override {
auto var = define_var(cc_data_type_name(stmt->ret_type), stmt->raw_name());
emit("{} = Ti_rand_{}();", var, data_type_short_name(stmt->ret_type));
emit("{} = Ti_rand_{}();", var, data_type_name(stmt->ret_type));
}

void visit(StackAllocaStmt *stmt) override {
Expand Down
6 changes: 3 additions & 3 deletions taichi/backends/cuda/codegen_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ class CodeGenLLVMCUDA : public CodeGenLLVM {
}

void visit(RandStmt *stmt) override {
llvm_val[stmt] = create_call(
fmt::format("cuda_rand_{}", data_type_short_name(stmt->ret_type)),
{get_context()});
llvm_val[stmt] =
create_call(fmt::format("cuda_rand_{}", data_type_name(stmt->ret_type)),
{get_context()});
}

void visit(RangeForStmt *for_stmt) override {
Expand Down
10 changes: 5 additions & 5 deletions taichi/backends/metal/codegen_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class KernelCodegen : public IRVisitor {

void visit(RandStmt *stmt) override {
emit("const auto {} = metal_rand_{}({});", stmt->raw_name(),
data_type_short_name(stmt->ret_type), kRandStateVarName);
data_type_name(stmt->ret_type), kRandStateVarName);
}

void visit(PrintStmt *stmt) override {
Expand All @@ -629,8 +629,8 @@ class KernelCodegen : public IRVisitor {
TI_ASSERT_INFO(dt->is_primitive(PrimitiveTypeID::i32) ||
dt->is_primitive(PrimitiveTypeID::f32),
"print() only supports i32 or f32 scalars for now.");
emit("{}.pm_set_{}({}, {});", msg_var_name, data_type_short_name(dt),
i, arg_stmt->raw_name());
emit("{}.pm_set_{}({}, {});", msg_var_name, data_type_name(dt), i,
arg_stmt->raw_name());
} else {
const int str_id = print_strtab_->put(std::get<std::string>(entry));
emit("{}.pm_set_str({}, {});", msg_var_name, i, str_id);
Expand Down Expand Up @@ -666,8 +666,8 @@ class KernelCodegen : public IRVisitor {
const auto ty = arg->element_type();
if (ty->is_primitive(PrimitiveTypeID::i32) ||
ty->is_primitive(PrimitiveTypeID::f32)) {
emit("{}.pm_set_{}({}, {});", asst_var_name,
data_type_short_name(ty), i, arg->raw_name());
emit("{}.pm_set_{}({}, {});", asst_var_name, data_type_name(ty), i,
arg->raw_name());
} else {
TI_ERROR(
"[Metal] assert() only supports i32 or f32 scalars for now.");
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/opengl/codegen_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class KernelGen : public IRVisitor {
used.uint32 = true;
if (dt->is_primitive(PrimitiveTypeID::u64))
used.uint64 = true;
return data_type_short_name(dt);
return data_type_name(dt);
}

std::string opengl_data_type_name(DataType dt) {
Expand Down
8 changes: 4 additions & 4 deletions taichi/codegen/codegen_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void CodeGenLLVM::visit(AllocaStmt *stmt) {

void CodeGenLLVM::visit(RandStmt *stmt) {
llvm_val[stmt] =
create_call(fmt::format("rand_{}", data_type_short_name(stmt->ret_type)));
create_call(fmt::format("rand_{}", data_type_name(stmt->ret_type)));
}

void CodeGenLLVM::emit_extra_unary(UnaryOpStmt *stmt) {
Expand Down Expand Up @@ -405,9 +405,9 @@ void CodeGenLLVM::visit(BinaryOpStmt *stmt) {
}
} else if (op == BinaryOpType::floordiv) {
if (is_integral(ret_type))
llvm_val[stmt] = create_call(
fmt::format("floordiv_{}", data_type_short_name(ret_type)),
{llvm_val[stmt->lhs], llvm_val[stmt->rhs]});
llvm_val[stmt] =
create_call(fmt::format("floordiv_{}", data_type_name(ret_type)),
{llvm_val[stmt->lhs], llvm_val[stmt->rhs]});
else {
auto div = builder->CreateFDiv(llvm_val[stmt->lhs], llvm_val[stmt->rhs]);
llvm_val[stmt] = builder->CreateIntrinsic(
Expand Down
8 changes: 1 addition & 7 deletions taichi/lang_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ real measure_cpe(std::function<void()> target,
return elasped_cycles / float64(total_batches * elements_per_call);
}

// TODO: Remove data_type_short_name. Having two names for a data type is
// confusing.
std::string data_type_name(DataType t) {
return data_type_short_name(t);
}

std::string data_type_format(DataType dt) {
if (dt->is_primitive(PrimitiveTypeID::i32)) {
return "%d";
Expand Down Expand Up @@ -129,7 +123,7 @@ int data_type_bits(DataType t) {
return data_type_size(t) * 8;
}

std::string data_type_short_name(DataType t) {
std::string data_type_name(DataType t) {
if (!t->is<PrimitiveType>()) {
return t->to_string();
}
Expand Down
2 changes: 0 additions & 2 deletions taichi/lang_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ std::string data_type_name(DataType t);

std::string data_type_format(DataType dt);

std::string data_type_short_name(DataType t);

enum class SNodeType {
#define PER_SNODE(x) x,
#include "taichi/inc/snodes.inc.h"
Expand Down
2 changes: 1 addition & 1 deletion taichi/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void Program::visualize_layout(const std::string &fn) {
if (!indices.empty())
emit("\\\\" + indices);
if (snode->type == SNodeType::place) {
emit("\\\\" + data_type_short_name(snode->dt));
emit("\\\\" + data_type_name(snode->dt));
}
emit("} ");

Expand Down
1 change: 0 additions & 1 deletion taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ void export_lang(py::module &m) {
expr.cast<GlobalVariableExpression>()->is_primal = false;
});
m.def("data_type_name", data_type_name);
m.def("data_type_short_name", data_type_short_name);

m.def("subscript", [](const Expr &expr, const ExprGroup &expr_group) {
return expr[expr_group];
Expand Down
4 changes: 2 additions & 2 deletions taichi/transforms/ir_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class IRPrinter : public IRVisitor {
std::string reint =
stmt->op_type == UnaryOpType::cast_value ? "" : "reinterpret_";
print("{}{} = {}{}<{}> {}", stmt->type_hint(), stmt->name(), reint,
unary_op_type_name(stmt->op_type),
data_type_short_name(stmt->cast_type), stmt->operand->name());
unary_op_type_name(stmt->op_type), data_type_name(stmt->cast_type),
stmt->operand->name());
} else {
print("{}{} = {} {}", stmt->type_hint(), stmt->name(),
unary_op_type_name(stmt->op_type), stmt->operand->name());
Expand Down