NVIDIA Holoscan SDK v2.9.0

holoscan.core

此模块为核心 C++ API 类提供 Python API。

Application 类是应从中派生的主要类,以创建自定义应用程序。

holoscan.core.Application([argv]) Application 类。
holoscan.core.Arg 表示类型化参数的类。
holoscan.core.ArgContainerType Arg 的容器类型的枚举类。
holoscan.core.ArgElementType Arg 的元素类型的枚举类。
holoscan.core.ArgList 表示参数列表的类。
holoscan.core.ArgType 包含参数类型信息的类。
holoscan.core.CLIOptions

属性

holoscan.core.Component 基础组件类。
holoscan.core.ComponentSpec holoscan.core._core.PyComponentSpec 的别名
holoscan.core.ConditionType Condition 类型的枚举类。
holoscan.core.Condition(fragment, *args, ...) 表示条件的类。
holoscan.core.Config 配置类。
holoscan.core.DataFlowMetric DataFlowMetric 类型的枚举类。
holoscan.core.DataFlowTracker 数据流跟踪器类。
holoscan.core.DLDevice DLDevice 类。
holoscan.core.DLDeviceType 成员
holoscan.core.ExecutionContext 执行上下文类。
holoscan.core.Executor 执行器类。
holoscan.core.Fragment([app, name]) Fragment 类。
holoscan.core.Graph holoscan.graphs._graphs.OperatorGraph 的别名
holoscan.core.InputContext 输入上下文类。
holoscan.core.IOSpec I/O 规范类。
holoscan.core.Message 表示消息的类。
holoscan.core.MetadataDictionary 表示 holoscan 元数据字典的类。
holoscan.core.MultiMessageConditionInfo 与多消息条件关联的信息。
holoscan.core.MetadataPolicy 枚举定义当键已存在时处理 MetadataDictionary::set 行为的策略。
holoscan.core.NetworkContext 表示网络上下文的类。
holoscan.core.Operator(fragment, *args, **kwargs) Operator 类。
holoscan.core.OperatorSpec holoscan.core._core.PyOperatorSpec 的别名
holoscan.core.OutputContext 输出上下文类。
holoscan.core.ParameterFlag 参数标志的枚举类。
holoscan.core.Resource(fragment, *args, **kwargs) 表示资源的类。
holoscan.core.SchedulingStatusType Condition 调度状态的枚举类。
holoscan.core.Tensor holoscan.core._core.PyTensor 的别名
holoscan.core.Tracker(app, *[, filename, ...]) 向应用程序添加数据流跟踪的上下文管理器。
holoscan.core.arg_to_py_object(arg) Arg 转换为相应 Python 对象的实用程序。
holoscan.core.arglist_to_kwargs(arglist) ArgList 转换为 Python kwargs 字典的实用程序。
holoscan.core.kwargs_to_arglist(**kwargs) 将一组 python 关键字参数转换为 ArgList 的实用程序。
holoscan.core.py_object_to_arg(obj[, name]) 将单个 python 参数转换为相应的 Arg 类型的实用程序。
class holoscan.core.Application(argv=None, *args, **kwargs)

基类:holoscan.core._core.Application

Application 类。

此构造函数解析命令行以查找 App Driver/Worker 识别的标志,并移除所有识别的标志,以便用户可以将剩余的标志用于自己的目的。

如果未指定参数,则从 sys.executablesys.argv 检索参数。

处理参数后的参数(解析 Holoscan 特定标志并移除它们)可通过 argv 属性访问。

参数
argvList[str]

要解析的命令行参数。第一个项目应该是 python 可执行文件的路径。如果未指定,则使用 [sys.executable, *sys.argv]

示例

复制
已复制!
            

>>> from holoscan.core import Application >>> import sys >>> Application().argv == sys.argv True >>> Application([]).argv == sys.argv True >>> Application([sys.executable, *sys.argv]).argv == sys.argv True >>> Application(["python3", "myapp.py", "--driver", "--address=10.0.0.1", "my_arg1"]).argv ['myapp.py', 'my_arg1']

属性

application 与 fragment 关联的应用程序。
argv 处理标志后的命令行参数。
description 应用程序的描述。
executor 获取与 fragment 关联的执行器。
fragment_graph 获取与应用程序关联的计算图(图节点是 Fragment)。
graph 获取与 fragment 关联的计算图(图节点是 Operator)。
is_metadata_enabled 用于获取或设置布尔值的属性,该布尔值控制是否启用 Operator 元数据传输。
name fragment 的名称。
options 对 CLI 选项的引用。
version 应用程序的版本。

方法

add_flow(*args, **kwargs) 重载函数。
add_fragment(self, frag) 向应用程序添加 fragment。
add_operator(self, op) 向应用程序添加 operator。
compose(self) 应用程序的 compose 方法。
compose_graph(self) 这是 compose 的包装器,仅当图尚未组合时才调用 compose。
config(*args, **kwargs) 重载函数。
config_keys(self) fragment 的配置文件中存在的键集。
from_config(self, key) 从关联的配置中检索参数。
kwargs(self, key) 从关联的配置中检索字典参数。
make_thread_pool(self, name, initialize_size) 创建与此 Fragment 关联的 ThreadPool。
network_context(*args, **kwargs) 重载函数。
run(self) 应用程序的 run 方法。
run_async() 异步运行应用程序。
scheduler(*args, **kwargs) 重载函数。
track(self, num_start_messages_to_skip, ...) fragment(或应用程序)的 track 方法。
track_distributed(self, ...)

__init__(self: holoscan.core._core.Application, argv: list[str] = []) → None

Application 类。

此构造函数解析命令行以查找 App Driver/Worker 识别的标志,并移除所有识别的标志,以便用户可以将剩余的标志用于自己的目的。

如果未指定参数,则从 sys.executablesys.argv 检索参数。

处理参数后的参数(解析 Holoscan 特定标志并移除它们)可通过 argv 属性访问。

参数
argvList[str]

要解析的命令行参数。第一个项目应该是 python 可执行文件的路径。如果未指定,则使用 [sys.executable, *sys.argv]

示例

复制
已复制!
            

>>> from holoscan.core import Application >>> import sys >>> Application().argv == sys.argv True >>> Application([]).argv == sys.argv True >>> Application([sys.executable, *sys.argv]).argv == sys.argv True >>> Application(["python3", "myapp.py", "--driver", "--address=10.0.0.1", "my_arg1"]).argv ['myapp.py', 'my_arg1']

add_flow(*args, **kwargs)

重载函数。

  1. add_flow(self: holoscan.core._core.Application, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator) -> None

  2. add_flow(self: holoscan.core._core.Application, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator, port_pairs: set[tuple[str, str]]) -> None

连接与 fragment 关联的两个 operator。

参数
upstream_opholoscan.core.Operator

源 operator。

downstream_opholoscan.core.Operator

目标 operator。

port_pairs(str, str) 元组的序列

要连接的端口序列。每个 2 元组的第一个元素是来自 upstream_op 的端口,而第二个元素是与之连接的 downstream_op 的端口。

注释

这是一个重载函数。存在其他变体

1.) 对于 Application 类,有一个变体,其中前两个参数的类型为 holoscan.core.Fragment 而不是 holoscan.core.Operator。此变体用于构建多 fragment 应用程序。 2.) 还有一些变体省略了 port_pairs 参数,这些变体适用于上游 operator/fragment 上只有一个输出,而下游 operator/fragment 上只有一个输入的情况。

  1. add_flow(self: holoscan.core._core.Application, upstream_frag: holoscan.core._core.Fragment, downstream_frag: holoscan.core._core.Fragment, port_pairs: set[tuple[str, str]]) -> None

add_fragment(self: holoscan.core._core.Application, frag: holoscan.core._core.Fragment) → None

向应用程序添加 fragment。

参数
fragholoscan.core.Fragment

要添加的 fragment。

add_operator(self: holoscan.core._core.Application, op: holoscan.core._core.Operator) → None

向应用程序添加 operator。

参数
opholoscan.core.Operator

要添加的 operator。

property application

与 fragment 关联的应用程序。

返回
appholoscan.core.Application
property argv

处理标志后的命令行参数。这不包括像 sys.argv 那样的 python 可执行文件。

返回
argvstr 列表
compose(self: holoscan.core._core.Application) → None

应用程序的 compose 方法。

应在 config 之后但在图开始运行之前调用此方法,以便组合计算图。此方法将由 Application.run 自动调用,因此通常无需直接调用它。

compose_graph(self: holoscan.core._core.Application) → None

这是 compose 的包装器,仅当图尚未组合时才调用 compose。

config(*args, **kwargs)

重载函数。

  1. config(self: holoscan.core._core.Fragment, config_file: str, prefix: str = ‘’) -> None

配置类。

表示从 YAML 文件读取的配置参数。

参数
configstr 或 holoscan.core.Config

配置文件的路径(YAML 格式)或 holoscan.core.Config 对象。

prefixstr,可选

`config` 文件的前缀路径。仅在重载变体中可用,该变体为 config 采用字符串。

2. config(self: holoscan.core._core.Fragment, arg0: holoscan.core._core.Config) -> None
3. config(self: holoscan.core._core.Fragment) -> holoscan.core._core.Config
config_keys(self: holoscan.core._core.Fragment) → set[str]

fragment 的配置文件中存在的键集。

property description

应用程序的描述。

返回
descriptionstr
property executor

获取与 fragment 关联的执行器。

property fragment_graph

