| 389 | } // namespace |
| 390 | |
| 391 | Status Compile(const CompilationOptions& options, const GraphFloat32& model, |
| 392 | const std::unordered_set<int>& tflite_graph_io, |
| 393 | const NodeShader& node_shader, |
| 394 | const WorkgroupsCalculator& workgroup_calculator, |
| 395 | std::unique_ptr<CompiledModel>* compiled_model) { |
| 396 | if (!IsBatchMatchesForAllValues(model)) { |
| 397 | return InvalidArgumentError("Only identical batch dimension is supported"); |
| 398 | } |
| 399 | GpuInfo gpu_info; |
| 400 | RETURN_IF_ERROR(RequestGpuInfo(&gpu_info)); |
| 401 | if (!IsOpenGl31OrAbove(gpu_info)) { |
| 402 | return InternalError( |
| 403 | "OpenGL ES 3.1 or above is required to use OpenGL inference."); |
| 404 | } |
| 405 | auto compiled_model_impl = absl::make_unique<CompiledModelImpl>(gpu_info); |
| 406 | compiled_model_impl->set_dynamic_batch(options.dynamic_batch); |
| 407 | auto compiler = NewCompiler(&node_shader, &gpu_info, options); |
| 408 | RETURN_IF_ERROR( |
| 409 | compiler->Compile(model, tflite_graph_io, [&](ShaderCode code) -> Status { |
| 410 | return compiled_model_impl->Add(workgroup_calculator, std::move(code)); |
| 411 | })); |
| 412 | *compiled_model = std::move(compiled_model_impl); |
| 413 | return OkStatus(); |
| 414 | } |
| 415 | |
| 416 | #ifndef TFLITE_GPU_BINARY_RELEASE |
| 417 | Status ReadSerializedModel(const std::vector<uint8_t>& serialized_model, |