---
title: BNNSGraph.Context
framework: accelerate
role: symbol
role_heading: Class
path: accelerate/bnnsgraph/context
---

# BNNSGraph.Context

A wrapper around a compiled graph object that adds a required modifiable context to support dynamically sized models and set execute-time options.

## Declaration

```swift
class Context
```

## Overview

Overview A BNNSGraph.Context instance provides a wrapper around the C API bnns_graph_t and bnns_graph_context_t types. Because this class manages its own memory, you don’t need to call BNNSGraphContextDestroy(_:) to deallocate its resources.

## Topics

### Creating a graph context

- [BNNSGraph.CompileOptions](accelerate/bnnsgraph/compileoptions.md)

### Specifying and querying a graph context’s properties

- [setDynamicShapes(_:forFunction:)](accelerate/bnnsgraph/context/setdynamicshapes(_:forfunction:).md)
- [BNNSGraph.Shape](accelerate/bnnsgraph/shape.md)
- [argumentCount(forFunction:)](accelerate/bnnsgraph/context/argumentcount(forfunction:).md)
- [argumentNames(forFunction:)](accelerate/bnnsgraph/context/argumentnames(forfunction:).md)
- [argumentPosition(forFunction:argument:)](accelerate/bnnsgraph/context/argumentposition(forfunction:argument:).md)
- [functionCount](accelerate/bnnsgraph/context/functioncount.md)
- [functionNames](accelerate/bnnsgraph/context/functionnames.md)
- [checkForNaNsAndInfinities](accelerate/bnnsgraph/context/checkfornansandinfinities.md)

### Specifying a tensor’s properties

- [tensor(forFunction:argument:fillKnownDynamicShapes:)](accelerate/bnnsgraph/context/tensor(forfunction:argument:fillknowndynamicshapes:).md)

### Executing a graph

- [executeFunction(_:arguments:)](accelerate/bnnsgraph/context/executefunction(_:arguments:)-8bhcn.md)
- [executeFunction(_:arguments:)](accelerate/bnnsgraph/context/executefunction(_:arguments:)-95snr.md)
- [BNNSGraph.PointerArgument](accelerate/bnnsgraph/pointerargument.md)

### Handling errors

- [BNNSGraph.Error](accelerate/bnnsgraph/error.md)

### Initializers

- [init(compileFromPath:functionName:options:)](accelerate/bnnsgraph/context/init(compilefrompath:functionname:options:)-3nn5g.md)
- [init(compileFromPath:functionName:options:)](accelerate/bnnsgraph/context/init(compilefrompath:functionname:options:)-6ghot.md)

### Instance Properties

- [streamingAdvanceCount](accelerate/bnnsgraph/context/streamingadvancecount.md)

### Instance Methods

- [allocateTensor(forFunction:argument:fillKnownDynamicShapes:)](accelerate/bnnsgraph/context/allocatetensor(forfunction:argument:fillknowndynamicshapes:).md)
- [executeFunction(_:arguments:)](accelerate/bnnsgraph/context/executefunction(_:arguments:)-52eh3.md)
- [setBatchSize(_:forFunction:)](accelerate/bnnsgraph/context/setbatchsize(_:forfunction:)-4872x.md)
- [setBatchSize(_:forFunction:)](accelerate/bnnsgraph/context/setbatchsize(_:forfunction:)-8eqzm.md)
