File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change
1
+ from abc import ABC
1
2
from dataclasses import asdict , dataclass
2
3
from typing import Any , Dict
3
4
4
5
5
6
@dataclass (eq = False )
6
- class NIRNode :
7
+ class NIRNode ( ABC ) :
7
8
"""Base superclass of Neural Intermediate Representation Unit (NIR).
8
9
9
10
All NIR primitives inherit from this class, but NIRNodes should never be
@@ -16,6 +17,9 @@ class NIRNode:
16
17
# output_type: Dict[str, np.ndarray] = field(init=False, kw_only=True)
17
18
# metadata: Dict[str, Any] = field(init=True, default_factory=dict)
18
19
20
+ def __init__ (self ) -> None :
21
+ raise AttributeError ("NIRNode does not have a default constructor." )
22
+
19
23
def __eq__ (self , other ):
20
24
return self is other
21
25
Original file line number Diff line number Diff line change @@ -582,3 +582,13 @@ def test_conv_type_inference():
582
582
raise AssertionError (f"type check failed for: { name } " )
583
583
graph .infer_types ()
584
584
assert graph ._check_types (), f"type inference failed for: { name } "
585
+
586
+
587
+ def test_node ():
588
+ try :
589
+ node = nir .ir .NIRNode ()
590
+ assert (
591
+ node is None
592
+ ), f"test failed, we should not be able to construct an NIRNode: { node } "
593
+ except AttributeError :
594
+ pass
You can’t perform that action at this time.
0 commit comments