<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Array/graphBuilderTensor(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sa10AccelerateAA10BNNSScalarRzlE18graphBuilderTensoryAA9BNNSGraphO0D0V0E0Vy__xGAGF"
  },
  "title" : "graphBuilderTensor(_:)"
}
-->

# graphBuilderTensor(_:)

Returns a tensor for the specified BNNS Graph builder.

```
func graphBuilderTensor(_ builder: BNNSGraph.Builder) -> BNNSGraph.Builder.Tensor<Element>
```

## Discussion

The following code shows how to use this function to register a tensor from an array.

```
   let x = [1, 2, 3, 4] as [Float]
   let y = [5, 6, 7, 8] as [Float]

   let context = try BNNSGraph.makeContext {
       builder in

       let x = lhs.graphBuilderTensor(builder)

       let z = x.matmul(transpose: true,
                        other: y)

       return [z] // On return, `z[0]` equals `70`.
   }
```

---

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)