From 1a66697b80a527af6d6dd1ed235199264696767e Mon Sep 17 00:00:00 2001 From: Jacob Bohlin Date: Fri, 11 Sep 2020 10:04:15 +0200 Subject: MLBEDSW-2809: Redo the Tensor addressing Added a static class TensorAddressMap that stores all Tensor addresses based on their equivalence_id. Made the "address" field into a property which getter and setter looks up/sets the tensor's address in TensorAddressMap. This makes the references to cpu_tensor/npu_tensor obsolete and they have been removed. Addition to scheduler: avoid SRAM spilling if an op has consumers in other subgraphs. Minor rework in LUTState; it will now assign a unique equivalence_id to the SHRAM lut tensor to avoid issues with addressing. The equivalent checks in LUTState now compares the values of the LUT instead of the the equivalence_id. Updated LUT unit tests accordingly. Signed-off-by: Jacob Bohlin Change-Id: I41de5a8a4e5f07b77d6544d8d4034b754993e503 --- ethosu/vela/test/test_lut.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'ethosu/vela/test/test_lut.py') diff --git a/ethosu/vela/test/test_lut.py b/ethosu/vela/test/test_lut.py index 3dda1793..ee1a40fe 100644 --- a/ethosu/vela/test/test_lut.py +++ b/ethosu/vela/test/test_lut.py @@ -15,6 +15,8 @@ # limitations under the License. # Description: # Unit tests for LUT support +import random + import numpy as np from ethosu.vela import insert_dma @@ -31,29 +33,29 @@ from ethosu.vela.test import testutil def set_256_lut(op, key): - values = list(range(256)) + random.seed(key) + values = random.choices(range(256), k=256) lut_tensor = create_const_tensor( op.name + "_lut", [1, 1, 1, 256], DataType.int8, values, np.uint8, TensorPurpose.LUT ) - lut_tensor.equivalence_id = lut.create_equivalence_id(key) op.set_activation_lut(lut_tensor) def set_1K_lut(op, key): - values = list(range(256)) + random.seed(key) + values = random.choices(range(256), k=256) lut_tensor = create_const_tensor( op.name + "_lut", [1, 1, 1, 256], DataType.int32, values, np.uint32, TensorPurpose.LUT ) - lut_tensor.equivalence_id = lut.create_equivalence_id(key) op.set_activation_lut(lut_tensor) def set_2K_lut(op, key): - values = list(range(512)) + random.seed(key) + values = random.choices(range(512), k=512) lut_tensor = create_const_tensor( op.name + "_lut", [1, 1, 1, 512], DataType.int32, values, np.uint32, TensorPurpose.LUT ) - lut_tensor.equivalence_id = lut.create_equivalence_id(key) op.set_activation_lut(lut_tensor) -- cgit v1.2.1