---
title: "graphBuilderTensor(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unsafemutablebufferpointer/graphbuildertensor(_:)"
---

# graphBuilderTensor(_:)

Returns a tensor for the specified BNNS Graph builder.

## Declaration

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

## Discussion

Discussion The following code shows how to use this function to register a tensor from an unsafe mutable buffer pointe:.    var xValues = [1, 2, 3, 4] as [Float]    var yValues = [5, 6, 7, 8] as [Float]

let context = try BNNSGraph.makeContext {        builder in

xValues.withUnsafeMutableBufferPointer { xPtr in            yValues.withUnsafeMutableBufferPointer { yPtr in

let x = xPtr.graphBuilderTensor(builder)

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

return [z] // On return, `z[0]` equals `70`.            }        }    } note: This function copies the values in self.
