diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/genspec.py | 10 | ||||
-rw-r--r-- | tools/tosa.py | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/tools/genspec.py b/tools/genspec.py index c871b75..33e8e35 100755 --- a/tools/genspec.py +++ b/tools/genspec.py @@ -44,6 +44,16 @@ class TOSASpecAsciidocGenerator: entry += "\n" file.write(entry) file.write("|===\n") + file.write("\n*Operation Function:*\n\n") + leveltext = "" + for arg in op.arguments: + if (len(arg.levellimits) > 0): + for limit in arg.levellimits: + leveltext += " LEVEL_CHECK(" + limit[0] + " <= " + limit[1] + ");\n" + if (len(leveltext) > 0): + file.write( + f"[source,c++]\n----\nif (level != tosa_level_none) {{\n{leveltext}}}\n----\n" + ) def generate(self, outdir): opdir = os.path.join(outdir, "operators") diff --git a/tools/tosa.py b/tools/tosa.py index 87b4f1a..2c2f8ec 100644 --- a/tools/tosa.py +++ b/tools/tosa.py @@ -9,12 +9,13 @@ class TOSAOperatorArgumentCategory: class TOSAOperatorArgument: - def __init__(self, name, description, categories, ty, shape): + def __init__(self, name, description, categories, ty, shape, levellimits): self.name = name self.description = description self.categories = categories self.type = ty self.shape = shape + self.levellimits = levellimits class TOSAOperatorDataTypeSupport: @@ -87,6 +88,11 @@ class TOSASpec: argcats = [] argtype = arg.get("type") shape = arg.get("shape") + levellimits = [] + for levellimit in arg.findall("levellimit"): + value = levellimit.get("value") + limit = levellimit.get("limit") + levellimits.append([value, limit]) cats = re.findall( r"(input|output|attribute)\(?([A-Z,]+)?\)?", arg.get("category") @@ -94,4 +100,4 @@ class TOSASpec: for cat in cats: argcats.append(TOSAOperatorArgumentCategory(cat[0], cat[1].split(","))) - return TOSAOperatorArgument(name, desc, argcats, argtype, shape) + return TOSAOperatorArgument(name, desc, argcats, argtype, shape, levellimits) |