yr.get_function_group_context#
- yr.get_function_group_context() FunctionGroupContext[source]#
Get the function group context of the current function instance.
Note
A valid function group context can only be obtained when using heterogeneous resources.
During the process deployment, the heterogeneous resource collection feature must be enabled (enabled by default). You need to choose different modes to collect different ranges of parameters, and you can set the parameter npu_collection_mode.
- Returns:
The function group context, i.e., FunctionGroupContext.
Examples
>>> import yr >>> yr.init() >>> >>> @yr.invoke ... def demo_func(name): ... context = yr.fcc.get_function_group_context() ... print(context) ... return name >>> >>> opts = yr.FunctionGroupOptions( ... cpu=1000, ... memory=1000, ... resources={ ... "NPU/Ascend910B4/count": 1, ... }, ... scheduling_affinity_each_bundle_size=2, ... ) >>> name = "function_demo" >>> objs = yr.fcc.create_function_group(demo_func, args=(name,), group_size=8, options=opts) >>> rets = yr.get(objs) >>> assert rets == [name for i in range(1, 9)] >>> yr.finalize()