aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/toco/tflite
diff options
context:
space:
mode:
authorGravatar Yu-Cheng Ling <ycling@google.com>2018-09-27 14:25:18 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-27 14:30:11 -0700
commitd0397c3314600da0c9cdc300ae87483331d54298 (patch)
tree8ec45f483facaa2219324a19a7f74e38e2e0a5e2 /tensorflow/contrib/lite/toco/tflite
parentcc83067469bc30bba55932c587f31ef68f15792f (diff)
Rename TFLite Eager delegate -> Flex delegate
PiperOrigin-RevId: 214835588
Diffstat (limited to 'tensorflow/contrib/lite/toco/tflite')
-rw-r--r--tensorflow/contrib/lite/toco/tflite/export.cc20
-rw-r--r--tensorflow/contrib/lite/toco/tflite/export.h4
-rw-r--r--tensorflow/contrib/lite/toco/tflite/export_test.cc2
-rw-r--r--tensorflow/contrib/lite/toco/tflite/operator.cc26
-rw-r--r--tensorflow/contrib/lite/toco/tflite/operator.h6
5 files changed, 29 insertions, 29 deletions
diff --git a/tensorflow/contrib/lite/toco/tflite/export.cc b/tensorflow/contrib/lite/toco/tflite/export.cc
index 9f60942f47..0c9fac249c 100644
--- a/tensorflow/contrib/lite/toco/tflite/export.cc
+++ b/tensorflow/contrib/lite/toco/tflite/export.cc
@@ -50,16 +50,16 @@ namespace {
details::OperatorKey GetOperatorKey(
const ::toco::Operator& op,
const std::map<OperatorType, std::unique_ptr<BaseOperator>>& ops_by_type,
- bool allow_eager_ops) {
+ bool allow_flex_ops) {
string custom_code;
if (op.type == OperatorType::kUnsupported) {
const TensorFlowUnsupportedOperator& unsupported_op =
static_cast<const TensorFlowUnsupportedOperator&>(op);
- // TODO(b/113715895): When `allow_eager_ops` is on, for now there's no way
+ // TODO(b/113715895): When `allow_flex_ops` is on, for now there's no way
// to populate a regular custom op. We need to find a way to fix this.
- if (allow_eager_ops) {
- custom_code = string(::tflite::kEagerCustomCodePrefix) +
+ if (allow_flex_ops) {
+ custom_code = string(::tflite::kFlexCustomCodePrefix) +
unsupported_op.tensorflow_op;
} else {
custom_code = unsupported_op.tensorflow_op;
@@ -101,11 +101,11 @@ void LoadTensorsMap(const Model& model, TensorsMap* tensors_map) {
void LoadOperatorsMap(
const Model& model, OperatorsMap* operators_map,
const std::map<OperatorType, std::unique_ptr<BaseOperator>>& ops_by_type,
- bool allow_eager_ops) {
+ bool allow_flex_ops) {
// First find a list of unique operator types.
std::set<OperatorKey> keys;
for (const auto& op : model.operators) {
- keys.insert(GetOperatorKey(*op, ops_by_type, allow_eager_ops));
+ keys.insert(GetOperatorKey(*op, ops_by_type, allow_flex_ops));
}
// Now assign indices to them and fill in the map.
int index = 0;
@@ -216,7 +216,7 @@ Offset<Vector<Offset<OperatorCode>>> ExportOperatorCodes(
for (const auto& op : model.operators) {
const details::OperatorKey operator_key =
- GetOperatorKey(*op, ops_by_type, params.allow_eager_ops);
+ GetOperatorKey(*op, ops_by_type, params.allow_flex_ops);
int op_index = operators_map.at(operator_key);
int op_version = operator_key.version;
@@ -281,7 +281,7 @@ Offset<Vector<Offset<Operator>>> ExportOperators(
}
int op_index = operators_map.at(
- GetOperatorKey(*op, ops_by_type, params.allow_eager_ops));
+ GetOperatorKey(*op, ops_by_type, params.allow_flex_ops));
auto tflite_op_it = ops_by_type.find(op->type);
BaseOperator* tflite_op = tflite_op_it == ops_by_type.end()
@@ -334,7 +334,7 @@ Offset<Vector<Offset<Buffer>>> ExportBuffers(
void Export(const Model& model, string* output_file_contents,
const ExportParams& params) {
- const auto ops_by_type = BuildOperatorByTypeMap(params.allow_eager_ops);
+ const auto ops_by_type = BuildOperatorByTypeMap(params.allow_flex_ops);
Export(model, output_file_contents, params, ops_by_type);
}
@@ -349,7 +349,7 @@ void Export(
details::OperatorsMap operators_map;
details::LoadOperatorsMap(model, &operators_map, ops_by_type,
- params.allow_eager_ops);
+ params.allow_flex_ops);
std::vector<const Array*> buffers_to_write;
Array empty_array;
diff --git a/tensorflow/contrib/lite/toco/tflite/export.h b/tensorflow/contrib/lite/toco/tflite/export.h
index b070a38768..29d6de4049 100644
--- a/tensorflow/contrib/lite/toco/tflite/export.h
+++ b/tensorflow/contrib/lite/toco/tflite/export.h
@@ -26,7 +26,7 @@ namespace tflite {
// The parameters for exporting a TFLite model.
struct ExportParams {
bool allow_custom_ops = false;
- bool allow_eager_ops = false;
+ bool allow_flex_ops = false;
bool quantize_weights = false;
};
@@ -121,7 +121,7 @@ void LoadTensorsMap(const Model& model, TensorsMap* tensors_map);
void LoadOperatorsMap(
const Model& model, OperatorsMap* operators_map,
const std::map<OperatorType, std::unique_ptr<BaseOperator>>& ops_by_type,
- bool allow_eager_ops);
+ bool allow_flex_ops);
} // namespace details
} // namespace tflite
diff --git a/tensorflow/contrib/lite/toco/tflite/export_test.cc b/tensorflow/contrib/lite/toco/tflite/export_test.cc
index 8d4d197c46..93882a91a7 100644
--- a/tensorflow/contrib/lite/toco/tflite/export_test.cc
+++ b/tensorflow/contrib/lite/toco/tflite/export_test.cc
@@ -105,7 +105,7 @@ TEST_F(ExportTest, LoadOperatorsMap) {
details::OperatorsMap operators;
const auto ops_by_type = BuildOperatorByTypeMap();
- // TODO(ycling): Add a test for allow_eager_ops.
+ // TODO(ycling): Add a test for allow_flex_ops.
details::LoadOperatorsMap(input_model_, &operators, ops_by_type, false);
EXPECT_EQ(0, operators[details::OperatorKey(OperatorType::kAdd, "", 1)]);
EXPECT_EQ(1, operators[details::OperatorKey(OperatorType::kConv, "", 1)]);
diff --git a/tensorflow/contrib/lite/toco/tflite/operator.cc b/tensorflow/contrib/lite/toco/tflite/operator.cc
index ca2a6a19b3..9addbb81e7 100644
--- a/tensorflow/contrib/lite/toco/tflite/operator.cc
+++ b/tensorflow/contrib/lite/toco/tflite/operator.cc
@@ -1160,8 +1160,8 @@ class Unpack : public BuiltinOperator<UnpackOperator, ::tflite::UnpackOptions,
class TensorFlowUnsupported : public BaseOperator {
public:
TensorFlowUnsupported(const string& name, OperatorType type,
- bool allow_eager_ops)
- : BaseOperator(name, type), allow_eager_ops_(allow_eager_ops) {}
+ bool allow_flex_ops)
+ : BaseOperator(name, type), allow_flex_ops_(allow_flex_ops) {}
Options Serialize(const Operator& op,
flatbuffers::FlatBufferBuilder* builder) const override {
@@ -1177,9 +1177,9 @@ class TensorFlowUnsupported : public BaseOperator {
std::unique_ptr<Operator> Deserialize(
const BuiltinOptions* builtin_options,
const CustomOptions* custom_options) const override {
- // Deserializing Eager ops doesn't work now.
+ // Deserializing Flex ops doesn't work now.
// TODO(ycling): Revisit and decide if we should fix the flow for importing
- // TFLite models with Eager ops.
+ // TFLite models with Flex ops.
auto op = absl::make_unique<TensorFlowUnsupportedOperator>();
if (custom_options) {
auto flexbuffer_map =
@@ -1200,13 +1200,13 @@ class TensorFlowUnsupported : public BaseOperator {
return std::unique_ptr<flexbuffers::Builder>();
}
- if (allow_eager_ops_) {
+ if (allow_flex_ops_) {
fbb->Vector([&]() {
fbb->String(node_def.op());
fbb->String(op.tensorflow_node_def);
});
fbb->Finish();
- LOG(INFO) << "Writing eager op: " << node_def.op();
+ LOG(INFO) << "Writing flex op: " << node_def.op();
return std::unique_ptr<flexbuffers::Builder>(fbb.release());
}
@@ -1316,13 +1316,13 @@ class TensorFlowUnsupported : public BaseOperator {
}
private:
- const bool allow_eager_ops_;
+ const bool allow_flex_ops_;
};
namespace {
// Build a vector containing all the known operators.
std::vector<std::unique_ptr<BaseOperator>> BuildOperatorList(
- bool allow_eager_ops = false) {
+ bool allow_flex_ops = false) {
std::vector<std::unique_ptr<BaseOperator>> ops;
using tensorflow::MakeUnique;
// Builtin Operators.
@@ -1434,7 +1434,7 @@ std::vector<std::unique_ptr<BaseOperator>> BuildOperatorList(
ops.push_back(MakeUnique<CTCBeamSearchDecoder>(
"CTC_BEAM_SEARCH_DECODER", OperatorType::kCTCBeamSearchDecoder));
ops.push_back(MakeUnique<TensorFlowUnsupported>(
- "TENSORFLOW_UNSUPPORTED", OperatorType::kUnsupported, allow_eager_ops));
+ "TENSORFLOW_UNSUPPORTED", OperatorType::kUnsupported, allow_flex_ops));
// There operators are supported by Toco, but not by TF Lite, and has no
// attributes.
@@ -1512,11 +1512,11 @@ std::vector<std::unique_ptr<BaseOperator>> BuildOperatorList(
} // namespace
std::map<OperatorType, std::unique_ptr<BaseOperator>> BuildOperatorByTypeMap(
- bool allow_eager_ops) {
+ bool allow_flex_ops) {
std::map<OperatorType, std::unique_ptr<BaseOperator>> result;
std::vector<std::unique_ptr<BaseOperator>> ops =
- BuildOperatorList(allow_eager_ops);
+ BuildOperatorList(allow_flex_ops);
for (auto& op : ops) {
result[op->type()] = std::move(op);
}
@@ -1525,11 +1525,11 @@ std::map<OperatorType, std::unique_ptr<BaseOperator>> BuildOperatorByTypeMap(
}
std::map<string, std::unique_ptr<BaseOperator>> BuildOperatorByNameMap(
- bool allow_eager_ops) {
+ bool allow_flex_ops) {
std::map<string, std::unique_ptr<BaseOperator>> result;
std::vector<std::unique_ptr<BaseOperator>> ops =
- BuildOperatorList(allow_eager_ops);
+ BuildOperatorList(allow_flex_ops);
for (auto& op : ops) {
result[op->name()] = std::move(op);
}
diff --git a/tensorflow/contrib/lite/toco/tflite/operator.h b/tensorflow/contrib/lite/toco/tflite/operator.h
index 702fb28ea6..13d9f6c49a 100644
--- a/tensorflow/contrib/lite/toco/tflite/operator.h
+++ b/tensorflow/contrib/lite/toco/tflite/operator.h
@@ -26,15 +26,15 @@ namespace tflite {
class BaseOperator;
// Return a map contained all know TF Lite Operators, keyed by their names.
-// TODO(ycling): The pattern to propagate parameters (e.g. allow_eager_ops)
+// TODO(ycling): The pattern to propagate parameters (e.g. allow_flex_ops)
// is ugly here. Consider refactoring.
std::map<string, std::unique_ptr<BaseOperator>> BuildOperatorByNameMap(
- bool allow_eager_ops = false);
+ bool allow_flex_ops = false);
// Return a map contained all know TF Lite Operators, keyed by the type of
// their tf.mini counterparts.
std::map<OperatorType, std::unique_ptr<BaseOperator>> BuildOperatorByTypeMap(
- bool allow_eager_ops = false);
+ bool allow_flex_ops = false);
// These are the flatbuffer types for custom and builtin options.
using CustomOptions = flatbuffers::Vector<uint8_t>;