Skip to content

Allow explicit values naming #172

@tlemo

Description

@tlemo

Currently, the values are automatically "named" using a simple auto-incremented numeric id.

This means that using the C++ APIs allow meaningful names for C++ variables, but they will not match the IR names. At best, code ends up looking like this:

auto input_tv0 = makeDummyTensor(1);
auto exp_tv1 = unaryOp(UnaryOpType::Exp, input_tv0);
auto sum_exp_tv2 = sum(exp_tv1, {-1});
auto bcast_sum_tv3 = broadcast(sum_exp_tv2, {true});

One solution would be to allow setting explicit names for values. This would be optional (if not set explicitly we'd default to an auto-naming scheme like we do today).

An hypothetical solution which is backward compatible with the current API usage could look like this:

auto input = makeDummyTensor(1)->named("tv0");
auto exp = unaryOp(UnaryOpType::Exp, input_tv0)->named("tv1");
auto sum_exp = sum(exp_tv1, {-1})->named("tv2");
auto bcast_sum = broadcast(sum_exp_tv2, {true})->named("tv3");

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions