set_attr

Applicable Products

Product

Supported

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

x

Atlas inference products

x

Atlas training products

x

Function Description

Sets the attributes of FlowNode.

Prototype

1
set_attr(attr_name, attr_value)

Parameters

Parameter

Data Type

Value Description

attr_name

str

Attribute name.

Currently, the following types are supported:

  • _flow_attr: a bool-type attribute that indicates the flow attribute. The value true indicates that the flow attribute exists, and false indicates that the flow attribute does not exist.
  • _flow_attr_depth: an INT-type attribute that specifies the queue depth. The value must be greater than or equal to 2. If this parameter is not set, the default depth 128 is used.
  • _flow_attr_enqueue_policy: a string-type attribute that specifies the enqueue policy and only supports FIFO and OVERWRITE. FIFO means data is enqueued in sequence and waits for dequeue operations when the queue is full, while OVERWRITE means no waiting occurs during enqueue and existing data is overwritten cyclically. The default policy is FIFO if this attribute is not configured.

attr_value

Union[bool, str, int]

Attribute value.

Returns

None is returned in normal scenarios.

TypeError is returned when the parameter type is incorrect.

Examples

1
2
3
4
5
6
import dataflow as df
pp = df.FuncProcessPoint(...)
flow_node = df.FlowNode(...)
flow_node.set_attr("_flow_attr",True)
flow_node.set_attr("_flow_attr_depth",5)
flow_node.set_attr("_flow_attr_enqueue_policy","FIFO")

Constraints

Setting depth and policy via _flow_attr_depth and _flow_attr_enqueue_policy takes no effect unless _flow_attr is enabled in advance.