aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Smolens <jared.smolens@arm.com>2021-03-04 15:24:10 -0800
committerKevin Cheng <kevin.cheng@arm.com>2021-04-30 09:45:47 -0700
commit573ecd4373f4e8f5d1a219147b5a259125059cf0 (patch)
tree7f221ded99ee3708a428c0e90d5a3e7d7b28c7e5
parent989cb050228b47085189b1c5cb0d9b705e1060e7 (diff)
downloadreference_model-573ecd4373f4e8f5d1a219147b5a259125059cf0.tar.gz
Re-order TOSA unit tests to match the spec ordering
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Signed-off-by: Jared Smolens <jared.smolens@arm.com> Change-Id: I0ef59cadd2f5097a08abb00d3fc256c556107ee0
-rw-r--r--verif/tosa_test_gen.py351
1 files changed, 207 insertions, 144 deletions
diff --git a/verif/tosa_test_gen.py b/verif/tosa_test_gen.py
index 134f569..7731a75 100644
--- a/verif/tosa_test_gen.py
+++ b/verif/tosa_test_gen.py
@@ -1851,13 +1851,130 @@ class TosaTestGen:
DEFAULT_RANK_RANGE = (1, 4)
TOSA_OP_LIST = {
- # Binary ops
+ # Tensor operators
+ "argmax": {
+ "op": Op.ARGMAX,
+ "operands": (1, 0),
+ "build_fcn": (build_argmax, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
+ "types": TYPE_NARROW_INT_FP,
+ },
+
+ "avg_pool2d": {
+ "op": Op.AVG_POOL2D,
+ "operands": (1, 0),
+ "rank": (4, 4),
+ "build_fcn": (build_pool2d, TosaTensorGen.tgNHWC, TosaArgGen.agPooling),
+ "qgen": TosaQuantGen.qgUnary,
+ "types": TYPE_NARROW_INT_FP,
+ },
+
+ # Templated operator. Filled in by createDynamicOpLists
+ "conv2d_TEMPLATE": {
+ "op": Op.CONV2D,
+ "operands": (1, 2),
+ "rank": (4, 4),
+ "build_fcn": (build_conv2d, TosaTensorGen.tgConv2D, TosaArgGen.agConv2D),
+ "qgen": TosaQuantGen.qgConv,
+ "types": TYPE_CONV2D,
+ "template": True,
+ },
+
+ # Conv3d TBD
+
+ # Templated operator. Filled in by createDynamicOpLists
+ "depthwise_conv2d_TEMPLATE": {
+ "op": Op.DEPTHWISE_CONV2D,
+ "operands": (1, 2),
+ "filter": [1, 1],
+ "rank": (4, 4),
+ "build_fcn": (
+ build_depthwise_conv2d,
+ TosaTensorGen.tgDepthwiseConv2D,
+ TosaArgGen.agConv2D,
+ ),
+ "qgen": TosaQuantGen.qgConv,
+ "types": TYPE_CONV2D,
+ "template": True,
+ },
+
+ "fully_connected": {
+ "op": Op.FULLY_CONNECTED,
+ "operands": (1, 2),
+ "rank": (2, 2),
+ "build_fcn": (build_fully_connected, TosaTensorGen.tgFullyConnected, None),
+ "qgen": TosaQuantGen.qgConv,
+ "types": TYPE_CONV2D,
+ },
+
+ "matmul": {
+ "op": Op.MATMUL,
+ "operands": (2, 0),
+ "rank": (2, 2),
+ "build_fcn": (build_matmul, TosaTensorGen.tgMatmul, None),
+ "qgen": TosaQuantGen.qgMatmul,
+ "types": TYPE_NARROW_INT_FP,
+ },
+
+ "max_pool2d": {
+ "op": Op.MAX_POOL2D,
+ "operands": (1, 0),
+ "rank": (4, 4),
+ "build_fcn": (build_pool2d, TosaTensorGen.tgNHWC, TosaArgGen.agPooling),
+ "types": TYPE_NARROW_INT_FP,
+ },
+
+ # Templated operator. Filled in by createDynamicOpLists
+ "transpose_conv2d_TEMPLATE": {
+ "op": Op.TRANSPOSE_CONV2D,
+ "operands": (1, 2),
+ "rank": (4, 4),
+ "build_fcn": (
+ build_transpose_conv2d,
+ TosaTensorGen.tgTransposeConv2D,
+ TosaArgGen.agTransposeConv2D,
+ ),
+ "qgen": TosaQuantGen.qgConv,
+ "types": TYPE_CONV2D,
+ "template": True,
+ },
+
+ # Activation functions
+ "clamp": {
+ "op": Op.CLAMP,
+ "operands": (1, 0),
+ "build_fcn": (build_clamp, TosaTensorGen.tgBasic, None),
+ "types": TYPE_NARROW_INT_FP,
+ },
+
+ "relun": {
+ "op": Op.RELUN,
+ "operands": (1, 0),
+ "build_fcn": (build_relun, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FI32,
+ },
+
+ "sigmoid": {
+ "op": Op.SIGMOID,
+ "operands": (1, 0),
+ "build_fcn": (build_sigmoid, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FP,
+ },
+
+ "tanh": {
+ "op": Op.TANH,
+ "operands": (1, 0),
+ "build_fcn": (build_tanh, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FP,
+ },
+
+ # Elementwise Binary Operators
"add": {
"op": Op.ADD,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
+
"arithmetic_right_shift": {
"op": Op.ARITHMETIC_RIGHT_SHIFT,
"operands": (2, 0),
@@ -1868,84 +1985,98 @@ class TosaTestGen:
),
"types": TYPE_INT,
},
+
"bitwise_and": {
"op": Op.BITWISE_AND,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_INT,
},
+
"bitwise_or": {
"op": Op.BITWISE_OR,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_INT,
},
+
"bitwise_xor": {
"op": Op.BITWISE_XOR,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_INT,
},
+
"logical_and": {
"op": Op.LOGICAL_AND,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_BOOL,
},
+
"logical_left_shift": {
"op": Op.LOGICAL_LEFT_SHIFT,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_INT,
},
+
"logical_right_shift": {
"op": Op.LOGICAL_RIGHT_SHIFT,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_INT,
},
+
"logical_or": {
"op": Op.LOGICAL_OR,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_BOOL,
},
+
"logical_xor": {
"op": Op.LOGICAL_XOR,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_BOOL,
},
- "max": {
+
+ "maximum": {
"op": Op.MAXIMUM,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
- "min": {
+
+ "minimum": {
"op": Op.MINIMUM,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
+
"mul": {
"op": Op.MUL,
"operands": (2, 0),
"build_fcn": (build_mul, TosaTensorGen.tgBroadcastFuzz, TosaArgGen.agMul),
"types": TYPE_INT_FP,
},
+
"pow": {
"op": Op.POW,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
+
"sub": {
"op": Op.SUB,
"operands": (2, 0),
"build_fcn": (build_binary_broadcast, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
+
"table": {
"op": Op.TABLE,
# Use the automatic generation functions to create the input array
@@ -1955,122 +2086,64 @@ class TosaTestGen:
"build_fcn": (build_table, TosaTensorGen.tgBasic, None),
"types": [DType.INT16],
},
- "argmax": {
- "op": Op.ARGMAX,
- "operands": (1, 0),
- "build_fcn": (build_argmax, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
- "types": TYPE_NARROW_INT_FP,
- },
- # Templated operator. Filled in by createDynamicOpLists
- "conv2d_TEMPLATE": {
- "op": Op.CONV2D,
- "operands": (1, 2),
- "rank": (4, 4),
- "build_fcn": (build_conv2d, TosaTensorGen.tgConv2D, TosaArgGen.agConv2D),
- "qgen": TosaQuantGen.qgConv,
- "types": TYPE_CONV2D,
- "template": True,
- },
- # Templated operator. Filled in by createDynamicOpLists
- "depthwise_conv2d_TEMPLATE": {
- "op": Op.DEPTHWISE_CONV2D,
- "operands": (1, 2),
- "filter": [1, 1],
- "rank": (4, 4),
- "build_fcn": (
- build_depthwise_conv2d,
- TosaTensorGen.tgDepthwiseConv2D,
- TosaArgGen.agConv2D,
- ),
- "qgen": TosaQuantGen.qgConv,
- "types": TYPE_CONV2D,
- "template": True,
- },
- # Templated operator. Filled in by createDynamicOpLists
- "transpose_conv2d_TEMPLATE": {
- "op": Op.TRANSPOSE_CONV2D,
- "operands": (1, 2),
- "rank": (4, 4),
- "build_fcn": (
- build_transpose_conv2d,
- TosaTensorGen.tgTransposeConv2D,
- TosaArgGen.agTransposeConv2D,
- ),
- "qgen": TosaQuantGen.qgConv,
- "types": TYPE_CONV2D,
- "template": True,
- },
- "fully_connected": {
- "op": Op.FULLY_CONNECTED,
- "operands": (1, 2),
- "rank": (2, 2),
- "build_fcn": (build_fully_connected, TosaTensorGen.tgFullyConnected, None),
- "qgen": TosaQuantGen.qgConv,
- "types": TYPE_CONV2D,
- },
- "matmul": {
- "op": Op.MATMUL,
- "operands": (2, 0),
- "rank": (2, 2),
- "build_fcn": (build_matmul, TosaTensorGen.tgMatmul, None),
- "qgen": TosaQuantGen.qgMatmul,
- "types": TYPE_NARROW_INT_FP,
- },
- # Unary operators
+
+ # Elementwise Unary operators
"abs": {
"op": Op.ABS,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FI32,
},
+
"bitwise_not": {
"op": Op.BITWISE_NOT,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_INT,
},
+
"ceil": {
"op": Op.CEIL,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
+
"clz": {
"op": Op.CLZ,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": [DType.INT32],
},
+
"exp": {
"op": Op.EXP,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
+
"floor": {
"op": Op.FLOOR,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
+
"log": {
"op": Op.LOG,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
- "floor": {
- "op": Op.FLOOR,
- "operands": (1, 0),
- "build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
- "types": TYPE_FP,
- },
+
"logical_not": {
"op": Op.LOGICAL_NOT,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_BOOL,
},
+
"negate": {
"op": Op.NEGATE,
"operands": (1, 0),
@@ -2078,25 +2151,29 @@ class TosaTestGen:
"qgen": TosaQuantGen.qgUnary,
"types": TYPE_INT_FP,
},
+
"reciprocal": {
"op": Op.RECIPROCAL,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
+
"rsqrt": {
"op": Op.RSQRT,
"operands": (1, 0),
"build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
"types": TYPE_FP,
},
- # Ternary operators
+
+ # Elementwise Ternary operators
"select": {
"op": Op.SELECT,
"operands": (3, 0),
"build_fcn": (build_select, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FIB,
},
+
# Comparison operators
"equal": {
"op": Op.EQUAL,
@@ -2104,96 +2181,64 @@ class TosaTestGen:
"build_fcn": (build_comparison, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
+
"greater_equal": {
"op": Op.GREATER_EQUAL,
"operands": (2, 0),
"build_fcn": (build_comparison, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
+
"greater": {
"op": Op.GREATER,
"operands": (2, 0),
"build_fcn": (build_comparison, TosaTensorGen.tgBroadcastFuzz, None),
"types": TYPE_FI32,
},
- # Pooling operators
- "avg_pool2d": {
- "op": Op.AVG_POOL2D,
- "operands": (1, 0),
- "rank": (4, 4),
- "build_fcn": (build_pool2d, TosaTensorGen.tgNHWC, TosaArgGen.agPooling),
- "qgen": TosaQuantGen.qgUnary,
- "types": TYPE_NARROW_INT_FP,
- },
- "max_pool2d": {
- "op": Op.MAX_POOL2D,
- "operands": (1, 0),
- "rank": (4, 4),
- "build_fcn": (build_pool2d, TosaTensorGen.tgNHWC, TosaArgGen.agPooling),
- "types": TYPE_NARROW_INT_FP,
- },
- # Reduce operators
- "reduce_any": {
- "op": Op.REDUCE_ANY,
+
+ # Reduction operators
+ "reduce_all": {
+ "op": Op.REDUCE_ALL,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_BOOL,
},
- "reduce_all": {
- "op": Op.REDUCE_ALL,
+
+ "reduce_any": {
+ "op": Op.REDUCE_ANY,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_BOOL,
},
+
"reduce_max": {
"op": Op.REDUCE_MAX,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_INT_FP,
},
+
"reduce_min": {
"op": Op.REDUCE_MAX,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_INT_FP,
},
+
"reduce_product": {
"op": Op.REDUCE_PRODUCT,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_FP,
},
+
"reduce_sum": {
"op": Op.REDUCE_SUM,
"operands": (1, 0),
"build_fcn": (build_reduce, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_FI32,
},
- # Activation functions
- "clamp": {
- "op": Op.CLAMP,
- "operands": (1, 0),
- "build_fcn": (build_clamp, TosaTensorGen.tgBasic, None),
- "types": TYPE_NARROW_INT_FP,
- },
- "relun": {
- "op": Op.RELUN,
- "operands": (1, 0),
- "build_fcn": (build_relun, TosaTensorGen.tgBasic, None),
- "types": TYPE_FI32,
- },
- "sigmoid": {
- "op": Op.SIGMOID,
- "operands": (1, 0),
- "build_fcn": (build_sigmoid, TosaTensorGen.tgBasic, None),
- "types": TYPE_FP,
- },
- "tanh": {
- "op": Op.TANH,
- "operands": (1, 0),
- "build_fcn": (build_tanh, TosaTensorGen.tgBasic, None),
- "types": TYPE_FP,
- },
+
# Data layout operators
"concat": {
"op": Op.CONCAT,
@@ -2201,6 +2246,7 @@ class TosaTestGen:
"build_fcn": (build_concat, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_FIB,
},
+
"pad": {
"op": Op.PAD,
"operands": (1, 0),
@@ -2208,30 +2254,35 @@ class TosaTestGen:
"qgen": TosaQuantGen.qgPad,
"types": TYPE_FIB,
},
+
"reshape": {
"op": Op.RESHAPE,
"operands": (1, 0),
"build_fcn": (build_reshape, TosaTensorGen.tgBasic, TosaArgGen.agReshape),
"types": TYPE_FIB,
},
+
"reverse": {
"op": Op.REVERSE,
"operands": (1, 0),
"build_fcn": (build_reverse, TosaTensorGen.tgBasic, TosaArgGen.agAxis),
"types": TYPE_FIB,
},
+
"slice": {
"op": Op.SLICE,
"operands": (1, 0),
"build_fcn": (build_slice, TosaTensorGen.tgBasic, TosaArgGen.agSlice),
"types": TYPE_FIB,
},
+
"tile": {
"op": Op.TILE,
"operands": (1, 0),
"build_fcn": (build_tile, TosaTensorGen.tgBasic, TosaArgGen.agTile),
"types": TYPE_FIB,
},
+
"transpose": {
"op": Op.TRANSPOSE,
"operands": (1, 0),
@@ -2243,6 +2294,36 @@ class TosaTestGen:
),
"types": TYPE_FIB,
},
+
+ # Data nodes
+ "const": {
+ "op": Op.CONST,
+ "operands": (1, 0),
+ "build_fcn": (build_placeholder, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FIB,
+ },
+
+ "identity": {
+ "op": Op.IDENTITY,
+ "operands": (1, 0),
+ "build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FIB,
+ },
+
+ "identityn": {
+ "op": Op.IDENTITYN,
+ "operands": (2, 0),
+ "build_fcn": (build_identityn, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FIB,
+ },
+
+ "placeholder": {
+ "op": Op.PLACEHOLDER,
+ "operands": (1, 0),
+ "build_fcn": (build_placeholder, TosaTensorGen.tgBasic, None),
+ "types": TYPE_FIB,
+ },
+
# Scatter/Gather
"gather": {
"op": Op.GATHER,
@@ -2252,6 +2333,7 @@ class TosaTestGen:
"build_fcn": (build_gather, TosaTensorGen.tgBasic, None),
"types": TYPE_INT_FP,
},
+
"scatter": {
"op": Op.SCATTER,
# Only specify 'values_in' tensor here.
@@ -2261,6 +2343,7 @@ class TosaTestGen:
"build_fcn": (build_scatter, TosaTensorGen.tgScatter, None),
"types": TYPE_INT_FP,
},
+
# Image operations
"resize": {
"op": Op.RESIZE,
@@ -2269,31 +2352,7 @@ class TosaTestGen:
"build_fcn": (build_resize, TosaTensorGen.tgNHWC, TosaArgGen.agResize),
"types": [DType.INT8, DType.INT16, DType.FLOAT],
},
- # Data nodes
- "placeholder": {
- "op": Op.PLACEHOLDER,
- "operands": (1, 0),
- "build_fcn": (build_placeholder, TosaTensorGen.tgBasic, None),
- "types": TYPE_FIB,
- },
- "const": {
- "op": Op.CONST,
- "operands": (1, 0),
- "build_fcn": (build_placeholder, TosaTensorGen.tgBasic, None),
- "types": TYPE_FIB,
- },
- "identity": {
- "op": Op.IDENTITY,
- "operands": (1, 0),
- "build_fcn": (build_unary, TosaTensorGen.tgBasic, None),
- "types": TYPE_FIB,
- },
- "identityn": {
- "op": Op.IDENTITYN,
- "operands": (2, 0),
- "build_fcn": (build_identityn, TosaTensorGen.tgBasic, None),
- "types": TYPE_FIB,
- },
+
# Type conversion
"cast": {
"op": Op.CAST,
@@ -2301,15 +2360,19 @@ class TosaTestGen:
"build_fcn": (build_cast, TosaTensorGen.tgBasic, TosaArgGen.agCast),
"types": [DType.FLOAT, DType.INT8, DType.INT16, DType.INT32, DType.BOOL],
},
+
"rescale": {
"op": Op.RESCALE,
"operands": (1, 0),
"build_fcn": (build_rescale, TosaTensorGen.tgBasic, TosaArgGen.agRescale),
"types": [DType.INT8, DType.INT16, DType.INT32, DType.INT48],
},
+
# Custom
# Not implemented.
- # Control flow
+
+
+ # Control flow operators
# Two varients of cond_if, one that generates one of two constant tensors (no
# inputs to the basic blocks, one output) and another that either adds or subtracts two tensors
# (two inputs to the basic blocks, one output)