Skip to content

Commit

Permalink
[luci/service] Remove useless null check (#14517)
Browse files Browse the repository at this point in the history
This commit removes null check created by loco::NodePool::create().
When node creation fails, it throws an exception instead of returning nullptr.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Jan 3, 2025
1 parent 090b8c3 commit 0dc8806
Show file tree
Hide file tree
Showing 64 changed files with 39 additions and 103 deletions.
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleAdd *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleAdd>();
if (cloned != nullptr)
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->fusedActivationFunction(node->fusedActivationFunction());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleArgMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleArgMax *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleArgMax>();
if (cloned != nullptr)
cloned->output_type(node->output_type());
cloned->output_type(node->output_type());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleArgMin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleArgMin *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleArgMin>();
if (cloned != nullptr)
cloned->output_type(node->output_type());
cloned->output_type(node->output_type());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleAveragePool2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleAveragePool2D *
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleAveragePool2D>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->padding(node->padding());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ luci::CircleNode *CloneNode::visit(const luci::CircleBCQFullyConnected *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleBCQFullyConnected>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->weights_hidden_size(node->weights_hidden_size());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleBCQGather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleBCQGather *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleBCQGather>();
if (cloned != nullptr)
{
cloned->axis(node->axis());
cloned->input_hidden_size(node->input_hidden_size());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleBatchMatMul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleBatchMatMul *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleBatchMatMul>();
if (cloned != nullptr)
{
cloned->adj_x(node->adj_x());
cloned->adj_y(node->adj_y());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleCast *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleCast>();
if (cloned != nullptr)
{
cloned->in_data_type(node->in_data_type());
cloned->out_data_type(node->out_data_type());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleConcatenation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleConcatenation *
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleConcatenation>(node->numValues());
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->axis(node->axis());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ luci::CircleConst *clone_circleconst(const luci::CircleConst *node, loco::Graph
{
auto cloned = graph->nodes()->create<luci::CircleConst>();

if (cloned != nullptr)
{
// dtype/shape
cloned->dtype(node->dtype());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleConv2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleConv2D *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleConv2D>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->padding(node->padding());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ luci::CircleNode *CloneNodeLet<CN::ABC>::visit(const luci::CircleCustom *node)
uint32_t num_in = node->numInputs();
uint32_t num_out = node->numOutputs();
auto *cloned = _graph->nodes()->create<luci::CircleCustom>(num_in, num_out);
if (cloned != nullptr)
{
cloned->custom_options(node->custom_options());
cloned->custom_code(node->custom_code());
Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleCustomOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleCustomOut *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleCustomOut>();
if (cloned != nullptr)
cloned->index(node->index());
cloned->index(node->index());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleDepthToSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::DEF>::visit(const luci::CircleDepthToSpace *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleDepthToSpace>();
if (cloned != nullptr)
cloned->block_size(node->block_size());
cloned->block_size(node->block_size());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleDepthwiseConv2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ luci::CircleNode *CloneNodeLet<CN::DEF>::visit(const luci::CircleDepthwiseConv2D
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleDepthwiseConv2D>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->padding(node->padding());
Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleDiv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ luci::CircleNode *CloneNodeLet<CN::DEF>::visit(const luci::CircleDiv *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleDiv>();
if (cloned != nullptr)
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->fusedActivationFunction(node->fusedActivationFunction());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleFakeQuant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::DEF>::visit(const luci::CircleFakeQuant *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleFakeQuant>();
if (cloned != nullptr)
{
cloned->min(node->min());
cloned->max(node->max());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleFullyConnected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ luci::CircleNode *CloneNodeLet<CN::DEF>::visit(const luci::CircleFullyConnected
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleFullyConnected>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->weights_format(node->weights_format());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleGRU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ luci::CircleNode *CloneNode::visit(const luci::CircleGRU *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleGRU>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->returnSequences(node->returnSequences());
Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleGather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::GHIJ>::visit(const luci::CircleGather *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleGather>();
if (cloned != nullptr)
cloned->axis(node->axis());
cloned->axis(node->axis());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleGelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::GHIJ>::visit(const luci::CircleGelu *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleGelu>();
if (cloned != nullptr)
cloned->approximate(node->approximate());
cloned->approximate(node->approximate());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleIfOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleIfOut *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleIfOut>();
if (cloned != nullptr)
cloned->index(node->index());
cloned->index(node->index());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleL2Normalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleL2Normalize *n
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleL2Normalize>();
if (cloned != nullptr)
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->fusedActivationFunction(node->fusedActivationFunction());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleL2Pool2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleL2Pool2D *node
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleL2Pool2D>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->padding(node->padding());
Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleLeakyRelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleLeakyRelu *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleLeakyRelu>();
if (cloned != nullptr)
cloned->alpha(node->alpha());
cloned->alpha(node->alpha());
return cloned;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleLocalResponseNormalization *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleLocalResponseNormalization>();
if (cloned != nullptr)
{
cloned->radius(node->radius());
cloned->bias(node->bias());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleMaxPool2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleMaxPool2D *nod
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleMaxPool2D>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->padding(node->padding());
Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleMean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleMean *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleMean>();
if (cloned != nullptr)
cloned->keep_dims(node->keep_dims());
cloned->keep_dims(node->keep_dims());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleMirrorPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleMirrorPad *nod
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleMirrorPad>();
if (cloned != nullptr)
cloned->mode(node->mode());
cloned->mode(node->mode());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleMul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ luci::CircleNode *CloneNodeLet<CN::KLMN>::visit(const luci::CircleMul *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleMul>();
if (cloned != nullptr)
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->fusedActivationFunction(node->fusedActivationFunction());
return cloned;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleNonMaxSuppressionV4Out *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleNonMaxSuppressionV4Out>();
if (cloned != nullptr)
cloned->index(node->index());
cloned->index(node->index());
return cloned;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleNonMaxSuppressionV5Out *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleNonMaxSuppressionV5Out>();
if (cloned != nullptr)
cloned->index(node->index());
cloned->index(node->index());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleOneHot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleOneHot *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleOneHot>();
if (cloned != nullptr)
cloned->axis(node->axis());
cloned->axis(node->axis());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CirclePack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CirclePack *node)
{
auto *cloned = _graph->nodes()->create<luci::CirclePack>(node->values_count());
if (cloned != nullptr)
cloned->axis(node->axis());
cloned->axis(node->axis());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleReduceAny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReduceAny *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReduceAny>();
if (cloned != nullptr)
cloned->keep_dims(node->keep_dims());
cloned->keep_dims(node->keep_dims());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleReduceMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReduceMax *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReduceMax>();
if (cloned != nullptr)
cloned->keep_dims(node->keep_dims());
cloned->keep_dims(node->keep_dims());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleReduceMin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReduceMin *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReduceMin>();
if (cloned != nullptr)
cloned->keep_dims(node->keep_dims());
cloned->keep_dims(node->keep_dims());
return cloned;
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/luci/service/src/Nodes/CircleReduceProd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReduceProd *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReduceProd>();
if (cloned != nullptr)
cloned->keep_dims(node->keep_dims());
cloned->keep_dims(node->keep_dims());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleReshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReshape *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReshape>();
if (cloned != nullptr)
{
uint32_t rank = node->newShape()->rank();
cloned->newShape()->rank(rank);
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleResizeBilinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleResizeBilinear *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleResizeBilinear>();
if (cloned != nullptr)
{
cloned->align_corners(node->align_corners());
cloned->half_pixel_centers(node->half_pixel_centers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleResizeNearestNeighbor *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleResizeNearestNeighbor>();
if (cloned != nullptr)
cloned->align_corners(node->align_corners());
cloned->align_corners(node->align_corners());
return cloned;
}

Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleReverseSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNodeLet<CN::OPQR>::visit(const luci::CircleReverseSequence *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleReverseSequence>();
if (cloned != nullptr)
{
cloned->seq_axis(node->seq_axis());
cloned->batch_axis(node->batch_axis());
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleRmsNorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace luci
luci::CircleNode *CloneNode::visit(const luci::CircleRmsNorm *node)
{
auto *cloned = _graph->nodes()->create<luci::CircleRmsNorm>();
if (cloned != nullptr)
{
cloned->epsilon(node->epsilon());
}
Expand Down
1 change: 0 additions & 1 deletion compiler/luci/service/src/Nodes/CircleSVDF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ luci::CircleNode *CloneNodeLet<CN::STUV>::visit(const luci::CircleSVDF *node)
return nullptr;

auto *cloned = _graph->nodes()->create<luci::CircleSVDF>();
if (cloned != nullptr)
{
cloned->fusedActivationFunction(node->fusedActivationFunction());
cloned->asymmetric_quantize_inputs(node->asymmetric_quantize_inputs());
Expand Down
Loading

0 comments on commit 0dc8806

Please sign in to comment.