You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/17 11:24:48 UTC
[GitHub] [tvm] mbaret commented on a change in pull request #9929: [microNPU] Refactor base address determination to codegen
mbaret commented on a change in pull request #9929:
URL: https://github.com/apache/tvm/pull/9929#discussion_r785814947
##########
File path: python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py
##########
@@ -101,20 +101,70 @@ def translate(tir_module, params):
encoded_constants : str
An hex string of the bytes that includes concat'd
encoded weights, encoded biases and scales.
- scratch_size : int
- The size of the scratch buffer needed.
+ base_addresses : List[util.BaseAddress]
+ base addresses
Review comment:
Could be more descriptive here.
##########
File path: tests/python/contrib/test_ethosu/test_tir_to_cs_translator.py
##########
@@ -796,19 +804,19 @@ def _check_buffer(address, region, length, buffer_var):
constant_tensor_read_mask[address : address + length] = np.ones(
length, dtype=buffer_dtype
)
- elif buffer_type == tir_to_cs_translator.BufferType.scratch:
+ elif buffer_type == tir_to_cs_translator.BufferType.runtime_allocate:
shape = list(buffer_info[buffer_var].shape)
assert length == np.prod(shape)
- assert address < scratch_size
+ assert address < runtime_allocation_size
size_in_bytes = int(np.prod(shape)) * dtype_bytes
# Every buffer is adjusted to align to 16 bytes
size_in_bytes = util.round_up(size_in_bytes, 16)
- assert address + size_in_bytes <= scratch_size
- # The scratch area should not be used by anyother buffer
- assert not scratch_allocation_mask[address : address + size_in_bytes].any()
- # The scratch area is marked as used
- scratch_allocation_mask[address : address + size_in_bytes] = np.ones(
+ assert address + size_in_bytes <= runtime_allocation_size
+ # The runtime_allocation area should not be used by anyother buffer
Review comment:
any other
##########
File path: python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py
##########
@@ -300,6 +351,7 @@ def classify_io(buffer):
assert buffer_type in (BufferType.input, BufferType.output)
address = 0
buffer_addresses[_buffer] = (address, buffer_type)
+ buffer_info[_buffer] = BufferInfo(None, info.dtype, info.dtype, buffer_type)
Review comment:
Stylistic preference, so feel free to ignore, but I'd favour using keyword initialization here where its not obvious what role the arguments are playing.
##########
File path: python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py
##########
@@ -228,7 +279,7 @@ def assign_addresses(buffer_info, npu_ops):
A list of Vela NpuOps with addesses within scratch and constant buffers
constant_tensor : NDArray
A unified constant data array of uint8 as the constant buffer
- scratch_size : int
+ runtime_allocation_size : int
The size of the scratch tensor.
Review comment:
Needs update
##########
File path: src/relay/backend/contrib/ethosu/utils.h
##########
@@ -34,47 +34,90 @@ namespace relay {
namespace contrib {
namespace ethosu {
+/*!
+ * \brief Base addresses are input pointers to
+ * the driver that get accessed by produced
Review comment:
incomplete?
##########
File path: python/tvm/relay/backend/contrib/ethosu/tir_to_cs_translator.py
##########
@@ -36,15 +36,15 @@ class BufferType(Enum):
constant = auto()
input_or_output = auto()
- scratch = auto()
+ runtime_allocate = auto()
Review comment:
I'm not sure if 'runtime_allocate'/'runtime_allocation' is the best name for this as it mixes up purpose and allocation strategy. I think we can stick to 'scratch' here and rely on the 'is_runtime_allocation' field on BaseAddress to provide the further info.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org