---
title: "allocate(as:count:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/bnnstensor/allocate(as:count:)"
---

# allocate(as:count:)

Allocates a tensor with existing size and stride populated by Context.tensor(forFunction:argument:fillKnownDynamicShapes:).

## Declaration

```swift
mutating func allocate<T>(as scalarType: T.Type, count: Int) where T : BNNSScalar
```

## Parameters

- `scalarType`: The data type.
- `count`: The allocation size represented by the count of scalarType elements.
