Skip to content

Commit

Permalink
Remove duplicated size check
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Mar 6, 2024
1 parent a1681db commit 974d8de
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ Status PadOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
ORT_RETURN_IF_NOT(ReadIntArrayFrom1DTensor(pads_tensor, pads, logger), "Error while read pads tensor");

// Constant value and axes are optional. Make sure they are not empty.
if (input_defs.size() >= 3 && !GetTensorName(input_defs, 2).empty()) {
if (!GetTensorName(input_defs, 2).empty()) {
const auto value_tensor = *initializers.at(input_defs[2]->Name());
emscripten::val value = emscripten::val::object();
ORT_RETURN_IF_NOT(ReadScalarTensorData(value_tensor, value, logger), "Cannot read constant value");
options.set("value", value);
}

if (input_defs.size() == 4 && !GetTensorName(input_defs, 3).empty()) {
if (!GetTensorName(input_defs, 3).empty()) {
const auto input_rank = input_shape.size();
std::vector<int64_t> axes;
const auto& axes_tensor = *initializers.at(input_defs[3]->Name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Status ReductionOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
if (opset >= 18 || (op_type == "ReduceSum" && opset >= 13)) {
// 'axes' is an optional input.
const auto noop_with_empty_axes = helper.Get("noop_with_empty_axes", 0);
if (input_defs.size() > 1 && !GetTensorName(input_defs, 1).empty()) {
if (!GetTensorName(input_defs, 1).empty()) {
// Optional input axes is provided, use axes initializer data.
const auto& initializers(model_builder.GetInitializerTensors());
const auto& axes_tensor = *initializers.at(input_defs[1]->Name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status SplitOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
axis = SafeInt<int32_t>(HandleNegativeAxis(axis, rank));
options.set("axis", axis);

if (input_defs.size() == 2 && !GetTensorName(input_defs, 1).empty()) {
if (!GetTensorName(input_defs, 1).empty()) {
// Inputs contains optional 'split' input
std::vector<int32_t> splits;
const auto& initializers(model_builder.GetInitializerTensors());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Status SqueezeUnsqueezeOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_buil
std::vector<int32_t> axes_data;
auto rank = input_rank;

if (node.SinceVersion() >= 13 && input_defs.size() > 1 && !GetTensorName(input_defs, 1).empty()) {
if (node.SinceVersion() >= 13 && !GetTensorName(input_defs, 1).empty()) {
// Input axes is provided, use axes initializer data.
const auto& initializers = model_builder.GetInitializerTensors();
const auto& axes_tensor = *initializers.at(input_defs[1]->Name());
Expand Down

0 comments on commit 974d8de

Please sign in to comment.