---
title: IfOperation
description: "条件节点，根据用户传入的处理函数（handle）的返回值，在setup阶段判断执行路径来选择opA或opB下发执行。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0303.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0303.html
indexId: fd8ac27c183b59f690a5fa75b384d22402bc904fee40fe59bb7335e27abb402c64
---
# IfOperation

#### 功能说明

条件节点，根据用户传入的处理函数（handle）的返回值，在setup阶段判断执行路径来选择opA或opB下发执行。


#### 定义

```
struct IfCondParam {
    void *userData;
    bool (*handle)(void *userData);
    Operation *opA = nullptr;
    Operation *opB = nullptr;
    uint8_t rsv[32] = {0};
};
```


#### 参数列表

| 成员名称 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| userData | void \* | \- | 传给回调的上下文指针（用户自定义数据）。 |
| handle | bool (\*)(void\*) | \- | 条件判断回调，返回 true 选择 opA，返回 false 选择 opB。 |
| opA | Operation \* | nullptr | 条件为true时执行的分支Operation。 |
| opB | Operation \* | nullptr | 条件为false时执行的分支Operation。 |


#### 约束说明

opA和opB的VariantPack需完全相同。
