Skip to content

Commit

Permalink
[microNPU][ETHOSU] Fix minimum buffer size
Browse files Browse the repository at this point in the history
Fix minimum buffer size for DMA operations according to alignment.
  • Loading branch information
Aleksei-grovety committed Jun 15, 2023
1 parent 02136b3 commit 5345541
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -926,17 +926,20 @@ def _create_npu_dma_op(serial_copy):
"""This is a helper function to capture the list of arguments
to create a NpuDmaOperation object"""
data_type_bytes = np.iinfo(np.dtype(serial_copy.read_address.dtype)).bits // 8
length = int(serial_copy.length.value) * data_type_bytes
# The buffer size in bytes must be at least 16 bytes
length = max(length, 16)
src = vapi.NpuAddressRange(
# region will be updated later
region=0,
address=serial_copy.read_address,
length=int(serial_copy.length.value) * data_type_bytes,
length=length,
)
dest = vapi.NpuAddressRange(
# region will be updated later
region=0,
address=serial_copy.write_address,
length=int(serial_copy.length.value) * data_type_bytes,
length=length,
)
return vapi.NpuDmaOperation(src, dest)

Expand Down Expand Up @@ -1076,7 +1079,6 @@ def _create_npu_op_binary_elementwise(serial_binary_elementwise: spec.SerialBina
def translate_ethosu_unary_elementwise(
tir_extern_call: tvm.tir.Call,
) -> vapi.NpuElementWiseOperation:

"""This function will translate a tir extern_call
as produced by Relay to TIR compilation.
Parameters
Expand Down

0 comments on commit 5345541

Please sign in to comment.