获取与应用程序关联的计算图(图节点是 Fragment)。

from_config(self: holoscan.core._core.Fragment, key: str) → object

从关联的配置中检索参数。

参数
keystr

要在配置文件中检索的键。这也可能是通过语法 ‘key.sub_key’ 的参数的特定组件。

返回
argsholoscan.core.ArgList

与键关联的参数列表。

property graph

获取与 fragment 关联的计算图(图节点是 Operator)。

property is_metadata_enabled

用于获取或设置布尔值的属性,该布尔值控制是否启用 Operator 元数据传输。

kwargs(self: holoscan.core._core.Fragment, key: str) → dict

从关联的配置中检索字典参数。

参数
keystr

要在配置文件中检索的键。这也可能是通过语法 ‘key.sub_key’ 的参数的特定组件。

返回
kwargsdict

包含配置文件中指定键下的参数的 Python 字典。

make_thread_pool(self: holoscan.core._core.Fragment, name: str, initialize_size: int = 1) → holoscan::ThreadPool

创建与此 Fragment 关联的 ThreadPool。

必须使用 add 方法将单个 operator 添加到池中。

参数
namestr

线程池的名称。

initialize_size1

池中的初始线程数。

property name

fragment 的名称。

返回
namestr
network_context(*args, **kwargs)

重载函数。

  1. network_context(self: holoscan.core._core.Fragment, network_context: holoscan.core._core.NetworkContext) -> None

为 Fragment 分配网络上下文

参数
network_contextholoscan.core.NetworkContext

要由底层 GXF 执行器使用的 network_context 类实例。如果未指定,则不会使用网络上下文。

2. network_context(self: holoscan.core._core.Fragment) -> holoscan.core._core.NetworkContext
获取 Fragment 要使用的网络上下文
property options

对 CLI 选项的引用。

返回
optionsholoscan.core.CLIOptions
run(self: holoscan.core._core.Application) → None

应用程序的 run 方法。

此方法运行计算。它必须首先通过 configcompose 初始化。

run_async()

异步运行应用程序。

此方法是一个便捷方法,它创建一个带有一个线程的线程池并在该线程中运行应用程序。线程池是使用 concurrent.futures.ThreadPoolExecutor 创建的。

返回
futureconcurrent.futures.Future 对象
scheduler(*args, **kwargs)

重载函数。

  1. scheduler(self: holoscan.core._core.Fragment, scheduler: holoscan.core._core.Scheduler) -> None

为 Fragment 分配调度器。

参数
schedulerholoscan.core.Scheduler

要由底层 GXF 执行器使用的调度器类实例。如果未指定,则默认值为 holoscan.gxf.GreedyScheduler

