From 5333c25baaf4fe136ed45edd6521dc7a2a5de851 Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Tue, 16 May 2023 09:08:48 +0100 Subject: 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 Change-Id: Ic57b9387950824e994c5e7f9ec1489c29159b974 --- tools/genspec.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tools/genspec.py') 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>'.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") -- cgit v1.2.1