MCPcopy Create free account
hub / github.com/NVIDIA/DALI / push_predicate

Method push_predicate

dali/python/nvidia/dali/_conditionals.py:187–216  ·  view source on GitHub ↗

Add next level of if/else scope that is predicated with the `predicate`. The user might have provided a predicate from a scope of higher level, which means that `predicate` might be subject to additional slicing. Apply that slicing and return the actual predicate that will be

(self, predicate)

Source from the content-addressed store, hash-verified

185 self._is_registration_allowed = True
186
187 def push_predicate(self, predicate):
188 """Add next level of if/else scope that is predicated with the `predicate`.
189 The user might have provided a predicate from a scope of higher level, which means
190 that `predicate` might be subject to additional slicing. Apply that slicing and return
191 the actual predicate that will be used for slicing when entering this scope.
192
193 The situation will happen for example in a case like this, where both predicates are
194 produced in global scope:
195
196 pred_0 = ...
197 pred_1 = ...
198
199 if pred_0: # push_pred(pred_0) -> returns pred_0
200 if pred_1: # push_pred(pred_1) ->
201 # -> returns fn._conditional.slice(pred_1, predicate=pred_0)
202
203 Parameters
204 ----------
205 predicate : DataNode
206 Predicate guarding this scope.
207
208 Returns
209 -------
210 DataNode
211 Actual predicate after applying necessary slices to use it in this scope.
212 """
213 new_pred = self.preprocess_input(predicate)
214 new_entry = _StackEntry(new_pred)
215 self._stack.append(new_entry)
216 return new_pred
217
218 def top(self):
219 """Get the top scope in the stack"""

Callers 2

_cond_managerFunction · 0.80
test_condition_stackFunction · 0.80

Calls 3

preprocess_inputMethod · 0.95
_StackEntryClass · 0.85
appendMethod · 0.45

Tested by 1

test_condition_stackFunction · 0.64