2. scheduler(self: holoscan.core._core.Fragment) -> holoscan.core._core.Scheduler
获取 Fragment 要使用的调度器。
track(self: holoscan.core._core.Fragment, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → holoscan::DataFlowTracker

fragment(或应用程序)的 track 方法。

此方法启用数据帧流跟踪并返回一个 DataFlowTracker 对象,该对象可用于显示指标数据,以便分析应用程序的性能。

参数
num_start_messages_to_skipint

开始时要跳过的消息数。

num_last_messages_to_discardint

结束时要丢弃的消息数。

latency_thresholdint

端到端延迟指标计算中要考虑的最小端到端延迟(毫秒)。

is_limited_trackingbool,可选

如果 True,则跟踪仅限于根节点和叶节点,从而通过避免中间 operator 来最大程度地减少时间戳。

返回
trackerholoscan.core.DataFlowTracker

数据流跟踪器对象,可用于显示指标数据,以便沿计算图的不同路径进行性能分析。

track_distributed(self: holoscan.core._core.Application, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → dict[str, holoscan::DataFlowTracker]
property version

应用程序的版本。

返回
versionstr
class holoscan.core.Arg

基类:pybind11_builtins.pybind11_object

表示类型化参数的类。

属性

arg_type 与参数对应的 ArgType 信息。
description YAML 格式字符串,描述参数。
has_value 布尔标志,指示是否已为参数分配值。
name 参数的名称。

__init__(self: holoscan.core._core.Arg, name: str) → None

表示类型化参数的类。

参数
namestr,可选

参数的名称。

property arg_type

与参数对应的 ArgType 信息。

返回
arg_typeholoscan.core.ArgType
property description

YAML 格式字符串,描述参数。

property has_value

布尔标志,指示是否已为参数分配值。

property name

参数的名称。

class holoscan.core.ArgContainerType

基类:pybind11_builtins.pybind11_object

Arg 的容器类型的枚举类。

成员

NATIVE

VECTOR

ARRAY

属性

name

value
ARRAY = <ArgContainerType.ARRAY: 2>
NATIVE = <ArgContainerType.NATIVE: 0>
VECTOR = <ArgContainerType.VECTOR: 1>
__init__(self: holoscan.core._core.ArgContainerType, value: int) → None
property name
property value
class holoscan.core.ArgElementType

基类:pybind11_builtins.pybind11_object

Arg 的元素类型的枚举类。

成员

CUSTOM

BOOLEAN

INT8

UNSIGNED8

INT16

UNSIGNED16

INT32

UNSIGNED32

INT64

UNSIGNED64

FLOAT32

FLOAT64

STRING

HANDLE

YAML_NODE

IO_SPEC

CONDITION

RESOURCE

属性

name

value
BOOLEAN = <ArgElementType.BOOLEAN: 1>
CONDITION = <ArgElementType.CONDITION: 18>
CUSTOM = <ArgElementType.CUSTOM: 0>
FLOAT32 = <ArgElementType.FLOAT32: 10>
FLOAT64 = <ArgElementType.FLOAT64: 11>
HANDLE = <ArgElementType.HANDLE: 15>
INT16 = <ArgElementType.INT16: 4>
INT32 = <ArgElementType.INT32: 6>
INT64 = <ArgElementType.INT64: 8>
INT8 = <ArgElementType.INT8: 2>
IO_SPEC = <ArgElementType.IO_SPEC: 17>
RESOURCE = <ArgElementType.RESOURCE: 19>
STRING = <ArgElementType.STRING: 14>
UNSIGNED16 = <ArgElementType.UNSIGNED16: 5>
UNSIGNED32 = <ArgElementType.UNSIGNED32: 7>
UNSIGNED64 = <ArgElementType.UNSIGNED64: 9>
UNSIGNED8 = <ArgElementType.UNSIGNED8: 3>
YAML_NODE = <ArgElementType.YAML_NODE: 16>
__init__(self: holoscan.core._core.ArgElementType, value: int) → None
property name
property value
class holoscan.core.ArgList

基类:pybind11_builtins.pybind11_object

表示参数列表的类。

属性

args Arg 对象的底层列表。
description YAML 格式字符串,描述列表。
name 参数列表的名称。
size 列表中的参数数量。

方法

add(*args, **kwargs) 重载函数。
clear(self) 清除参数列表。

__init__(self: holoscan.core._core.ArgList) → None

表示参数列表的类。

add(*args, **kwargs)

重载函数。

  1. add(self: holoscan.core._core.ArgList, arg: holoscan.core._core.Arg) -> None

向列表中添加参数。

  1. add(self: holoscan.core._core.ArgList, arg: holoscan.core._core.ArgList) -> None

向列表中添加参数列表。

property args

Arg 对象的底层列表。

clear(self: holoscan.core._core.ArgList) → None

清除参数列表。

property description

YAML 格式字符串,描述列表。

property name

参数列表的名称。

返回
namestr
property size

列表中的参数数量。

class holoscan.core.ArgType

基类:pybind11_builtins.pybind11_object

包含参数类型信息的类。

属性

container_type 参数的容器类型。
dimension 参数容器的维度。
element_type 参数的元素类型。
to_string 描述参数类型的字符串。

__init__(*args, **kwargs)

重载函数。

  1. __init__(self: holoscan.core._core.ArgType) -> None

包含参数类型信息的类。

  1. __init__(self: holoscan.core._core.ArgType, element_type: holoscan.core._core.ArgElementType, container_type: holoscan.core._core.ArgContainerType) -> None

包含参数类型信息的类。

参数
element_typeholoscan.core.ArgElementType

参数的元素类型。

container_typeholoscan.core.ArgContainerType

参数的容器类型。

property container_type

参数的容器类型。

property dimension

参数容器的维度。

property element_type

参数的元素类型。

property to_string

描述参数类型的字符串。

class holoscan.core.CLIOptions

基类:pybind11_builtins.pybind11_object

属性

config_path 配置文件的路径。
driver_address App Driver 的地址。
run_driver 运行 App Driver 的标志。
run_worker 运行 App Worker 的标志。
worker_address App Worker 的地址。
worker_targets App Worker 的 fragment 列表。

方法

print(self) 打印 CLI 选项。

__init__(self: holoscan.core._core.CLIOptions, run_driver: bool = False, run_worker: bool = False, driver_address: str = '', worker_address: str = '', worker_targets: list[str] = [], config_path: str = '') → None

CLIOptions 类。

property config_path

配置文件的路径。

property driver_address

App Driver 的地址。

print(self: holoscan.core._core.CLIOptions) → None

打印 CLI 选项。

property run_driver

运行 App Driver 的标志。

property run_worker

运行 App Worker 的标志。

property worker_address

App Worker 的地址。

property worker_targets

App Worker 的 fragment 列表。

返回
worker_targetsstr 列表
class holoscan.core.Component

基类:holoscan.core._core.ComponentBase

基础组件类。

属性

args 与组件关联的参数列表。
description YAML 格式字符串,描述组件。
fragment 包含组件的 fragment。
id 组件的标识符。
name 组件的名称。

方法

add_arg(*args, **kwargs) 重载函数。
initialize(self) 初始化组件。

__init__(self: holoscan.core._core.Component) → None

基础组件类。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
property description

YAML 格式字符串,描述组件。

property fragment

包含组件的 fragment。

返回
nameholoscan.core.Fragment
property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize(self: holoscan.core._core.ComponentBase) → None

初始化组件。

property name

组件的名称。

返回
namestr
holoscan.core.ComponentSpec

holoscan.core._core.PyComponentSpec 的别名

class holoscan.core.Condition(fragment, *args, **kwargs)

基类:holoscan.core._core.Condition

表示条件的类。

属性

args 与组件关联的参数列表。
condition_type 条件类型。
description YAML 格式字符串,描述条件。
fragment Fragment,条件所属的 Fragment。
id 组件的标识符。
name 条件的名称。

spec

方法

add_arg(*args, **kwargs) 重载函数。
check(timestamp) check 的默认实现。
initialize() initialize 的默认实现
on_execute(timestamp) on_execute 的默认实现
receiver(self, port_name) 获取与此条件关联的 operator 的输入端口使用的接收器。
setup(spec) setup 方法的默认实现。
transmitter(self, port_name) 获取与此条件关联的 operator 的输出端口使用的发送器。
update_state(timestamp) update_state 的默认实现

ConditionComponentType

class ConditionComponentType

基类:pybind11_builtins.pybind11_object

成员

NATIVE

GXF

属性

name

value
GXF = <ConditionComponentType.GXF: 1>
NATIVE = <ConditionComponentType.NATIVE: 0>
__init__(self: holoscan.core._core.Condition.ConditionComponentType, value: int) → None
property name
property value
__init__(self: holoscan.core._core.Condition, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) → None

表示条件的类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置条件的名称。

如果提供了 fragment 关键字参数,则它必须是 holoscan.core.Fragment (或 holoscan.core.Application) 类型。也可以改为以位置参数的形式提供单个 Fragment 对象。

任何其他参数都将从 Python 参数类型转换为 C++ Arg 类型,并存储在 self.args 中。(有关如何进行类型转换的详细信息,请参阅 py_object_to_arg 实用程序)。

参数
*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
check(timestamp: int) → tuple[holoscan.core._core.SchedulingStatusType, Optional[int]]

check 的默认实现。

参数
timestampint

调用 check 方法时的时间戳。 此方法由底层 GXF 框架调用,以确定操作器是否准备好执行。

返回
status_type: SchedulingStatusType

操作器的当前状态。 有关各种状态类型的解释,请参阅关于原生条件创建的文档。

target_timestamp: int or None

指定操作器预计准备就绪的特定目标时间戳。 只有在相关时才应提供此项(它有助于底层框架避免在目标时间之前重复检查的开销)。

注释

当满足所需条件时,该方法应返回 SchedulingStatusType.READY。

操作器将始终使用此默认实现执行,该默认实现始终执行。

property condition_type

条件类型。

holoscan.core.Condition.ConditionComponentType 枚举,表示条件的类型。 当前实现的两种类型为 NATIVE 和 GXF。

property description

YAML 格式字符串,描述条件。

property fragment

Fragment,条件所属的 Fragment。

返回
nameholoscan.core.Fragment
property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize()

initialize 的默认实现

property name

条件的名称。

返回
namestr
on_execute(timestamp)

on_execute 的默认实现

参数
timestampint

调用 on_execute 方法时的时间戳。

注释

此方法由底层 GXF 框架在为条件分配的操作器调用 Operator.compute 后立即调用。

receiver(self: holoscan.core._core.Condition, port_name: str) → Optional[holoscan::Receiver]

获取与此条件关联的 operator 的输入端口使用的接收器。

参数
port_namestr

输入端口的名称。

返回
receiverholoscan.resources.Receiver

此输入端口使用的接收器。 如果端口不存在,则为 None。

setup(spec: holoscan.core._core.PyComponentSpec)

setup 方法的默认实现。

property spec
transmitter(self: holoscan.core._core.Condition, port_name: str) → Optional[holoscan::Transmitter]

获取与此条件关联的 operator 的输出端口使用的发送器。

参数
port_namestr

输出端口的名称。

返回
transmitterholoscan.resources.Transmitter or None

此输出端口使用的发送器。 如果端口不存在,则为 None。

update_state(timestamp)

update_state 的默认实现

参数
timestampint

调用 update_state 方法时的时间戳。

注释

此方法始终由底层 GXF 框架在 Condition.check 方法之前立即调用。 在某些情况下,Condition.on_execute 方法也可能希望调用此方法。

class holoscan.core.ConditionType

基类:pybind11_builtins.pybind11_object

Condition 类型的枚举类。

成员

NONE

MESSAGE_AVAILABLE

DOWNSTREAM_MESSAGE_AFFORDABLE

COUNT

BOOLEAN

PERIODIC

ASYNCHRONOUS

EXPIRING_MESSAGE_AVAILABLE

MULTI_MESSAGE_AVAILABLE

MULTI_MESSAGE_AVAILABLE_TIMEOUT

属性

name

value
ASYNCHRONOUS = <ConditionType.ASYNCHRONOUS: 6>
BOOLEAN = <ConditionType.BOOLEAN: 4>
COUNT = <ConditionType.COUNT: 3>
DOWNSTREAM_MESSAGE_AFFORDABLE = <ConditionType.DOWNSTREAM_MESSAGE_AFFORDABLE: 2>
EXPIRING_MESSAGE_AVAILABLE = <ConditionType.EXPIRING_MESSAGE_AVAILABLE: 7>
MESSAGE_AVAILABLE = <ConditionType.MESSAGE_AVAILABLE: 1>
MULTI_MESSAGE_AVAILABLE = <ConditionType.MULTI_MESSAGE_AVAILABLE: 8>
MULTI_MESSAGE_AVAILABLE_TIMEOUT = <ConditionType.MULTI_MESSAGE_AVAILABLE_TIMEOUT: 9>
NONE = <ConditionType.NONE: 0>
PERIODIC = <ConditionType.PERIODIC: 5>
__init__(self: holoscan.core._core.ConditionType, value: int) → None
property name
property value
class holoscan.core.Config

基类:pybind11_builtins.pybind11_object

配置类。

表示从 YAML 文件读取的配置参数。

属性

config_file 与 Config 对象关联的配置文件(YAML 格式)。
prefix 待办事项

__init__(self: holoscan.core._core.Config, config_file: str, prefix: str = '') → None

配置类。

表示从 YAML 文件读取的配置参数。

参数
config_filestr

配置文件的路径(YAML 格式)。

prefixstr,可选

待办事项

property config_file

与 Config 对象关联的配置文件(YAML 格式)。

property prefix

待办事项

class holoscan.core.DLDevice

基类:pybind11_builtins.pybind11_object

DLDevice 类。

属性

device_id 设备 ID (int)。
device_type 设备类型 (DLDeviceType)。

__init__(self: holoscan.core._core.DLDevice, arg0: holoscan.core._core.DLDeviceType, arg1: int) → None
property device_id

设备 ID (int)。

property device_type

设备类型 (DLDeviceType)。

支持以下设备类型

  • DLDeviceType.DLCPU: 系统内存 (kDLCPU)

  • DLDeviceType.DLCUDA: CUDA GPU 内存 (kDLCUDA)

  • DLDeviceType.DLCUDAHost: CUDA pinned 内存 (kDLCUDAHost)

  • DLDeviceType.DLCUDAManaged: CUDA managed 内存 (kDLCUDAManaged)

class holoscan.core.DLDeviceType

基类:pybind11_builtins.pybind11_object

成员

DLCPU

DLCUDA

DLCUDAHOST

DLCUDAMANAGED

属性

name

value
DLCPU = <DLDeviceType.DLCPU: 1>
DLCUDA = <DLDeviceType.DLCUDA: 2>
DLCUDAHOST = <DLDeviceType.DLCUDAHOST: 3>
DLCUDAMANAGED = <DLDeviceType.DLCUDAMANAGED: 13>
__init__(self: holoscan.core._core.DLDeviceType, value: int) → None
property name
property value
class holoscan.core.DataFlowMetric

基类:pybind11_builtins.pybind11_object

DataFlowMetric 类型的枚举类。

成员

MAX_MESSAGE_ID

MIN_MESSAGE_ID

MAX_E2E_LATENCY

AVG_E2E_LATENCY

MIN_E2E_LATENCY

NUM_SRC_MESSAGES

NUM_DST_MESSAGES

属性

name

value
AVG_E2E_LATENCY = <DataFlowMetric.AVG_E2E_LATENCY: 3>
MAX_E2E_LATENCY = <DataFlowMetric.MAX_E2E_LATENCY: 2>
MAX_MESSAGE_ID = <DataFlowMetric.MAX_MESSAGE_ID: 0>
MIN_E2E_LATENCY = <DataFlowMetric.MIN_E2E_LATENCY: 4>
MIN_MESSAGE_ID = <DataFlowMetric.MIN_MESSAGE_ID: 1>
NUM_DST_MESSAGES = <DataFlowMetric.NUM_DST_MESSAGES: 6>
NUM_SRC_MESSAGES = <DataFlowMetric.NUM_SRC_MESSAGES: 5>
__init__(self: holoscan.core._core.DataFlowMetric, value: int) → None
property name
property value
class holoscan.core.DataFlowTracker

基类:pybind11_builtins.pybind11_object

数据流跟踪器类。

DataFlowTracker 类用于跟踪根操作器和叶操作器之间不同路径的数据流指标。 开发人员可以使用此类在应用程序执行期间和/或在应用程序结束后作为摘要获取数据流指标。

方法

enable_logging(self[, filename, ...]) 在每次叶操作器执行结束时启用帧的日志记录。
end_logging(self) 写出日志缓冲区中的任何剩余消息并关闭文件
get_metric(*args, **kwargs) 重载函数。
get_num_paths(self) 跟踪路径的数量
get_path_strings(self) 返回字符串数组,这些字符串是路径名称。
print(self) 以美观打印的格式将数据流跟踪的结果打印到标准输出
set_discard_last_messages(self, arg0) 设置执行结束时要丢弃的消息数。
set_skip_latencies(self, arg0) 设置将执行端到端延迟计算的阈值延迟。
set_skip_starting_messages(self, arg0) 设置执行开始时要跳过的消息数。

__init__(self: holoscan.core._core.DataFlowTracker) → None

数据流跟踪器类。

DataFlowTracker 类用于跟踪根操作器和叶操作器之间不同路径的数据流指标。 开发人员可以使用此类在应用程序执行期间和/或在应用程序结束后作为摘要获取数据流指标。

enable_logging(self: holoscan.core._core.DataFlowTracker, filename: str = 'logger.log', num_buffered_messages: int = 100) → None

在每次叶操作器执行结束时启用帧的日志记录。

包含元组数组(形式为(操作器名称、消息接收时间戳、消息发布时间戳))的路径记录在文件中。 日志记录不考虑要跳过或丢弃的消息数或阈值延迟。

此函数缓冲由 num_buffered_messages 设置的多行,然后再将缓冲区刷新到日志文件。

参数
filenamestr

日志文件的名称。

num_buffered_messagesint

在将缓冲区刷新到日志文件之前要缓冲的消息数。

end_logging(self: holoscan.core._core.DataFlowTracker) → None

写出日志缓冲区中的任何剩余消息并关闭文件

get_metric(*args, **kwargs)

重载函数。

  1. get_metric(self: holoscan.core._core.DataFlowTracker, pathstring: str, metric: holoscan.core._core.DataFlowMetric) -> float

返回给定路径的指标值。

如果 metric 是 DataFlowMetric::NUM_SRC_MESSAGES,则该函数返回 -1。

参数
pathstringstr

要查询指标的路径名称字符串

metricholoscan.core.DataFlowMetric

要查询的指标。

返回
valfloat

给定路径的指标值

注释

此函数还有一个重载版本,仅接受 metric 参数。

  1. get_metric(self: holoscan.core._core.DataFlowTracker, metric: holoscan.core._core.DataFlowMetric = <DataFlowMetric.NUM_SRC_MESSAGES: 5>) -> dict[str, int]

get_num_paths(self: holoscan.core._core.DataFlowTracker) → int

跟踪路径的数量

返回
num_pathsint

跟踪路径的数量

get_path_strings(self: holoscan.core._core.DataFlowTracker) → list[str]

返回字符串数组,这些字符串是路径名称。 每个路径名称是以逗号分隔的路径中操作器名称列表。 路径与两个操作器之间的边无关。

返回
pathslist[str]

路径名称的列表。

print(self: holoscan.core._core.DataFlowTracker) → None

以美观打印的格式将数据流跟踪的结果打印到标准输出

set_discard_last_messages(self: holoscan.core._core.DataFlowTracker, arg0: int) → None

设置执行结束时要丢弃的消息数。

这不会影响日志文件或源消息指标的数量。

参数
numint

要丢弃的消息数。

set_skip_latencies(self: holoscan.core._core.DataFlowTracker, arg0: int) → None

设置将执行端到端延迟计算的阈值延迟。 任何严格小于阈值延迟的延迟都将被忽略。

这不会影响日志文件或源消息指标的数量。

参数
thresholdint

阈值延迟,以毫秒为单位。

set_skip_starting_messages(self: holoscan.core._core.DataFlowTracker, arg0: int) → None

设置执行开始时要跳过的消息数。

这不会影响日志文件或源消息指标的数量。

参数
numint

要跳过的消息数。

class holoscan.core.ExecutionContext

基类: holoscan.core._core.ExecutionContext

执行上下文类。

属性

input
output

方法

allocate_cuda_stream(self[, stream_name]) 使用操作器的关联 CUDA 线程池分配内部 CUDA 流。
device_from_stream(self, cuda_stream_ptr) 确定与给定 CUDA 流对应的设备 ID。
synchronize_streams(self, cuda_stream_ptrs, ...) 使用操作器的关联 CUDA 线程池分配内部 CUDA 流。

__init__(*args, **kwargs)
allocate_cuda_stream(self: holoscan.core._core.ExecutionContext, stream_name: str = '') → int

使用操作器关联的 CUDA 线程池分配内部 CUDA 流。

参数
namestr,可选

要分配的 CUDA 流的名称。

返回
stream_ptrint

与创建的 cudaStream_t 对应的内存地址。

device_from_stream(self: holoscan.core._core.ExecutionContext, cuda_stream_ptr: int) → Optional[int]

确定与给定 CUDA 流对应的设备 ID。

参数
cuda_stream_ptr: int

CUDA 流的内存地址。 这必须是 Holoscan 管理的流,设备查询才能工作。

返回
device_idint or None

如果 CUDA 流由 Holoscan 管理,则返回与该流对应的设备 ID。 否则,输出将为 None。

property input
property output
synchronize_streams(self: holoscan.core._core.ExecutionContext, cuda_stream_ptrs: list[Optional[int]], target_cuda_stream_ptr: int) → None

使用操作器关联的 CUDA 线程池分配内部 CUDA 流。

参数
cuda_stream_ptrs: list[int or None], optional

要同步的 CUDA 流的内存地址列表。 任何 None 元素都将被忽略。

target_stream_ptr: int

要同步到的目标 CUDA 流的内存地址。

class holoscan.core.Executor

基类:pybind11_builtins.pybind11_object

执行器类。

属性

context 对应的 GXF 上下文。
context_uint64 对应的 GXF 上下文,表示为 64 位无符号整数地址
fragment 执行器所属的片段。

方法

run(self, arg0) 可以调用以运行执行器的方法。

__init__(self: holoscan.core._core.Executor, fragment: holoscan::Fragment) → None

执行器类。

参数
fragmentholoscan.core.Fragment

执行器与之关联的片段。

property context

对应的 GXF 上下文。 这将是一个不透明的 PyCapsule 对象。

property context_uint64

对应的 GXF 上下文,表示为 64 位无符号整数地址

property fragment

执行器所属的片段。

返回
nameholoscan.core.Fragment
run(self: holoscan.core._core.Executor, arg0: holoscan.graphs._graphs.OperatorGraph) → None

可以调用以运行执行器的方法。

class holoscan.core.Fragment(app=None, name='', *args, **kwargs)

基类: holoscan.core._core.Fragment

Fragment 类。

属性

application 与 fragment 关联的应用程序。
executor 获取与 fragment 关联的执行器。
graph 获取与 fragment 关联的计算图(图节点是 Operator)。
is_metadata_enabled 用于获取或设置布尔值的属性,该布尔值控制是否启用 Operator 元数据传输。
name fragment 的名称。

方法

add_flow(*args, **kwargs) 重载函数。
add_operator(self, op) 向片段添加操作器。
compose(self) 片段的 compose 方法。
config(*args, **kwargs) 重载函数。
config_keys(self) fragment 的配置文件中存在的键集。
from_config(self, key) 从关联的配置中检索参数。
kwargs(self, key) 从关联的配置中检索字典参数。
make_thread_pool(self, name, initialize_size) 创建与此 Fragment 关联的 ThreadPool。
network_context(*args, **kwargs) 重载函数。
run(self) 片段的 run 方法。
run_async() 异步运行片段。
scheduler(*args, **kwargs) 重载函数。
track(self, num_start_messages_to_skip, ...) fragment(或应用程序)的 track 方法。

__init__(self: holoscan.core._core.Fragment, arg0: object) → None

Fragment 类。

add_flow(*args, **kwargs)

重载函数。

  1. add_flow(self: holoscan.core._core.Fragment, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator) -> None

  2. add_flow(self: holoscan.core._core.Fragment, upstream_op: holoscan.core._core.Operator, downstream_op: holoscan.core._core.Operator, port_pairs: set[tuple[str, str]]) -> None

连接与 fragment 关联的两个 operator。

参数
upstream_opholoscan.core.Operator

源 operator。

downstream_opholoscan.core.Operator

目标 operator。

port_pairs(str, str) 元组的序列

要连接的端口序列。每个 2 元组的第一个元素是来自 upstream_op 的端口,而第二个元素是与之连接的 downstream_op 的端口。

注释

这是一个重载函数。存在其他变体

1.) 对于 Application 类,有一个变体,其中前两个参数的类型为 holoscan.core.Fragment 而不是 holoscan.core.Operator。此变体用于构建多 fragment 应用程序。 2.) 还有一些变体省略了 port_pairs 参数,这些变体适用于上游 operator/fragment 上只有一个输出,而下游 operator/fragment 上只有一个输入的情况。

