aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKevin Petit <kevin.petit@arm.com>2023-05-16 09:08:48 +0100
committerKevin Petit <kevin.petit@arm.com>2023-05-24 09:45:01 +0100
commit5333c25baaf4fe136ed45edd6521dc7a2a5de851 (patch)
tree8f132429aabe8a3e6f1ef89414c1dd933164d95b /tools
parent277a4f17f13ac882075e109c339cdeda03f8eedd (diff)
downloadspecification-5333c25baaf4fe136ed45edd6521dc7a2a5de851.tar.gz
Formalise the description of operator argument types
- Standardise the terminology for operator arguments. Argument, Operand, and Parameter were used interchangeably. - Introduce a templatized tensor_t<> type for tensor arguments. Scalars are represented by rank-0 tensors. - Types can be checked with the XSD schema. Signed-off-by: Kevin Petit <kevin.petit@arm.com> Change-Id: Ic57b9387950824e994c5e7f9ec1489c29159b974
Diffstat (limited to 'tools')
-rwxr-xr-xtools/genspec.py21
-rw-r--r--tools/tosa.py10
2 files changed, 25 insertions, 6 deletions
diff --git a/tools/genspec.py b/tools/genspec.py
index c64f05b..11a3e72 100755
--- a/tools/genspec.py
+++ b/tools/genspec.py
@@ -18,10 +18,11 @@ class TOSASpecAsciidocGenerator:
def generate_operator(self, op, file):
file.write("\n*Arguments:*\n")
- file.write("[cols='2,1,1,1,2,4']")
+ file.write("[cols='3,3,2,2,4,8']")
file.write("\n|===\n")
file.write("|Argument|Type|Name|Shape|Rank|Description\n\n")
for arg in op.arguments:
+ # Argument
cats = arg.categories
if len(cats) > 1:
cattext = ""
@@ -33,6 +34,19 @@ class TOSASpecAsciidocGenerator:
sep = " "
else:
cattext = cats[0].name.title()
+
+ # Type
+ if arg.type == 'tensor_t':
+ argtype = 'T<{}>'.format(arg.tensor_element_type)
+ elif arg.type == 'tensor_list_t':
+ if arg.tensor_element_type == '-':
+ argtype = 'tensor_list_t'
+ else:
+ argtype = 'tensor_list_t<T<{}>>'.format(arg.tensor_element_type)
+ else:
+ argtype = arg.type
+
+ # Rank
if len(arg.rank) > 0:
if (arg.rank[0] == arg.rank[1]):
rank = f'{arg.rank[0]}'
@@ -40,9 +54,12 @@ class TOSASpecAsciidocGenerator:
rank = f'{arg.rank[0]} to {arg.rank[1]}'
else:
rank = ""
+
+ # Format and write line
file.write(
- f"|{cattext}|{arg.type}|{arg.name}|{arg.shape}|{rank}|{arg.description}\n"
+ f"|{cattext}|{argtype}|{arg.name}|{arg.shape}|{rank}|{arg.description}\n"
)
+
file.write("|===\n")
if op.typesupports:
file.write("\n*Supported Data Types:*\n\n")
diff --git a/tools/tosa.py b/tools/tosa.py
index 218412f..d01d9c2 100644
--- a/tools/tosa.py
+++ b/tools/tosa.py
@@ -36,11 +36,12 @@ class TOSALevel:
self.maximums = maximums
class TOSAOperatorArgument:
- def __init__(self, name, description, categories, ty, shape, levellimits, rank):
+ def __init__(self, name, description, categories, ty, elty, shape, levellimits, rank):
self.name = name
self.description = description
self.categories = categories
self.type = ty
+ self.tensor_element_type = elty
self.shape = shape
self.levellimits = levellimits
self.rank = rank
@@ -144,14 +145,15 @@ class TOSASpec:
desc = arg.find("description").text.strip()
argcats = []
argtype = arg.get("type")
+ argtelty = arg.get("tensor-element-type")
shape = arg.get("shape")
levellimits = []
rank = []
r = arg.find("rank")
if r != None:
- if shape == "-":
- raise RuntimeError(f"rank is not empty, but shape is '-' for {op_name}: {name}")
rank = [r.get('min'),r.get('max')]
+ if shape == "-" and (rank[0] != '0' or rank[1] != '0'):
+ raise RuntimeError(f"rank is not empty or non-zero, but shape is '-' for {op_name}: {name}")
# validate rank against the shape argument
(shape_check, shape_rank) = get_rank_from_shape(shape)
if shape_check and (shape_rank < int(rank[0]) or shape_rank > int(rank[1])):
@@ -170,7 +172,7 @@ class TOSASpec:
for cat in cats:
argcats.append(TOSAOperatorArgumentCategory(cat[0], cat[1].split(",")))
- return TOSAOperatorArgument(name, desc, argcats, argtype, shape, levellimits, rank)
+ return TOSAOperatorArgument(name, desc, argcats, argtype, argtelty, shape, levellimits, rank)
def __load_enum(self, arg):
name = arg.get("name")