> ## Documentation Index
> Fetch the complete documentation index at: https://sdk.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SdkLayout API Reference

> Use `SdkLayout` to define code regions, configure colors, and specify program layout for Cerebras SDK kernels.

This API is part of the `sdkruntimepybind` module documented in the [SdkRuntime API Reference](/api-docs/sdkruntime-api).

## Imports

The classes and enums documented on this page live in
`cerebras.sdk.runtime.sdkruntimepybind`. The canonical import block for an
`SdkLayout`-based host program is:

```python theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
from cerebras.sdk.runtime.sdkruntimepybind import (
    SdkLayout,
    SdkTarget,
    Color,
    Route,
    Edge,
    RoutingPosition,
)
```

For host programs that mix `SdkLayout` with `SdkRuntime` (the typical case),
import `SdkRuntime` and `SdkCompileArtifacts` from the same module:

```python theme={"languages":{"custom":["/languages/csl-tmlanguage.json"]}}
from cerebras.sdk.runtime.sdkruntimepybind import (
    SdkRuntime,
    SdkCompileArtifacts,
)
```

## CodeRegion

<span id="CodeRegion" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">CodeRegion</span></>} type="Bases: object">
  Specifies a code region.

  <Expandable title="content">
    <span id="coderegion-color" />

    <ParamField body={<><span className="sig-name">color</span><span className="sig-param">(name: str) → <a href="#color">Color</a></span></>}>
      Create and return a new color that is scoped within a region.

      <Expandable title="Parameters">
        <ParamField body="name (str)">
          Name to be assigned to the color.
        </ParamField>
      </Expandable>

      > * **Returns**: A new color scoped within this region.
      > * **Return type**: [`Color`](#color)
    </ParamField>

    <span id="color-1" />

    <ParamField body={<><span className="sig-name">color</span><span className="sig-param">(name: str, value: int) → <a href="#color">Color</a></span></>}>
      Create and return a new color (with a value) that is scoped within a region.

      <Expandable title="Parameters">
        <ParamField body="name (str)">
          Name to be assigned to the color.
        </ParamField>

        <ParamField body="value (int)">
          Value to be assigned to the color.
        </ParamField>
      </Expandable>

      > * **Returns**: A new color scoped within this region.
      > * **Return type**: [`Color`](#color)
    </ParamField>

    <span id="create_input_port" />

    <ParamField body={<><span className="sig-name">create_input_port</span><span className="sig-param">(color: <a href="#color">Color</a>, edge: <a href="#edge">Edge</a>, routes: List[<a href="#routingposition">RoutingPosition</a>], data_size: int, prefix: str = '') → <a href="#porthandle">PortHandle</a></span></>}>
      Given a color, an orientation (i.e., `edge`), a set of output routes, a size, and an
      optional prefix, create and return a new input communication port. The optional prefix
      can be used to create unique ports with the same color. Ports must be unique, otherwise an
      exception is thrown.

      <Expandable title="Parameters">
        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color of the input port.
        </ParamField>

        <ParamField body={<>edge (<a href="#edge">Edge</a>)</>}>
          Edge on which to create the input port.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of output routes for the input port.
        </ParamField>

        <ParamField body="data_size (int)">
          The size of the port's data, used to verify port compatibility.
        </ParamField>

        <ParamField body="prefix (str)">
          Optional prefix to port's name, which allows creation of unique ports with the same color.
        </ParamField>
      </Expandable>

      > * **Returns**: Handle to the created input port.
      > * **Return type**: [`PortHandle`](#porthandle)
    </ParamField>

    <span id="create_output_port" />

    <ParamField body={<><span className="sig-name">create_output_port</span><span className="sig-param">(color: <a href="#color">Color</a>, edge: <a href="#edge">Edge</a>, routes: List[<a href="#routingposition">RoutingPosition</a>], data_size: int, prefix: str = '') → <a href="#porthandle">PortHandle</a></span></>}>
      Given a color, an orientation (i.e., `edge`), a set of input routes, a size, and an
      optional prefix, create and return a new output communication port. The optional prefix
      can be used to create unique ports with the same color. Ports must be unique, otherwise an
      exception is thrown.

      <Expandable title="Parameters">
        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color of the output port.
        </ParamField>

        <ParamField body={<>edge (<a href="#edge">Edge</a>)</>}>
          Edge on which to create the output port.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of input routes for the output port.
        </ParamField>

        <ParamField body="data_size (int)">
          The size of the port's data, used to verify port compatibility.
        </ParamField>

        <ParamField body="prefix (str)">
          Optional prefix to port's name, which allows creation of unique ports with the same color.
        </ParamField>
      </Expandable>

      > * **Returns**: Handle to the created output port.
      > * **Return type**: [`PortHandle`](#porthandle)
    </ParamField>

    <span id="paint" />

    <ParamField body={<><span className="sig-name">paint</span><span className="sig-param">(coord: <a href="#intvector">IntVector</a>, color: <a href="#color">Color</a>, routes: List[<a href="#routingposition">RoutingPosition</a>])</span></>}>
      Set the routing for a given color on a single PE within this region.

      <Expandable title="Parameters">
        <ParamField body={<>coord (<a href="#intvector">IntVector</a>)</>}>
          Coordinate on which color will be painted.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color to be painted on this coordinate.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of routing positions which will be applied to this color.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="paint_all" />

    <ParamField body={<><span className="sig-name">paint_all</span><span className="sig-param">(color: <a href="#color">Color</a>, routes: List[<a href="#routingposition">RoutingPosition</a>])</span></>}>
      Set the routing for a given color on all PEs of the region.

      <Expandable title="Parameters">
        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color to be painted on this region.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of routing positions which will be applied to this color.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="paint_all-1" />

    <ParamField body={<><span className="sig-name">paint_all</span><span className="sig-param">(color: <a href="#color">Color</a>, routes: List[<a href="#routingposition">RoutingPosition</a>], edge_routes: List[<a href="#edgerouteinfo">EdgeRouteInfo</a>])</span></>}>
      Set the routing for a given color on all PEs of the region with special routing on one or
      all region edges.

      <Expandable title="Parameters">
        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color to be painted on this region.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of routing positions which will be applied to this color.
        </ParamField>

        <ParamField body={<>edge_routes (List[<a href="#edgerouteinfo">EdgeRouteInfo</a>])</>}>
          List of routing positions to be applied to this color on the region's edges.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="paint_range" />

    <ParamField body={<><span className="sig-name">paint_range</span><span className="sig-param">(rect: <a href="#intrectangle">IntRectangle</a>, color: <a href="#color">Color</a>, routes: List[<a href="#routingposition">RoutingPosition</a>])</span></>}>
      Set the routing for a given color on a contiguous rectangular subset of PEs within this region.

      <Expandable title="Parameters">
        <ParamField body={<>rect (<a href="#intrectangle">IntRectangle</a>)</>}>
          Rectangular subset of PEs within this region on which color will be painted.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color to be painted on this rectangle.
        </ParamField>

        <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
          List of routing positions which will be applied to this color.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="place" />

    <ParamField body={<><span className="sig-name">place</span><span className="sig-param">(x: int, y: int)</span></>}>
      Place code region at specific coordinates `(x, y)`.

      <Expandable title="Parameters">
        <ParamField body="x (int)">
          x-coordinate at which core region will be placed.
        </ParamField>

        <ParamField body="y (int)">
          y-coordinate at which core region will be placed.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param" />

    <ParamField body={<><span className="sig-name">set_param</span><span className="sig-param">(coord: <a href="#intvector">IntVector</a>, name: str, value: int)</span></>}>
      Set an unsigned integer parameter on a single PE within this region.

      <Expandable title="Parameters">
        <ParamField body={<>coord (<a href="#intvector">IntVector</a>)</>}>
          Coordinate on which parameter will be set.
        </ParamField>

        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body="value (int)">
          Unsigned integer value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param-1" />

    <ParamField body={<><span className="sig-name">set_param</span><span className="sig-param">(coord: <a href="#intvector">IntVector</a>, color: <a href="#color">Color</a>)</span></>}>
      Set a color parameter on a single PE within this region.

      <Expandable title="Parameters">
        <ParamField body={<>coord (<a href="#intvector">IntVector</a>)</>}>
          Coordinate on which parameter will be set.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param-2" />

    <ParamField body={<><span className="sig-name">set_param</span><span className="sig-param">(coord: <a href="#intvector">IntVector</a>, name: str, value: <a href="#color">Color</a>)</span></>}>
      Set the value of parameter `name` on a single PE within this region with the value of
      color `value`.

      <Expandable title="Parameters">
        <ParamField body={<>coord (<a href="#intvector">IntVector</a>)</>}>
          Coordinate on which parameter will be set.
        </ParamField>

        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_all" />

    <ParamField body={<><span className="sig-name">set_param_all</span><span className="sig-param">(name: str, value: int)</span></>}>
      Set an unsigned integer parameter on all PEs of the region.

      <Expandable title="Parameters">
        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body="value (int)">
          Unsigned integer value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_all-1" />

    <ParamField body={<><span className="sig-name">set_param_all</span><span className="sig-param">(color: <a href="#color">Color</a>)</span></>}>
      Set a color parameter on all PEs of the region.

      <Expandable title="Parameters">
        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_all-2" />

    <ParamField body={<><span className="sig-name">set_param_all</span><span className="sig-param">(name: str, value: <a href="#color">Color</a>)</span></>}>
      Set the value of parameter `name` on all PEs of the region with the value of color `value`.

      <Expandable title="Parameters">
        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_range" />

    <ParamField body={<><span className="sig-name">set_param_range</span><span className="sig-param">(rect: <a href="#intrectangle">IntRectangle</a>, name: str, value: int)</span></>}>
      Set an unsigned integer parameter on a contiguous rectangular subset of PEs within this region.

      <Expandable title="Parameters">
        <ParamField body={<>rect (<a href="#intrectangle">IntRectangle</a>)</>}>
          Rectangular subset of PEs within this region on which parameter will be set.
        </ParamField>

        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body="value (int)">
          Unsigned integer value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_range-1" />

    <ParamField body={<><span className="sig-name">set_param_range</span><span className="sig-param">(rect: <a href="#intrectangle">IntRectangle</a>, color: <a href="#color">Color</a>)</span></>}>
      Set a color parameter on a contiguous rectangular subset of PEs within this region.

      <Expandable title="Parameters">
        <ParamField body={<>rect (<a href="#intrectangle">IntRectangle</a>)</>}>
          Rectangular subset of PEs within this region on which parameter will be set.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_param_range-2" />

    <ParamField body={<><span className="sig-name">set_param_range</span><span className="sig-param">(rect: <a href="#intrectangle">IntRectangle</a>, name: str, value: <a href="#color">Color</a>)</span></>}>
      Set the value of parameter `name` on a contiguous rectangular subset of PEs within this
      region with the value of color `value`.

      <Expandable title="Parameters">
        <ParamField body={<>rect (<a href="#intrectangle">IntRectangle</a>)</>}>
          Rectangular subset of PEs within this region on which parameter will be set.
        </ParamField>

        <ParamField body="name (str)">
          Name of the parameter.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color value of the parameter.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_symbol_all" />

    <ParamField body={<><span className="sig-name">set_symbol_all</span><span className="sig-param">(symbol: str, data: np.ndarray, width: int, height: int)</span></>}>
      Given a symbol name `symbol` and `data` with a given 2D shape specified by `width`
      and `height`, store `data` uniformly across the PEs of this code region. The 2D shape of
      `data` must be a multiple of the code region's dimensions or an error will be emitted.

      <Expandable title="Parameters">
        <ParamField body="symbol (str)">
          Name of the symbol.
        </ParamField>

        <ParamField body="data (np.ndarray)">
          2D data array to be applied to the symbol. Data must be of type `np.int32`,
          `np.uint32`, `np.float32`, `np.int16`, or `np.uint16`.
        </ParamField>

        <ParamField body="width (int)">
          Width of 2D data array.
        </ParamField>

        <ParamField body="height (int)">
          Height of 2D data array.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Color

<span id="Color" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">Color</span><span className="sig-param">(name: str, value: Optional[int] = None)</span></>} type="Bases: object">
  Represents a color with an optional user-specified physical value. Objects of this class can be
  used for routing and can also be used to set microcode parameter values. If a physical value is
  not provided, then a physical value will be allocated automatically by the compiler.

  <Expandable title="content">
    <Expandable title="Parameters">
      <ParamField body="name (str)">
        Name given to the color.
      </ParamField>

      <ParamField body="value (Optional[int])">
        Physical value given to the color. If not provided, then a value will be allocated
        automatically by the compiler. The maximum value is 23.
      </ParamField>
    </Expandable>

    <span id="get_global_name" />

    <ParamField body={<><span className="sig-name">get_global_name</span><span className="sig-param">() → str</span></>}>
      Returns the global name of the color. If this color is attached to a region, then the name
      returned takes the form `region_name` + `_` + `name`.

      > * **Returns**: Global name of the color.
      > * **Return type**: `str`
    </ParamField>

    <span id="get_local_param_name" />

    <ParamField body={<><span className="sig-name">get_local_param_name</span><span className="sig-param">() → str</span></>}>
      Returns the name of the color.

      > * **Returns**: Name of the color.
      > * **Return type**: `str`
    </ParamField>

    <span id="get_value" />

    <ParamField body={<><span className="sig-name">get_value</span><span className="sig-param">() → Optional[int]</span></>}>
      Returns the color's physical value if one has been assigned. Otherwise, returns `None`.

      > * **Returns**: Physical value of the color.
      > * **Return type**: `Optional[int]`
    </ParamField>
  </Expandable>
</ParamField>

## Edge

<span id="Edge" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">Edge</span></>} type="Bases: Enum">
  Represents edge positions along the boundary of a code region.

  > **Values**:
  >
  > * TOP
  > * BOTTOM
  > * LEFT
  > * RIGHT
</ParamField>

## EdgeRouteInfo

<span id="EdgeRouteInfo" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">EdgeRouteInfo</span></>} type="Bases: object">
  For a given code region, represents the routing positions in one of the region's four edges.
</ParamField>

## FP16TYPE

<span id="FP16TYPE" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">FP16TYPE</span></>} type="Bases: Enum">
  Specifies the 16-bit floating point format for compilation.

  > **Values**:
  >
  > * **F16**: IEEE 754 half-precision (`f16`)
  > * **BF16**: Brain floating point (`bf16`)
  > * **CB16**: Cerebras 16-bit floating point (`cb16`)
</ParamField>

## SdkLayout

<span id="SdkLayout" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">SdkLayout</span><span className="sig-param">(platform: <a href="/api-docs/sdkruntime-api#sdkexecutionplatform">SdkExecutionPlatform</a>, **kwargs)</span></>} type="Bases: object">
  Specifies a program layout. This API allows the user to define rectangular code regions, define
  color routing and switching, automatically allocate colors, and automatically route between code
  regions.

  <Expandable title="content">
    <Expandable title="Parameters">
      <ParamField body={<>platform (<a href="/api-docs/sdkruntime-api#sdkexecutionplatform">SdkExecutionPlatform</a>)</>}>
        Execution platform specification.
      </ParamField>
    </Expandable>

    <Expandable title="Keyword Arguments">
      <ParamField body="msg_level (str)">
        Message logging output level. Available output levels are `DEBUG`,
        `INFO`, `WARNING`, and `ERROR`. Default value is `WARNING`.
      </ParamField>
    </Expandable>

    <span id="__init__" />

    <ParamField body={<><span className="sig-name">__init__</span><span className="sig-param">(path: Union[pathlib.Path, str], **kwargs)</span></>}>
      Constructor variant that takes a path to a fabric JSON file which is used to define the
      compile target and execution platform. Takes same kwargs as above.

      <Expandable title="Parameters">
        <ParamField body="path (Union[pathlib.Path, str])">
          Path to a fabric JSON file.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="__init__-1" />

    <ParamField body={<><span className="sig-name">__init__</span><span className="sig-param">(target: <a href="/api-docs/sdkruntime-api#sdktarget">SdkTarget</a>, **kwargs)</span></>}>
      Constructor variant that takes a target architecture. Takes same kwargs as above.

      <Expandable title="Parameters">
        <ParamField body={<>target (<a href="/api-docs/sdkruntime-api#sdktarget">SdkTarget</a>)</>}>
          Target architecture for compilation.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="compile" />

    <ParamField body={<><span className="sig-name">compile</span><span className="sig-param">(out_prefix: str, libs: List[str] = [], cslc_prefix: str = "", save_port_map: bool = False, f16_type: <a href="#fp16type">FP16TYPE</a> = FP16TYPE.F16) → <a href="/api-docs/sdkruntime-api#sdkcompileartifacts">SdkCompileArtifacts</a></span></>}>
      Compile this layout and produce artifacts with a given path prefix.

      <Expandable title="Parameters">
        <ParamField body="out_prefix (str)">
          Path to which artifacts will be produced.
        </ParamField>

        <ParamField body="libs (List[str])">
          List of additional library search paths for the compiler.
        </ParamField>

        <ParamField body="cslc_prefix (str)">
          Path prefix for the CSL compiler. If empty, the default compiler is used.
        </ParamField>

        <ParamField body="save_port_map (bool)">
          If `True`, saves the port mapping to a file.
        </ParamField>

        <ParamField body={<>f16_type (<a href="#fp16type">FP16TYPE</a>)</>}>
          Specifies the 16-bit floating point format for compilation.
        </ParamField>
      </Expandable>

      > * **Returns**: Compilation artifacts.
      > * **Return type**: [`SdkCompileArtifacts`](/api-docs/sdkruntime-api#sdkcompileartifacts)
    </ParamField>

    <span id="connect" />

    <ParamField body={<><span className="sig-name">connect</span><span className="sig-param">(tx: <a href="#porthandle">PortHandle</a>, rx: <a href="#porthandle">PortHandle</a>)</span></>}>
      Automatically connect two ports.

      <Expandable title="Parameters">
        <ParamField body={<>tx (<a href="#porthandle">PortHandle</a>)</>}>
          Transmitting output data port which will send data to `rx`.
        </ParamField>

        <ParamField body={<>rx (<a href="#porthandle">PortHandle</a>)</>}>
          Receiving input data port which will receive data from `tx`.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="create_code_region" />

    <ParamField body={<><span className="sig-name">create_code_region</span><span className="sig-param">(source: str, name: str, width: int, height: int) → <a href="#coderegion">CodeRegion</a></span></>}>
      Create a code region.

      <Expandable title="Parameters">
        <ParamField body="source (str)">
          Path to code source file.
        </ParamField>

        <ParamField body="name (str)">
          Name of the created code region.
        </ParamField>

        <ParamField body="width (int)">
          Width in PEs of the created code region.
        </ParamField>

        <ParamField body="height (int)">
          Height in PEs of the created code region.
        </ParamField>
      </Expandable>

      > * **Returns**: The created code region object.
      > * **Return type**: [`CodeRegion`](#coderegion)
    </ParamField>

    <span id="create_input_stream" />

    <ParamField body={<><span className="sig-name">create_input_stream</span><span className="sig-param">(port: <a href="#porthandle">PortHandle</a>, io_loc: Optional[<a href="#intvector">IntVector</a>] = None, io_buffer_size: int = 1024) → str</span></>}>
      Sets up an input stream from the host to a 1-PE region at `io_loc` and then to input port
      `port`. If `io_loc` is not provided, an available location will be automatically picked.
      `io_buffer_size` can be provided to specify the buffer size at `io_loc`. Returns the name
      of the stream's port which can be used by the [`SdkRuntime`](/api-docs/sdkruntime-api#sdkruntime) direct link API method
      [`SdkRuntime.send()`](/api-docs/sdkruntime-api#send).

      <Expandable title="Parameters">
        <ParamField body={<>port (<a href="#porthandle">PortHandle</a>)</>}>
          Handle to input port.
        </ParamField>

        <ParamField body={<>io_loc (Optional[<a href="#intvector">IntVector</a>])</>}>
          PE location on wafer which receives input stream data. If not provided, a
          location is automatically chosen.
        </ParamField>

        <ParamField body="io_buffer_size (int)">
          Buffer size allocated at `io_loc`. Default is 1024.
        </ParamField>
      </Expandable>

      > * **Returns**: Name of created input stream's port.
      > * **Return type**: `str`
    </ParamField>

    <span id="create_input_stream_from_loc" />

    <ParamField body={<><span className="sig-name">create_input_stream_from_loc</span><span className="sig-param">(loc: <a href="#intvector">IntVector</a>, color: <a href="#color">Color</a>, prefix: str = '') → str</span></>}>
      Sets up an input stream from the host to `loc` on a given color `color` assuming that
      a code region is already defined at `loc` to consume the incoming data. An optional
      prefix can be provided to uniquely identify the stream in case of naming conflicts. Returns
      the name of the stream's port which can be used by the [`SdkRuntime`](/api-docs/sdkruntime-api#sdkruntime) direct link API
      method [`SdkRuntime.send()`](/api-docs/sdkruntime-api#send).

      <Expandable title="Parameters">
        <ParamField body={<>loc (<a href="#intvector">IntVector</a>)</>}>
          PE location of existing input port into which data will be streamed.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color on which stream transmits data.
        </ParamField>

        <ParamField body="prefix (str)">
          Optional prefix prepended to created stream's name.
        </ParamField>
      </Expandable>

      > * **Returns**: Name of created input stream's port.
      > * **Return type**: `str`
    </ParamField>

    <span id="create_output_stream" />

    <ParamField body={<><span className="sig-name">create_output_stream</span><span className="sig-param">(port: <a href="#porthandle">PortHandle</a>, io_loc: <a href="#intvector">IntVector</a> = None, io_buffer_size: int = 1024) → str</span></>}>
      Sets up an output stream from output port `port` to a 1-PE region at `io_loc` and then
      to the host. If `io_loc` is not provided, an available location will be automatically
      picked. `io_buffer_size` can be provided to specify the buffer size at `io_loc`. Returns
      the name of the stream's port which can be used by the [`SdkRuntime`](/api-docs/sdkruntime-api#sdkruntime) direct link API
      methods [`SdkRuntime.receive()`](/api-docs/sdkruntime-api#receive) and [`SdkRuntime.receive_tofile()`](/api-docs/sdkruntime-api#receive_tofile).

      <Expandable title="Parameters">
        <ParamField body={<>port (<a href="#porthandle">PortHandle</a>)</>}>
          Handle to output port.
        </ParamField>

        <ParamField body={<>io_loc (Optional[<a href="#intvector">IntVector</a>])</>}>
          PE location on wafer which sends out output stream data. If not provided, a
          location is automatically chosen.
        </ParamField>

        <ParamField body="io_buffer_size (int)">
          Buffer size allocated at `io_loc`. Default is 1024.
        </ParamField>
      </Expandable>

      > * **Returns**: Name of created output stream's port.
      > * **Return type**: `str`
    </ParamField>

    <span id="create_output_stream_from_loc" />

    <ParamField body={<><span className="sig-name">create_output_stream_from_loc</span><span className="sig-param">(loc: <a href="#intvector">IntVector</a>, color: <a href="#color">Color</a>, prefix: str = '') → str</span></>}>
      Sets up an output stream to the host from `loc` on a given color `color` assuming that
      a code region is already defined at `loc` to produce the outgoing data. An optional
      prefix can be provided to uniquely identify the stream in case of naming conflicts. Returns
      the name of the stream's port which can be used by the [`SdkRuntime`](/api-docs/sdkruntime-api#sdkruntime) direct link API
      methods [`SdkRuntime.receive()`](/api-docs/sdkruntime-api#receive) and [`SdkRuntime.receive_tofile()`](/api-docs/sdkruntime-api#receive_tofile).

      <Expandable title="Parameters">
        <ParamField body={<>loc (<a href="#intvector">IntVector</a>)</>}>
          PE location of existing output port from which data will be streamed.
        </ParamField>

        <ParamField body={<>color (<a href="#color">Color</a>)</>}>
          Color on which stream transmits data.
        </ParamField>

        <ParamField body="prefix (str)">
          Optional prefix prepended to created stream's name.
        </ParamField>
      </Expandable>

      > * **Returns**: Name of created output stream's port.
      > * **Return type**: `str`
    </ParamField>

    <span id="hstack" />

    <ParamField body={<><span className="sig-name">hstack</span><span className="sig-param">(children: List[<a href="#coderegion">CodeRegion</a>]) → int</span></>}>
      Place child code regions horizontally and relative to the first child in the given list, and
      return the width of the resulting code region.

      <Expandable title="Parameters">
        <ParamField body={<>children (List[<a href="#coderegion">CodeRegion</a>])</>}>
          Code regions to be placed.
        </ParamField>
      </Expandable>

      > * **Returns**: Width of resulting code region.
      > * **Return type**: `int`
    </ParamField>

    <span id="hstack-1" />

    <ParamField body={<><span className="sig-name">hstack</span><span className="sig-param">(children: List[<a href="#coderegion">CodeRegion</a>], origin: <a href="#intvector">IntVector</a>) → int</span></>}>
      Place child code regions horizontally and relative to a specified origin, and return the
      width of the resulting code region.

      <Expandable title="Parameters">
        <ParamField body={<>children (List[<a href="#coderegion">CodeRegion</a>])</>}>
          Code regions to be placed.
        </ParamField>

        <ParamField body={<>origin (<a href="#intvector">IntVector</a>)</>}>
          PE coordinate which serves as origin for placed code regions.
        </ParamField>
      </Expandable>

      > * **Returns**: Width of resulting code region.
      > * **Return type**: `int`
    </ParamField>

    <span id="vstack" />

    <ParamField body={<><span className="sig-name">vstack</span><span className="sig-param">(children: List[<a href="#coderegion">CodeRegion</a>]) → int</span></>}>
      Place child code regions vertically and relative to the first child in the given list, and
      return the height of the resulting code region.

      <Expandable title="Parameters">
        <ParamField body={<>children (List[<a href="#coderegion">CodeRegion</a>])</>}>
          Code regions to be placed.
        </ParamField>
      </Expandable>

      > * **Returns**: Height of resulting code region.
      > * **Return type**: `int`
    </ParamField>

    <span id="vstack-1" />

    <ParamField body={<><span className="sig-name">vstack</span><span className="sig-param">(children: List[<a href="#coderegion">CodeRegion</a>], origin: <a href="#intvector">IntVector</a>) → int</span></>}>
      Place child code regions vertically and relative to a specified origin, and return the
      height of the resulting code region.

      <Expandable title="Parameters">
        <ParamField body={<>children (List[<a href="#coderegion">CodeRegion</a>])</>}>
          Code regions to be placed.
        </ParamField>

        <ParamField body={<>origin (<a href="#intvector">IntVector</a>)</>}>
          PE coordinate which serves as origin for placed code regions.
        </ParamField>
      </Expandable>

      > * **Returns**: Height of resulting code region.
      > * **Return type**: `int`
    </ParamField>
  </Expandable>
</ParamField>

## PortHandle

<span id="PortHandle" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">PortHandle</span></>} type="Bases: object">
  Handle to a program input or output data port.
</ParamField>

## Route

<span id="Route" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">Route</span></>} type="Bases: Enum">
  Represents route directions.

  > **Values**:
  >
  > * RAMP
  > * EAST
  > * WEST
  > * NORTH
  > * SOUTH
</ParamField>

## RoutingPosition

<span id="RoutingPosition" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">RoutingPosition</span></>} type="Bases: object">
  Represents a single routing position, which can consist of one or more route values
  for input and one or more route values for output.

  <Expandable title="content">
    <span id="set_input" />

    <ParamField body={<><span className="sig-name">set_input</span><span className="sig-param">(routes: List[<a href="#route">Route</a>])</span></>}>
      Set a list of routes as the input route position.

      <Expandable title="Parameters">
        <ParamField body={<>routes (List[<a href="#route">Route</a>])</>}>
          List of routes to be set as the input route position.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="set_output" />

    <ParamField body={<><span className="sig-name">set_output</span><span className="sig-param">(routes: List[<a href="#route">Route</a>])</span></>}>
      Set a list of routes as the output route position.

      <Expandable title="Parameters">
        <ParamField body={<>routes (List[<a href="#route">Route</a>])</>}>
          List of routes to be set as the output route position.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="add_input" />

    <ParamField body={<><span className="sig-name">add_input</span><span className="sig-param">(route: <a href="#route">Route</a>)</span></>}>
      Add a route to the input route position.

      <Expandable title="Parameters">
        <ParamField body={<>route (<a href="#route">Route</a>)</>}>
          Route to be added to the input route position.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="add_output" />

    <ParamField body={<><span className="sig-name">add_output</span><span className="sig-param">(route: <a href="#route">Route</a>)</span></>}>
      Add a route to the output route position.

      <Expandable title="Parameters">
        <ParamField body={<>route (<a href="#route">Route</a>)</>}>
          Route to be added to the output route position.
        </ParamField>
      </Expandable>
    </ParamField>

    <span id="get_input" />

    <ParamField body={<><span className="sig-name">get_input</span><span className="sig-param">() → List[<a href="#route">Route</a>]</span></>}>
      For this routing position object, return a list of all input routes in the input route
      position.

      > * **Returns**: List of all routes in the input route position.
      > * **Return type**: List\[[`Route`](#route)]
    </ParamField>

    <span id="get_output" />

    <ParamField body={<><span className="sig-name">get_output</span><span className="sig-param">() → List[<a href="#route">Route</a>]</span></>}>
      For this routing position object, return a list of all output routes in the output route
      position.

      > * **Returns**: List of all routes in the output route position.
      > * **Return type**: List\[[`Route`](#route)]
    </ParamField>
  </Expandable>
</ParamField>

## get\_edge\_routing

<span id="get_edge_routing" />

<ParamField body={<>cerebras.sdk.runtime.sdkruntimepybind.<span className="sig-name">get_edge_routing</span><span className="sig-param">(edge: <a href="#edge">Edge</a>, routes: List[<a href="#routingposition">RoutingPosition</a>]) → <a href="#edgerouteinfo">EdgeRouteInfo</a></span></>}>
  Construct an edge routing info object from a given edge and routing positions.

  <Expandable title="Parameters">
    <ParamField body={<>edge (<a href="#edge">Edge</a>)</>}>
      Edge of code region.
    </ParamField>

    <ParamField body={<>routes (List[<a href="#routingposition">RoutingPosition</a>])</>}>
      List of routing positions to be applied to edge.
    </ParamField>
  </Expandable>

  > * **Returns**: Object containing edge routing info.
  > * **Return type**: [`EdgeRouteInfo`](#edgerouteinfo)
</ParamField>

## Geometry

### IntRectangle

<span id="IntRectangle" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.geometry.geometry.<span className="sig-name">IntRectangle</span><span className="sig-param">(origin: <a href="#intvector">IntVector</a>, dims: <a href="#intvector">IntVector</a>)</span></>} type="Bases: object">
  Defines a rectangle of values.

  <Expandable title="Parameters">
    <ParamField body={<>origin (<a href="#intvector">IntVector</a>)</>}>
      Origin of rectangle's northwest corner.
    </ParamField>

    <ParamField body={<>dims (<a href="#intvector">IntVector</a>)</>}>
      Width and height of rectangle.
    </ParamField>
  </Expandable>
</ParamField>

### IntVector

<span id="IntVector" />

<ParamField body={<><span className="sig-kw">class </span>cerebras.geometry.geometry.<span className="sig-name">IntVector</span><span className="sig-param">(x: int, y: int)</span></>} type="Bases: object">
  Wraps a tuple of two integer values, often used to specify coordinates or offsets.

  <Expandable title="Parameters">
    <ParamField body="x (int)">
      x-coordinate
    </ParamField>

    <ParamField body="y (int)">
      y-coordinate
    </ParamField>
  </Expandable>
</ParamField>