add_operator(self: holoscan.core._core.Fragment, op: holoscan.core._core.Operator) → None

向片段添加操作器。

参数
opholoscan.core.Operator

要添加的 operator。

property application

与 fragment 关联的应用程序。

返回
appholoscan.core.Application
compose(self: holoscan.core._core.Fragment) → None

片段的 compose 方法。

应在 config 之后但在 run 之前调用此方法,以便组合计算图。

config(*args, **kwargs)

重载函数。

  1. config(self: holoscan.core._core.Fragment, config_file: str, prefix: str = ‘’) -> None

配置类。

表示从 YAML 文件读取的配置参数。

参数
configstr 或 holoscan.core.Config

配置文件的路径(YAML 格式)或 holoscan.core.Config 对象。

prefixstr,可选

`config` 文件的前缀路径。仅在重载变体中可用,该变体为 config 采用字符串。

2. config(self: holoscan.core._core.Fragment, arg0: holoscan.core._core.Config) -> None
3. config(self: holoscan.core._core.Fragment) -> holoscan.core._core.Config
config_keys(self: holoscan.core._core.Fragment) → set[str]

fragment 的配置文件中存在的键集。

property executor

获取与 fragment 关联的执行器。

from_config(self: holoscan.core._core.Fragment, key: str) → object

