tensorflow/lite/tools/optimize/modify_model_interface_test.cc
// Create a model with 1 FC.
Create a model with 1 FC.
Create a model with 1 FC .
std::unique_ptr<ModelT> CreateFloatModel() {
  auto model = absl::make_unique<ModelT>();
  auto subgraph = absl::make_unique<tflite::SubGraphT>();
  auto buffer = absl::make_unique<tflite::BufferT>();
  auto fc_op_code = absl::make_unique<OperatorCodeT>();
  auto fc_op = absl::make_unique<OperatorT>();
  model->subgraphs.push_back(std::move(subgraph));
  fc_op_code->builtin_code = BuiltinOperator_FULLY_CONNECTED;
  fc_op_code->deprecated_builtin_code =
      static_cast<int8_t>(BuiltinOperator_FULLY_CONNECTED);
  fc_op_code->version = 2;
  fc_op->opcode_index = 0;
  fc_op->inputs = {0};
  fc_op->outputs = {1};
  model->subgraphs[0]->operators.push_back(std::move(fc_op));
  model->operator_codes.push_back(std::move(fc_op_code));
  model->subgraphs[0]->inputs = {0};
  model->subgraphs[0]->outputs = {1};
  auto tensor_0 = absl::make_unique<TensorT>();
  tensor_0->name = "tensor_0";
  tensor_0->shape = {};
  tensor_0->type = TensorType_FLOAT32;
  auto tensor_1 = absl::make_unique<TensorT>();
  tensor_1->name = "tensor_1";
  tensor_1->shape = {};
  tensor_1->type = TensorType_FLOAT32;
  model->subgraphs[0]->tensors.push_back(std::move(tensor_0));
  model->subgraphs[0]->tensors.push_back(std::move(tensor_1));
  model->buffers.push_back(std::move(buffer));
  return model;
}
std :: unique_ptr < ModelT > CreateFloatModel ( ) { auto model = absl :: make_unique < ModelT > ( ) ; auto subgraph = absl :: make_unique < tflite :: SubGraphT > ( ) ; auto buffer = absl :: make_unique < tflite :: BufferT > ( ) ; auto fc_op_code = absl :: make_unique < OperatorCodeT > ( ) ; auto fc_op = absl :: make_unique < OperatorT > ( ) ; model -> subgraphs . push_back ( std :: move ( subgraph ) ) ; fc_op_code -> builtin_code = BuiltinOperator_FULLY_CONNECTED ; fc_op_code -> deprecated_builtin_code = static_cast < int8_t > ( BuiltinOperator_FULLY_CONNECTED ) ; fc_op_code -> version = 2 ; fc_op -> opcode_index = 0 ; fc_op -> inputs = { 0 } ; fc_op -> outputs = { 1 } ; model -> subgraphs [ 0 ] -> operators . push_back ( std :: move ( fc_op ) ) ; model -> operator_codes . push_back ( std :: move ( fc_op_code ) ) ; model -> subgraphs [ 0 ] -> inputs = { 0 } ; model -> subgraphs [ 0 ] -> outputs = { 1 } ; auto tensor_0 = absl :: make_unique < TensorT > ( ) ; tensor_0 -> name = " " ; tensor_0 -> shape = { } ; tensor_0 -> type = TensorType_FLOAT32 ; auto tensor_1 = absl :: make_unique < TensorT > ( ) ; tensor_1 -> name = " " ; tensor_1 -> shape = { } ; tensor_1 -> type = TensorType_FLOAT32 ; model -> subgraphs [ 0 ] -> tensors . push_back ( std :: move ( tensor_0 ) ) ; model -> subgraphs [ 0 ] -> tensors . push_back ( std :: move ( tensor_1 ) ) ; model -> buffers . push_back ( std :: move ( buffer ) ) ; return model ; }
Create a model with 1 FC.
Create a model with 1 FC .
// Op code // Op. // Model input/output. // Tensors // Buffer