---
title: "BNNSGraphCompileFromFile(_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/bnnsgraphcompilefromfile(_:_:_:)"
---

# BNNSGraphCompileFromFile(_:_:_:)

Compiles a source mlmodelc file to a graph object.

## Declaration

```swift
func BNNSGraphCompileFromFile(_ filename: UnsafePointer<CChar>, _ function: UnsafePointer<CChar>?, _ options: bnns_graph_compile_options_t) -> bnns_graph_t
```

## Parameters

- `filename`: The path to the source mlmodelc file.
- `function`: The name of the function that this operation compiles. Pass nil to specify that the operation compiles all the functions in the source file.
- `options`: The compilation options. Pass nil to specify that the operation uses the default set of options.

## Return Value

Return Value A compiled graph object. If the operation fails, the graph object’s data property is nil.

## Discussion

Discussion Xcode automatically compiles a Core ML model package (files with an .mlpackage file extension) into an mlmodelc file. The following code compiles a bnns_graph_t instance from a file named myModel.mlpackage that you copy into the project. let options = BNNSGraphCompileOptionsMakeDefault() defer {     BNNSGraphCompileOptionsDestroy(options) }

guard let fileName = Bundle.main.url(     forResource: "myModel",     withExtension: "mlmodelc")?.path() else {     fatalError() }

let graph = BNNSGraphCompileFromFile(fileName,                                       nil,                                      options)

if graph.size == 0 {     fatalError() }

## See Also

### Related Documentation

- [Updating a Model File to a Model Package](coreml/updating-a-model-file-to-a-model-package.md)

### Compiling a graph object

- [bnns_graph_t](accelerate/bnns_graph_t.md)
