Class NoGradGuard
java.lang.Object
smile.deep.tensor.NoGradGuard
- All Implemented Interfaces:
AutoCloseable
A RAII-style guard that disables gradient calculation for the duration of its
lifetime. Use it with try-with-resources:
try (var guard = Tensor.noGradGuard()) {
// inference code; no autograd graph is built
}
The guard is thread-local; it does not affect computation in other threads.-
Method Summary
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-