Creates a NetBuilder that will execute once as the next step of the current NetBuilder. After execution, a bool tensor will indicate whether the inner execution was halted with `stop` or `stop_if`. Example: a = ops.Const(True) with
(self, has_stopped_blob=None, name=None)
| 299 | return NetBuilder.current().add(_Loop(iters, name=name)) |
| 300 | |
| 301 | def stop_guard(self, has_stopped_blob=None, name=None): |
| 302 | """ |
| 303 | Creates a NetBuilder that will execute once as the next step of the |
| 304 | current NetBuilder. After execution, a bool tensor will indicate |
| 305 | whether the inner execution was halted with `stop` or `stop_if`. |
| 306 | Example: |
| 307 | a = ops.Const(True) |
| 308 | with ops.stop_guard() as sg1: |
| 309 | ops.stop_if(a) |
| 310 | ops.Print(ops.Const('did not stop')) |
| 311 | b = ops.Const(False) |
| 312 | with ops.stop_guard() as sg2: |
| 313 | ops.stop_if(b) |
| 314 | ops.Print(ops.Const('did not stop')) |
| 315 | ops.Print(sg1.has_stopped(), []) |
| 316 | ops.Print(sg2.has_stopped(), []) |
| 317 | In the example, 'did not stop' will be printed once, |
| 318 | followed by True and False. |
| 319 | """ |
| 320 | return NetBuilder.current().add( |
| 321 | _StopGuard(has_stopped_blob=has_stopped_blob, name=name)) |
| 322 | |
| 323 | def If(self, cond, name=None): |
| 324 | """ |