maccel.future.Future Class Reference#
|
Runtime Library v0.30
Mobilint SDK qb
|
maccel.future.Future Class Reference
Represents a future for retrieving the result of asynchronous inference. More...
Public Member Functions | |
| __init__ (self, Optional[Union[_cMaccel.FutureFloat, _cMaccel.FutureInt8]] _future=None, Optional[List[np.ndarray]] _inputs=None) | |
| from_cpp (cls, Union[_cMaccel.FutureFloat, _cMaccel.FutureInt8] _future, List[np.ndarray] _inputs) | |
| bool | wait_for (self, int timeout_ms) |
| Waits for asynchronous inference to complete or until the timeout elapses. | |
| List[np.ndarray] | get (self) |
| Blocks until asynchronous inference completes and retrieves the output. | |
Protected Attributes | |
| _future = _future if _future is not None else _cMaccel.FutureFloat() | |
| _inputs = _inputs | |
Detailed Description
Represents a future for retrieving the result of asynchronous inference.
This class provides a mechanism similar to C++11 std::future, allowing access to the result of an asynchronous inference operation initiated via Model.infer_async(). For details on C++11 std::future, refer to https://en.cppreference.com/w/cpp/thread/future.html .
The Future object enables the caller to:
- Wait for the inference to complete (wait_for)
- Block until completion and retrieve the output (get)
Constructor & Destructor Documentation
◆ __init__()
| maccel.future.Future.__init__ | ( | self, | |
| Optional[Union[_cMaccel.FutureFloat, _cMaccel.FutureInt8]] | _future = None, | ||
| Optional[List[np.ndarray]] | _inputs = None ) |
Member Function Documentation
◆ from_cpp()
| maccel.future.Future.from_cpp | ( | cls, | |
| Union[_cMaccel.FutureFloat, _cMaccel.FutureInt8] | _future, | ||
| List[np.ndarray] | _inputs ) |
◆ wait_for()
| bool maccel.future.Future.wait_for | ( | self, | |
| int | timeout_ms ) |
Waits for asynchronous inference to complete or until the timeout elapses.
- Note
- This method is safe to call multiple times. Calling it with a timeout of zero (i.e., wait_for(0)) performs a non-blocking check to see whether asynchronous inference has already completed.
- Parameters
-
[in] timeout_ms Maximum duration to wait, in milliseconds.
- Returns
- True if inference completed before the timeout, false otherwise.
◆ get()
| List[np.ndarray] maccel.future.Future.get | ( | self | ) |
Blocks until asynchronous inference completes and retrieves the output.
- Note
- This method should be called only once per Future. If called again, the return value will be invalid, and it will raise maccel.MAccelError "Future_NotValid".
- Returns
- A list of numpy ndarray containing the inference output.
Member Data Documentation
◆ _future
|
protected |
◆ _inputs
The documentation for this class was generated from the following file:
Generated by