Skip to content
Snippets Groups Projects
Commit 8ea707df authored by Hugo Winbladh's avatar Hugo Winbladh Committed by Oscar Gustafsson
Browse files

add sink operation

parent ce58bd0e
No related branches found
No related tags found
1 merge request!425Add a sink operation to avoid dangling nodes
...@@ -73,7 +73,6 @@ class Constant(AbstractOperation): ...@@ -73,7 +73,6 @@ class Constant(AbstractOperation):
def __str__(self) -> str: def __str__(self) -> str:
return f"{self.value}" return f"{self.value}"
class Addition(AbstractOperation): class Addition(AbstractOperation):
""" """
Binary addition operation. Binary addition operation.
...@@ -1263,3 +1262,46 @@ class Shift(AbstractOperation): ...@@ -1263,3 +1262,46 @@ class Shift(AbstractOperation):
if not isinstance(value, int): if not isinstance(value, int):
raise TypeError("value must be an int") raise TypeError("value must be an int")
self.set_param("value", value) 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")
@property
def latency(self) -> int:
return self.latency_offsets["in0"]
def __repr__(self) -> str:
return f"Sink()"
def __str__(self) -> str:
return f"sink"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment