---
title: "variableFromTensor(_:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/variablefromtensor(_:name:)"
---

# variableFromTensor(_:name:)

Creates a variable from an input tensor.

## Declaration

```swift
func variableFromTensor(_ tensor: MPSGraphTensor, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The tensor from which to form the variable.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.
