Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 706887638
  • Loading branch information
ai-edge-bot authored and copybara-github committed Dec 18, 2024
1 parent ae94f57 commit 2af84d4
Show file tree
Hide file tree
Showing 48 changed files with 109 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ limitations under the License.

namespace toco {

::tensorflow::Status RemoveTrivialConcatenationInput::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status RemoveTrivialConcatenationInput::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
// TensorFlow allows Concatenation nodes to have 0-D inputs,
// and they are then treated as empty i.e. omitted from concatenation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ bool IsFakeQuantTrivial(GraphTransformation* transformation, const Model& model,
} // namespace

// Removes FakeQuant ops that are trivial (have no effect, are redundant, etc).
::tensorflow::Status RemoveTrivialFakeQuant::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status RemoveTrivialFakeQuant::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto op_it = model->operators.begin() + op_index;
auto* op = op_it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ bool IsTrivialFusedActivationFunc(
// Attempts to remove both fused and unfused activation functions if the
// quantization params indicate that the representable values fall inside the
// activation range.
::tensorflow::Status RemoveTrivialQuantizedActivationFunc::Run(
Model* model, std::size_t op_index, bool* modified) {
absl::Status RemoveTrivialQuantizedActivationFunc::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
auto* op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ bool IsTrivialMinMax(GraphTransformation* transformation, const Model& model,

// Attempts to remove min/max functions if the quantization params indicate that
// the representable values fall inside the clip range.
::tensorflow::Status RemoveTrivialQuantizedMinMax::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status RemoveTrivialQuantizedMinMax::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
auto* op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/remove_trivial_reshape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ bool IsReshapeTrivial(const Model& model, const Operator& op,

} // namespace

::tensorflow::Status RemoveTrivialReshape::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status RemoveTrivialReshape::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto reshape_it = model->operators.begin() + op_index;
auto* reshape_op = reshape_it->get();
Expand Down
4 changes: 2 additions & 2 deletions tflite/toco/graph_transformations/remove_trivial_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ bool IsSliceTrivial(const Model& model, const Operator& op,

} // namespace

::tensorflow::Status RemoveTrivialSlice::Run(Model* model, std::size_t op_index,
bool* modified) {
absl::Status RemoveTrivialSlice::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto reshape_it = model->operators.begin() + op_index;
auto* slice_op = reshape_it->get();
Expand Down
4 changes: 2 additions & 2 deletions tflite/toco/graph_transformations/remove_unused_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status RemoveUnusedOp::Run(Model* model, std::size_t op_index,
bool* modified) {
absl::Status RemoveUnusedOp::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
const auto* op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ bool IsMoveOperator(OperatorType optype) {

// Swap elementwise operators such that all value operators occur before all
// element move operators, e.g. negation then transpose.
::tensorflow::Status ReorderElementwiseUnary::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ReorderElementwiseUnary::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto element_op_it = model->operators.begin() + op_index;
std::unique_ptr<Operator>& element_op = *element_op_it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ std::vector<int> ComputeNewPerm(std::vector<int> input_dims,

// Swaps reshape-transpose to transpose-reshape whenever possible. This is
// possible when the reshape does not affect memory ordering.
::tensorflow::Status ReorderReshapeTranspose::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ReorderReshapeTranspose::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto transpose_it = model->operators.begin() + op_index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolveBatchNormalization::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveBatchNormalization::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto bn_it = model->operators.begin() + op_index;
if (bn_it->get()->type != OperatorType::kBatchNormalization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolveBatchToSpaceNDAttributes::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveBatchToSpaceNDAttributes::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto op_it = model->operators.begin() + op_index;
if (op_it->get()->type != OperatorType::kBatchToSpaceND)
Expand Down
6 changes: 3 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ bool EvaluateBinaryOperatorOnConstantInputs(Model* model,
}
} // namespace

::tensorflow::Status ResolveConstantBinaryOperator::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantBinaryOperator::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto binary_it = model->operators.begin() + op_index;
const auto* binary_op = binary_it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ void SetMinMaxForConcatenedArray(GraphTransformation* transformation,
} // namespace

// Resolves the concatenation operator if all its inputs are constant arrays.
::tensorflow::Status ResolveConstantConcatenation::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantConcatenation::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto concat_it = model->operators.begin() + op_index;
const auto* concat_base_op = concat_it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ void GetBoundsForQuantizedDataType(ArrayDataType quantized_data_type,
}
}

::tensorflow::Status ResolveConstantFakeQuant::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantFakeQuant::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto fakequant_it = model->operators.begin() + op_index;
const auto* fakequant_base_op = fakequant_it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_fill.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ bool ComputeFillArray(Model* model, FillOperator* op) {
return true;
}

::tensorflow::Status ResolveConstantFill::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantFill::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto fill_it = model->operators.begin() + op_index;
auto* base_op = fill_it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_gather.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ inline void Gather(const Array& input_array, const Array& coords_array,
// Resolves a constant Gather operation.
// This simply performs the gather and produces the output array with the
// appropriate values.
::tensorflow::Status ResolveConstantGather::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantGather::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_pack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ void Pack(Model* model, PackOperator const& op) {

} // namespace

::tensorflow::Status ResolveConstantPack::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantPack::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ bool ComputeRandomUniformArray(Model* model, RandomUniformOperator* op) {
return true;
}

::tensorflow::Status ResolveConstantRandomUniform::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantRandomUniform::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
auto* base_op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ void FillRangeOutput(const Array& start_array, const Array& limit_array,
CHECK_EQ(buffer.data.size(), output_array->shape().dims()[0]);
}

::tensorflow::Status ResolveConstantRange::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantRange::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
auto* base_op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_reshape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ limitations under the License.
namespace toco {

// Resolves a constant reshape operation by copying the buffer.
::tensorflow::Status ResolveConstantReshape::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantReshape::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ namespace toco {
// This implementation is looking strictly for all-or-nothing on the select
// condition. It's possible to enhance this by looking per-element and possibly
// producing a Mul op.
::tensorflow::Status ResolveConstantSelect::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantSelect::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolveConstantShapeOrRank::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantShapeOrRank::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
const auto* op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ bool Slice(SliceOperator const& op, Array const& input_array,

} // namespace

::tensorflow::Status ResolveConstantSlice::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantSlice::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ void StridedSlice(StridedSliceOperator const& op, Array const& input_array,

} // anonymous namespace

::tensorflow::Status ResolveConstantStridedSlice::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantStridedSlice::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_tile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ inline void Tile(const Array& input_array, const Array& multiples_array,
} // namespace

// Resolves a constant Tile operation.
::tensorflow::Status ResolveConstantTile::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantTile::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ void Transpose(Model* model, const Array& input_array,

} // namespace

::tensorflow::Status ResolveConstantTranspose::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantTranspose::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto it = model->operators.begin() + op_index;
const auto* base_op = it->get();
Expand Down
6 changes: 3 additions & 3 deletions tflite/toco/graph_transformations/resolve_constant_unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ bool CopyMinMaxFromFirstInput(const Operator& op, Model* model) {
return true;
}

::tensorflow::Status ResolveConstantUnaryOperator::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveConstantUnaryOperator::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto unary_it = model->operators.begin() + op_index;
const auto* unary_op = unary_it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolveFakeQuantArgsFromVars::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveFakeQuantArgsFromVars::Run(Model* model,
std::size_t op_index,
bool* modified) {
*modified = false;
const auto fakequant_it = model->operators.begin() + op_index;
auto* fakequant_base_op = fakequant_it->get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolveGatherAttributes::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveGatherAttributes::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
auto* gather_op = model->operators[op_index].get();
if (gather_op->type != OperatorType::kGather) return absl::OkStatus();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_multiply_by_zero.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ void FillArrayWithZeros(Array* array) {
// Removes a multiplication by array of constant zeros by making the output
// array to an array of constant zeros and removing the input arrays if they
// are no longer needed.
::tensorflow::Status ResolveMultiplyByZero::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolveMultiplyByZero::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto mul_it = model->operators.begin() + op_index;
auto* mul_op = mul_it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_pad_attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolvePadAttributes::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolvePadAttributes::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto pad_it = model->operators.begin() + op_index;
auto* pad_op = pad_it->get();
Expand Down
5 changes: 2 additions & 3 deletions tflite/toco/graph_transformations/resolve_padv2_attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ limitations under the License.

namespace toco {

::tensorflow::Status ResolvePadV2Attributes::Run(Model* model,
std::size_t op_index,
bool* modified) {
absl::Status ResolvePadV2Attributes::Run(Model* model, std::size_t op_index,
bool* modified) {
*modified = false;
const auto pad_it = model->operators.begin() + op_index;
auto* pad_op = pad_it->get();
Expand Down
Loading

0 comments on commit 2af84d4

Please sign in to comment.