<commit_before>import taichi as ti

@ti.all_archs
def test_dynamic():
  x = ti.var(ti.f32)
  n = 128

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, 32).place(x)

  @ti.kernel
  def func():
    pass

  for i in range(n):
    x[i] = i

  for i in range(n):
    assert x[i] == i


@ti.all_archs
def test_dynamic2():
  x = ti.var(ti.f32)
  n = 128

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, 32).place(x)

  @ti.kernel
  def func():
    for i in range(n):
      x[i] = i

  func()

  for i in range(n):
    assert x[i] == i


# @ti.all_archs
def test_dynamic_matrix():
  x = ti.Matrix(2, 1, dt=ti.i32)
  n = 8192

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, chunk_size=8).place(x)

  @ti.kernel
  def func():
    ti.serialize()
    for i in range(n // 4):
      x[i * 4][1, 0] = i

  func()
  
  for i in range(n // 4):
    a = x[i * 4][1, 0]
    assert a == i
    if i + 1 < n // 4:
      b = x[i * 4 + 1][1, 0]
      assert b == 0
    
test_dynamic_matrix()


@ti.all_archs
def test_append():
  x = ti.var(ti.i32)
  n = 128
  
  @ti.layout<commit_msg>all tests passed<commit_after>import taichi as ti

@ti.all_archs
def test_dynamic():
  x = ti.var(ti.f32)
  n = 128

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, 32).place(x)

  @ti.kernel
  def func():
    pass

  for i in range(n):
    x[i] = i

  for i in range(n):
    assert x[i] == i


@ti.all_archs
def test_dynamic2():
  x = ti.var(ti.f32)
  n = 128

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, 32).place(x)

  @ti.kernel
  def func():
    for i in range(n):
      x[i] = i

  func()

  for i in range(n):
    assert x[i] == i


@ti.all_archs
def test_dynamic_matrix():
  x = ti.Matrix(2, 1, dt=ti.i32)
  n = 8192

  @ti.layout
  def place():
    ti.root.dynamic(ti.i, n, chunk_size=128).place(x)

  @ti.kernel
  def func():
    ti.serialize()
    for i in range(n // 4):
      x[i * 4][1, 0] = i

  func()
  
  for i in range(n // 4):
    a = x[i * 4][1, 0]
    assert a == i
    if i + 1 < n // 4:
      b = x[i * 4 + 1][1, 0]
      assert b == 0


@ti.all_archs
def test_append():
  x = ti.var(ti.i32)
  n = 128
  
  @ti.layout
{'fraction_non_alphanumeric': 0.17534883720930233, 'fraction_numerical': 0.04186046511627907, 'mean_word_length': 2.0905172413793105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6060639', 'n_tokens_mistral': 1051, 'n_tokens_neox': 954, 'n_words': 254}