MLBEDSW-2567: CLI option to specify allocation alignment

Added the CLI option. Only applies to CPU tensors. Added an
AllocationError which is raised when Allocation fails.

Signed-off-by: Jacob Bohlin <jacob.bohlin@arm.com>
Change-Id: I89164dea3ac7b7add7bc40aec2ce8fe50600105d
diff --git a/ethosu/vela/vela.py b/ethosu/vela/vela.py
index 91899c2..923d8ec 100644
--- a/ethosu/vela/vela.py
+++ b/ethosu/vela/vela.py
@@ -36,6 +36,7 @@
 from .nn_graph import TensorAllocator
 from .scheduler import ParetoMetric
 from .tensor import MemArea
+from .tensor import Tensor
 
 
 def process(fname, arch, model_reader_options, compiler_options, scheduler_options):
@@ -259,7 +260,12 @@
         default=1.0,
         help=("Performs an additional scaling of weight compression scale estimate (default: %(default)s)"),
     )
-
+    parser.add_argument(
+        "--allocation-alignment",
+        type=int,
+        default=Tensor.AllocationQuantum,
+        help=("Controls the allocation byte alignment of cpu tensors (default: %(default)s)"),
+    )
     args = parser.parse_args(args=args)
 
     # Read configuration file
@@ -280,6 +286,12 @@
     else:
         force_block_config = None
 
+    alignment = args.allocation_alignment
+    if alignment < 16:
+        parser.error("the following argument needs to be greater or equal to 16: ALLOCATION_ALIGNMENT")
+    if alignment & (alignment - 1) != 0:
+        parser.error("the following argument needs to be a power of 2: ALLOCATION_ALIGNMENT")
+
     arch = architecture_features.ArchitectureFeatures(
         vela_config=config,
         system_config=args.system_config,
@@ -307,6 +319,7 @@
         tensor_allocator=args.tensor_allocator,
         timing=args.timing,
         output_dir=args.output_dir,
+        allocation_alignment=alignment,
     )
 
     scheduler_options = scheduler.SchedulerOptions(