Skip to content
Snippets Groups Projects

Add a sink operation to avoid dangling nodes

Merged Hugo Winbladh requested to merge 132-add-a-sink-operation-to-avoid-dangling-nodes into master
2 unresolved threads
+ 43
1
@@ -73,7 +73,6 @@ class Constant(AbstractOperation):
def __str__(self) -> str:
return f"{self.value}"
class Addition(AbstractOperation):
"""
Binary addition operation.
@@ -1263,3 +1262,46 @@ class Shift(AbstractOperation):
if not isinstance(value, int):
raise TypeError("value must be an int")
self.set_param("value", value)
class Sink(AbstractOperation):
r"""
Sink operation.
Used for ignoring the output from another operation to avoid dangling output nodes.
Parameters
==========
name : Name, optional
Operation name.
"""
_execution_time = 0
is_linear = True
is_constant = True
def __init__(self, name: Name = ""):
"""Construct a Sink operation."""
super().__init__(
input_count=1,
output_count=0,
name=name,
latency_offsets={"in0": 0},
)
@classmethod
def type_name(cls) -> TypeName:
return TypeName("sink")
def evaluate(self):
return self.param("value")
Please register or sign in to reply
@property
def latency(self) -> int:
    • Probably this can be hardcoded to a suitable value (like 0).

      • Author Contributor

        The latency is kind of hard-coded to 0 already since the constructor sets the latency_offsets to {'in0': 0}. However the code may be more readable if the latency function explicitly always returns 0.

      • Please register or sign in to reply
Please register or sign in to reply
return self.latency_offsets["in0"]
def __repr__(self) -> str:
return "Sink()"
def __str__(self) -> str:
return "sink"
Loading