aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2021-12-13 15:40:04 -0800
committerEric Kunze <eric.kunze@arm.com>2022-01-07 14:28:31 -0800
commita3eded0843874a78e69e4b985cb2a492bfab78f3 (patch)
tree18a71120e14ff64cf2acbe4463dea78cff910c5a
parentf734f1b1c81d401f7e1891c763824038501b4969 (diff)
downloadspecification-a3eded0843874a78e69e4b985cb2a492bfab78f3.tar.gz
Add rudimentary spell check for specification
We can't easily spell check the entire specification, the pseudocode and operator tables make it unworkable. This adds a simple python script that tries to extract just the description of the operators for checking. It also does a check over the entire license. A custom dictionary is used to contain specification custom words. Change-Id: I74558c03af1506e2970f20b3246d920c2753ca44 Signed-off-by: Eric Kunze <eric.kunze@arm.com>
-rw-r--r--Makefile26
-rw-r--r--chapters/introduction.adoc10
-rw-r--r--chapters/pseudocode.adoc4
-rw-r--r--tools/dictionary.dic67
-rw-r--r--tools/get_descriptions.py53
5 files changed, 149 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index cf2ab53..407047d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
#
# This confidential and proprietary software may be used only as
# authorised by a licensing agreement from ARM Limited
-# (C) COPYRIGHT 2020 ARM Limited
+# (C) COPYRIGHT 2020-2022 ARM Limited
# ALL RIGHTS RESERVED
# The entire notice above must be reproduced on all authorised
# copies and copies may only be made to the extent permitted
@@ -11,6 +11,7 @@
TOSAREVISION=0.24.0 draft
MKDIR=mkdir -p
ASCIIDOC=asciidoctor
+ASPELL=aspell
HTMLDIR=out/html
PDFDIR=out/pdf
@@ -18,13 +19,14 @@ PDFDIR=out/pdf
COMMON_ARGS= -a revnumber="$(TOSAREVISION)"
SPECSRC := tosa_spec.adoc
-SPECFILES = $(wildcard chapters/[A-Za-z]*.adoc) tosa.css
+ADOCFILES = $(wildcard chapters/[A-Za-z]*.adoc)
+SPECFILES = $(ADOCFILES) tosa.css
.DELETE_ON_ERROR:
-.PHONY: all html pdf clean
+.PHONY: all html pdf clean spell
-all: html pdf
+all: spell html pdf
html: $(HTMLDIR)/tosa_spec.html
@@ -34,6 +36,19 @@ clean:
$(RM) $(HTMLDIR)/tosa_spec.html
$(RM) $(PDFDIR)/tosa_spec.pdf
+spell: out/spell.txt
+
+out/spell.txt: $(ADOCFILES) FORCE
+ @echo Running spell check
+ @mkdir -p $(@D)
+ @tools/get_descriptions.py $(ADOCFILES) \
+ | $(ASPELL) list -v -l en-US --encoding=UTF-8 --add-extra-dicts=./tools/dictionary.dic\
+ | sort -u > $@
+ @-if [ -s $@ ] ; then \
+ echo Spelling errors detected, check $@; \
+ else echo No spelling errors found ; \
+ fi
+
$(HTMLDIR)/tosa_spec.html: $(SPECSRC) $(SPECFILES)
$(MKDIR) $(HTMLDIR)
$(ASCIIDOC) -b html5 -a stylesheet=tosa.css $(COMMON_ARGS) -o $@ $<
@@ -41,3 +56,6 @@ $(HTMLDIR)/tosa_spec.html: $(SPECSRC) $(SPECFILES)
$(PDFDIR)/tosa_spec.pdf: $(SPECSRC) $(SPECFILES)
$(MKDIR) $(PDFDIR)
$(ASCIIDOC) -r asciidoctor-pdf -b pdf $(COMMON_ARGS) -o $@ $(SPECSRC)
+
+.PHONY: FORCE
+FORCE:
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc
index 855be3d..3fb5476 100644
--- a/chapters/introduction.adoc
+++ b/chapters/introduction.adoc
@@ -1,7 +1,7 @@
//
// This confidential and proprietary software may be used only as
// authorised by a licensing agreement from ARM Limited
-// (C) COPYRIGHT 2020-2021 ARM Limited
+// (C) COPYRIGHT 2020-2022 ARM Limited
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorised
// copies and copies may only be made to the extent permitted
@@ -74,8 +74,8 @@ The term conformant will mean the same as compliant.
==== Baseline Inference Profile
-The <<Operator Graphs>> section of this specification defines a TOSA graph and the behaviour defined for a TOSA graph.
-This behaviour is captured in the pseudo-code function tosa_execute_graph().
+The <<Operator Graphs>> section of this specification defines a TOSA graph and the behavior defined for a TOSA graph.
+This behavior is captured in the pseudo-code function tosa_execute_graph().
For a given input graph (with attributes) and input tensors there are three possible tosa_graph_result values after executing the graph:
* tosa_unpredictable: The result of the graph on the given inputs cannot be relied upon.
@@ -449,7 +449,7 @@ void generate_lookup_table(int16_t *table, int32_t (*reference)(int32_t))
=== Floating-point
-TOSA does not define bit-exact behaviour of the floating-point type, since floating-point operation results can vary according to operation order (floating-point addition is not associative in general) and rounding behaviour.
+TOSA does not define bit-exact behavior of the floating-point type, since floating-point operation results can vary according to operation order (floating-point addition is not associative in general) and rounding behavior.
If a bit-exact answer is required then integer operations should be used.
TOSA does define that the floating-point type must support the following list of features.
These features ensure that detection of overflow and other exceptional conditions can be handled consistently.
@@ -460,7 +460,7 @@ These features ensure that detection of overflow and other exceptional condition
* The floating-point type must support signed zero
* The floating-point type must support handling of infinities, NaNs, zeros as in the following table
-.floating-point behaviour
+.floating-point behavior
|===
|Case|Result
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc
index d5f05db..71cc14d 100644
--- a/chapters/pseudocode.adoc
+++ b/chapters/pseudocode.adoc
@@ -27,8 +27,8 @@ This condition is captured in the ERROR_IF function.
*Implementation Notes*
-* An implementation is not required to detect unpredictable behaviour. If tosa_execute_graph() returns tosa_unpredictable then the tosa_test_compliance() function does not require any specific output from an implementation.
-* An implementation is required to detect errors in a graph that does not have unpredictable behaviour (see tosa_test_compliance).
+* An implementation is not required to detect unpredictable behavior. If tosa_execute_graph() returns tosa_unpredictable then the tosa_test_compliance() function does not require any specific output from an implementation.
+* An implementation is required to detect errors in a graph that does not have unpredictable behavior (see tosa_test_compliance).
* An acceptable implementation is to stop and report an error on the first ERROR_IF condition that occurs. This satifies tosa_test_compliance() even if the tosa_execute_graph() was tosa_unpredictable.
* If the tosa_execute_graphs() result is tosa_unpredictable or tosa_error, then there is no requirement on the implementation to execute any portion of the TOSA graph.
diff --git a/tools/dictionary.dic b/tools/dictionary.dic
new file mode 100644
index 0000000..94ef782
--- /dev/null
+++ b/tools/dictionary.dic
@@ -0,0 +1,67 @@
+personal_ws-1.1 en 500
+activations
+ARGMAX
+AsciiDoc
+BILINEAR
+bilinearly
+bitwise
+BITWISE
+Bool
+CEIL
+CLZ
+concat
+CONCAT
+COND
+conformant
+const
+CONST
+CONV
+CPUs
+denormalizing
+DEPTHWISE
+Elementwise
+foreach
+Fulbourn
+GPUs
+Hadamard
+INTDIV
+licence
+Licence
+LICENCE
+licensable
+lookups
+lowerroman
+MATMUL
+md
+MERCHANTABILITY
+MUL
+multipler
+NPUs
+precisions
+pseudocode
+Pseudocode
+PyTorch
+quantization
+Quantization
+quantized
+Quantized
+README
+Rescale
+RESCALE
+rescaled
+RSQRT
+sigmoid
+Sigmoid
+SIGMOID
+SIMD
+subtensor
+tanh
+TANH
+TensorFlow
+tensorinfo
+TFLite
+tosa
+TOSA
+TPUs
+unary
+Unary
diff --git a/tools/get_descriptions.py b/tools/get_descriptions.py
new file mode 100644
index 0000000..3f2ee05
--- /dev/null
+++ b/tools/get_descriptions.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+
+# Copyright (c) 2022, ARM Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Script to pull the descriptions out of the specification so that
+# they can be run through a spellcheck with less noise
+
+import argparse
+import re
+
+parser = argparse.ArgumentParser()
+parser.add_argument(
+ "filenames", nargs="+", help="filename to extract descriptions from"
+)
+args = parser.parse_args()
+
+for name in args.filenames:
+ # special case the license as it is all text
+ if name == "chapters/tosa_license.adoc":
+ always_in = True
+ else:
+ always_in = False
+ with open(name, "r") as docfile:
+ in_description = False
+ for text in docfile:
+ if always_in:
+ print(text)
+ continue
+ if not in_description:
+ # Look for the start of an operator
+ if re.match(r'^===', text):
+ in_description = True
+ print(text)
+ else:
+ # Stop when we get to a subsection like *Arguments*
+ # or pseudocode in a [source] section. Spellcheck is
+ # not useful there
+ if re.match(r'[\[\*]', text):
+ in_description = False
+ else:
+ print(text)