Skip to content

Commit

Permalink
[luci/pass] Revise FoldCastPass to use enum for types (Samsung#12398)
Browse files Browse the repository at this point in the history
This will revise FoldCastPass to use enum for possible cast types.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Jan 3, 2024
1 parent 094fc01 commit 92b4284
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions compiler/luci/pass/src/FoldCastPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ luci::CircleConst *cast_const(luci::CircleConst *node, loco::DataType from_dtype
{
assert(node->dtype() == from_dtype);

bool do_casting = false;
enum CAST_TYPES
{
CAST_NONE = 0,
CAST_S64_S32,
};

CAST_TYPES cast_type = CAST_NONE;
if (from_dtype == loco::DataType::S64)
{
if (to_dtype == loco::DataType::S32)
do_casting = true;
cast_type = CAST_S64_S32;
}
// TODO: Support more data types
if (not do_casting)
if (cast_type == CAST_NONE)
return nullptr;

auto name = node->name();
Expand All @@ -52,9 +58,9 @@ luci::CircleConst *cast_const(luci::CircleConst *node, loco::DataType from_dtype
constant->shape_status(luci::ShapeStatus::VALID);

// TODO: Support more data types
if (from_dtype == loco::DataType::S64)
switch (cast_type)
{
if (to_dtype == loco::DataType::S32)
case CAST_S64_S32:
{
constant->size<loco::DataType::S32>(num_elems);
for (uint32_t i = 0; i < num_elems; i++)
Expand All @@ -64,7 +70,8 @@ luci::CircleConst *cast_const(luci::CircleConst *node, loco::DataType from_dtype
constant->name(name + "_S32");
return constant;
}
return nullptr;
default:
break;
}

return nullptr;
Expand Down

0 comments on commit 92b4284

Please sign in to comment.