<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSTensor/allocate(initializingFrom:shape:stride:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:So10BNNSTensora10AccelerateE8allocate16initializingFrom5shape6strideABx_SaySiGAHtAC0B6BufferRzAC10BNNSScalar7ElementRpzlFZ"
  },
  "title" : "allocate(initializingFrom:shape:stride:)"
}
-->

# allocate(initializingFrom:shape:stride:)

Creates a `BNNSTensor` populated with a **copy** of the values in `source`.

```
static func allocate<C>(initializingFrom source: C, shape: [Int], stride: [Int]) -> BNNSTensor where C : AccelerateBuffer, C.Element : BNNSScalar
```

## Parameters

`source`

The collection that provides the source elements.

`shape`

The shape of the tensor.

`stride`

The stride of the tensor.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)