From 4fcc5519095ead2e1a48f03246314bf967ed5bb2 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Sat, 6 Sep 2025 10:59:57 +0800 Subject: [PATCH 1/5] typos: fix Instalation to Installation and other typos --- README.md | 2 +- facto/inputgen/argtuple/engine.py | 4 ++-- facto/inputgen/overview.md | 2 +- facto/inputgen/variable/space.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd4831a..c77e163 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Here is an [overview](facto/inputgen/overview.md) of InputGen SpecDB is a [database](facto/specdb/db.py#L30) of specifications covering most of the Core ATen Ops. They have been developed using the ATen CPU kernels as a reference. -## Instalation +## Installation ```bash git clone https://github.com/meta-pytorch/FACTO.git cd FACTO diff --git a/facto/inputgen/argtuple/engine.py b/facto/inputgen/argtuple/engine.py index 2d37e40..5871017 100644 --- a/facto/inputgen/argtuple/engine.py +++ b/facto/inputgen/argtuple/engine.py @@ -11,11 +11,11 @@ def reverse_topological_sort(graph): - def dfs(node, visited, strack): + def dfs(node, visited, stack): visited[node] = True for neig in graph[node]: if not visited[neig]: - dfs(neig, visited, strack) + dfs(neig, visited, stack) stack.append(node) visited = {node: False for node in graph} diff --git a/facto/inputgen/overview.md b/facto/inputgen/overview.md index ce25b07..eb632c8 100644 --- a/facto/inputgen/overview.md +++ b/facto/inputgen/overview.md @@ -38,7 +38,7 @@ An argument of an op might depend on another argument. For example, an argument ### Constraints A given constraint has 3 parts: an attribute, a suffix and a lambda function. -We already went through the attributes. The suffix is a basic operation, like Equal (Eq), Not Equal (Ne), Less than (Lt), Greather than (Gt), etc. +We already went through the attributes. The suffix is a basic operation, like Equal (Eq), Not Equal (Ne), Less than (Lt), Greater than (Gt), etc. The lambda function takes the dependencies (other arguments) as inputs, and outputs certain value. The constraint should then be read as: attribute suffix value. For example, if the attribute is Length, and suffix is Gt, and the lambda function outputs 4, then the constraint is saying that the Length > 4. ## Generation diff --git a/facto/inputgen/variable/space.py b/facto/inputgen/variable/space.py index 907ffad..517838b 100644 --- a/facto/inputgen/variable/space.py +++ b/facto/inputgen/variable/space.py @@ -19,7 +19,7 @@ class Discrete: """ - Representes a set of discrete values. Examples: + Represents a set of discrete values. Examples: >>> d = Discrete(['a','b','c']) >>> d.contains('a') @@ -149,9 +149,9 @@ def __init__( self.upper_open = upper_open def __str__(self) -> str: - lower_braket = "(" if self.lower_open else "[" - upper_braket = ")" if self.upper_open else "]" - return f"{lower_braket}{self.lower}, {self.upper}{upper_braket}" + lower_bracket = "(" if self.lower_open else "[" + upper_bracket = ")" if self.upper_open else "]" + return f"{lower_bracket}{self.lower}, {self.upper}{upper_bracket}" def __eq__(self, other: "Interval") -> bool: return ( @@ -337,7 +337,7 @@ def set_lower(self, lower: Union[int, float], lower_open: bool = False) -> None: def set_upper(self, upper: Union[int, float], upper_open: bool = False) -> None: """Sets the upper bound, being open or closed depending on the flag. In other - words, it removes all values greather than the given value. It also removes the value + words, it removes all values greater than the given value. It also removes the value itself if upper_open is True.""" for ix, r in enumerate(self.intervals): if r.upper < upper: From b3d310236d04a3f1fdfa343bc30e12956b3a0c2f Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 12 Sep 2025 14:09:16 +0800 Subject: [PATCH 2/5] empty commit From 899adff9823bef00c688a8e5db2771bf97691809 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 12 Sep 2025 16:21:28 +0800 Subject: [PATCH 3/5] fix test_meta_arg_engine --- test/inputgen/test_meta_arg_engine.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/inputgen/test_meta_arg_engine.py b/test/inputgen/test_meta_arg_engine.py index d801441..7eeada4 100644 --- a/test/inputgen/test_meta_arg_engine.py +++ b/test/inputgen/test_meta_arg_engine.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. import unittest - +import sys from facto.inputgen.argument.engine import MetaArgEngine from facto.inputgen.argument.type import ArgType from facto.inputgen.attribute.model import Attribute @@ -73,12 +73,18 @@ def test_optional_int(self): engine = MetaArgEngine(outarg, ArgType.IntOpt, constraints, deps, True) ms = list(engine.gen(Attribute.OPTIONAL)) # focus is OPTIONAL self.assertEqual(len(ms), 1) - self.assertEqual(str(ms[0]), "ArgType.IntOpt None") + if sys.version_info >= (3, 11): + self.assertEqual(str(ms[0]), "ArgType.IntOpt None") + else: + self.assertEqual(str(ms[0]), "Integer? None") engine = MetaArgEngine(outarg, ArgType.IntOpt, constraints, deps, True) ms = list(engine.gen(Attribute.VALUE)) # focus is VALUE self.assertEqual(len(ms), 1) - self.assertEqual(str(ms[0]), "ArgType.IntOpt None") + if sys.version_info >= (3, 11): + self.assertEqual(str(ms[0]), "ArgType.IntOpt None") + else: + self.assertEqual(str(ms[0]), "Integer? None") if __name__ == "__main__": From 97d36f31261de351f7b80a0586a1ca8ca63d8d05 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 12 Sep 2025 16:31:58 +0800 Subject: [PATCH 4/5] add custom __str__ to fix test_meta_arg_engine --- facto/inputgen/argument/type.py | 4 ++++ test/inputgen/test_meta_arg_engine.py | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/facto/inputgen/argument/type.py b/facto/inputgen/argument/type.py index b3a9f25..c2890d6 100644 --- a/facto/inputgen/argument/type.py +++ b/facto/inputgen/argument/type.py @@ -45,6 +45,10 @@ class ArgType(str, Enum): StringOpt = "String?" MemoryFormat = "MemoryFormat" + def __str__(self): + cls_name = self.__class__.__name__ + return f'{cls_name}.{self.name}' + def is_tensor(self) -> bool: return self in [ArgType.Tensor, ArgType.TensorOpt] diff --git a/test/inputgen/test_meta_arg_engine.py b/test/inputgen/test_meta_arg_engine.py index 7eeada4..84ead8c 100644 --- a/test/inputgen/test_meta_arg_engine.py +++ b/test/inputgen/test_meta_arg_engine.py @@ -73,18 +73,12 @@ def test_optional_int(self): engine = MetaArgEngine(outarg, ArgType.IntOpt, constraints, deps, True) ms = list(engine.gen(Attribute.OPTIONAL)) # focus is OPTIONAL self.assertEqual(len(ms), 1) - if sys.version_info >= (3, 11): - self.assertEqual(str(ms[0]), "ArgType.IntOpt None") - else: - self.assertEqual(str(ms[0]), "Integer? None") + self.assertEqual(str(ms[0]), "ArgType.IntOpt None") engine = MetaArgEngine(outarg, ArgType.IntOpt, constraints, deps, True) ms = list(engine.gen(Attribute.VALUE)) # focus is VALUE self.assertEqual(len(ms), 1) - if sys.version_info >= (3, 11): - self.assertEqual(str(ms[0]), "ArgType.IntOpt None") - else: - self.assertEqual(str(ms[0]), "Integer? None") + self.assertEqual(str(ms[0]), "ArgType.IntOpt None") if __name__ == "__main__": From e897d4c1df4cf3f87a10fd8178305d3bd42f5fb9 Mon Sep 17 00:00:00 2001 From: ooooo <3164076421@qq.com> Date: Fri, 12 Sep 2025 16:37:42 +0800 Subject: [PATCH 5/5] revert sys --- test/inputgen/test_meta_arg_engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/inputgen/test_meta_arg_engine.py b/test/inputgen/test_meta_arg_engine.py index 84ead8c..d801441 100644 --- a/test/inputgen/test_meta_arg_engine.py +++ b/test/inputgen/test_meta_arg_engine.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. import unittest -import sys + from facto.inputgen.argument.engine import MetaArgEngine from facto.inputgen.argument.type import ArgType from facto.inputgen.attribute.model import Attribute