Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ path = [".github/ISSUE_TEMPLATE/*.md"]
precedence = "override"
SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"]
SPDX-License-Identifier = "MIT"

[[annotations]]
path = [".github/instructions/**"]
precedence = "override"
SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"]
SPDX-License-Identifier = "MIT"

[[annotations]]
path = [".agents/skills/**"]
precedence = "override"
SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"]
SPDX-License-Identifier = "MIT"
2 changes: 1 addition & 1 deletion python/tb/test_blc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def test_blc_basic(dut):
cv2.imwrite("blc_ref.png", ((ref * 256) / np.max(ref)).astype(np.uint8))
cv2.imwrite("blc.png", ((result * 256) / np.max(result)).astype(np.uint8))

assert np.allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0)
np.testing.assert_allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0)
Comment thread
timor-amd marked this conversation as resolved.

await Timer(20 * 10, unit="ns")

Expand Down
2 changes: 1 addition & 1 deletion python/tb/test_colorgain.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async def test_colorgain_basic(dut):
cv2.imwrite("colorgain_ref.png", ((ref * 256) / np.max(ref)).astype(np.uint8))
cv2.imwrite("colorgain.png", ((result * 256) / np.max(result)).astype(np.uint8))

assert np.allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0)
np.testing.assert_allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0)
Comment thread
timor-amd marked this conversation as resolved.

await Timer(20 * 10, unit="ns")

Expand Down
6 changes: 4 additions & 2 deletions python/tb/test_demosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def test_demosaic_basic(dut):
# tuser should only be set for first line (signals start of frame)
tuser = 0

result = np.zeros((h - 4, 3 * (w - 4)), dtype=np.uint16)
result = np.zeros((h - 4, 3 * (w - 4)), dtype=np.uint32)
for y in range(0, h - 4):
frame = await tb.axis_sink.recv()
result[y, :] = unpack_buffer(
Expand Down Expand Up @@ -153,7 +153,9 @@ async def test_demosaic_basic(dut):
cv2.imwrite("demosaic.png", (rgb2 / np.max(rgb2)) * 256)
cv2.imwrite("demosaic_ref.png", (ref_rgb / np.max(ref_rgb)) * 256)

assert np.allclose(rgb3.astype(np.uint32), ref_rgb.astype(np.uint32), atol=0)
np.testing.assert_allclose(
rgb3.astype(np.uint32), ref_rgb.astype(np.uint32), atol=0
)

await Timer(20 * 10, unit="ns")

Expand Down
6 changes: 3 additions & 3 deletions python/tb/test_linebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def reset(self):

@cocotb.test()
@pytest.mark.sim
async def test_colorgain_basic(dut):
async def test_linebuffer_basic(dut):
"""Try accessing the design."""

tb = TB(dut)
Expand Down Expand Up @@ -104,7 +104,7 @@ async def test_colorgain_basic(dut):
for y in range(0, h):
frame = AxiStreamFrame(
pack_buffer(
cfa[y, :].astype(np.uint16),
cfa[y, :].astype(np.uint32),
int(dut.PIXEL_PER_CYCLE.value),
int(dut.PIXEL_BIT_WIDTH.value),
),
Expand All @@ -114,7 +114,7 @@ async def test_colorgain_basic(dut):
# tuser should only be set for first line (signals start of frame)
tuser = 0

result = np.zeros((h - conv_loss, w * conv_size), dtype=np.uint16)
result = np.zeros((h - conv_loss, w * conv_size), dtype=np.uint32)
for y in range(0, h - conv_loss):
frame = await tb.axis_sink.recv()
result[y, :] = unpack_buffer(
Expand Down
2 changes: 1 addition & 1 deletion python/tb/test_minmaxmean.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def test_minmaxmean_basic(dut):
for y in range(0, h):
frame = AxiStreamFrame(
pack_buffer(
cfa[y, :].astype(np.uint16),
cfa[y, :].astype(np.uint32),
int(dut.PIXEL_PER_CYCLE.value),
int(dut.PIXEL_BIT_WIDTH.value),
),
Expand Down
2 changes: 1 addition & 1 deletion python/test/test_gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_gamma():

diff_pwl = np.abs(output_pwl - reference)
print("max absolute error pwl: ", np.max(diff_pwl))
assert np.allclose(output_pwl, reference, atol=1e-2)
np.testing.assert_allclose(output_pwl, reference, atol=1e-2)

# plt.plot(reference)
# plt.plot(output)
Expand Down
5 changes: 1 addition & 4 deletions python/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ def test_bitsqrt():
Test bitsqrt
"""
export_lut(bitsqrt_lut, "bitsqrt.mem")
# rand = (np.random.rand(100, 100) * np.iinfo(np.uint32).max).astype(np.uint32)
rand = np.linspace(1, np.iinfo(np.uint32).max - 1, 10000000).astype(np.uint32)
# rand = np.linspace(1, 1024, 1024).astype(np.uint32)
rand[rand == 0] = 1 # exclude zero
# output = bitlog2(rand).astype(np.float32) / 2**24
output = bitsqrt(rand).astype(np.float32) / 2**16
reference = np.sqrt(rand)
print("max error: ", np.max(np.abs(output - reference)))
assert np.allclose(output, reference, rtol=1e-2)
np.testing.assert_allclose(output, reference, rtol=1e-2)
mask = np.abs(output - reference) > 60
masked = output.copy()
masked[mask] = 0
Expand Down