从关联的配置中检索参数。

参数
keystr

要在配置文件中检索的键。这也可能是通过语法 ‘key.sub_key’ 的参数的特定组件。

返回
argsholoscan.core.ArgList

与键关联的参数列表。

property graph

获取与 fragment 关联的计算图(图节点是 Operator)。

property is_metadata_enabled

用于获取或设置布尔值的属性,该布尔值控制是否启用 Operator 元数据传输。

kwargs(self: holoscan.core._core.Fragment, key: str) → dict

从关联的配置中检索字典参数。

参数
keystr

要在配置文件中检索的键。这也可能是通过语法 ‘key.sub_key’ 的参数的特定组件。

返回
kwargsdict

包含配置文件中指定键下的参数的 Python 字典。

make_thread_pool(self: holoscan.core._core.Fragment, name: str, initialize_size: int = 1) → holoscan::ThreadPool

创建与此 Fragment 关联的 ThreadPool。

必须使用 add 方法将单个 operator 添加到池中。

参数
namestr

线程池的名称。

initialize_size1

池中的初始线程数。

property name

fragment 的名称。

返回
namestr
network_context(*args, **kwargs)

重载函数。

  1. network_context(self: holoscan.core._core.Fragment, network_context: holoscan.core._core.NetworkContext) -> None

为 Fragment 分配网络上下文

参数
network_contextholoscan.core.NetworkContext

要由底层 GXF 执行器使用的 network_context 类实例。如果未指定,则不会使用网络上下文。

2. network_context(self: holoscan.core._core.Fragment) -> holoscan.core._core.NetworkContext
获取 Fragment 要使用的网络上下文
run(self: holoscan.core._core.Fragment) → None

片段的 run 方法。

此方法运行计算。它必须首先通过 configcompose 初始化。

run_async()

异步运行片段。

此方法是一个便捷方法,它创建一个包含一个线程的线程池,并在该线程中运行片段。 线程池是使用 concurrent.futures.ThreadPoolExecutor 创建的。

返回
futureconcurrent.futures.Future 对象
scheduler(*args, **kwargs)

重载函数。

  1. scheduler(self: holoscan.core._core.Fragment, scheduler: holoscan.core._core.Scheduler) -> None

为 Fragment 分配调度器。

参数
schedulerholoscan.core.Scheduler

要由底层 GXF 执行器使用的调度器类实例。如果未指定,则默认值为 holoscan.gxf.GreedyScheduler

2. scheduler(self: holoscan.core._core.Fragment) -> holoscan.core._core.Scheduler
获取 Fragment 要使用的调度器。
track(self: holoscan.core._core.Fragment, num_start_messages_to_skip: int = 10, num_last_messages_to_discard: int = 10, latency_threshold: int = 0, is_limited_tracking: bool = False) → holoscan::DataFlowTracker

fragment(或应用程序)的 track 方法。

此方法启用数据帧流跟踪并返回一个 DataFlowTracker 对象,该对象可用于显示指标数据,以便分析应用程序的性能。

参数
num_start_messages_to_skipint

开始时要跳过的消息数。

num_last_messages_to_discardint

结束时要丢弃的消息数。

latency_thresholdint

端到端延迟指标计算中要考虑的最小端到端延迟(毫秒)。

is_limited_trackingbool,可选

如果 True,则跟踪仅限于根节点和叶节点,从而通过避免中间 operator 来最大程度地减少时间戳。

返回
trackerholoscan.core.DataFlowTracker

数据流跟踪器对象,可用于显示指标数据,以便沿计算图的不同路径进行性能分析。

class holoscan.core.FragmentGraph

基类:pybind11_builtins.pybind11_object

所有图的抽象基类

__init__(*args, **kwargs)
holoscan.core.Graph

holoscan.graphs._graphs.OperatorGraph 的别名

class holoscan.core.IOSpec

基类:pybind11_builtins.pybind11_object

I/O 规范类。

属性

conditions 与此 I/O 规范关联的 Condition 对象列表。
connector_type I/O 规范类的接收器或发送器类型。
io_type I/O 规范类的类型(输入或输出)。
name I/O 规范类的名称。
queue_size 输入/输出队列的大小。

方法

IOSize I/O 大小类。
condition(self, arg0, **kwargs) 向此输入/输出添加条件。
connector(*args, **kwargs) 重载函数。

ConnectorType
IOType

ANY_SIZE = IOSize(-1)
class ConnectorType

基类:pybind11_builtins.pybind11_object

枚举,表示接收器类型(对于输入规范)或发送器类型(对于输出规范)。

成员

DEFAULT

DOUBLE_BUFFER

UCX

属性

name

value
DEFAULT = <ConnectorType.DEFAULT: 0>
DOUBLE_BUFFER = <ConnectorType.DOUBLE_BUFFER: 1>
UCX = <ConnectorType.UCX: 2>
__init__(self: holoscan.core._core.IOSpec.ConnectorType, value: int) → None
property name
property value
class IOSize

基类:pybind11_builtins.pybind11_object

I/O 大小类。

参数
sizeint

输入/输出队列的大小。

属性

size I/O 大小类的 size。

__init__(self: holoscan.core._core.IOSpec.IOSize, size: int) → None
property size

I/O 大小类的 size。

返回
sizeint
class IOType

基类:pybind11_builtins.pybind11_object

枚举,表示 I/O 规范类型(输入或输出)。

成员

INPUT

OUTPUT

属性

name

value
INPUT = <IOType.INPUT: 0>
OUTPUT = <IOType.OUTPUT: 1>
__init__(self: holoscan.core._core.IOSpec.IOType, value: int) → None
property name
property value
PRECEDING_COUNT = IOSize(0)
SIZE_ONE = IOSize(1)
__init__(self: holoscan.core._core.IOSpec, op_spec: holoscan::OperatorSpec, name: str, io_type: holoscan.core._core.IOSpec.IOType) → None

I/O 规范类。

参数
op_specholoscan.core.OperatorSpec

关联操作器的操作器规范类。

namestr

IOSpec 对象的名称。

io_typeholoscan.core.IOSpec.IOType

枚举,指示这是输入还是输出规范。

condition(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.ConditionType, **kwargs)holoscan.core._core.IOSpec

向此输入/输出添加条件。

支持以下 ConditionType

  • ConditionType.NONE

  • ConditionType.MESSAGE_AVAILABLE

  • ConditionType.DOWNSTREAM_MESSAGE_AFFORDABLE

  • ConditionType.COUNT

  • ConditionType.BOOLEAN

参数
kindholoscan.core.ConditionType

条件的类型。

**kwargs

将转换为与条件关联的 ArgList 的 Python 关键字参数。

返回
objholoscan.core.IOSpec

self 对象。

property conditions

与此 I/O 规范关联的 Condition 对象列表。

返回
conditionholoscan.core.Condition 列表
connector(*args, **kwargs)

重载函数。

  1. connector(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.IOSpec.ConnectorType, **kwargs) -> holoscan.core._core.IOSpec

向此输入/输出添加连接器(发送器或接收器)。

支持以下 ConditionType

  • IOSpec.ConnectorType.DEFAULT

  • IOSpec.ConnectorType.DOUBLE_BUFFER

  • IOSpec.ConnectorType.UCX

如果未调用此方法,则 IOSpec 的 connector_type 将为 ConnectorType.DEFAULT,这将导致使用 DoubleBuffered 接收器或发送器(或者如果启用流跟踪,则使用它们的带注释变体)。

参数
kindholoscan.core.IOSpec.ConnectorType

连接器的类型。 例如,对于 IOSpec.ConnectorType.DOUBLE_BUFFER 类型,输入端口将使用 holoscan.resources.DoubleBufferReceiver,输出端口将使用 holoscan.resources.DoubleBufferTransmitter

**kwargs

将会被强制转换为与资源(连接器)关联的 ArgList 的 Python 关键字参数。

返回
objholoscan.core.IOSpec

self 对象。

注释

这是一个重载函数。存在其他变体

1.) 无参数的变体将仅返回与此 IOSpec 对象使用的发送器或接收器相对应的 holoscan.core.Resource。如果显式设置为 None,它将返回 None

