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

# allocate(initializingFrom:)

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

## Declaration

```swift
mutating func allocate<T>(initializingFrom source: some AccelerateBuffer) where T : BNNSScalar
```

## Parameters

- `source`: The collection that provides the source elements.

## Discussion

Discussion This function copies the data in source to the tensor and sets the tensor’s data_type property to that of the source collection’s elements.
