aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/operation.py
diff options
context:
space:
mode:
authorTim Hall <tim.hall@arm.com>2022-07-21 11:46:03 +0100
committertim.hall <tim.hall@arm.com>2022-07-23 16:56:07 +0000
commit885033b5bf2f6513b438f273b2bc71964f0c6c59 (patch)
treec52a6c5bbe1c6f4295aa94206b80a37a60fcf182 /ethosu/vela/operation.py
parent47c7636586be265eed9e352e6ad4c090a02fb31f (diff)
downloadethos-u-vela-885033b5bf2f6513b438f273b2bc71964f0c6c59.tar.gz
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
Diffstat (limited to 'ethosu/vela/operation.py')
-rw-r--r--ethosu/vela/operation.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/ethosu/vela/operation.py b/ethosu/vela/operation.py
index f3eace7e..1a34d0e1 100644
--- a/ethosu/vela/operation.py
+++ b/ethosu/vela/operation.py
@@ -248,8 +248,9 @@ class Op(Enum):
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 @@ class Op(Enum):
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 @@ class Operation:
__slots__ = (
"type",
+ "original_type",
"name",
"op_index",
"attrs",
@@ -497,6 +502,7 @@ class Operation:
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]] = []