Describes a callback to be used as a per-sample/per-frame argument to the operator. ---------- name : Union[str, int] String with the name of a named argument of the operator or an int if the data should be passed as a positional input. cb : Callable[[SampleDesc
| 58 | |
| 59 | |
| 60 | class ArgCb: |
| 61 | """ |
| 62 | Describes a callback to be used as a per-sample/per-frame argument to the operator. |
| 63 | ---------- |
| 64 | name : Union[str, int] |
| 65 | String with the name of a named argument of the operator or an int if the data |
| 66 | should be passed as a positional input. |
| 67 | cb : Callable[[SampleDesc], np.ndarray] |
| 68 | Callback that based on the SampleDesc instance produces a single parameter for |
| 69 | specific sample/frame. |
| 70 | is_per_frame : bool |
| 71 | Flag if the cb should be run for every sample (sequence) or for every frame. |
| 72 | In the latter case, the argument is passed wrapped |
| 73 | in per-frame call to the operator. |
| 74 | dest_device : str |
| 75 | Controls whether the produced data should be passed to the operator in cpu or gpu memory. |
| 76 | If set to "gpu", the copy to gpu is added in the pipeline. |
| 77 | Applicable only to positional inputs. |
| 78 | """ |
| 79 | |
| 80 | def __init__( |
| 81 | self, |
| 82 | name: Union[str, int], |
| 83 | cb: Callable[[SampleDesc], np.ndarray], |
| 84 | is_per_frame: bool, |
| 85 | dest_device: str = "cpu", |
| 86 | ): |
| 87 | self.desc = ArgDesc(name, "F" if is_per_frame else "", dest_device) |
| 88 | self.cb = cb |
| 89 | |
| 90 | def __repr__(self): |
| 91 | return "ArgCb{}".format((self.cb, self.desc)) |
| 92 | |
| 93 | |
| 94 | @dataclass |
no outgoing calls