Skip to content

[BUG] Error when passing shared tiles to Warp functions #1313

Closed

Description

@daedalus5

Bug Description

Passing shared-memory tiles to @wp.func fails to compile

Problem

When a @wp.func has a tile parameter (e.g., wp.tile(dtype=float, shape=(M, N))), the tile annotation defaults to register storage. If the function is called with a shared-memory tile, the generated C++ fails to compile because the function signature uses tile_register_t but the caller passes tile_shared_t.

Reproduction

import warp as wp
import numpy as np

BLOCK_DIM = 64
TILE_M = 4
TILE_N = 4

@wp.func
def scale_tile(t: wp.tile(dtype=float, shape=(TILE_M, TILE_N))):
    return t * 2.0

@wp.kernel(enable_backward=False)
def compute(input: wp.array2d(dtype=float), out: wp.array2d(dtype=float)):
    i = wp.tid()
    t = wp.tile_load(input, shape=(TILE_M, TILE_N), offset=(0, 0), storage="shared")
    r = scale_tile(t)  # fails here
    wp.tile_store(out, r)

inp = wp.array(np.ones((TILE_M, TILE_N), dtype=np.float32) * 3.0, device="cpu")
out = wp.zeros((TILE_M, TILE_N), dtype=float, device="cpu")
wp.launch_tiled(compute, dim=[1], inputs=[inp, out], block_dim=BLOCK_DIM, device="cpu")

Error:

error: no matching function for call to 'scale_tile_0'
note: candidate function not viable: no known conversion from
  'tile_shared_t<float, tile_layout_strided_t<...>>'
  to 'tile_register_t<float, tile_layout_register_t<...>>'

Impact

Users cannot pass shared-memory tiles to @wp.func functions. This is a common pattern — tile_load with storage="shared" and tile_matmul both produce shared tiles, and users often want to wrap tile operations in helper functions.

The workaround is to avoid @wp.func and inline the tile operations directly in the kernel, which hurts code reuse and readability.

System Information

No response

Activity

  1. added this to the 1.12.1 milestone on Mar 20, 2026
  2. self-assigned this
    on Mar 20, 2026
  3. added theissue type on Mar 20, 2026
  4. shi-eric commented on Mar 24, 2026

    @shi-eric
    Contributor

    Added in cdda8f3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions