| 208 | } // namespace |
| 209 | |
| 210 | std::unique_ptr<Model> Import(const TocoFlags& toco_flags, |
| 211 | const ModelFlags& model_flags, |
| 212 | const string& input_file_contents) { |
| 213 | std::unique_ptr<Model> model; |
| 214 | switch (toco_flags.input_format()) { |
| 215 | case TENSORFLOW_GRAPHDEF: { |
| 216 | TensorFlowImportFlags tf_import_flags; |
| 217 | tf_import_flags.drop_control_dependency = |
| 218 | toco_flags.has_drop_control_dependency() |
| 219 | ? toco_flags.drop_control_dependency() |
| 220 | : (toco_flags.output_format() != TENSORFLOW_GRAPHDEF); |
| 221 | |
| 222 | tf_import_flags.import_all_ops_as_unsupported = |
| 223 | toco_flags.force_select_tf_ops(); |
| 224 | |
| 225 | model = ImportTensorFlowGraphDef(model_flags, tf_import_flags, |
| 226 | input_file_contents); |
| 227 | break; |
| 228 | } |
| 229 | case TFLITE: |
| 230 | model = toco::tflite::Import(model_flags, input_file_contents); |
| 231 | ResolveModelFlags(model_flags, model.get()); |
| 232 | CheckInvariants(*model); |
| 233 | break; |
| 234 | default: |
| 235 | LOG(FATAL) << "Unhandled input_format='" |
| 236 | << FileFormat_Name(toco_flags.input_format()) << "'"; |
| 237 | } |
| 238 | |
| 239 | LogDump(kLogLevelModelChanged, "AT IMPORT", *model); |
| 240 | |
| 241 | return model; |
| 242 | } |
| 243 | |
| 244 | tensorflow::Status TransformWithStatus(const TocoFlags& toco_flags, |
| 245 | Model* model) { |
no test coverage detected