2.) 接受单个 holoscan.core.Resource 作为参数的变体,该 holoscan.core.Resource 对应于发送器或接收器。这将设置 IOSpec 对象使用的发送器或接收器。

  1. connector(self: holoscan.core._core.IOSpec) -> holoscan.core._core.Resource

  2. connector(self: holoscan.core._core.IOSpec, arg0: holoscan.core._core.Resource) -> None

property connector_type

I/O 规范类的接收器或发送器类型。

返回
connector_typeholoscan.core.IOSpec.ConnectorType
property io_type

I/O 规范类的类型(输入或输出)。

返回
io_typeholoscan.core.IOSpec.IOType
property name

I/O 规范类的名称。

返回
namestr
property queue_size

输入/输出队列的大小。

注释

此值仅用于初始化输入端口。队列大小由 'OperatorSpec.input()' 方法或此属性设置。如果队列大小设置为“任意大小”(C++ 中的 IOSpec::kAnySize 或 Python 中的 IOSpec.ANY_SIZE),则连接器/条件设置将被忽略。如果队列大小设置为其他值,则默认连接器(DoubleBufferReceiver/UcxReceiver)和条件(MessageAvailableCondition)将使用队列大小进行初始化(连接器的“capacity”和条件的“min_size”),如果它们未设置。

class holoscan.core.InputContext

基类: holoscan.core._core.InputContext

输入上下文类。

方法

receive(self, name, *[, kind]) 从指定的端口接收对象。
receive_cuda_stream(self[, input_port_name, ...]) 接收与指定输入端口关联的 CUDA 流。
receive_cuda_streams(self[, input_port_name]) 接收与指定输入端口关联的 CUDA 流列表。

__init__(*args, **kwargs)
receive(self: holoscan.core._core.PyInputContext, name: str, *, kind: str = '') → object

从指定的端口接收对象。

参数
namestr

要从中接收对象的端口的名称。

返回
dataobject

接收到的 Python 对象。如果端口上没有接收到实体,则 data 将为 None

receive_cuda_stream(self: holoscan.core._core.PyInputContext, input_port_name: str = None, allocate: bool = True) → int

接收与指定输入端口关联的 CUDA 流。

参数
input_port_namestr, 可选

要从中接收对象的输入端口的名称。

allocatebool, 可选

如果为 True,则操作符应分配自己的 CUDA 流并将任何传入的流同步到它。然后此函数返回的流是内部分配的流。

返回
stream_ptrint

底层 cudaStream_t 的内存地址。

receive_cuda_streams(self: holoscan.core._core.PyInputContext, input_port_name: str = None) → list[Optional[int]]

接收与指定输入端口关联的 CUDA 流列表。

列表的大小将等于端口上接收到的消息数量。对于不包含 CudaStream 的消息,列表中的相应条目将为 None

参数
input_port_namestr, 可选

要从中接收对象的输入端口的名称。

返回
stream_ptrslist[int]

每个消息的底层 cudaStream_t 的内存地址。对于任何没有流的消息,列表将包含 None。

class holoscan.core.Message

基类:pybind11_builtins.pybind11_object

表示消息的类。

消息是一种数据结构,用于在操作符之间传递数据。它包装了一个 std::any 对象,并提供了类型安全的接口来访问数据。

此类由 holoscan::gxf::GXFWrapper 使用,以支持 Holoscan 原生操作符。holoscan::gxf::GXFWrapper 将持有此类的对象,并将消息委托给 Holoscan 原生操作符。

__init__(*args, **kwargs)
class holoscan.core.MetadataDictionary

基类:pybind11_builtins.pybind11_object

表示 holoscan 元数据字典的类。

属性

policy 元数据策略属性,用于控制 setupdate 方法的行为。

方法

clear(self) 从字典中清除所有项目
erase(self, key) 从字典中删除具有给定键的项目。
get(self, key[, value]) 从字典中获取具有给定键的项目。
has_key(self, key) 确定字典中是否存在具有给定键的项目。
insert(self, other) 将来自另一个 MetadataDictionary 的项目插入到此字典中。
items(self) 返回字典中所有项目的 (键, 值) 元组列表。
keys(self) 获取字典中元数据键的列表。
merge(self, other) 将来自另一个 MetadataDictionary 的项目合并到此字典中。
pop(self, key, default) 从字典中弹出指定的项目。
set(self, key, value[, dtype, cast_to_cpp]) 使用给定的键将给定的值存储在字典中。
size(self) 获取元数据字典的大小。
swap(self, other) 将此 MetadataDictionary 的内容与另一个 MetadataDictionary 的内容交换。
type_dict(self) 返回与值对应的 C++ std::type_info 名称的字典列表。
update(self, other) 使用来自另一个 MetadataDictionary 的项目更新此字典中的项目。

__init__(self: holoscan.core._core.MetadataDictionary) → None

表示 holoscan 元数据字典的类。

clear(self: holoscan.core._core.MetadataDictionary) → None

从字典中清除所有项目

erase(self: holoscan.core._core.MetadataDictionary, key: str) → bool

从字典中删除具有给定键的项目。

参数
keystr

要在字典中检查的键。

返回
bool

如果找到并删除了键,则为 True,否则为 False。

get(self: holoscan.core._core.MetadataDictionary, key: str, value: object = None) → object

从字典中获取具有给定键的项目。

返回
object

存储在字典中具有给定键的值。

has_key(self: holoscan.core._core.MetadataDictionary, key: str) → bool

确定字典中是否存在具有给定键的项目。

参数
keystr

要在字典中检查的键。

返回
bool

如果键存在于字典中,则为 True,否则为 False。

