---
title: "constant(_:dataType:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/constant(_:datatype:)"
---

# constant(_:dataType:)

Creates a constant operation and returns the result tensor.

## Declaration

```swift
func constant(_ scalar: Double, dataType: MPSDataType) -> MPSGraphTensor
```

## Parameters

- `scalar`: The scalar value to fill the entire tensor values with.
- `dataType`: The dataType of the constant tensor.

## Return Value

Return Value A valid MPSGraphTensor object.
