class Device
| Info | Value |
|---|---|
| Package | mvnc |
| Module | mvncapi |
| Version | 2.0 |
| See also | DeviceOption, Graph, Fifo, enumerate_devices() |
Overview
The Device class represents a neural compute device and provides methods to communicate with the device to perform inferences.
Create an instance of this class each neural compute device. You can get a list of identifiers for neural compute devices present in the system with enumerate_devices().
Initialization
Create a Device instance:
device = mvncapi.Device(identifier)
| Parameter | Type | Description |
|---|---|---|
| identifier | ctypes.c_void_p | The identifier of the device to initialize. A list of valid identifiers can be obtained by calling the mvncapi module global function enumerate_devices(). |
When the Device has been successfully created the DeviceState will be CREATED.
Methods
| Method | Description |
|---|---|
| close | Cease communication with the device. |
| destroy | Destroy the Device and free associated resources. |
| get_option | Get the value of a DeviceOption. |
| open | Initialize the device and open communication. |
| set_option | Set the value of a DeviceOption. |
Typical Usage
- Create a Device.
- Open the device with Device.open().
- Use the device.
- Close the device with Device.close().
- Destroy the Device and free associated resources with Device.destroy().
See the Python API Overview for more information about typical API usage.
Example
from mvnc import mvncapi
# Get a list of valid device identifiers
device_list = mvncapi.enumerate_devices()
# Create a Device instance for the first device found
device = mvncapi.Device(device_list[0])
# Get the device name and output to console
print(device.get_option(mvncapi.DeviceOption.RO_DEVICE_NAME))
# Open communication with the device
device.open()
#
# Use the device...
#
# Clean up
device.close()
device.destroy()