insert(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None

将来自另一个 MetadataDictionary 的项目插入到此字典中。

参数
otherMetadataDictionary

将来自 other 的项目插入到此字典中。如果键已存在于此字典中,则不会更新值。

items(self: holoscan.core._core.MetadataDictionary) → list[tuple[str, object]]

返回字典中所有项目的 (键, 值) 元组列表。

返回
itemsList[Tuple[str, object]]

字典中所有项目的 (键, 值) 元组列表。

keys(self: holoscan.core._core.MetadataDictionary) → list[str]

获取字典中元数据键的列表。

返回
List[str]

字典中键的列表。

merge(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None

将来自另一个 MetadataDictionary 的项目合并到此字典中。

参数
otherMetadataDictionary

将来自 other 的项目合并到此字典中。如果键已存在于此字典中,则不会更新值。任何插入到此字典中的项目都将从 other 中删除。

property policy

元数据策略属性,用于控制 setupdate 方法的行为。

它可以设置为以下模式之一

MetadataPolicy.REJECT - 如果键已存在,则拒绝新值 MetadataPolicy.UPDATE - 如果键已存在,则更新新值 MetadataPolicy.RAISE - 如果键已存在,则引发异常

pop(self: holoscan.core._core.MetadataDictionary, key: str, default: object = <holoscan.core._core.MetaNoneValue object at 0x7f056023c3f0>) → object

从字典中弹出指定的项目。

参数
keystr

要从字典中弹出的键。

defaultobject, 可选

如果字典中未找到键,则返回的值。如果未提供,则当指定的键不存在时,将引发 KeyError。

返回
valueobject

存储在字典中具有给定键的值。

set(self: holoscan.core._core.MetadataDictionary, key: str, value: object, dtype: Optional[numpy.dtype] = None, cast_to_cpp: bool = False) → None

使用给定的键将给定的值存储在字典中。

参数
keystr

用于存储值的键。

valueobject

要设置的值。默认情况下,直接存储 Python 对象。如果元数据将发送到包装 C++ 操作符的下游操作符,则可能希望将数据强制转换为 C++ 类型。这可以通过将 cast_to_cpp 设置为 True 来完成。

dtypenumpy.dtype, 可选

cast_to_cpp 为 True 时,dtype 参数可用于指示值应强制转换为哪种数字类型。如果未提供,则 Python float 的默认 C++ 类型将为 double,Python int 的默认 C++ 类型将为 int64_t

cast_to_cppbool, 可选

如果为 True,则 Python 对象将被转换为相应的 C++ 类型(如果可能)。如果为 False,则将直接存储 Python 对象。可以强制转换的类型为 strbool 以及各种浮点和整数类型。具有统一元素类型的可迭代对象或序列将变为包含类型的 std::vector。

size(self: holoscan.core._core.MetadataDictionary) → int

获取元数据字典的大小。

返回
sizeint

字典中项目的数量。

swap(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None

将此 MetadataDictionary 的内容与另一个 MetadataDictionary 的内容交换。

参数
otherMetadataDictionary

要与之交换内容的元数据字典。

type_dict(self: holoscan.core._core.MetadataDictionary) → dict

返回与值对应的 C++ std::type_info 名称的字典列表。

返回
type_dictDict[str, str]

键将与此 MetadataDictionary 的键匹配,而值是与值对应的 C++ 类型名称。这些类型名称主要与存储为 C++ 类型的项目相关。所有值是 Python 对象的项目都将具有名称 typeid(GILGuardedPythonObject).name()

update(self: holoscan.core._core.MetadataDictionary, other: holoscan.core._core.MetadataDictionary) → None

使用来自另一个 MetadataDictionary 的项目更新此字典中的项目。

参数
otherMetadataDictionary

将来自 other 的项目插入到此字典中。如果键已存在于此字典中,则将根据此字典的元数据策略更新值。

class holoscan.core.MetadataPolicy

基类:pybind11_builtins.pybind11_object

枚举定义当键已存在时处理 MetadataDictionary::set 行为的策略。

MetadataPolicy.REJECT - 如果键已存在,则拒绝新值 MetadataPolicy.UPDATE - 如果键已存在,则更新新值 MetadataPolicy.RAISE - 如果键已存在,则引发异常

成员

REJECT

UPDATE

RAISE

属性

name

value
RAISE = <MetadataPolicy.RAISE: 3>
REJECT = <MetadataPolicy.REJECT: 0>
UPDATE = <MetadataPolicy.UPDATE: 2>
__init__(self: holoscan.core._core.MetadataPolicy, value: int) → None
property name
property value
class holoscan.core.MultiMessageConditionInfo

基类:pybind11_builtins.pybind11_object

与多消息条件关联的信息。

属性

args
kind
port_names

__init__(self: holoscan.core._core.MultiMessageConditionInfo) → None
property args
property kind
property port_names
class holoscan.core.NetworkContext

基类: holoscan.core._core.Component

表示网络上下文的类。

属性

args 与组件关联的参数列表。
description YAML 格式字符串,描述组件。
fragment 网络上下文所属的片段。
id 组件的标识符。
name 网络上下文的名称。

spec

方法

add_arg(*args, **kwargs) 重载函数。
initialize(self) 网络上下文的初始化方法。
setup(self, arg0) 网络上下文的设置方法。

__init__(self: holoscan.core._core.NetworkContext, *args, **kwargs) → None

表示网络上下文的类。

参数
*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
property description

YAML 格式字符串,描述组件。

property fragment

网络上下文所属的片段。

返回
nameholoscan.core.Fragment
property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize(self: holoscan.core._core.NetworkContext) → None

网络上下文的初始化方法。

property name

网络上下文的名称。

返回
namestr
setup(self: holoscan.core._core.NetworkContext, arg0: holoscan.core._core.ComponentSpec) → None

网络上下文的设置方法。

property spec
class holoscan.core.Operator(fragment, *args, **kwargs)

基类: holoscan.core._core.Operator

Operator 类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置操作符的名称。

Condition 类将被添加到 self.conditionsResource 类将被添加到 self.resources,任何其他参数将从 Python 参数类型强制转换为 C++ Arg 并存储在 self.args 中。(有关如何进行强制转换的详细信息,请参阅 py_object_to_arg 实用程序)。当通过 kwarg 提供 Condition 或 Resource 时,其名称将自动更新为 kwarg 的名称。

参数
fragmentholoscan.core.Fragment

此操作符将属于的 holoscan.core.Fragment (或 holoscan.core.Application)。

*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

属性

args 与组件关联的参数列表。
conditions 与操作符关联的条件。
description 描述操作符的 YAML 格式字符串。
fragment 操作符所属的片段 (holoscan.core.Fragment)。
id 组件的标识符。
is_metadata_enabled 布尔值,指示此操作符所属的片段是否已启用元数据传输。
metadata 与操作符关联的元数据字典 (holoscan.core.MetadataDictionary)。
metadata_policy 与操作符关联的元数据策略 (holoscan.core.MetadataPolicy)。
name 操作符的名称。
operator_type 操作符类型。
resources 与操作符关联的资源。
spec 与操作符关联的操作符规范 (holoscan.core.OperatorSpec)。

方法

add_arg(*args, **kwargs) 重载函数。
compute(op_input, op_output, context) 计算的默认实现
initialize() initialize 的默认实现
receiver(self, port_name) 获取输入端口使用的接收器。
resource(self, name) 与操作符关联的资源。
setup(spec) setup 方法的默认实现。
start() 启动的默认实现
stop() 停止的默认实现
transmitter(self, port_name) 获取输出端口使用的发送器。

OperatorType

class OperatorType

基类:pybind11_builtins.pybind11_object

执行器使用的操作符类型的枚举类。

  • NATIVE:原生操作符。

  • GXF:GXF 操作符。

  • VIRTUAL:虚拟操作符。(供内部使用,不适用于应用程序作者)

成员

NATIVE

GXF

VIRTUAL

属性

name

value
GXF = <OperatorType.GXF: 1>
NATIVE = <OperatorType.NATIVE: 0>
VIRTUAL = <OperatorType.VIRTUAL: 2>
__init__(self: holoscan.core._core.Operator.OperatorType, value: int) → None
property name
property value
__init__(self: holoscan.core._core.Operator, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) → None

Operator 类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置操作符的名称。

Condition 类将被添加到 self.conditionsResource 类将被添加到 self.resources,任何其他参数将从 Python 参数类型强制转换为 C++ Arg 并存储在 self.args 中。(有关如何进行强制转换的详细信息,请参阅 py_object_to_arg 实用程序)。当通过 kwarg 提供 Condition 或 Resource 时,其名称将自动更新为 kwarg 的名称。

参数
fragmentholoscan.core.Fragment

此操作符将属于的 holoscan.core.Fragment (或 holoscan.core.Application)。

*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

  1. add_arg(self: holoscan.core._core.Operator, **kwargs) -> None

通过 Python kwargs 向组件添加参数。

  1. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Condition) -> None

  2. add_arg(self: holoscan.core._core.Operator, arg: holoscan.core._core.Resource) -> None

向操作符添加条件或资源。

这可用于在操作符已构建之后向其添加条件或资源。

参数
argholoscan.core.Condition 或 holoscan.core.Resource

要添加的条件或资源。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
compute(op_input, op_output, context)

计算的默认实现

property conditions

与操作符关联的条件。

property description

描述操作符的 YAML 格式字符串。

property fragment

操作符所属的片段 (holoscan.core.Fragment)。

property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize()

initialize 的默认实现

property is_metadata_enabled

布尔值,指示此操作符所属的片段是否已启用元数据传输。

property metadata

与操作符关联的元数据字典 (holoscan.core.MetadataDictionary)。

property metadata_policy

与操作符关联的元数据策略 (holoscan.core.MetadataPolicy)。

property name

操作符的名称。

property operator_type

操作符类型。

holoscan.core.Operator.OperatorType 枚举,表示操作符的类型。当前实现的两种类型是原生和 GXF。

receiver(self: holoscan.core._core.Operator, port_name: str) → Optional[holoscan::Receiver]

获取输入端口使用的接收器。

参数
port_namestr

输入端口的名称。

返回
receiverholoscan.resources.Receiver

此输入端口使用的接收器。 如果端口不存在,则为 None。

resource(self: holoscan.core._core.Operator, name: str) → Optional[object]

与操作符关联的资源。

参数
namestr

要检索的资源的名称

返回
holoscan.core.Resource 或 None

具有给定名称的资源。如果未找到具有给定名称的资源,则返回 None。

property resources

与操作符关联的资源。

setup(spec: holoscan.core._core.PyOperatorSpec)

setup 方法的默认实现。

property spec

与操作符关联的操作符规范 (holoscan.core.OperatorSpec)。

start()

启动的默认实现

stop()

停止的默认实现

transmitter(self: holoscan.core._core.Operator, port_name: str) → Optional[holoscan::Transmitter]

获取输出端口使用的发送器。

参数
port_namestr

输出端口的名称。

返回
transmitterholoscan.resources.Transmitter or None

此输出端口使用的发送器。 如果端口不存在,则为 None。

class holoscan.core.OperatorGraph

基类:pybind11_builtins.pybind11_object

所有图的抽象基类

__init__(*args, **kwargs)
holoscan.core.OperatorSpec

holoscan.core._core.PyOperatorSpec 的别名

class holoscan.core.OutputContext

基类: holoscan.core._core.OutputContext

输出上下文类。

方法

emit(self, data, name[, emitter_name, ...]) 在指定的端口上发出 Python 或 C++ 对象。
set_cuda_stream(self, stream_ptr[, ...]) 指定要与指定输出端口上的任何数据一起发出的 CUDA 流。

OutputType

class OutputType

基类:pybind11_builtins.pybind11_object

成员

SHARED_POINTER

GXF_ENTITY

属性

name

value
GXF_ENTITY = <OutputType.GXF_ENTITY: 1>
SHARED_POINTER = <OutputType.SHARED_POINTER: 0>
__init__(self: holoscan.core._core.OutputContext.OutputType, value: int) → None
property name
property value
__init__(*args, **kwargs)
emit(self: holoscan.core._core.PyOutputContext, data: object, name: str, emitter_name: str = '', acq_timestamp: int = - 1) → None

在指定的端口上发出 Python 或 C++ 对象。

参数
dataobject

要发出的 Python 对象。如果它是类似张量的对象,则它将作为 C++ holoscan::Tensor 传输,以便与期望 holoscan::Tensor 的 C++ 操作符兼容(转换为 C++ 张量类型时不需要复制数据)。类似地,如果 data 是一个字典,其中所有键都是字符串,并且所有值都是类似张量的对象,那么它将作为 holoscan::TensorMap 传输,以便与 Holoscan C++ 操作符兼容。类似地,如果检测到输出端口跨分布式应用程序中的片段连接,则将自动执行数据序列化,以便可以通过 UCX 通过网络发送数据。

namestr

要在其上发出对象的端口的名称。

emitter_namestr, 可选

这可以用于强制发射与默认选择的类型不同的类型。例如,如果 data 是一个 Python str 对象,它通常会被作为 Python 字符串发射。但是,要将字符串作为下游 C++ 运算符期望的 std::string 发送,可以设置 emitter_name="std::string" 以确保数据将被强制转换为这种类型。一般来说,任何已在类型注册表中注册的类型都可以在此处指定,只要提供的对象可以强制转换为该类型即可。要获取当前注册的类型名称列表,请调用 holoscan.core.io_type_registry.registered_types()

set_cuda_stream(self: holoscan.core._core.PyOutputContext, stream_ptr: int, output_port_name: str = None) → None

指定要与指定输出端口上的任何数据一起发出的 CUDA 流。

参数
stream_ptrint

要发射的底层 cudaStream_t 的内存地址。

output_port_namestr,可选

要在其上发射流的输出端口的名称。如果运算符上只有一个输出端口,则可以不指定。

class holoscan.core.ParameterFlag

基类:pybind11_builtins.pybind11_object

参数标志的枚举类。

支持以下标志: - NONE:参数是强制性的和静态的。它不能在运行时更改。 - OPTIONAL:参数是可选的,可能在运行时不可用。 - DYNAMIC:参数是动态的,可能在运行时更改。

成员

NONE

OPTIONAL

DYNAMIC

属性

name

value
DYNAMIC = <ParameterFlag.DYNAMIC: 2>
NONE = <ParameterFlag.NONE: 0>
OPTIONAL = <ParameterFlag.OPTIONAL: 1>
__init__(self: holoscan.core._core.ParameterFlag, value: int) → None
property name
property value
class holoscan.core.Resource(fragment, *args, **kwargs)

基类:holoscan.core._core.Resource

表示资源的类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置资源的名称。

如果提供了 fragment 关键字参数,则它必须是 holoscan.core.Fragment (或 holoscan.core.Application) 类型。也可以改为以位置参数的形式提供单个 Fragment 对象。

任何其他参数都将从 Python 参数类型转换为 C++ Arg 类型,并存储在 self.args 中。(有关如何进行类型转换的详细信息,请参阅 py_object_to_arg 实用程序)。

参数
*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

属性

args 与组件关联的参数列表。
description 描述资源的 YAML 格式字符串。
fragment 资源所属的片段。
id 组件的标识符。
name 资源的名称。
resource_type 资源类型。

spec

方法

add_arg(*args, **kwargs) 重载函数。
initialize(self) 资源的初始化方法。
setup(spec) setup 方法的默认实现。

ResourceType

class ResourceType

基类:pybind11_builtins.pybind11_object

成员

NATIVE

GXF

属性

name

value
GXF = <ResourceType.GXF: 1>
NATIVE = <ResourceType.NATIVE: 0>
__init__(self: holoscan.core._core.Resource.ResourceType, value: int) → None
property name
property value
__init__(self: holoscan.core._core.Resource, arg0: object, arg1: holoscan::Fragment, *args, **kwargs) → None

表示资源的类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置资源的名称。

如果提供了 fragment 关键字参数,则它必须是 holoscan.core.Fragment (或 holoscan.core.Application) 类型。也可以改为以位置参数的形式提供单个 Fragment 对象。

任何其他参数都将从 Python 参数类型转换为 C++ Arg 类型,并存储在 self.args 中。(有关如何进行类型转换的详细信息,请参阅 py_object_to_arg 实用程序)。

参数
*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
property description

描述资源的 YAML 格式字符串。

property fragment

资源所属的片段。

返回
nameholoscan.core.Fragment
property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize(self: holoscan.core._core.Resource) → None

资源的初始化方法。

property name

资源的名称。

返回
namestr
property resource_type

资源类型。

holoscan.core.Resource.ResourceType 枚举,表示资源的类型。当前实现的两种类型是 NATIVE 和 GXF。

setup(spec: holoscan.core._core.PyComponentSpec)

setup 方法的默认实现。

property spec
class holoscan.core.Scheduler

基类: holoscan.core._core.Component

表示调度器的类。

属性

args 与组件关联的参数列表。
description YAML 格式字符串,描述组件。
fragment 调度器所属的片段。
id 组件的标识符。
name 调度器的名称。

spec

方法

add_arg(*args, **kwargs) 重载函数。
initialize(self) 调度器的初始化方法。
setup(self, arg0) 调度器的 setup 方法。

__init__(self: holoscan.core._core.Scheduler, *args, **kwargs) → None

表示调度器的类。

可以使用任意数量的 Python 位置参数和关键字参数进行初始化。

如果提供了 name 关键字参数,则它必须是 str 类型,并将用于设置调度器的名称。

如果提供了 fragment 关键字参数,则它必须是 holoscan.core.Fragment (或 holoscan.core.Application) 类型。也可以改为以位置参数的形式提供单个 Fragment 对象。

任何其他参数都将从 Python 参数类型转换为 C++ Arg 类型,并存储在 self.args 中。(有关如何进行类型转换的详细信息,请参阅 py_object_to_arg 实用程序)。

参数
*args

位置参数。

**kwargs

关键字参数。

引发
RuntimeError

如果提供了 name kwarg,但不是 str 类型。 如果提供了多个 Fragment 类型的参数。 如果任何其他参数无法通过 py_object_to_arg 转换为 Arg 类型。

add_arg(*args, **kwargs)

重载函数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.Arg) -> None

向组件添加参数。

  1. add_arg(self: holoscan.core._core.ComponentBase, arg: holoscan.core._core.ArgList) -> None

向组件添加参数列表。

property args

与组件关联的参数列表。

返回
arglistholoscan.core.ArgList
property description

YAML 格式字符串,描述组件。

property fragment

调度器所属的片段。

返回
nameholoscan.core.Fragment
property id

组件的标识符。

标识符最初设置为 -1,并在组件初始化时变为有效值。

使用默认执行器 (holoscan.gxf.GXFExecutor),标识符设置为 GXF 组件 ID。

返回
idint
initialize(self: holoscan.core._core.Scheduler) → None

调度器的初始化方法。

property name

调度器的名称。

返回
namestr
setup(self: holoscan.core._core.Scheduler, arg0: holoscan.core._core.ComponentSpec) → None

调度器的 setup 方法。

property spec
class holoscan.core.SchedulingStatusType

基类:pybind11_builtins.pybind11_object

Condition 调度状态的枚举类。

成员

NEVER

READY

WAIT

WAIT_TIME

WAIT_EVENT

属性

name

value
NEVER = <SchedulingStatusType.NEVER: 0>
READY = <SchedulingStatusType.READY: 1>
WAIT = <SchedulingStatusType.WAIT: 2>
WAIT_EVENT = <SchedulingStatusType.WAIT_EVENT: 4>
WAIT_TIME = <SchedulingStatusType.WAIT_TIME: 3>
__init__(self: holoscan.core._core.SchedulingStatusType, value: int) → None
property name
property value
holoscan.core.Tensor

holoscan.core._core.PyTensor 的别名

class holoscan.core.Tracker(app, *, filename=None, num_buffered_messages=100, num_start_messages_to_skip=10, num_last_messages_to_discard=10, latency_threshold=0, is_limited_tracking=False)

基类:object

向应用程序添加数据流跟踪的上下文管理器。

__init__(app, *, filename=None, num_buffered_messages=100, num_start_messages_to_skip=10, num_last_messages_to_discard=10, latency_threshold=0, is_limited_tracking=False)
参数
appholoscan.core.Application

应在其上应用流跟踪的流。

filenamestr 或 None,可选

如果为 None,则禁用文件日志记录。否则,日志记录将写入指定的文件。

num_buffered_messagesint,可选

filename 不是 None 时,控制文件写入之间缓冲的消息数。

num_start_messages_to_skipint,可选

在执行开始时要跳过的消息数。这不会影响日志文件或源消息指标。

num_last_messages_to_discardint,可选

在执行结束时要丢弃的消息数。这不会影响日志文件或源消息指标。

latency_thresholdint,可选

端到端延迟指标计算中要考虑的最小端到端延迟(毫秒)。

is_limited_trackingbool,可选

如果为 true,则跟踪仅限于根节点和叶节点,通过避免中间运算符来最小化时间戳。

holoscan.core.arg_to_py_object(arg: holoscan.core._core.Arg) → object

Arg 转换为相应 Python 对象的实用程序。

参数
argholoscan.core.Arg

要转换的参数。

返回
objAny

与提供的参数对应的 Python 对象。例如,任何整数类型的参数都将变为 Python int,而 std::vector<double> 将变为 Python 浮点数列表。

holoscan.core.arglist_to_kwargs(arglist: holoscan.core._core.ArgList) → dict

ArgList 转换为 Python kwargs 字典的实用程序。

参数
arglistholoscan.core.ArgList

要转换的参数列表。

返回
kwargsdict

Python 字典,其键与 ArgList 中的参数名称匹配。这些值将像 arg_to_py_object 一样进行转换。

holoscan.core.kwargs_to_arglist(**kwargs)holoscan.core._core.ArgList

将一组 python 关键字参数转换为 ArgList 的实用程序。

参数
**kwargs

要转换的 python 关键字参数。

返回
arglistholoscan.core.ArgList

ArgList 类,对应于提供的关键字值。参数名称将与关键字名称匹配。这些值将像 py_object_to_arg 一样进行转换。

holoscan.core.py_object_to_arg(obj: object, name: str = '')holoscan.core._core.Arg

将单个 python 参数转换为相应的 Arg 类型的实用程序。

参数
valueAny

要转换的 python 值。

返回
objholoscan.core.Arg

Arg 类,对应于提供的值。例如,Python 浮点数将变为包含 C++ double 的 Arg,而 Python 整数列表将变为对应于 std::vector<uint64_t>Arg

namestr,可选

要分配给参数的名称。

上一个 holoscan.conditions
下一个 holoscan.decorator
© 版权所有 2022-2024,NVIDIA。 上次更新于 2025 年 1 月 27 日。