pub struct IIfConditional { /* private fields */ }Expand description
IIfConditional
Helper for constructing conditionally-executed subgraphs.
An If-conditional conditionally executes part of the network according to the following pseudo-code:
If condition is true then: output = trueSubgraph(trueInputs); Else output = falseSubgraph(falseInputs); Emit output
Condition is a 0D boolean tensor (representing a scalar). trueSubgraph represents a network subgraph that is executed when condition evaluates to True. falseSubgraph represents a network subgraph that is executed when condition evaluates to False.
The following constraints apply to If-conditionals:
- Both the trueSubgraph and falseSubgraph must be defined.
- The number of output tensors in both subgraphs is the same.
- Corresponding output tensors from the true/false subgraphs have the same type and rank.
The subgraphs may directly use tensors defined outside of the IIfConditional.
Implementations§
Source§impl IIfConditional
impl IIfConditional
Sourcepub fn setCondition(
self: Pin<&mut IIfConditional>,
condition: Pin<&mut ITensor>,
) -> *mut IConditionLayer
pub fn setCondition( self: Pin<&mut IIfConditional>, condition: Pin<&mut ITensor>, ) -> *mut IConditionLayer
Set the condition tensor for this If-Conditional construct.
conditionThe condition tensor that will determine which subgraph to execute.
condition tensor must be a 0D execution tensor (scalar) with type DataType::kBOOL.
See IConditionLayer
Sourcepub fn addOutput(
self: Pin<&mut IIfConditional>,
trueSubgraphOutput: Pin<&mut ITensor>,
falseSubgraphOutput: Pin<&mut ITensor>,
) -> *mut IIfConditionalOutputLayer
pub fn addOutput( self: Pin<&mut IIfConditional>, trueSubgraphOutput: Pin<&mut ITensor>, falseSubgraphOutput: Pin<&mut ITensor>, ) -> *mut IIfConditionalOutputLayer
Add an If-conditional output.
trueSubgraphOutputThe output of the subgraph executed when the conditional evaluates to true.falseSubgraphOutputThe output of the subgraph executed when the conditional evaluates to false.
Each output layer of an IIfConditional represents a single output of either the true-subgraph or the false-subgraph of an IIfConditional, depending on which subgraph was executed.
The ranks of the two tensors must be equal unless the condition is a build-time constant.
Sourcepub fn addInput(
self: Pin<&mut IIfConditional>,
input: Pin<&mut ITensor>,
) -> *mut IIfConditionalInputLayer
pub fn addInput( self: Pin<&mut IIfConditional>, input: Pin<&mut ITensor>, ) -> *mut IIfConditionalInputLayer
Add an If-conditional input.
inputAn input to the conditional that can be used by either or both of the conditional’s subgraphs.
Sourcepub unsafe fn setName(self: Pin<&mut IIfConditional>, name: *const c_char)
pub unsafe fn setName(self: Pin<&mut IIfConditional>, name: *const c_char)
Set the name of the conditional.
The name is used in error diagnostics. This method copies the name string.
The string name must be null-terminated, and be at most 4096 bytes including the terminator.
See [getName()]
Sourcepub fn getName(self: &IIfConditional) -> *const c_char
pub fn getName(self: &IIfConditional) -> *const c_char
Return the name of the conditional.
See [setName()]