1 // 2 // Copyright (c) 2023 Apple Inc. All rights reserved. 3 // Provided subject to the LICENSE file in the top level directory. 4 // 5 6 #pragma once 7 8 #include <executorch/backends/apple/mps/runtime/MPSExecutor.h> 9 10 #include <executorch/runtime/backend/interface.h> 11 #include <executorch/runtime/core/memory_allocator.h> 12 #include <executorch/runtime/platform/compiler.h> 13 14 #include <memory> 15 #include <vector> 16 17 namespace executorch { 18 namespace backends { 19 namespace mps { 20 namespace delegate { 21 22 class MPSCompiler { 23 public: 24 // Takes Flatbuffer Serialized MPS Model and rebuilds the MPSGraphExecutable 25 // returns an executor object that holds the MPS runtime object which we 26 // can then use to set inputs and run inference using the MPSGraphExecutable. 27 ET_NODISCARD static executorch::runtime::Error compileModel( 28 const void* buffer_pointer, 29 size_t num_bytes, 30 MPSExecutor* executor, 31 executorch::runtime::MemoryAllocator* runtime_allocator, 32 executorch::runtime::ArrayRef<executorch::runtime::CompileSpec> 33 compile_specs); 34 }; 35 36 } // namespace delegate 37 } // namespace mps 38 } // namespace backends 39 } // namespace executorch 40