<!--
{
  "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/ContiguousArray/graphBuilderTensor(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s15ContiguousArrayV10AccelerateAC10BNNSScalarRzlE18graphBuilderTensoryAC9BNNSGraphO0F0V0G0Vy__xGAIF"
  },
  "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 a contiguous array.

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

   let context = try BNNSGraph.makeContext {
       builder in

       let x = x.graphBuilderTensor(builder)

       let z = x.matmul(transpose: truee,
                        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)