MLBEDSW-4157: Add RESIZE_NEAREST_NEIGHBOR support
- Changed ResizeBilinear to support ResizeNearestNeighbor as well for
1x1 IFM, IFM equal OFM, and non-align corners
- Added support for ResizeNearestNeighbor with align corners by
converting to a DepthwiseConv
- Updated supported operator unit tests
- Added is_resize() helper function and some associated refactoring
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: Id5bdf2a25e8aa6a4f28b7236250abf768141ce37
diff --git a/ethosu/vela/operation.py b/ethosu/vela/operation.py
index f3eace7..1a34d0e 100644
--- a/ethosu/vela/operation.py
+++ b/ethosu/vela/operation.py
@@ -248,8 +248,9 @@
RescaleAdd = OperatorInfo(block_type=NpuBlockType.ElementWise, indices=NNG_IFM_IFM2_INDICES)
RescaleMul = OperatorInfo(block_type=NpuBlockType.ElementWise, indices=NNG_IFM_IFM2_INDICES)
Reshape = OperatorInfo(indices=NNG_IFM_INDICES)
+ # resize ops map to pooling operations unless explicitly converted to other operations in the graph optimiser
ResizeBilinear = OperatorInfo(block_type=NpuBlockType.Pooling, indices=NNG_IFM_INDICES)
- ResizeNearestNeighbor = OperatorInfo()
+ ResizeNearestNeighbor = OperatorInfo(block_type=NpuBlockType.Pooling, indices=NNG_IFM_INDICES)
ReverseSequence = OperatorInfo()
ReverseV2 = OperatorInfo()
Rnn = OperatorInfo(block_type=NpuBlockType.VectorProduct, indices=NNG_IFM_WEIGHTS_INDICES)
@@ -364,6 +365,9 @@
def is_concat_op(self):
return self in (Op.Concat, Op.ConcatTFLite, Op.PackReshaped, Op.Pack)
+ def is_resize_op(self):
+ return self in (Op.ResizeBilinear, Op.ResizeNearestNeighbor)
+
def needs_bias(self):
return bool(self.info.indices.biases)
@@ -467,6 +471,7 @@
__slots__ = (
"type",
+ "original_type",
"name",
"op_index",
"attrs",
@@ -497,6 +502,7 @@
def __init__(self, op_type: Op, name: str):
self.type = op_type
+ self.original_type = op_type
self.name = name
self.attrs: Dict[str, Any] = {}
self.inputs: List[Optional[Tensor]] = []