diff --git a/README.md b/README.md index 869616f3ac8fe9..84f1f3ff324994 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # [OpenVINO™ Toolkit](https://01.org/openvinotoolkit) - Deep Learning Deployment Toolkit repository -[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/openvinotoolkit/openvino/releases/tag/2020.3.0) +[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/openvinotoolkit/openvino/releases/tag/2020.3.2) [![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE) This toolkit allows developers to deploy pre-trained deep learning models diff --git a/inference-engine/cmake/vpu_dependencies.cmake b/inference-engine/cmake/vpu_dependencies.cmake index bae2eecc2d6090..781a980814cd8c 100644 --- a/inference-engine/cmake/vpu_dependencies.cmake +++ b/inference-engine/cmake/vpu_dependencies.cmake @@ -19,7 +19,7 @@ set(VPU_SUPPORTED_FIRMWARES usb-ma2450 usb-ma2x8x pcie-ma248x) # Default packages # -set(FIRMWARE_PACKAGE_VERSION 1119) +set(FIRMWARE_PACKAGE_VERSION 1656) # # CMake variables to override default firmware files diff --git a/inference-engine/samples/common/format_reader/bmp.h b/inference-engine/samples/common/format_reader/bmp.h index 3d9081d89cdf88..a3187f3f7fada0 100644 --- a/inference-engine/samples/common/format_reader/bmp.h +++ b/inference-engine/samples/common/format_reader/bmp.h @@ -23,14 +23,14 @@ class BitMap : public Reader { private: static Register reg; - typedef struct { + typedef struct BmpHeaderType { unsigned short type = 0u; /* Magic identifier */ unsigned int size = 0u; /* File size in bytes */ unsigned int reserved = 0u; unsigned int offset = 0u; /* Offset to image data, bytes */ } BmpHeader; - typedef struct { + typedef struct BmpInfoHeaderType { unsigned int size = 0u; /* Header size in bytes */ int width = 0, height = 0; /* Width and height of image */ unsigned short planes = 0u; /* Number of colour planes */ diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp index 06b7c95425f07e..f8d9c913c816a6 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp @@ -97,5 +97,7 @@ DECLARE_VPU_MYRIAD_CONFIG_KEY(PLUGIN_LOG_FILE_PATH); DECLARE_VPU_MYRIAD_CONFIG_KEY(DEVICE_CONNECT_TIMEOUT); +DECLARE_VPU_MYRIAD_CONFIG_KEY(ENABLE_ASYNC_DMA); + } // namespace VPUConfigParams } // namespace InferenceEngine diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_config.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_config.cpp index d6eb8186d40d9f..11930a73554401 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_config.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_config.cpp @@ -100,6 +100,7 @@ IE_SUPPRESS_DEPRECATED_END setOption(_pluginLogFilePath, config, VPU_MYRIAD_CONFIG_KEY(PLUGIN_LOG_FILE_PATH)); setOption(_deviceName, config, CONFIG_KEY(DEVICE_ID)); setOption(_forceReset, switches, config, VPU_MYRIAD_CONFIG_KEY(FORCE_RESET)); + setOption(_enableAsyncDma, switches, config, VPU_MYRIAD_CONFIG_KEY(ENABLE_ASYNC_DMA)); setOption(_platform, platforms, config, VPU_MYRIAD_CONFIG_KEY(PLATFORM)); setOption(_protocol, protocols, config, VPU_MYRIAD_CONFIG_KEY(PROTOCOL)); setOption(_watchdogInterval, watchdogIntervals, config, VPU_MYRIAD_CONFIG_KEY(WATCHDOG)); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_config.h b/inference-engine/src/vpu/myriad_plugin/myriad_config.h index d9ba6b66473d08..8754c3ce328322 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_config.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_config.h @@ -35,6 +35,10 @@ class MyriadConfig final : public ParsedConfig { return _forceReset; } + bool asyncDma() const { + return _enableAsyncDma; + } + PowerConfig powerConfig() const { return _powerConfig; } @@ -68,6 +72,7 @@ class MyriadConfig final : public ParsedConfig { private: std::string _pluginLogFilePath; bool _forceReset = false; + bool _enableAsyncDma = true; PowerConfig _powerConfig = PowerConfig::FULL; ncDevicePlatform_t _platform = NC_ANY_PLATFORM; ncDeviceProtocol_t _protocol = NC_ANY_PROTOCOL; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp index 9b7b96cfabdd48..d952a67dc08d06 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp @@ -89,6 +89,7 @@ ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, const ncDeviceProtocol_t& configProtocol = config.protocol(); const std::string& configDevName = config.deviceName(); PowerConfig powerConfig = config.powerConfig(); + int enableAsyncDma = config.asyncDma(); int lastDeviceIdx = devicePool.empty() ? -1 : devicePool.back()->_deviceIdx; ncStatus_t statusOpen = NC_ERROR; @@ -204,6 +205,14 @@ ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, return status; } + status = ncDeviceSetOption(device._deviceHandle, NC_RW_ENABLE_ASYNC_DMA, reinterpret_cast(&enableAsyncDma), sizeof(dataLength)); + + if (status != NC_OK) { + _log->warning("Failed to set option for async DMA"); + ncDeviceClose(&device._deviceHandle, _mvnc->watchdogHndl()); + return status; + } + /* TODO: what should we do if we do not know maximum available graphs? What if we got number <= 0? */ device._graphNum = 1; device._deviceIdx = lastDeviceIdx + 1; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h b/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h index 7f05b67f6fe8db..641a4c9bf10664 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/common/tensor_type.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace kernel_selector { #define KERNEL_SELECTOR_TENSOR_DIM_MAX 9 diff --git a/inference-engine/thirdparty/movidius/mvnc/include/mvnc.h b/inference-engine/thirdparty/movidius/mvnc/include/mvnc.h index a3f6d2d3f11b10..1cd6ec8e0557d1 100644 --- a/inference-engine/thirdparty/movidius/mvnc/include/mvnc.h +++ b/inference-engine/thirdparty/movidius/mvnc/include/mvnc.h @@ -121,6 +121,7 @@ typedef enum { NC_RO_DEVICE_PROTOCOL = 2018, // returns device protocol (USB, PCIe) NC_RW_DEVICE_POWER_CONFIG = 2100, // writes config for the power manager to device NC_RW_DEVICE_POWER_CONFIG_RESET = 2101, // resets power manager config on device + NC_RW_ENABLE_ASYNC_DMA = 2102 // enable/disable asynchronous DMA on device } ncDeviceOption_t; typedef enum { diff --git a/inference-engine/thirdparty/movidius/mvnc/include/ncCommPrivate.h b/inference-engine/thirdparty/movidius/mvnc/include/ncCommPrivate.h index 729a292d022a27..c18b5f64212991 100644 --- a/inference-engine/thirdparty/movidius/mvnc/include/ncCommPrivate.h +++ b/inference-engine/thirdparty/movidius/mvnc/include/ncCommPrivate.h @@ -113,7 +113,8 @@ typedef enum { DEVICE_SET_STDIO_REDIRECT_XLINK = 5, DEVICE_SET_POWER_CONFIG = 6, DEVICE_RESET_POWER_CONFIG = 7, - DEVICE_COMMAND_LAST = 8 + DEVICE_ENABLE_ASYNC_DMA = 8, + DEVICE_COMMAND_LAST = 9 } deviceCommandType_t; typedef struct { diff --git a/inference-engine/thirdparty/movidius/mvnc/src/mvnc_api.c b/inference-engine/thirdparty/movidius/mvnc/src/mvnc_api.c index 39007833881d4f..bdf5c1802eaa44 100644 --- a/inference-engine/thirdparty/movidius/mvnc/src/mvnc_api.c +++ b/inference-engine/thirdparty/movidius/mvnc/src/mvnc_api.c @@ -82,8 +82,23 @@ static OVERLAPPED global_lock_overlap = { 0 }; #define GLOBAL_UNLOCK() UnlockFileEx(global_lock_fd, 0, MAXDWORD, MAXDWORD, &global_lock_overlap) #else static int global_lock_fd = -1; -#define GLOBAL_LOCK() flock(global_lock_fd, LOCK_EX) -#define GLOBAL_UNLOCK() flock(global_lock_fd, LOCK_UN) +#define GLOBAL_LOCK() \ + do { \ + CHECK_MUTEX_SUCCESS_RC(flock(global_lock_fd, LOCK_EX), NC_ERROR); \ + if (pthread_mutex_lock(&deviceOpenMutex) != 0) { \ + CHECK_MUTEX_SUCCESS(flock(global_lock_fd, LOCK_UN)); \ + return NC_ERROR; \ + } \ + } while (0) + +#define GLOBAL_UNLOCK() \ + do { \ + if (flock(global_lock_fd, LOCK_UN) != 0) { \ + CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); \ + return NC_ERROR; \ + } \ + CHECK_MUTEX_SUCCESS_RC(pthread_mutex_unlock(&deviceOpenMutex), NC_ERROR); \ + } while (0) #endif #define STRINGIFY(_text) #_text @@ -743,17 +758,10 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, } GLOBAL_LOCK(); - int error = pthread_mutex_lock(&deviceOpenMutex); - if (error) { - GLOBAL_UNLOCK(); - mvLog(MVLOG_ERROR, "pthread_mutex_lock(&deviceOpenMutex) failed with error: %d", error); - return NC_ERROR; - } if (!initialized) { ncStatus_t sc; if ((sc = initializeXLink()) != 0) { - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return sc; } @@ -769,7 +777,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, } if (rc != X_LINK_SUCCESS) { - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return parseXLinkError(NC_ERROR); } @@ -789,7 +796,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, d->wd_interval = watchdogInterval; *deviceHandlePtr = dH; } else { - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); mvLog(MVLOG_ERROR, "Memory allocation failed"); free(d); @@ -799,7 +805,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, if (d->dev_addr == NULL) { destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_OUT_OF_MEMORY; } @@ -811,7 +816,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, if (!handler) { mvLog(MVLOG_ERROR, "Memory allocation failed"); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_OUT_OF_MEMORY; } @@ -841,7 +845,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, mvLog(MVLOG_ERROR, "Can't get firmware, error: %s", ncStatusToStr(sc)); free(handler); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_MVCMD_NOT_FOUND; } @@ -852,7 +855,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, __func__, XLinkErrorToStr(rc), d->dev_addr); free(handler); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_ERROR; } else { @@ -911,7 +913,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, mvLog(MVLOG_ERROR, "Can't get firmware, error: %s", ncStatusToStr(sc)); free(handler); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_MVCMD_NOT_FOUND; } @@ -1012,7 +1013,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, } free(handler); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_ERROR; } @@ -1023,7 +1023,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, mvLog(MVLOG_ERROR, "Failed connection to device (%s) with error %d", d->dev_addr, rc); free(handler); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return parseXLinkError(rc); } @@ -1036,7 +1035,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, if (d->dev_addr == NULL || d->dev_addr_booted == NULL || d->xlink == NULL) { mvLog(MVLOG_ERROR, "device is invalid"); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_INVALID_HANDLE; } @@ -1044,11 +1042,10 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, devices = d; mvLog(MVLOG_INFO, "XLinkConnect done - link Id %d\n", handler->linkId); - + int error = 0; if ((error = pthread_mutex_init(&d->dev_data_m, NULL)) != 0) { mvLog(MVLOG_ERROR, "pthread_mutex_init (dev_data_m) failed with error: %d", error); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_ERROR; } @@ -1057,7 +1054,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, mvLog(MVLOG_ERROR, "pthread_mutex_init (dev_stream_m) failed with error: %d", error); CHECK_MUTEX_SUCCESS(pthread_mutex_destroy(&d->dev_data_m)); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_ERROR; } @@ -1066,7 +1062,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, CHECK_MUTEX_SUCCESS(pthread_mutex_destroy(&d->dev_data_m)); CHECK_MUTEX_SUCCESS(pthread_mutex_destroy(&d->dev_stream_m)); destroyDeviceHandle(deviceHandlePtr); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); return NC_ERROR; } @@ -1082,7 +1077,6 @@ ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t **deviceHandlePtr, sleepForSeconds(1); - CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&deviceOpenMutex)); GLOBAL_UNLOCK(); streamId_t deviceMonitorStreamId = XLinkOpenStream(d->xlink->linkId, "deviceMonitor", CONFIG_STREAM_SIZE); @@ -1933,22 +1927,24 @@ ncStatus_t checkGraphMonitorResponse(streamId_t graphMonStream) { return NC_OK; } -static void lockAllInferences() { +static ncStatus_t lockAllInferences() { + GLOBAL_LOCK(); struct _devicePrivate_t *d = devices; while (d) { CHECK_MUTEX_SUCCESS(pthread_mutex_lock(&d->graph_stream_m)); d = d->next; } - return; + return NC_OK; } -static void unlockAllInferences() { +static ncStatus_t unlockAllInferences() { struct _devicePrivate_t *d = devices; while (d) { CHECK_MUTEX_SUCCESS(pthread_mutex_unlock(&d->graph_stream_m)); d = d->next; } - return; + GLOBAL_UNLOCK(); + return NC_OK; } ncStatus_t ncGraphAllocate(struct ncDeviceHandle_t * deviceHandle, @@ -1998,7 +1994,12 @@ ncStatus_t ncGraphAllocate(struct ncDeviceHandle_t * deviceHandle, } GLOBAL_UNLOCK(); - lockAllInferences(); + rc = lockAllInferences(); + if (rc != 0) { + mvLog(MVLOG_ERROR, "can't lock all inferences"); + unlockAllInferences(); + return rc; + } g->id = graphIdCount++; streamId_t streamId; @@ -2163,7 +2164,11 @@ ncStatus_t ncGraphAllocate(struct ncDeviceHandle_t * deviceHandle, g->debug_buffer = g->aux_buffer; g->time_taken = (float *) (g->aux_buffer + 120); - unlockAllInferences(); + rc = unlockAllInferences(); + if (rc != 0) { + mvLog(MVLOG_ERROR, "Can't unlock all inferences"); + return rc; + } GLOBAL_LOCK(); g->dev = d; @@ -2516,6 +2521,7 @@ ncStatus_t ncGraphGetOption(struct ncGraphHandle_t * graphHandle, if (opAccess != NC_OP_ACCESS_READ_ONLY && opAccess != NC_OP_ACCESS_READ_WRITE) { mvLog(MVLOG_ERROR, "There is no such option"); + GLOBAL_UNLOCK(); return NC_INVALID_PARAMETERS; } @@ -2685,20 +2691,32 @@ static ncStatus_t getDeviceOption(struct _devicePrivate_t *d, return rc; } -static ncStatus_t setDevicePowerConfig(struct _devicePrivate_t *d, +static ncStatus_t setDeviceOption(struct _devicePrivate_t *d, ncDeviceOption_t option, const void *data, unsigned int dataLength){ XLinkError_t rc = X_LINK_SUCCESS; deviceCommand_t config; - if (option != NC_RW_DEVICE_POWER_CONFIG_RESET && option != NC_RW_DEVICE_POWER_CONFIG) { - mvLog(MVLOG_ERROR, "No such option"); - return NC_INVALID_PARAMETERS; + switch (option) { + case NC_RW_DEVICE_POWER_CONFIG_RESET: { + config.type = DEVICE_RESET_POWER_CONFIG; + break; + } + case NC_RW_DEVICE_POWER_CONFIG: { + config.type = DEVICE_SET_POWER_CONFIG; + break; + } + case NC_RW_ENABLE_ASYNC_DMA: { + config.type = DEVICE_ENABLE_ASYNC_DMA; + break; + } + default: { + mvLog(MVLOG_ERROR, "No such option"); + return NC_INVALID_PARAMETERS; + } } - config.type = (option == NC_RW_DEVICE_POWER_CONFIG ? DEVICE_SET_POWER_CONFIG : DEVICE_RESET_POWER_CONFIG); config.arg = *(uint32_t*)data; - rc = XLinkWriteData(d->device_mon_stream_id, (const uint8_t *)&config, sizeof(config)); if (rc != X_LINK_SUCCESS) @@ -2748,20 +2766,11 @@ ncStatus_t ncDeviceSetOption(struct ncDeviceHandle_t *deviceHandle, if (opAccess != NC_OP_ACCESS_READ_WRITE) { mvLog(MVLOG_ERROR, "There is no such option"); + GLOBAL_UNLOCK(); return NC_INVALID_PARAMETERS; } - switch (option) { - case NC_RW_DEVICE_POWER_CONFIG: - case NC_RW_DEVICE_POWER_CONFIG_RESET: - { - rc = setDevicePowerConfig(d, option, data, dataLength); - break; - } - default: - rc = NC_INVALID_PARAMETERS; - mvLog(MVLOG_ERROR, "There is no such option"); - } + setDeviceOption(d, option, data, dataLength); GLOBAL_UNLOCK(); return rc; @@ -2817,6 +2826,7 @@ ncStatus_t ncDeviceGetOption(struct ncDeviceHandle_t * deviceHandle, if (opAccess != NC_OP_ACCESS_READ_ONLY && opAccess != NC_OP_ACCESS_READ_WRITE) { mvLog(MVLOG_ERROR, "There is no such option"); + GLOBAL_UNLOCK(); return NC_INVALID_PARAMETERS; } diff --git a/model-optimizer/requirements_kaldi.txt b/model-optimizer/requirements_kaldi.txt index acd2c87d4736b3..a5829bfc15f470 100644 --- a/model-optimizer/requirements_kaldi.txt +++ b/model-optimizer/requirements_kaldi.txt @@ -1,3 +1,3 @@ networkx>=1.11 -numpy==1.13.0 +numpy>=1.12.0 defusedxml>=0.5.0