mirror of https://github.com/opencv/opencv.git
Merge pull request #12703 from wzw-intel:vkcom
* dnn: Add a Vulkan based backend This commit adds a new backend "DNN_BACKEND_VKCOM" and a new target "DNN_TARGET_VULKAN". VKCOM means vulkan based computation library. This backend uses Vulkan API and SPIR-V shaders to do the inference computation for layers. The layer types that implemented in DNN_BACKEND_VKCOM include: Conv, Concat, ReLU, LRN, PriorBox, Softmax, MaxPooling, AvePooling, Permute This is just a beginning work for Vulkan in OpenCV DNN, more layer types will be supported and performance tuning is on the way. Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com> * dnn/vulkan: Add FindVulkan.cmake to detect Vulkan SDK In order to build dnn with Vulkan support, need installing Vulkan SDK and setting environment variable "VULKAN_SDK" and add "-DWITH_VULKAN=ON" to cmake command. You can download Vulkan SDK from: https://vulkan.lunarg.com/sdk/home#linux For how to install, see https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html https://vulkan.lunarg.com/doc/sdk/latest/windows/getting_started.html https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html respectively for linux, windows and mac. To run the vulkan backend, also need installing mesa driver. On Ubuntu, use this command 'sudo apt-get install mesa-vulkan-drivers' To test, use command '$BUILD_DIR/bin/opencv_test_dnn --gtest_filter=*VkCom*' Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com> * dnn/Vulkan: dynamically load Vulkan runtime No compile-time dependency on Vulkan library. If Vulkan runtime is unavailable, fallback to CPU path. Use environment "OPENCL_VULKAN_RUNTIME" to specify path to your own vulkan runtime library. Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com> * dnn/Vulkan: Add a python script to compile GLSL shaders to SPIR-V shaders The SPIR-V shaders are in format of text-based 32-bit hexadecimal numbers, and inserted into .cpp files as unsigned int32 array. * dnn/Vulkan: Put Vulkan headers into 3rdparty directory and some other fixes Vulkan header files are copied from https://github.com/KhronosGroup/Vulkan-Docs/tree/master/include/vulkan to 3rdparty/include Fix the Copyright declaration issue. Refine OpenCVDetectVulkan.cmake * dnn/Vulkan: Add vulkan backend tests into existing ones. Also fixed some test failures. - Don't use bool variable as uniform for shader - Fix dispathed group number beyond max issue - Bypass "group > 1" convolution. This should be support in future. * dnn/Vulkan: Fix multiple initialization in one thread.pull/12949/head^2
parent
220b278575
commit
6e3ea8b49d
89 changed files with 16275 additions and 12 deletions
@ -0,0 +1,92 @@ |
|||||||
|
//
|
||||||
|
// File: vk_platform.h
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2014-2017 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#ifndef VK_PLATFORM_H_ |
||||||
|
#define VK_PLATFORM_H_ |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" |
||||||
|
{ |
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
/*
|
||||||
|
*************************************************************************************************** |
||||||
|
* Platform-specific directives and type declarations |
||||||
|
*************************************************************************************************** |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Platform-specific calling convention macros.
|
||||||
|
* |
||||||
|
* Platforms should define these so that Vulkan clients call Vulkan commands |
||||||
|
* with the same calling conventions that the Vulkan implementation expects. |
||||||
|
* |
||||||
|
* VKAPI_ATTR - Placed before the return type in function declarations. |
||||||
|
* Useful for C++11 and GCC/Clang-style function attribute syntax. |
||||||
|
* VKAPI_CALL - Placed after the return type in function declarations. |
||||||
|
* Useful for MSVC-style calling convention syntax. |
||||||
|
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types. |
||||||
|
* |
||||||
|
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); |
||||||
|
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); |
||||||
|
*/ |
||||||
|
#if defined(_WIN32) |
||||||
|
// On Windows, Vulkan commands use the stdcall convention
|
||||||
|
#define VKAPI_ATTR |
||||||
|
#define VKAPI_CALL __stdcall |
||||||
|
#define VKAPI_PTR VKAPI_CALL |
||||||
|
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 |
||||||
|
#error "Vulkan isn't supported for the 'armeabi' NDK ABI" |
||||||
|
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) |
||||||
|
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
|
||||||
|
// calling convention, i.e. float parameters are passed in registers. This
|
||||||
|
// is true even if the rest of the application passes floats on the stack,
|
||||||
|
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||||
|
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) |
||||||
|
#define VKAPI_CALL |
||||||
|
#define VKAPI_PTR VKAPI_ATTR |
||||||
|
#else |
||||||
|
// On other platforms, use the default calling convention
|
||||||
|
#define VKAPI_ATTR |
||||||
|
#define VKAPI_CALL |
||||||
|
#define VKAPI_PTR |
||||||
|
#endif |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
|
||||||
|
#if !defined(VK_NO_STDINT_H) |
||||||
|
#if defined(_MSC_VER) && (_MSC_VER < 1600) |
||||||
|
typedef signed __int8 int8_t; |
||||||
|
typedef unsigned __int8 uint8_t; |
||||||
|
typedef signed __int16 int16_t; |
||||||
|
typedef unsigned __int16 uint16_t; |
||||||
|
typedef signed __int32 int32_t; |
||||||
|
typedef unsigned __int32 uint32_t; |
||||||
|
typedef signed __int64 int64_t; |
||||||
|
typedef unsigned __int64 uint64_t; |
||||||
|
#else |
||||||
|
#include <stdint.h> |
||||||
|
#endif |
||||||
|
#endif // !defined(VK_NO_STDINT_H)
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} // extern "C"
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,83 @@ |
|||||||
|
#ifndef VULKAN_H_ |
||||||
|
#define VULKAN_H_ 1 |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "vk_platform.h" |
||||||
|
#include "vulkan_core.h" |
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_ANDROID_KHR |
||||||
|
#include "vulkan_android.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_FUCHSIA |
||||||
|
#include <zircon/types.h> |
||||||
|
#include "vulkan_fuchsia.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_IOS_MVK |
||||||
|
#include "vulkan_ios.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_MACOS_MVK |
||||||
|
#include "vulkan_macos.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_MIR_KHR |
||||||
|
#include <mir_toolkit/client_types.h> |
||||||
|
#include "vulkan_mir.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_VI_NN |
||||||
|
#include "vulkan_vi.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_WAYLAND_KHR |
||||||
|
#include <wayland-client.h> |
||||||
|
#include "vulkan_wayland.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_WIN32_KHR |
||||||
|
#include <windows.h> |
||||||
|
#include "vulkan_win32.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_XCB_KHR |
||||||
|
#include <xcb/xcb.h> |
||||||
|
#include "vulkan_xcb.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_XLIB_KHR |
||||||
|
#include <X11/Xlib.h> |
||||||
|
#include "vulkan_xlib.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT |
||||||
|
#include <X11/Xlib.h> |
||||||
|
#include <X11/extensions/Xrandr.h> |
||||||
|
#include "vulkan_xlib_xrandr.h" |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif // VULKAN_H_
|
@ -0,0 +1,126 @@ |
|||||||
|
#ifndef VULKAN_ANDROID_H_ |
||||||
|
#define VULKAN_ANDROID_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_android_surface 1 |
||||||
|
struct ANativeWindow; |
||||||
|
|
||||||
|
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6 |
||||||
|
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkAndroidSurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkAndroidSurfaceCreateFlagsKHR flags; |
||||||
|
struct ANativeWindow* window; |
||||||
|
} VkAndroidSurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_ANDROID_external_memory_android_hardware_buffer 1 |
||||||
|
struct AHardwareBuffer; |
||||||
|
|
||||||
|
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 3 |
||||||
|
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer" |
||||||
|
|
||||||
|
typedef struct VkAndroidHardwareBufferUsageANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
void* pNext; |
||||||
|
uint64_t androidHardwareBufferUsage; |
||||||
|
} VkAndroidHardwareBufferUsageANDROID; |
||||||
|
|
||||||
|
typedef struct VkAndroidHardwareBufferPropertiesANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
void* pNext; |
||||||
|
VkDeviceSize allocationSize; |
||||||
|
uint32_t memoryTypeBits; |
||||||
|
} VkAndroidHardwareBufferPropertiesANDROID; |
||||||
|
|
||||||
|
typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
void* pNext; |
||||||
|
VkFormat format; |
||||||
|
uint64_t externalFormat; |
||||||
|
VkFormatFeatureFlags formatFeatures; |
||||||
|
VkComponentMapping samplerYcbcrConversionComponents; |
||||||
|
VkSamplerYcbcrModelConversion suggestedYcbcrModel; |
||||||
|
VkSamplerYcbcrRange suggestedYcbcrRange; |
||||||
|
VkChromaLocation suggestedXChromaOffset; |
||||||
|
VkChromaLocation suggestedYChromaOffset; |
||||||
|
} VkAndroidHardwareBufferFormatPropertiesANDROID; |
||||||
|
|
||||||
|
typedef struct VkImportAndroidHardwareBufferInfoANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
struct AHardwareBuffer* buffer; |
||||||
|
} VkImportAndroidHardwareBufferInfoANDROID; |
||||||
|
|
||||||
|
typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkDeviceMemory memory; |
||||||
|
} VkMemoryGetAndroidHardwareBufferInfoANDROID; |
||||||
|
|
||||||
|
typedef struct VkExternalFormatANDROID { |
||||||
|
VkStructureType sType; |
||||||
|
void* pNext; |
||||||
|
uint64_t externalFormat; |
||||||
|
} VkExternalFormatANDROID; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties); |
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID( |
||||||
|
VkDevice device, |
||||||
|
const struct AHardwareBuffer* buffer, |
||||||
|
VkAndroidHardwareBufferPropertiesANDROID* pProperties); |
||||||
|
|
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID( |
||||||
|
VkDevice device, |
||||||
|
const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, |
||||||
|
struct AHardwareBuffer** pBuffer); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,58 @@ |
|||||||
|
#ifndef VULKAN_FUCHSIA_H_ |
||||||
|
#define VULKAN_FUCHSIA_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_FUCHSIA_imagepipe_surface 1 |
||||||
|
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1 |
||||||
|
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA; |
||||||
|
|
||||||
|
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkImagePipeSurfaceCreateFlagsFUCHSIA flags; |
||||||
|
zx_handle_t imagePipeHandle; |
||||||
|
} VkImagePipeSurfaceCreateInfoFUCHSIA; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA( |
||||||
|
VkInstance instance, |
||||||
|
const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,58 @@ |
|||||||
|
#ifndef VULKAN_IOS_H_ |
||||||
|
#define VULKAN_IOS_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_MVK_ios_surface 1 |
||||||
|
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2 |
||||||
|
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkIOSSurfaceCreateFlagsMVK; |
||||||
|
|
||||||
|
typedef struct VkIOSSurfaceCreateInfoMVK { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkIOSSurfaceCreateFlagsMVK flags; |
||||||
|
const void* pView; |
||||||
|
} VkIOSSurfaceCreateInfoMVK; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK( |
||||||
|
VkInstance instance, |
||||||
|
const VkIOSSurfaceCreateInfoMVK* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,58 @@ |
|||||||
|
#ifndef VULKAN_MACOS_H_ |
||||||
|
#define VULKAN_MACOS_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_MVK_macos_surface 1 |
||||||
|
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2 |
||||||
|
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; |
||||||
|
|
||||||
|
typedef struct VkMacOSSurfaceCreateInfoMVK { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkMacOSSurfaceCreateFlagsMVK flags; |
||||||
|
const void* pView; |
||||||
|
} VkMacOSSurfaceCreateInfoMVK; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK( |
||||||
|
VkInstance instance, |
||||||
|
const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,65 @@ |
|||||||
|
#ifndef VULKAN_MIR_H_ |
||||||
|
#define VULKAN_MIR_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_mir_surface 1 |
||||||
|
#define VK_KHR_MIR_SURFACE_SPEC_VERSION 4 |
||||||
|
#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkMirSurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkMirSurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkMirSurfaceCreateFlagsKHR flags; |
||||||
|
MirConnection* connection; |
||||||
|
MirSurface* mirSurface; |
||||||
|
} VkMirSurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, const VkMirSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkMirSurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
uint32_t queueFamilyIndex, |
||||||
|
MirConnection* connection); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,58 @@ |
|||||||
|
#ifndef VULKAN_VI_H_ |
||||||
|
#define VULKAN_VI_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_NN_vi_surface 1 |
||||||
|
#define VK_NN_VI_SURFACE_SPEC_VERSION 1 |
||||||
|
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkViSurfaceCreateFlagsNN; |
||||||
|
|
||||||
|
typedef struct VkViSurfaceCreateInfoNN { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkViSurfaceCreateFlagsNN flags; |
||||||
|
void* window; |
||||||
|
} VkViSurfaceCreateInfoNN; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN( |
||||||
|
VkInstance instance, |
||||||
|
const VkViSurfaceCreateInfoNN* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,65 @@ |
|||||||
|
#ifndef VULKAN_WAYLAND_H_ |
||||||
|
#define VULKAN_WAYLAND_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_wayland_surface 1 |
||||||
|
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 |
||||||
|
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkWaylandSurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkWaylandSurfaceCreateFlagsKHR flags; |
||||||
|
struct wl_display* display; |
||||||
|
struct wl_surface* surface; |
||||||
|
} VkWaylandSurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
uint32_t queueFamilyIndex, |
||||||
|
struct wl_display* display); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,276 @@ |
|||||||
|
#ifndef VULKAN_WIN32_H_ |
||||||
|
#define VULKAN_WIN32_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_win32_surface 1 |
||||||
|
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6 |
||||||
|
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkWin32SurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkWin32SurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkWin32SurfaceCreateFlagsKHR flags; |
||||||
|
HINSTANCE hinstance; |
||||||
|
HWND hwnd; |
||||||
|
} VkWin32SurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkWin32SurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
uint32_t queueFamilyIndex); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_KHR_external_memory_win32 1 |
||||||
|
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 |
||||||
|
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32" |
||||||
|
|
||||||
|
typedef struct VkImportMemoryWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkExternalMemoryHandleTypeFlagBits handleType; |
||||||
|
HANDLE handle; |
||||||
|
LPCWSTR name; |
||||||
|
} VkImportMemoryWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkExportMemoryWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
const SECURITY_ATTRIBUTES* pAttributes; |
||||||
|
DWORD dwAccess; |
||||||
|
LPCWSTR name; |
||||||
|
} VkExportMemoryWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkMemoryWin32HandlePropertiesKHR { |
||||||
|
VkStructureType sType; |
||||||
|
void* pNext; |
||||||
|
uint32_t memoryTypeBits; |
||||||
|
} VkMemoryWin32HandlePropertiesKHR; |
||||||
|
|
||||||
|
typedef struct VkMemoryGetWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkDeviceMemory memory; |
||||||
|
VkExternalMemoryHandleTypeFlagBits handleType; |
||||||
|
} VkMemoryGetWin32HandleInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); |
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR( |
||||||
|
VkDevice device, |
||||||
|
const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, |
||||||
|
HANDLE* pHandle); |
||||||
|
|
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( |
||||||
|
VkDevice device, |
||||||
|
VkExternalMemoryHandleTypeFlagBits handleType, |
||||||
|
HANDLE handle, |
||||||
|
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_KHR_win32_keyed_mutex 1 |
||||||
|
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1 |
||||||
|
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex" |
||||||
|
|
||||||
|
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
uint32_t acquireCount; |
||||||
|
const VkDeviceMemory* pAcquireSyncs; |
||||||
|
const uint64_t* pAcquireKeys; |
||||||
|
const uint32_t* pAcquireTimeouts; |
||||||
|
uint32_t releaseCount; |
||||||
|
const VkDeviceMemory* pReleaseSyncs; |
||||||
|
const uint64_t* pReleaseKeys; |
||||||
|
} VkWin32KeyedMutexAcquireReleaseInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_external_semaphore_win32 1 |
||||||
|
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1 |
||||||
|
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32" |
||||||
|
|
||||||
|
typedef struct VkImportSemaphoreWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkSemaphore semaphore; |
||||||
|
VkSemaphoreImportFlags flags; |
||||||
|
VkExternalSemaphoreHandleTypeFlagBits handleType; |
||||||
|
HANDLE handle; |
||||||
|
LPCWSTR name; |
||||||
|
} VkImportSemaphoreWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkExportSemaphoreWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
const SECURITY_ATTRIBUTES* pAttributes; |
||||||
|
DWORD dwAccess; |
||||||
|
LPCWSTR name; |
||||||
|
} VkExportSemaphoreWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkD3D12FenceSubmitInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
uint32_t waitSemaphoreValuesCount; |
||||||
|
const uint64_t* pWaitSemaphoreValues; |
||||||
|
uint32_t signalSemaphoreValuesCount; |
||||||
|
const uint64_t* pSignalSemaphoreValues; |
||||||
|
} VkD3D12FenceSubmitInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkSemaphoreGetWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkSemaphore semaphore; |
||||||
|
VkExternalSemaphoreHandleTypeFlagBits handleType; |
||||||
|
} VkSemaphoreGetWin32HandleInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); |
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR( |
||||||
|
VkDevice device, |
||||||
|
const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); |
||||||
|
|
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( |
||||||
|
VkDevice device, |
||||||
|
const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, |
||||||
|
HANDLE* pHandle); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_KHR_external_fence_win32 1 |
||||||
|
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1 |
||||||
|
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32" |
||||||
|
|
||||||
|
typedef struct VkImportFenceWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkFence fence; |
||||||
|
VkFenceImportFlags flags; |
||||||
|
VkExternalFenceHandleTypeFlagBits handleType; |
||||||
|
HANDLE handle; |
||||||
|
LPCWSTR name; |
||||||
|
} VkImportFenceWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkExportFenceWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
const SECURITY_ATTRIBUTES* pAttributes; |
||||||
|
DWORD dwAccess; |
||||||
|
LPCWSTR name; |
||||||
|
} VkExportFenceWin32HandleInfoKHR; |
||||||
|
|
||||||
|
typedef struct VkFenceGetWin32HandleInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkFence fence; |
||||||
|
VkExternalFenceHandleTypeFlagBits handleType; |
||||||
|
} VkFenceGetWin32HandleInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); |
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR( |
||||||
|
VkDevice device, |
||||||
|
const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); |
||||||
|
|
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( |
||||||
|
VkDevice device, |
||||||
|
const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, |
||||||
|
HANDLE* pHandle); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_NV_external_memory_win32 1 |
||||||
|
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 |
||||||
|
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" |
||||||
|
|
||||||
|
typedef struct VkImportMemoryWin32HandleInfoNV { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkExternalMemoryHandleTypeFlagsNV handleType; |
||||||
|
HANDLE handle; |
||||||
|
} VkImportMemoryWin32HandleInfoNV; |
||||||
|
|
||||||
|
typedef struct VkExportMemoryWin32HandleInfoNV { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
const SECURITY_ATTRIBUTES* pAttributes; |
||||||
|
DWORD dwAccess; |
||||||
|
} VkExportMemoryWin32HandleInfoNV; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( |
||||||
|
VkDevice device, |
||||||
|
VkDeviceMemory memory, |
||||||
|
VkExternalMemoryHandleTypeFlagsNV handleType, |
||||||
|
HANDLE* pHandle); |
||||||
|
#endif |
||||||
|
|
||||||
|
#define VK_NV_win32_keyed_mutex 1 |
||||||
|
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1 |
||||||
|
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" |
||||||
|
|
||||||
|
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
uint32_t acquireCount; |
||||||
|
const VkDeviceMemory* pAcquireSyncs; |
||||||
|
const uint64_t* pAcquireKeys; |
||||||
|
const uint32_t* pAcquireTimeoutMilliseconds; |
||||||
|
uint32_t releaseCount; |
||||||
|
const VkDeviceMemory* pReleaseSyncs; |
||||||
|
const uint64_t* pReleaseKeys; |
||||||
|
} VkWin32KeyedMutexAcquireReleaseInfoNV; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,66 @@ |
|||||||
|
#ifndef VULKAN_XCB_H_ |
||||||
|
#define VULKAN_XCB_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_xcb_surface 1 |
||||||
|
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 |
||||||
|
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkXcbSurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkXcbSurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkXcbSurfaceCreateFlagsKHR flags; |
||||||
|
xcb_connection_t* connection; |
||||||
|
xcb_window_t window; |
||||||
|
} VkXcbSurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkXcbSurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
uint32_t queueFamilyIndex, |
||||||
|
xcb_connection_t* connection, |
||||||
|
xcb_visualid_t visual_id); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,66 @@ |
|||||||
|
#ifndef VULKAN_XLIB_H_ |
||||||
|
#define VULKAN_XLIB_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_KHR_xlib_surface 1 |
||||||
|
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 |
||||||
|
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" |
||||||
|
|
||||||
|
typedef VkFlags VkXlibSurfaceCreateFlagsKHR; |
||||||
|
|
||||||
|
typedef struct VkXlibSurfaceCreateInfoKHR { |
||||||
|
VkStructureType sType; |
||||||
|
const void* pNext; |
||||||
|
VkXlibSurfaceCreateFlagsKHR flags; |
||||||
|
Display* dpy; |
||||||
|
Window window; |
||||||
|
} VkXlibSurfaceCreateInfoKHR; |
||||||
|
|
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); |
||||||
|
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( |
||||||
|
VkInstance instance, |
||||||
|
const VkXlibSurfaceCreateInfoKHR* pCreateInfo, |
||||||
|
const VkAllocationCallbacks* pAllocator, |
||||||
|
VkSurfaceKHR* pSurface); |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
uint32_t queueFamilyIndex, |
||||||
|
Display* dpy, |
||||||
|
VisualID visualID); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,54 @@ |
|||||||
|
#ifndef VULKAN_XLIB_XRANDR_H_ |
||||||
|
#define VULKAN_XLIB_XRANDR_H_ 1 |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2015-2018 The Khronos Group Inc. |
||||||
|
** |
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
** you may not use this file except in compliance with the License. |
||||||
|
** You may obtain a copy of the License at |
||||||
|
** |
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
** |
||||||
|
** Unless required by applicable law or agreed to in writing, software |
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
** See the License for the specific language governing permissions and |
||||||
|
** limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
/*
|
||||||
|
** This header is generated from the Khronos Vulkan XML API Registry. |
||||||
|
** |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
#define VK_EXT_acquire_xlib_display 1 |
||||||
|
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 |
||||||
|
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" |
||||||
|
|
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); |
||||||
|
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay); |
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES |
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
Display* dpy, |
||||||
|
VkDisplayKHR display); |
||||||
|
|
||||||
|
VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT( |
||||||
|
VkPhysicalDevice physicalDevice, |
||||||
|
Display* dpy, |
||||||
|
RROutput rrOutput, |
||||||
|
VkDisplayKHR* pDisplay); |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,27 @@ |
|||||||
|
# Find Vulkan |
||||||
|
# |
||||||
|
# Vulkan_INCLUDE_DIRS |
||||||
|
# Vulkan_LIBRARIES |
||||||
|
# Vulkan_FOUND |
||||||
|
if (WIN32) |
||||||
|
find_path(Vulkan_INCLUDE_DIRS NAMES vulkan/vulkan.h HINTS |
||||||
|
"$ENV{VULKAN_SDK}/Include" |
||||||
|
"$ENV{VK_SDK_PATH}/Include") |
||||||
|
if (CMAKE_CL_64) |
||||||
|
find_library(Vulkan_LIBRARIES NAMES vulkan-1 HINTS |
||||||
|
"$ENV{VULKAN_SDK}/Bin" |
||||||
|
"$ENV{VK_SDK_PATH}/Bin") |
||||||
|
else() |
||||||
|
find_library(Vulkan_LIBRARIES NAMES vulkan-1 HINTS |
||||||
|
"$ENV{VULKAN_SDK}/Bin32" |
||||||
|
"$ENV{VK_SDK_PATH}/Bin32") |
||||||
|
endif() |
||||||
|
else() |
||||||
|
find_path(Vulkan_INCLUDE_DIRS NAMES vulkan/vulkan.h HINTS |
||||||
|
"$ENV{VULKAN_SDK}/include") |
||||||
|
find_library(Vulkan_LIBRARIES NAMES vulkan HINTS |
||||||
|
"$ENV{VULKAN_SDK}/lib") |
||||||
|
endif() |
||||||
|
include(FindPackageHandleStandardArgs) |
||||||
|
find_package_handle_standard_args(Vulkan DEFAULT_MSG Vulkan_LIBRARIES Vulkan_INCLUDE_DIRS) |
||||||
|
mark_as_advanced(Vulkan_INCLUDE_DIRS Vulkan_LIBRARIES) |
@ -0,0 +1,20 @@ |
|||||||
|
set(VULKAN_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/include" CACHE PATH "Vulkan include directory") |
||||||
|
set(VULKAN_LIBRARIES "") |
||||||
|
|
||||||
|
try_compile(VALID_VULKAN |
||||||
|
"${OpenCV_BINARY_DIR}" |
||||||
|
"${OpenCV_SOURCE_DIR}/cmake/checks/vulkan.cpp" |
||||||
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${VULKAN_INCLUDE_DIRS}" |
||||||
|
OUTPUT_VARIABLE TRY_OUT |
||||||
|
) |
||||||
|
if(NOT ${VALID_VULKAN}) |
||||||
|
message(WARNING "Can't use Vulkan") |
||||||
|
return() |
||||||
|
endif() |
||||||
|
|
||||||
|
set(HAVE_VULKAN 1) |
||||||
|
|
||||||
|
if(HAVE_VULKAN) |
||||||
|
add_definitions(-DVK_NO_PROTOTYPES) |
||||||
|
include_directories(${VULKAN_INCLUDE_DIRS}) |
||||||
|
endif() |
@ -0,0 +1,6 @@ |
|||||||
|
#include <vulkan/vulkan.h> |
||||||
|
|
||||||
|
int main(int /*argc*/, char** /*argv*/) |
||||||
|
{ |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,162 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <opencv2/dnn/shape_utils.hpp> |
||||||
|
#include "op_vkcom.hpp" |
||||||
|
|
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
namespace dnn |
||||||
|
{ |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
void copyToTensor(vkcom::Tensor &dst, const Mat &src) |
||||||
|
{ |
||||||
|
CV_Assert(src.isContinuous() && src.type() == CV_32F); |
||||||
|
|
||||||
|
std::vector<int> mat_shape = shape(src); |
||||||
|
dst.reshape((const char*)src.data, mat_shape); |
||||||
|
} |
||||||
|
|
||||||
|
void copyToMat(Mat &dst, vkcom::Tensor &src) |
||||||
|
{ |
||||||
|
CV_Assert(dst.type() == CV_32F); |
||||||
|
|
||||||
|
std::vector<int> shape = src.getShape(); |
||||||
|
void *data = src.map(); |
||||||
|
Mat tmp(shape, CV_32F, data); |
||||||
|
tmp.copyTo(dst); |
||||||
|
src.unMap(); |
||||||
|
} |
||||||
|
|
||||||
|
vkcom::Tensor VkComTensor(const Ptr<BackendWrapper>& ptr) |
||||||
|
{ |
||||||
|
CV_Assert(!ptr.empty()); |
||||||
|
return ptr.dynamicCast<VkComBackendWrapper>()->getTensor(); |
||||||
|
} |
||||||
|
|
||||||
|
void setDirty(std::vector<Ptr<BackendWrapper> >& ptrs) |
||||||
|
{ |
||||||
|
for (const Ptr<BackendWrapper>& ptr : ptrs) |
||||||
|
{ |
||||||
|
ptr.dynamicCast<VkComBackendWrapper>()->setDeviceDirty(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
std::vector<vkcom::Tensor> VkComTensors(const std::vector<Ptr<BackendWrapper> >& ptrs) |
||||||
|
{ |
||||||
|
std::vector<vkcom::Tensor> vec; |
||||||
|
vec.reserve(ptrs.size()); |
||||||
|
for (const Ptr<BackendWrapper>& ptr : ptrs) |
||||||
|
{ |
||||||
|
vec.push_back(VkComTensor(ptr)); |
||||||
|
} |
||||||
|
return vec; |
||||||
|
} |
||||||
|
|
||||||
|
VkComBackendNode::VkComBackendNode(const std::vector<Ptr<BackendWrapper> >& inputsWrapper, |
||||||
|
const std::shared_ptr<vkcom::OpBase>& op, |
||||||
|
const std::vector<Ptr<BackendWrapper> >& blobsWrapper) |
||||||
|
: BackendNode(DNN_BACKEND_VKCOM) |
||||||
|
{ |
||||||
|
operation = op; |
||||||
|
|
||||||
|
inputsWrapper_ = inputsWrapper; |
||||||
|
ins = VkComTensors(inputsWrapper_); |
||||||
|
|
||||||
|
if (!blobsWrapper.empty()) |
||||||
|
{ |
||||||
|
blobs = VkComTensors(blobsWrapper); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool VkComBackendNode::forward(std::vector<vkcom::Tensor>& outs) |
||||||
|
{ |
||||||
|
for (int i = 0, n = inputsWrapper_.size(); i < n; ++i) |
||||||
|
{ |
||||||
|
inputsWrapper_[i].dynamicCast<VkComBackendWrapper>()->copyToDevice(); |
||||||
|
} |
||||||
|
|
||||||
|
return operation->forward(ins, blobs, outs); |
||||||
|
} |
||||||
|
|
||||||
|
VkComBackendWrapper::VkComBackendWrapper(Mat& m) : BackendWrapper(DNN_BACKEND_VKCOM, DNN_TARGET_VULKAN) |
||||||
|
{ |
||||||
|
copyToTensor(tensor, m); |
||||||
|
host = &m; |
||||||
|
hostDirty = false; |
||||||
|
deviceDirty = false; |
||||||
|
} |
||||||
|
|
||||||
|
VkComBackendWrapper::VkComBackendWrapper(const Ptr<BackendWrapper>& baseBuffer, Mat& m) |
||||||
|
: BackendWrapper(DNN_BACKEND_VKCOM, DNN_TARGET_VULKAN) |
||||||
|
{ |
||||||
|
Ptr<VkComBackendWrapper> base = baseBuffer.dynamicCast<VkComBackendWrapper>(); |
||||||
|
CV_Assert(!base.empty()); |
||||||
|
|
||||||
|
host = &m; |
||||||
|
tensor = base->tensor; |
||||||
|
CV_Assert(tensor.count() >= m.total()); |
||||||
|
tensor.reshape(0, shape(m)); |
||||||
|
hostDirty = false; |
||||||
|
deviceDirty = false; |
||||||
|
} |
||||||
|
|
||||||
|
void VkComBackendWrapper::copyToHost() |
||||||
|
{ |
||||||
|
if (deviceDirty) |
||||||
|
copyToMat(*host, tensor); |
||||||
|
} |
||||||
|
|
||||||
|
void VkComBackendWrapper::setHostDirty() |
||||||
|
{ |
||||||
|
hostDirty = true; |
||||||
|
}; |
||||||
|
|
||||||
|
void VkComBackendWrapper::setDeviceDirty() |
||||||
|
{ |
||||||
|
deviceDirty = true; |
||||||
|
}; |
||||||
|
|
||||||
|
void VkComBackendWrapper::copyToDevice() |
||||||
|
{ |
||||||
|
if (hostDirty) |
||||||
|
{ |
||||||
|
copyToTensor(tensor, *host); |
||||||
|
hostDirty = false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
vkcom::Tensor VkComBackendWrapper::getTensor() |
||||||
|
{ |
||||||
|
return tensor; |
||||||
|
} |
||||||
|
#endif |
||||||
|
void forwardVkCom(std::vector<Ptr<BackendWrapper> > &outputs, |
||||||
|
const Ptr<BackendNode>& node) |
||||||
|
{ |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
CV_Assert(!node.empty()); |
||||||
|
|
||||||
|
Ptr<VkComBackendNode> node_ = node.dynamicCast<VkComBackendNode>(); |
||||||
|
std::vector<vkcom::Tensor> outs = VkComTensors(outputs); |
||||||
|
node_->forward(outs); |
||||||
|
setDirty(outputs); |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
bool haveVulkan() |
||||||
|
{ |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
return vkcom::isAvailable(); |
||||||
|
#else |
||||||
|
return false; |
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
} |
||||||
|
|
||||||
|
} // namespace dnn
|
||||||
|
} // namespace cv
|
@ -0,0 +1,74 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_OP_VKCOM_HPP |
||||||
|
#define OPENCV_DNN_OP_VKCOM_HPP |
||||||
|
|
||||||
|
#include <opencv2/dnn/shape_utils.hpp> |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include "vkcom/include/vkcom.hpp" |
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
namespace cv |
||||||
|
{ |
||||||
|
namespace dnn |
||||||
|
{ |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
std::vector<vkcom::Tensor> VkComTensors(const std::vector<Ptr<BackendWrapper> >& ptrs); |
||||||
|
|
||||||
|
vkcom::Tensor VkComTensor(const Ptr<BackendWrapper>& ptr); |
||||||
|
|
||||||
|
// Data copied from/to Mat to/from Tensor. Change the shape of dst if
|
||||||
|
// needed to make it the same shape as src
|
||||||
|
void copyToTensor(vkcom::Tensor &dst, const Mat &src); |
||||||
|
|
||||||
|
void copyToMat(Mat &dst, const vkcom::Tensor &src); |
||||||
|
|
||||||
|
class VkComBackendNode : public BackendNode |
||||||
|
{ |
||||||
|
public: |
||||||
|
VkComBackendNode(const std::vector<Ptr<BackendWrapper> >& inputsWrapper, |
||||||
|
const std::shared_ptr<vkcom::OpBase> &op, |
||||||
|
const std::vector<Ptr<BackendWrapper> >& blobsWrapper = |
||||||
|
std::vector<Ptr<BackendWrapper> >()); |
||||||
|
|
||||||
|
bool forward(std::vector<vkcom::Tensor>& outs); |
||||||
|
|
||||||
|
private: |
||||||
|
std::vector<vkcom::Tensor> ins; |
||||||
|
std::vector<vkcom::Tensor> blobs; |
||||||
|
std::vector<Ptr<BackendWrapper> > inputsWrapper_; |
||||||
|
std::shared_ptr<vkcom::OpBase> operation; |
||||||
|
}; |
||||||
|
|
||||||
|
class VkComBackendWrapper : public BackendWrapper |
||||||
|
{ |
||||||
|
public: |
||||||
|
VkComBackendWrapper(Mat& m); |
||||||
|
VkComBackendWrapper(const Ptr<BackendWrapper>& baseBuffer, Mat& m); |
||||||
|
|
||||||
|
virtual void copyToHost() CV_OVERRIDE; |
||||||
|
virtual void setHostDirty() CV_OVERRIDE; |
||||||
|
void setDeviceDirty(); |
||||||
|
void copyToDevice(); |
||||||
|
vkcom::Tensor getTensor(); |
||||||
|
|
||||||
|
private: |
||||||
|
vkcom::Tensor tensor; |
||||||
|
Mat* host; |
||||||
|
bool hostDirty; |
||||||
|
bool deviceDirty; |
||||||
|
}; |
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
void forwardVkCom(std::vector<Ptr<BackendWrapper> > &outputs, const Ptr<BackendNode>& node); |
||||||
|
|
||||||
|
bool haveVulkan(); |
||||||
|
} // namespace dnn
|
||||||
|
} // namespace cv
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_OP_VKCOM_HPP
|
@ -0,0 +1,41 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_BUFFER_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_BUFFER_HPP |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
class Buffer |
||||||
|
{ |
||||||
|
public: |
||||||
|
Buffer(VkDevice& device) |
||||||
|
: device_(device), buffer_(VK_NULL_HANDLE), memory_(VK_NULL_HANDLE){}; |
||||||
|
Buffer(VkDevice& device, size_t size_in_bytes, const char* data); |
||||||
|
~Buffer(); |
||||||
|
VkDeviceMemory getVkMemory() { return memory_; } |
||||||
|
VkBuffer getVkBuffer() { return buffer_; } |
||||||
|
|
||||||
|
private: |
||||||
|
Buffer(); |
||||||
|
bool init(size_t size_in_bytes, const char* data); |
||||||
|
VkDevice device_; |
||||||
|
VkBuffer buffer_; |
||||||
|
VkDeviceMemory memory_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_BUFFER_HPP
|
@ -0,0 +1,58 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_BASE_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_BASE_HPP |
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "vkcom.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
// Forward declare
|
||||||
|
class Context; |
||||||
|
|
||||||
|
class OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpBase(); |
||||||
|
virtual ~OpBase(); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) = 0; |
||||||
|
protected: |
||||||
|
void initVulkanThing(int buffer_num); |
||||||
|
void createDescriptorSetLayout(int buffer_num); |
||||||
|
void createDescriptorSet(int buffer_num); |
||||||
|
void createShaderModule(const uint32_t* spv, size_t sz, const std::string& source = std::string()); |
||||||
|
void createPipeline(size_t push_constants_size = 0); |
||||||
|
void createCommandBuffer(); |
||||||
|
void recordCommandBuffer(void* push_constants = NULL, size_t push_constants_size = 0); |
||||||
|
void runCommandBuffer(); |
||||||
|
|
||||||
|
const Context* ctx_; |
||||||
|
VkPipeline pipeline_; |
||||||
|
VkCommandBuffer cmd_buffer_; |
||||||
|
VkDescriptorPool descriptor_pool_; |
||||||
|
VkDescriptorSet descriptor_set_; |
||||||
|
VkDevice device_; |
||||||
|
VkDescriptorSetLayout descriptor_set_layout_; |
||||||
|
VkPipelineLayout pipeline_layout_; |
||||||
|
VkShaderModule module_; |
||||||
|
int group_x_; |
||||||
|
int group_y_; |
||||||
|
int group_z_; |
||||||
|
std::string type_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_BASE_HPP
|
@ -0,0 +1,55 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_CONCAT_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_CONCAT_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
struct ConcatShaderConfig |
||||||
|
{ |
||||||
|
int local_size_x; |
||||||
|
int local_size_y; |
||||||
|
int local_size_z; |
||||||
|
int block_height; |
||||||
|
int block_width; |
||||||
|
int block_depth; |
||||||
|
}; |
||||||
|
|
||||||
|
class OpConcat: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpConcat(const int axis); |
||||||
|
bool forward(std::vector<Tensor>& ins, Tensor& out); |
||||||
|
void reshapeOutTensor(std::vector<Tensor *>& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
|
||||||
|
private: |
||||||
|
bool init(const int axis); |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
ConcatShaderConfig config_; |
||||||
|
int axis_; |
||||||
|
int out_concat_axis_; |
||||||
|
int accumulated_concat_axis_; |
||||||
|
int concat_size_; |
||||||
|
int total_concat_size_; |
||||||
|
int thread_num_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_CONCAT_HPP
|
@ -0,0 +1,85 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_CONV_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_CONV_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
enum ConvShaderType |
||||||
|
{ |
||||||
|
kConvShaderTypeBasic = 0, |
||||||
|
kConvShaderTypeIDLF = 1, |
||||||
|
kConvShaderTypeNum |
||||||
|
}; |
||||||
|
|
||||||
|
struct ConvShaderConfig |
||||||
|
{ |
||||||
|
int local_size_x; |
||||||
|
int local_size_y; |
||||||
|
int local_size_z; |
||||||
|
int block_height; |
||||||
|
int block_width; |
||||||
|
int block_depth; |
||||||
|
ConvShaderType shader_type; |
||||||
|
}; |
||||||
|
|
||||||
|
class OpConv : public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpConv(const int out_channel, const bool has_bias, |
||||||
|
const int* filter_size, const int* pad, |
||||||
|
const int* stride, const int* dilation, |
||||||
|
const int activation, const int group, |
||||||
|
const int padding_mode); |
||||||
|
void reshapeOutTensor(Tensor& in, Tensor& out); |
||||||
|
bool forward(Tensor& in, Tensor& filter_weights, Tensor& bias, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
private: |
||||||
|
bool init(const int out_channel, const bool has_bias, |
||||||
|
const int* filter_size, const int* pad, |
||||||
|
const int* stride, const int* dilation, |
||||||
|
const int activation, const int group, |
||||||
|
const int padding_mode); |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
int batch_; |
||||||
|
int in_height_; |
||||||
|
int in_width_; |
||||||
|
int in_channel_; |
||||||
|
int out_height_; |
||||||
|
int out_width_; |
||||||
|
int out_channel_; |
||||||
|
int filter_height_; |
||||||
|
int filter_width_; |
||||||
|
int stride_height_; |
||||||
|
int stride_width_; |
||||||
|
int padding_top_; |
||||||
|
int padding_left_; |
||||||
|
int dilation_height_; |
||||||
|
int dilation_width_; |
||||||
|
int activation_; |
||||||
|
PaddingMode padding_mode_; |
||||||
|
int group_; |
||||||
|
int has_bias_; |
||||||
|
Tensor swizzled_weights; |
||||||
|
ConvShaderConfig config_; |
||||||
|
bool dwconv_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_CONV_HPP
|
@ -0,0 +1,70 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_LRN_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_LRN_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
enum LRNShaderType |
||||||
|
{ |
||||||
|
kLRNShaderTypeBasic = 0, |
||||||
|
kLRNShaderTypeNum |
||||||
|
}; |
||||||
|
|
||||||
|
struct LRNShaderConfig |
||||||
|
{ |
||||||
|
int local_size_x; |
||||||
|
int local_size_y; |
||||||
|
int local_size_z; |
||||||
|
int block_height; |
||||||
|
int block_width; |
||||||
|
int block_depth; |
||||||
|
LRNShaderType shader_type; |
||||||
|
}; |
||||||
|
|
||||||
|
class OpLRN : public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpLRN(const int radius, const float bias, |
||||||
|
const float alpha, const float beta, |
||||||
|
const bool norm_by_size); |
||||||
|
void reshapeOutTensor(Tensor& in, Tensor& out); |
||||||
|
bool forward(Tensor& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
|
||||||
|
private: |
||||||
|
bool init(const int radius, const float bias, |
||||||
|
const float alpha, const float beta, |
||||||
|
const bool norm_by_size); |
||||||
|
bool computeGroupCount(); |
||||||
|
int batch_; |
||||||
|
int height_; |
||||||
|
int width_; |
||||||
|
int channels_; |
||||||
|
int radius_; |
||||||
|
float bias_; |
||||||
|
float alpha_; |
||||||
|
float beta_; |
||||||
|
int filter_len_; |
||||||
|
int thread_num_; |
||||||
|
bool norm_by_size_; |
||||||
|
LRNShaderConfig config_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_LRN_HPP
|
@ -0,0 +1,50 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_PERMUTE_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_PERMUTE_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
class OpPermute: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpPermute(std::vector<size_t>& order); |
||||||
|
bool forward(std::vector<Tensor>& ins, std::vector<Tensor>& outs); |
||||||
|
void reshapeOutTensor(std::vector<Tensor *>& in, std::vector<Tensor>& outs); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
|
||||||
|
private: |
||||||
|
void prepareStrides(const Shape &shape_before, const Shape &shape_after); |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
std::vector<int> order_; |
||||||
|
bool need_permute_; |
||||||
|
int global_size_; |
||||||
|
int nthreads_; |
||||||
|
int dims_; |
||||||
|
Tensor tensor_order_; |
||||||
|
Tensor tensor_old_stride_; |
||||||
|
Tensor tensor_new_stride_; |
||||||
|
std::vector<int> old_stride_; |
||||||
|
std::vector<int> new_stride_; |
||||||
|
Shape in_shape_; |
||||||
|
Shape out_shape_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_PERMUTE_HPP
|
@ -0,0 +1,70 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_POOL_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_POOL_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
enum PoolType { kPoolTypeAvg, kPoolTypeMax, kPoolTypeNum }; |
||||||
|
|
||||||
|
struct PoolShaderConfig |
||||||
|
{ |
||||||
|
int local_size_x; |
||||||
|
int local_size_y; |
||||||
|
int local_size_z; |
||||||
|
int block_height; |
||||||
|
int block_width; |
||||||
|
int block_depth; |
||||||
|
}; |
||||||
|
|
||||||
|
class OpPool: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpPool(const int* filter_size, const int* pad, const int* stride, |
||||||
|
const int padding_mode, const PoolType pool_type, |
||||||
|
const bool avg_pool_padded_area); |
||||||
|
bool forward(Tensor& in, Tensor& out, Tensor& mask); |
||||||
|
void reshapeOutTensor(Tensor& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
private: |
||||||
|
bool init(const int* filter_size, const int* pad, const int* stride, |
||||||
|
const int padding_mode, const PoolType type, const bool avg_pool_padded_area); |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
int batch_; |
||||||
|
int channels_; |
||||||
|
int in_height_; |
||||||
|
int in_width_; |
||||||
|
int out_height_; |
||||||
|
int out_width_; |
||||||
|
int filter_height_; |
||||||
|
int filter_width_; |
||||||
|
int stride_height_; |
||||||
|
int stride_width_; |
||||||
|
int padding_left_; |
||||||
|
int padding_top_; |
||||||
|
PoolType pool_type_; |
||||||
|
int avg_pool_padded_area_; |
||||||
|
int need_mask_; |
||||||
|
PaddingMode padding_mode_; |
||||||
|
int activation_; |
||||||
|
PoolShaderConfig config_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_POOL_HPP
|
@ -0,0 +1,66 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_PRIOR_BOX_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_PRIOR_BOX_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
class OpPriorBox: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpPriorBox(float step_x, |
||||||
|
float step_y, |
||||||
|
bool clip, |
||||||
|
int num_priors, |
||||||
|
std::vector<float>& variance, |
||||||
|
std::vector<float>& offsets_x, |
||||||
|
std::vector<float>& offsets_y, |
||||||
|
std::vector<float>& box_widths, |
||||||
|
std::vector<float>& box_heights); |
||||||
|
bool forward(std::vector<Tensor>& in, Tensor& out); |
||||||
|
void reshapeOutTensor(std::vector<Tensor *>& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
private: |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
int global_size_; |
||||||
|
int nthreads_; |
||||||
|
float step_x_; |
||||||
|
float step_y_; |
||||||
|
bool clip_; |
||||||
|
int num_priors_; |
||||||
|
std::vector<float> variance_; |
||||||
|
std::vector<float> offsets_x_; |
||||||
|
std::vector<float> offsets_y_; |
||||||
|
std::vector<float> box_widths_; |
||||||
|
std::vector<float> box_heights_; |
||||||
|
int img_h_; |
||||||
|
int img_w_; |
||||||
|
int in_h_; |
||||||
|
int in_w_; |
||||||
|
int out_channel_; |
||||||
|
int out_channel_size_; |
||||||
|
Tensor tensor_offsets_x_; |
||||||
|
Tensor tensor_offsets_y_; |
||||||
|
Tensor tensor_widths_; |
||||||
|
Tensor tensor_heights_; |
||||||
|
Tensor tensor_variance_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_PRIOR_BOX_HPP
|
@ -0,0 +1,37 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_RELU_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_RELU_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
class OpReLU: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpReLU(const float slope = 1.f); |
||||||
|
bool forward(Tensor& in, Tensor& out); |
||||||
|
void reshapeOutTensor(Tensor& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
private: |
||||||
|
bool computeGroupCount(); |
||||||
|
int total_; |
||||||
|
float slope_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_RELU_HPP
|
@ -0,0 +1,56 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP |
||||||
|
|
||||||
|
#include "vkcom.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
struct SoftmaxShaderConfig |
||||||
|
{ |
||||||
|
int local_size_x; |
||||||
|
int local_size_y; |
||||||
|
int local_size_z; |
||||||
|
int block_height; |
||||||
|
int block_width; |
||||||
|
int block_depth; |
||||||
|
}; |
||||||
|
|
||||||
|
class OpSoftmax: public OpBase |
||||||
|
{ |
||||||
|
public: |
||||||
|
OpSoftmax(const int axis, const bool log_softmax = false); |
||||||
|
~OpSoftmax(); |
||||||
|
void reshapeOutTensor(Tensor& in, Tensor& out); |
||||||
|
bool forward(Tensor& in, Tensor& out); |
||||||
|
virtual bool forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) CV_OVERRIDE; |
||||||
|
private: |
||||||
|
bool init(const int axis, const bool log_softmax); |
||||||
|
bool computeGroupCount(); |
||||||
|
|
||||||
|
int axis_; |
||||||
|
int channels_; |
||||||
|
int channel_size_; |
||||||
|
int outer_size_; |
||||||
|
bool log_softmax_; |
||||||
|
SoftmaxShaderConfig config_; |
||||||
|
Tensor* max_tensor_; |
||||||
|
Tensor* sum_tensor_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_OP_SOFTMAX_HPP
|
@ -0,0 +1,59 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_TENSOR_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_TENSOR_HPP |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
#endif |
||||||
|
#include <memory> |
||||||
|
#include "vkcom.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
class Buffer; |
||||||
|
|
||||||
|
class Tensor |
||||||
|
{ |
||||||
|
public: |
||||||
|
Tensor(Format fmt = kFormatFp32); |
||||||
|
Tensor(const char* data, std::vector<int>& shape, Format fmt = kFormatFp32); |
||||||
|
void* map(); |
||||||
|
void unMap(); |
||||||
|
Shape getShape() const; |
||||||
|
int dimSize(const int dim) const; |
||||||
|
int dimNum() const; |
||||||
|
int count(const int start_axis = 0, const int end_axis = -1) const; |
||||||
|
|
||||||
|
// Change shape and format to as passed in.
|
||||||
|
// Copy data if data != NULL
|
||||||
|
// Allocate new internal buffer if new size > old size or alloc flag is true
|
||||||
|
Tensor reshape(const char* data, const std::vector<int>& shape, bool alloc = false, Format fmt = kFormatInvalid); |
||||||
|
|
||||||
|
void setTo(float val); |
||||||
|
int getFormat() const; |
||||||
|
size_t size() const { return size_in_byte_; } |
||||||
|
bool isEmpty() { return size_in_byte_ == 0 ? true : false; } |
||||||
|
void copyTo(Tensor& dst); |
||||||
|
std::shared_ptr<Buffer> getBuffer() { return buffer_; } |
||||||
|
|
||||||
|
private: |
||||||
|
VkDevice device_; |
||||||
|
std::vector<int> shape_; |
||||||
|
size_t size_in_byte_; |
||||||
|
std::shared_ptr<Buffer> buffer_; |
||||||
|
Format format_; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_TENSOR_HPP
|
@ -0,0 +1,63 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_HPP |
||||||
|
|
||||||
|
#include <vector> |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
enum Format{ |
||||||
|
kFormatInvalid = -1, |
||||||
|
kFormatFp16, |
||||||
|
kFormatFp32, |
||||||
|
kFormatFp64, |
||||||
|
kFormatInt32, |
||||||
|
kFormatNum |
||||||
|
}; |
||||||
|
|
||||||
|
enum OpType { |
||||||
|
kOpTypeConv, |
||||||
|
kOpTypePool, |
||||||
|
kOpTypeDWConv, |
||||||
|
kOpTypeLRN, |
||||||
|
kOpTypeConcat, |
||||||
|
kOpTypeSoftmax, |
||||||
|
kOpTypeReLU, |
||||||
|
kOpTypePriorBox, |
||||||
|
kOpTypePermute, |
||||||
|
kOpTypeNum |
||||||
|
}; |
||||||
|
enum PaddingMode { kPaddingModeSame, kPaddingModeValid, kPaddingModeCaffe, kPaddingModeNum }; |
||||||
|
enum FusedActivationType { kNone, kRelu, kRelu1, kRelu6, kActivationNum }; |
||||||
|
typedef std::vector<int> Shape; |
||||||
|
|
||||||
|
/* context APIs */ |
||||||
|
bool initPerThread(); |
||||||
|
void deinitPerThread(); |
||||||
|
bool isAvailable(); |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#include "tensor.hpp" |
||||||
|
#include "buffer.hpp" |
||||||
|
#include "op_base.hpp" |
||||||
|
#include "op_concat.hpp" |
||||||
|
#include "op_conv.hpp" |
||||||
|
#include "op_lrn.hpp" |
||||||
|
#include "op_softmax.hpp" |
||||||
|
#include "op_relu.hpp" |
||||||
|
#include "op_pool.hpp" |
||||||
|
#include "op_prior_box.hpp" |
||||||
|
#include "op_permute.hpp" |
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_HPP
|
@ -0,0 +1,69 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int channels; |
||||||
|
int in_h; |
||||||
|
int in_w; |
||||||
|
int out_h; |
||||||
|
int out_w; |
||||||
|
int padding_h; |
||||||
|
int padding_w; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int total; |
||||||
|
int padded_area; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(binding = 1) writeonly buffer Output{ |
||||||
|
float out_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
void main() |
||||||
|
{ |
||||||
|
int global_size = int(gl_WorkGroupSize.x * gl_NumWorkGroups.x); |
||||||
|
int gid = int(gl_GlobalInvocationID.x); |
||||||
|
for (int index = gid; index < p.total; index += global_size) |
||||||
|
{ |
||||||
|
const int pw = index % p.out_w; |
||||||
|
const int ph = (index / p.out_w) % p.out_h; |
||||||
|
const int c = (index / p.out_w / p.out_h) % p.channels; |
||||||
|
const int n = index / p.out_w / p.out_h / p.channels; |
||||||
|
int hstart = ph * p.stride_h - p.padding_h; |
||||||
|
int wstart = pw * p.stride_w - p.padding_w; |
||||||
|
int hend = min(hstart + p.filter_h, p.in_h + p.padding_h); |
||||||
|
int wend = min(wstart + p.filter_w, p.in_w + p.padding_w); |
||||||
|
int pool_size; |
||||||
|
if (p.padded_area == 1) |
||||||
|
{ |
||||||
|
pool_size = (hend - hstart) * (wend - wstart); |
||||||
|
hstart = max(hstart, 0); |
||||||
|
wstart = max(wstart, 0); |
||||||
|
hend = min(hend, p.in_h); |
||||||
|
wend = min(wend, p.in_w); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
hstart = max(hstart, 0); |
||||||
|
wstart = max(wstart, 0); |
||||||
|
hend = min(hend, p.in_h); |
||||||
|
wend = min(wend, p.in_w); |
||||||
|
pool_size = (hend - hstart) * (wend - wstart); |
||||||
|
} |
||||||
|
float aveval = 0; |
||||||
|
int off = (n * p.channels + c) * p.in_h * p.in_w; |
||||||
|
for (int h = hstart; h < hend; ++h) { |
||||||
|
for (int w = wstart; w < wend; ++w) { |
||||||
|
aveval += in_buffer[off + h * p.in_w + w]; |
||||||
|
} |
||||||
|
} |
||||||
|
out_buffer[index] = aveval / pool_size; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,208 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int avg_pool_spv[1538] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x000000f5,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0007000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00000015,0x00060010, |
||||||
|
0x00000004,0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2, |
||||||
|
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000008,0x626f6c67,0x735f6c61, |
||||||
|
0x00657a69,0x00070005,0x0000000d,0x4e5f6c67,0x6f576d75,0x72476b72,0x7370756f,0x00000000, |
||||||
|
0x00030005,0x00000014,0x00646967,0x00080005,0x00000015,0x475f6c67,0x61626f6c,0x766e496c, |
||||||
|
0x7461636f,0x496e6f69,0x00000044,0x00040005,0x00000019,0x65646e69,0x00000078,0x00050005, |
||||||
|
0x00000021,0x68737570,0x636f6c42,0x0000006b,0x00060006,0x00000021,0x00000000,0x6e616863, |
||||||
|
0x736c656e,0x00000000,0x00050006,0x00000021,0x00000001,0x685f6e69,0x00000000,0x00050006, |
||||||
|
0x00000021,0x00000002,0x775f6e69,0x00000000,0x00050006,0x00000021,0x00000003,0x5f74756f, |
||||||
|
0x00000068,0x00050006,0x00000021,0x00000004,0x5f74756f,0x00000077,0x00060006,0x00000021, |
||||||
|
0x00000005,0x64646170,0x5f676e69,0x00000068,0x00060006,0x00000021,0x00000006,0x64646170, |
||||||
|
0x5f676e69,0x00000077,0x00060006,0x00000021,0x00000007,0x746c6966,0x685f7265,0x00000000, |
||||||
|
0x00060006,0x00000021,0x00000008,0x746c6966,0x775f7265,0x00000000,0x00060006,0x00000021, |
||||||
|
0x00000009,0x69727473,0x685f6564,0x00000000,0x00060006,0x00000021,0x0000000a,0x69727473, |
||||||
|
0x775f6564,0x00000000,0x00050006,0x00000021,0x0000000b,0x61746f74,0x0000006c,0x00060006, |
||||||
|
0x00000021,0x0000000c,0x64646170,0x615f6465,0x00616572,0x00030005,0x00000023,0x00000070, |
||||||
|
0x00030005,0x0000002a,0x00007770,0x00030005,0x00000030,0x00006870,0x00030005,0x00000039, |
||||||
|
0x00000063,0x00030005,0x00000045,0x0000006e,0x00040005,0x00000050,0x61747368,0x00007472, |
||||||
|
0x00040005,0x0000005a,0x61747377,0x00007472,0x00040005,0x00000064,0x646e6568,0x00000000, |
||||||
|
0x00040005,0x00000071,0x646e6577,0x00000000,0x00050005,0x00000084,0x6c6f6f70,0x7a69735f, |
||||||
|
0x00000065,0x00040005,0x000000ae,0x76657661,0x00006c61,0x00030005,0x000000b0,0x0066666f, |
||||||
|
0x00030005,0x000000bd,0x00000068,0x00030005,0x000000c7,0x00000077,0x00040005,0x000000d2, |
||||||
|
0x75706e49,0x00003074,0x00060006,0x000000d2,0x00000000,0x625f6e69,0x65666675,0x00000072, |
||||||
|
0x00030005,0x000000d4,0x00000000,0x00040005,0x000000e7,0x7074754f,0x00007475,0x00060006, |
||||||
|
0x000000e7,0x00000000,0x5f74756f,0x66667562,0x00007265,0x00030005,0x000000e9,0x00000000, |
||||||
|
0x00040047,0x0000000d,0x0000000b,0x00000018,0x00040047,0x00000015,0x0000000b,0x0000001c, |
||||||
|
0x00050048,0x00000021,0x00000000,0x00000023,0x00000000,0x00050048,0x00000021,0x00000001, |
||||||
|
0x00000023,0x00000004,0x00050048,0x00000021,0x00000002,0x00000023,0x00000008,0x00050048, |
||||||
|
0x00000021,0x00000003,0x00000023,0x0000000c,0x00050048,0x00000021,0x00000004,0x00000023, |
||||||
|
0x00000010,0x00050048,0x00000021,0x00000005,0x00000023,0x00000014,0x00050048,0x00000021, |
||||||
|
0x00000006,0x00000023,0x00000018,0x00050048,0x00000021,0x00000007,0x00000023,0x0000001c, |
||||||
|
0x00050048,0x00000021,0x00000008,0x00000023,0x00000020,0x00050048,0x00000021,0x00000009, |
||||||
|
0x00000023,0x00000024,0x00050048,0x00000021,0x0000000a,0x00000023,0x00000028,0x00050048, |
||||||
|
0x00000021,0x0000000b,0x00000023,0x0000002c,0x00050048,0x00000021,0x0000000c,0x00000023, |
||||||
|
0x00000030,0x00030047,0x00000021,0x00000002,0x00040047,0x000000d1,0x00000006,0x00000004, |
||||||
|
0x00040048,0x000000d2,0x00000000,0x00000018,0x00050048,0x000000d2,0x00000000,0x00000023, |
||||||
|
0x00000000,0x00030047,0x000000d2,0x00000003,0x00040047,0x000000d4,0x00000022,0x00000000, |
||||||
|
0x00040047,0x000000d4,0x00000021,0x00000000,0x00040047,0x000000e6,0x00000006,0x00000004, |
||||||
|
0x00040048,0x000000e7,0x00000000,0x00000019,0x00050048,0x000000e7,0x00000000,0x00000023, |
||||||
|
0x00000000,0x00030047,0x000000e7,0x00000003,0x00040047,0x000000e9,0x00000022,0x00000000, |
||||||
|
0x00040047,0x000000e9,0x00000021,0x00000001,0x00040047,0x000000f4,0x0000000b,0x00000019, |
||||||
|
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020, |
||||||
|
0x00000001,0x00040020,0x00000007,0x00000007,0x00000006,0x00040015,0x00000009,0x00000020, |
||||||
|
0x00000000,0x0004002b,0x00000009,0x0000000a,0x00000100,0x00040017,0x0000000b,0x00000009, |
||||||
|
0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d, |
||||||
|
0x00000001,0x0004002b,0x00000009,0x0000000e,0x00000000,0x00040020,0x0000000f,0x00000001, |
||||||
|
0x00000009,0x0004003b,0x0000000c,0x00000015,0x00000001,0x000f001e,0x00000021,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,0x00000022,0x00000009,0x00000021, |
||||||
|
0x0004003b,0x00000022,0x00000023,0x00000009,0x0004002b,0x00000006,0x00000024,0x0000000b, |
||||||
|
0x00040020,0x00000025,0x00000009,0x00000006,0x00020014,0x00000028,0x0004002b,0x00000006, |
||||||
|
0x0000002c,0x00000004,0x0004002b,0x00000006,0x00000035,0x00000003,0x0004002b,0x00000006, |
||||||
|
0x00000041,0x00000000,0x0004002b,0x00000006,0x00000052,0x00000009,0x0004002b,0x00000006, |
||||||
|
0x00000056,0x00000005,0x0004002b,0x00000006,0x0000005c,0x0000000a,0x0004002b,0x00000006, |
||||||
|
0x00000060,0x00000006,0x0004002b,0x00000006,0x00000066,0x00000007,0x0004002b,0x00000006, |
||||||
|
0x0000006a,0x00000001,0x0004002b,0x00000006,0x00000073,0x00000008,0x0004002b,0x00000006, |
||||||
|
0x00000077,0x00000002,0x0004002b,0x00000006,0x0000007e,0x0000000c,0x00030016,0x000000ac, |
||||||
|
0x00000020,0x00040020,0x000000ad,0x00000007,0x000000ac,0x0004002b,0x000000ac,0x000000af, |
||||||
|
0x00000000,0x0003001d,0x000000d1,0x000000ac,0x0003001e,0x000000d2,0x000000d1,0x00040020, |
||||||
|
0x000000d3,0x00000002,0x000000d2,0x0004003b,0x000000d3,0x000000d4,0x00000002,0x00040020, |
||||||
|
0x000000dd,0x00000002,0x000000ac,0x0003001d,0x000000e6,0x000000ac,0x0003001e,0x000000e7, |
||||||
|
0x000000e6,0x00040020,0x000000e8,0x00000002,0x000000e7,0x0004003b,0x000000e8,0x000000e9, |
||||||
|
0x00000002,0x0004002b,0x00000009,0x000000f3,0x00000001,0x0006002c,0x0000000b,0x000000f4, |
||||||
|
0x0000000a,0x000000f3,0x000000f3,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003, |
||||||
|
0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000014,0x00000007,0x0004003b,0x00000007,0x00000019,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000002a,0x00000007,0x0004003b,0x00000007,0x00000030,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000039,0x00000007,0x0004003b,0x00000007,0x00000045,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000050,0x00000007,0x0004003b,0x00000007,0x0000005a,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000064,0x00000007,0x0004003b,0x00000007,0x00000071,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000084,0x00000007,0x0004003b,0x000000ad,0x000000ae,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x000000b0,0x00000007,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x000000c7,0x00000007,0x00050041,0x0000000f,0x00000010,0x0000000d,0x0000000e,0x0004003d, |
||||||
|
0x00000009,0x00000011,0x00000010,0x00050084,0x00000009,0x00000012,0x0000000a,0x00000011, |
||||||
|
0x0004007c,0x00000006,0x00000013,0x00000012,0x0003003e,0x00000008,0x00000013,0x00050041, |
||||||
|
0x0000000f,0x00000016,0x00000015,0x0000000e,0x0004003d,0x00000009,0x00000017,0x00000016, |
||||||
|
0x0004007c,0x00000006,0x00000018,0x00000017,0x0003003e,0x00000014,0x00000018,0x0004003d, |
||||||
|
0x00000006,0x0000001a,0x00000014,0x0003003e,0x00000019,0x0000001a,0x000200f9,0x0000001b, |
||||||
|
0x000200f8,0x0000001b,0x000400f6,0x0000001d,0x0000001e,0x00000000,0x000200f9,0x0000001f, |
||||||
|
0x000200f8,0x0000001f,0x0004003d,0x00000006,0x00000020,0x00000019,0x00050041,0x00000025, |
||||||
|
0x00000026,0x00000023,0x00000024,0x0004003d,0x00000006,0x00000027,0x00000026,0x000500b1, |
||||||
|
0x00000028,0x00000029,0x00000020,0x00000027,0x000400fa,0x00000029,0x0000001c,0x0000001d, |
||||||
|
0x000200f8,0x0000001c,0x0004003d,0x00000006,0x0000002b,0x00000019,0x00050041,0x00000025, |
||||||
|
0x0000002d,0x00000023,0x0000002c,0x0004003d,0x00000006,0x0000002e,0x0000002d,0x0005008b, |
||||||
|
0x00000006,0x0000002f,0x0000002b,0x0000002e,0x0003003e,0x0000002a,0x0000002f,0x0004003d, |
||||||
|
0x00000006,0x00000031,0x00000019,0x00050041,0x00000025,0x00000032,0x00000023,0x0000002c, |
||||||
|
0x0004003d,0x00000006,0x00000033,0x00000032,0x00050087,0x00000006,0x00000034,0x00000031, |
||||||
|
0x00000033,0x00050041,0x00000025,0x00000036,0x00000023,0x00000035,0x0004003d,0x00000006, |
||||||
|
0x00000037,0x00000036,0x0005008b,0x00000006,0x00000038,0x00000034,0x00000037,0x0003003e, |
||||||
|
0x00000030,0x00000038,0x0004003d,0x00000006,0x0000003a,0x00000019,0x00050041,0x00000025, |
||||||
|
0x0000003b,0x00000023,0x0000002c,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x00050087, |
||||||
|
0x00000006,0x0000003d,0x0000003a,0x0000003c,0x00050041,0x00000025,0x0000003e,0x00000023, |
||||||
|
0x00000035,0x0004003d,0x00000006,0x0000003f,0x0000003e,0x00050087,0x00000006,0x00000040, |
||||||
|
0x0000003d,0x0000003f,0x00050041,0x00000025,0x00000042,0x00000023,0x00000041,0x0004003d, |
||||||
|
0x00000006,0x00000043,0x00000042,0x0005008b,0x00000006,0x00000044,0x00000040,0x00000043, |
||||||
|
0x0003003e,0x00000039,0x00000044,0x0004003d,0x00000006,0x00000046,0x00000019,0x00050041, |
||||||
|
0x00000025,0x00000047,0x00000023,0x0000002c,0x0004003d,0x00000006,0x00000048,0x00000047, |
||||||
|
0x00050087,0x00000006,0x00000049,0x00000046,0x00000048,0x00050041,0x00000025,0x0000004a, |
||||||
|
0x00000023,0x00000035,0x0004003d,0x00000006,0x0000004b,0x0000004a,0x00050087,0x00000006, |
||||||
|
0x0000004c,0x00000049,0x0000004b,0x00050041,0x00000025,0x0000004d,0x00000023,0x00000041, |
||||||
|
0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050087,0x00000006,0x0000004f,0x0000004c, |
||||||
|
0x0000004e,0x0003003e,0x00000045,0x0000004f,0x0004003d,0x00000006,0x00000051,0x00000030, |
||||||
|
0x00050041,0x00000025,0x00000053,0x00000023,0x00000052,0x0004003d,0x00000006,0x00000054, |
||||||
|
0x00000053,0x00050084,0x00000006,0x00000055,0x00000051,0x00000054,0x00050041,0x00000025, |
||||||
|
0x00000057,0x00000023,0x00000056,0x0004003d,0x00000006,0x00000058,0x00000057,0x00050082, |
||||||
|
0x00000006,0x00000059,0x00000055,0x00000058,0x0003003e,0x00000050,0x00000059,0x0004003d, |
||||||
|
0x00000006,0x0000005b,0x0000002a,0x00050041,0x00000025,0x0000005d,0x00000023,0x0000005c, |
||||||
|
0x0004003d,0x00000006,0x0000005e,0x0000005d,0x00050084,0x00000006,0x0000005f,0x0000005b, |
||||||
|
0x0000005e,0x00050041,0x00000025,0x00000061,0x00000023,0x00000060,0x0004003d,0x00000006, |
||||||
|
0x00000062,0x00000061,0x00050082,0x00000006,0x00000063,0x0000005f,0x00000062,0x0003003e, |
||||||
|
0x0000005a,0x00000063,0x0004003d,0x00000006,0x00000065,0x00000050,0x00050041,0x00000025, |
||||||
|
0x00000067,0x00000023,0x00000066,0x0004003d,0x00000006,0x00000068,0x00000067,0x00050080, |
||||||
|
0x00000006,0x00000069,0x00000065,0x00000068,0x00050041,0x00000025,0x0000006b,0x00000023, |
||||||
|
0x0000006a,0x0004003d,0x00000006,0x0000006c,0x0000006b,0x00050041,0x00000025,0x0000006d, |
||||||
|
0x00000023,0x00000056,0x0004003d,0x00000006,0x0000006e,0x0000006d,0x00050080,0x00000006, |
||||||
|
0x0000006f,0x0000006c,0x0000006e,0x0007000c,0x00000006,0x00000070,0x00000001,0x00000027, |
||||||
|
0x00000069,0x0000006f,0x0003003e,0x00000064,0x00000070,0x0004003d,0x00000006,0x00000072, |
||||||
|
0x0000005a,0x00050041,0x00000025,0x00000074,0x00000023,0x00000073,0x0004003d,0x00000006, |
||||||
|
0x00000075,0x00000074,0x00050080,0x00000006,0x00000076,0x00000072,0x00000075,0x00050041, |
||||||
|
0x00000025,0x00000078,0x00000023,0x00000077,0x0004003d,0x00000006,0x00000079,0x00000078, |
||||||
|
0x00050041,0x00000025,0x0000007a,0x00000023,0x00000060,0x0004003d,0x00000006,0x0000007b, |
||||||
|
0x0000007a,0x00050080,0x00000006,0x0000007c,0x00000079,0x0000007b,0x0007000c,0x00000006, |
||||||
|
0x0000007d,0x00000001,0x00000027,0x00000076,0x0000007c,0x0003003e,0x00000071,0x0000007d, |
||||||
|
0x00050041,0x00000025,0x0000007f,0x00000023,0x0000007e,0x0004003d,0x00000006,0x00000080, |
||||||
|
0x0000007f,0x000500aa,0x00000028,0x00000081,0x00000080,0x0000006a,0x000300f7,0x00000083, |
||||||
|
0x00000000,0x000400fa,0x00000081,0x00000082,0x00000098,0x000200f8,0x00000082,0x0004003d, |
||||||
|
0x00000006,0x00000085,0x00000064,0x0004003d,0x00000006,0x00000086,0x00000050,0x00050082, |
||||||
|
0x00000006,0x00000087,0x00000085,0x00000086,0x0004003d,0x00000006,0x00000088,0x00000071, |
||||||
|
0x0004003d,0x00000006,0x00000089,0x0000005a,0x00050082,0x00000006,0x0000008a,0x00000088, |
||||||
|
0x00000089,0x00050084,0x00000006,0x0000008b,0x00000087,0x0000008a,0x0003003e,0x00000084, |
||||||
|
0x0000008b,0x0004003d,0x00000006,0x0000008c,0x00000050,0x0007000c,0x00000006,0x0000008d, |
||||||
|
0x00000001,0x0000002a,0x0000008c,0x00000041,0x0003003e,0x00000050,0x0000008d,0x0004003d, |
||||||
|
0x00000006,0x0000008e,0x0000005a,0x0007000c,0x00000006,0x0000008f,0x00000001,0x0000002a, |
||||||
|
0x0000008e,0x00000041,0x0003003e,0x0000005a,0x0000008f,0x0004003d,0x00000006,0x00000090, |
||||||
|
0x00000064,0x00050041,0x00000025,0x00000091,0x00000023,0x0000006a,0x0004003d,0x00000006, |
||||||
|
0x00000092,0x00000091,0x0007000c,0x00000006,0x00000093,0x00000001,0x00000027,0x00000090, |
||||||
|
0x00000092,0x0003003e,0x00000064,0x00000093,0x0004003d,0x00000006,0x00000094,0x00000071, |
||||||
|
0x00050041,0x00000025,0x00000095,0x00000023,0x00000077,0x0004003d,0x00000006,0x00000096, |
||||||
|
0x00000095,0x0007000c,0x00000006,0x00000097,0x00000001,0x00000027,0x00000094,0x00000096, |
||||||
|
0x0003003e,0x00000071,0x00000097,0x000200f9,0x00000083,0x000200f8,0x00000098,0x0004003d, |
||||||
|
0x00000006,0x00000099,0x00000050,0x0007000c,0x00000006,0x0000009a,0x00000001,0x0000002a, |
||||||
|
0x00000099,0x00000041,0x0003003e,0x00000050,0x0000009a,0x0004003d,0x00000006,0x0000009b, |
||||||
|
0x0000005a,0x0007000c,0x00000006,0x0000009c,0x00000001,0x0000002a,0x0000009b,0x00000041, |
||||||
|
0x0003003e,0x0000005a,0x0000009c,0x0004003d,0x00000006,0x0000009d,0x00000064,0x00050041, |
||||||
|
0x00000025,0x0000009e,0x00000023,0x0000006a,0x0004003d,0x00000006,0x0000009f,0x0000009e, |
||||||
|
0x0007000c,0x00000006,0x000000a0,0x00000001,0x00000027,0x0000009d,0x0000009f,0x0003003e, |
||||||
|
0x00000064,0x000000a0,0x0004003d,0x00000006,0x000000a1,0x00000071,0x00050041,0x00000025, |
||||||
|
0x000000a2,0x00000023,0x00000077,0x0004003d,0x00000006,0x000000a3,0x000000a2,0x0007000c, |
||||||
|
0x00000006,0x000000a4,0x00000001,0x00000027,0x000000a1,0x000000a3,0x0003003e,0x00000071, |
||||||
|
0x000000a4,0x0004003d,0x00000006,0x000000a5,0x00000064,0x0004003d,0x00000006,0x000000a6, |
||||||
|
0x00000050,0x00050082,0x00000006,0x000000a7,0x000000a5,0x000000a6,0x0004003d,0x00000006, |
||||||
|
0x000000a8,0x00000071,0x0004003d,0x00000006,0x000000a9,0x0000005a,0x00050082,0x00000006, |
||||||
|
0x000000aa,0x000000a8,0x000000a9,0x00050084,0x00000006,0x000000ab,0x000000a7,0x000000aa, |
||||||
|
0x0003003e,0x00000084,0x000000ab,0x000200f9,0x00000083,0x000200f8,0x00000083,0x0003003e, |
||||||
|
0x000000ae,0x000000af,0x0004003d,0x00000006,0x000000b1,0x00000045,0x00050041,0x00000025, |
||||||
|
0x000000b2,0x00000023,0x00000041,0x0004003d,0x00000006,0x000000b3,0x000000b2,0x00050084, |
||||||
|
0x00000006,0x000000b4,0x000000b1,0x000000b3,0x0004003d,0x00000006,0x000000b5,0x00000039, |
||||||
|
0x00050080,0x00000006,0x000000b6,0x000000b4,0x000000b5,0x00050041,0x00000025,0x000000b7, |
||||||
|
0x00000023,0x0000006a,0x0004003d,0x00000006,0x000000b8,0x000000b7,0x00050084,0x00000006, |
||||||
|
0x000000b9,0x000000b6,0x000000b8,0x00050041,0x00000025,0x000000ba,0x00000023,0x00000077, |
||||||
|
0x0004003d,0x00000006,0x000000bb,0x000000ba,0x00050084,0x00000006,0x000000bc,0x000000b9, |
||||||
|
0x000000bb,0x0003003e,0x000000b0,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000050, |
||||||
|
0x0003003e,0x000000bd,0x000000be,0x000200f9,0x000000bf,0x000200f8,0x000000bf,0x000400f6, |
||||||
|
0x000000c1,0x000000c2,0x00000000,0x000200f9,0x000000c3,0x000200f8,0x000000c3,0x0004003d, |
||||||
|
0x00000006,0x000000c4,0x000000bd,0x0004003d,0x00000006,0x000000c5,0x00000064,0x000500b1, |
||||||
|
0x00000028,0x000000c6,0x000000c4,0x000000c5,0x000400fa,0x000000c6,0x000000c0,0x000000c1, |
||||||
|
0x000200f8,0x000000c0,0x0004003d,0x00000006,0x000000c8,0x0000005a,0x0003003e,0x000000c7, |
||||||
|
0x000000c8,0x000200f9,0x000000c9,0x000200f8,0x000000c9,0x000400f6,0x000000cb,0x000000cc, |
||||||
|
0x00000000,0x000200f9,0x000000cd,0x000200f8,0x000000cd,0x0004003d,0x00000006,0x000000ce, |
||||||
|
0x000000c7,0x0004003d,0x00000006,0x000000cf,0x00000071,0x000500b1,0x00000028,0x000000d0, |
||||||
|
0x000000ce,0x000000cf,0x000400fa,0x000000d0,0x000000ca,0x000000cb,0x000200f8,0x000000ca, |
||||||
|
0x0004003d,0x00000006,0x000000d5,0x000000b0,0x0004003d,0x00000006,0x000000d6,0x000000bd, |
||||||
|
0x00050041,0x00000025,0x000000d7,0x00000023,0x00000077,0x0004003d,0x00000006,0x000000d8, |
||||||
|
0x000000d7,0x00050084,0x00000006,0x000000d9,0x000000d6,0x000000d8,0x00050080,0x00000006, |
||||||
|
0x000000da,0x000000d5,0x000000d9,0x0004003d,0x00000006,0x000000db,0x000000c7,0x00050080, |
||||||
|
0x00000006,0x000000dc,0x000000da,0x000000db,0x00060041,0x000000dd,0x000000de,0x000000d4, |
||||||
|
0x00000041,0x000000dc,0x0004003d,0x000000ac,0x000000df,0x000000de,0x0004003d,0x000000ac, |
||||||
|
0x000000e0,0x000000ae,0x00050081,0x000000ac,0x000000e1,0x000000e0,0x000000df,0x0003003e, |
||||||
|
0x000000ae,0x000000e1,0x000200f9,0x000000cc,0x000200f8,0x000000cc,0x0004003d,0x00000006, |
||||||
|
0x000000e2,0x000000c7,0x00050080,0x00000006,0x000000e3,0x000000e2,0x0000006a,0x0003003e, |
||||||
|
0x000000c7,0x000000e3,0x000200f9,0x000000c9,0x000200f8,0x000000cb,0x000200f9,0x000000c2, |
||||||
|
0x000200f8,0x000000c2,0x0004003d,0x00000006,0x000000e4,0x000000bd,0x00050080,0x00000006, |
||||||
|
0x000000e5,0x000000e4,0x0000006a,0x0003003e,0x000000bd,0x000000e5,0x000200f9,0x000000bf, |
||||||
|
0x000200f8,0x000000c1,0x0004003d,0x00000006,0x000000ea,0x00000019,0x0004003d,0x000000ac, |
||||||
|
0x000000eb,0x000000ae,0x0004003d,0x00000006,0x000000ec,0x00000084,0x0004006f,0x000000ac, |
||||||
|
0x000000ed,0x000000ec,0x00050088,0x000000ac,0x000000ee,0x000000eb,0x000000ed,0x00060041, |
||||||
|
0x000000dd,0x000000ef,0x000000e9,0x00000041,0x000000ea,0x0003003e,0x000000ef,0x000000ee, |
||||||
|
0x000200f9,0x0000001e,0x000200f8,0x0000001e,0x0004003d,0x00000006,0x000000f0,0x00000008, |
||||||
|
0x0004003d,0x00000006,0x000000f1,0x00000019,0x00050080,0x00000006,0x000000f2,0x000000f1, |
||||||
|
0x000000f0,0x0003003e,0x00000019,0x000000f2,0x000200f9,0x0000001b,0x000200f8,0x0000001d, |
||||||
|
0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,29 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int out_concat_axis; |
||||||
|
int accumulated_concat_axis; |
||||||
|
int concat_size; |
||||||
|
int total_concat_size; |
||||||
|
int thread_num; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float data[]; |
||||||
|
} src; |
||||||
|
layout(binding = 1) writeonly buffer Output{ |
||||||
|
float data[]; |
||||||
|
} dst; |
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
void main() |
||||||
|
{ |
||||||
|
int index = int(gl_GlobalInvocationID.x); |
||||||
|
if (index < p.thread_num) |
||||||
|
{ |
||||||
|
int concat_num = index / p.total_concat_size; |
||||||
|
int concat_index = index % p.total_concat_size; |
||||||
|
int out_index = concat_index + (concat_num * p.out_concat_axis + p.accumulated_concat_axis) * p.concat_size; |
||||||
|
dst.data[out_index] = src.data[index]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,83 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int concat_spv[541] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x0000004b,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00040005,0x00000008,0x65646e69,0x00000078,0x00080005, |
||||||
|
0x0000000c,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005, |
||||||
|
0x00000013,0x68737570,0x636f6c42,0x0000006b,0x00070006,0x00000013,0x00000000,0x5f74756f, |
||||||
|
0x636e6f63,0x615f7461,0x00736978,0x00090006,0x00000013,0x00000001,0x75636361,0x616c756d, |
||||||
|
0x5f646574,0x636e6f63,0x615f7461,0x00736978,0x00060006,0x00000013,0x00000002,0x636e6f63, |
||||||
|
0x735f7461,0x00657a69,0x00080006,0x00000013,0x00000003,0x61746f74,0x6f635f6c,0x7461636e, |
||||||
|
0x7a69735f,0x00000065,0x00060006,0x00000013,0x00000004,0x65726874,0x6e5f6461,0x00006d75, |
||||||
|
0x00030005,0x00000015,0x00000070,0x00050005,0x0000001e,0x636e6f63,0x6e5f7461,0x00006d75, |
||||||
|
0x00060005,0x00000024,0x636e6f63,0x695f7461,0x7865646e,0x00000000,0x00050005,0x00000029, |
||||||
|
0x5f74756f,0x65646e69,0x00000078,0x00040005,0x0000003b,0x7074754f,0x00007475,0x00050006, |
||||||
|
0x0000003b,0x00000000,0x61746164,0x00000000,0x00030005,0x0000003d,0x00747364,0x00040005, |
||||||
|
0x00000040,0x75706e49,0x00003074,0x00050006,0x00000040,0x00000000,0x61746164,0x00000000, |
||||||
|
0x00030005,0x00000042,0x00637273,0x00040047,0x0000000c,0x0000000b,0x0000001c,0x00050048, |
||||||
|
0x00000013,0x00000000,0x00000023,0x00000000,0x00050048,0x00000013,0x00000001,0x00000023, |
||||||
|
0x00000004,0x00050048,0x00000013,0x00000002,0x00000023,0x00000008,0x00050048,0x00000013, |
||||||
|
0x00000003,0x00000023,0x0000000c,0x00050048,0x00000013,0x00000004,0x00000023,0x00000010, |
||||||
|
0x00030047,0x00000013,0x00000002,0x00040047,0x0000003a,0x00000006,0x00000004,0x00040048, |
||||||
|
0x0000003b,0x00000000,0x00000019,0x00050048,0x0000003b,0x00000000,0x00000023,0x00000000, |
||||||
|
0x00030047,0x0000003b,0x00000003,0x00040047,0x0000003d,0x00000022,0x00000000,0x00040047, |
||||||
|
0x0000003d,0x00000021,0x00000001,0x00040047,0x0000003f,0x00000006,0x00000004,0x00040048, |
||||||
|
0x00000040,0x00000000,0x00000018,0x00050048,0x00000040,0x00000000,0x00000023,0x00000000, |
||||||
|
0x00030047,0x00000040,0x00000003,0x00040047,0x00000042,0x00000022,0x00000000,0x00040047, |
||||||
|
0x00000042,0x00000021,0x00000000,0x00040047,0x0000004a,0x0000000b,0x00000019,0x00020013, |
||||||
|
0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001, |
||||||
|
0x00040020,0x00000007,0x00000007,0x00000006,0x00040015,0x00000009,0x00000020,0x00000000, |
||||||
|
0x00040017,0x0000000a,0x00000009,0x00000003,0x00040020,0x0000000b,0x00000001,0x0000000a, |
||||||
|
0x0004003b,0x0000000b,0x0000000c,0x00000001,0x0004002b,0x00000009,0x0000000d,0x00000000, |
||||||
|
0x00040020,0x0000000e,0x00000001,0x00000009,0x0007001e,0x00000013,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00040020,0x00000014,0x00000009,0x00000013,0x0004003b, |
||||||
|
0x00000014,0x00000015,0x00000009,0x0004002b,0x00000006,0x00000016,0x00000004,0x00040020, |
||||||
|
0x00000017,0x00000009,0x00000006,0x00020014,0x0000001a,0x0004002b,0x00000006,0x00000020, |
||||||
|
0x00000003,0x0004002b,0x00000006,0x0000002c,0x00000000,0x0004002b,0x00000006,0x00000030, |
||||||
|
0x00000001,0x0004002b,0x00000006,0x00000034,0x00000002,0x00030016,0x00000039,0x00000020, |
||||||
|
0x0003001d,0x0000003a,0x00000039,0x0003001e,0x0000003b,0x0000003a,0x00040020,0x0000003c, |
||||||
|
0x00000002,0x0000003b,0x0004003b,0x0000003c,0x0000003d,0x00000002,0x0003001d,0x0000003f, |
||||||
|
0x00000039,0x0003001e,0x00000040,0x0000003f,0x00040020,0x00000041,0x00000002,0x00000040, |
||||||
|
0x0004003b,0x00000041,0x00000042,0x00000002,0x00040020,0x00000044,0x00000002,0x00000039, |
||||||
|
0x0004002b,0x00000009,0x00000048,0x00000100,0x0004002b,0x00000009,0x00000049,0x00000001, |
||||||
|
0x0006002c,0x0000000a,0x0000004a,0x00000048,0x00000049,0x00000049,0x00050036,0x00000002, |
||||||
|
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008, |
||||||
|
0x00000007,0x0004003b,0x00000007,0x0000001e,0x00000007,0x0004003b,0x00000007,0x00000024, |
||||||
|
0x00000007,0x0004003b,0x00000007,0x00000029,0x00000007,0x00050041,0x0000000e,0x0000000f, |
||||||
|
0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010,0x0000000f,0x0004007c,0x00000006, |
||||||
|
0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011,0x0004003d,0x00000006,0x00000012, |
||||||
|
0x00000008,0x00050041,0x00000017,0x00000018,0x00000015,0x00000016,0x0004003d,0x00000006, |
||||||
|
0x00000019,0x00000018,0x000500b1,0x0000001a,0x0000001b,0x00000012,0x00000019,0x000300f7, |
||||||
|
0x0000001d,0x00000000,0x000400fa,0x0000001b,0x0000001c,0x0000001d,0x000200f8,0x0000001c, |
||||||
|
0x0004003d,0x00000006,0x0000001f,0x00000008,0x00050041,0x00000017,0x00000021,0x00000015, |
||||||
|
0x00000020,0x0004003d,0x00000006,0x00000022,0x00000021,0x00050087,0x00000006,0x00000023, |
||||||
|
0x0000001f,0x00000022,0x0003003e,0x0000001e,0x00000023,0x0004003d,0x00000006,0x00000025, |
||||||
|
0x00000008,0x00050041,0x00000017,0x00000026,0x00000015,0x00000020,0x0004003d,0x00000006, |
||||||
|
0x00000027,0x00000026,0x0005008b,0x00000006,0x00000028,0x00000025,0x00000027,0x0003003e, |
||||||
|
0x00000024,0x00000028,0x0004003d,0x00000006,0x0000002a,0x00000024,0x0004003d,0x00000006, |
||||||
|
0x0000002b,0x0000001e,0x00050041,0x00000017,0x0000002d,0x00000015,0x0000002c,0x0004003d, |
||||||
|
0x00000006,0x0000002e,0x0000002d,0x00050084,0x00000006,0x0000002f,0x0000002b,0x0000002e, |
||||||
|
0x00050041,0x00000017,0x00000031,0x00000015,0x00000030,0x0004003d,0x00000006,0x00000032, |
||||||
|
0x00000031,0x00050080,0x00000006,0x00000033,0x0000002f,0x00000032,0x00050041,0x00000017, |
||||||
|
0x00000035,0x00000015,0x00000034,0x0004003d,0x00000006,0x00000036,0x00000035,0x00050084, |
||||||
|
0x00000006,0x00000037,0x00000033,0x00000036,0x00050080,0x00000006,0x00000038,0x0000002a, |
||||||
|
0x00000037,0x0003003e,0x00000029,0x00000038,0x0004003d,0x00000006,0x0000003e,0x00000029, |
||||||
|
0x0004003d,0x00000006,0x00000043,0x00000008,0x00060041,0x00000044,0x00000045,0x00000042, |
||||||
|
0x0000002c,0x00000043,0x0004003d,0x00000039,0x00000046,0x00000045,0x00060041,0x00000044, |
||||||
|
0x00000047,0x0000003d,0x0000002c,0x0000003e,0x0003003e,0x00000047,0x00000046,0x000200f9, |
||||||
|
0x0000001d,0x000200f8,0x0000001d,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,73 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float image_data[]; |
||||||
|
}; |
||||||
|
layout(binding = 1) readonly buffer Input1 { |
||||||
|
float bias_data[]; |
||||||
|
}; |
||||||
|
layout(binding = 2) readonly buffer Input3{ |
||||||
|
float weight_data[]; |
||||||
|
}; |
||||||
|
layout(binding = 3) writeonly buffer Output{ |
||||||
|
float convolved_image_data[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int in_h; |
||||||
|
int in_w; |
||||||
|
int out_h; |
||||||
|
int out_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int pad_h; |
||||||
|
int pad_w; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int dilation_h; |
||||||
|
int dilation_w; |
||||||
|
int channels; |
||||||
|
int batch; |
||||||
|
int has_bias; |
||||||
|
int M; |
||||||
|
int K; |
||||||
|
int N; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
void main() |
||||||
|
{ |
||||||
|
int gx = int(gl_GlobalInvocationID.x); |
||||||
|
int gy = int(gl_GlobalInvocationID.y); |
||||||
|
int gz = int(gl_GlobalInvocationID.z); |
||||||
|
if(gx < p.M && gy < p.N && gz < p.batch) |
||||||
|
{ |
||||||
|
float sum = 0.0f; |
||||||
|
int output_y = gx / p.out_w; |
||||||
|
int output_x = gx % p.out_w; |
||||||
|
int org_y = output_y * p.stride_h - p.pad_h; |
||||||
|
int org_x = output_x * p.stride_w - p.pad_w; |
||||||
|
int weight_off = gy * p.K; |
||||||
|
int input_off = gz * p.in_h * p.in_w * p.channels + (org_y * p.in_w + org_x); |
||||||
|
for(int c = 0; c < p.channels; c++) |
||||||
|
{ |
||||||
|
for(int y = 0; y < p.filter_h; y++) |
||||||
|
{ |
||||||
|
for(int x = 0; x < p.filter_w; x++) |
||||||
|
{ |
||||||
|
if((org_y + y * p.dilation_h >= 0) && (org_y + y * p.dilation_h < p.in_h) && (org_x + x * p.dilation_w >= 0) && (org_x + x * p.dilation_w < p.in_w)) |
||||||
|
{ |
||||||
|
sum += image_data[input_off + x * p.dilation_w] * weight_data[weight_off + x]; |
||||||
|
} |
||||||
|
} |
||||||
|
input_off += p.in_w * p.dilation_h; |
||||||
|
weight_off += p.filter_w; |
||||||
|
} |
||||||
|
input_off += p.in_h * p.in_w - p.in_w * p.filter_h * p.dilation_h; |
||||||
|
} |
||||||
|
int offset = gz * p.M * p.N + gx + gy * p.M; |
||||||
|
if (p.has_bias == 1) |
||||||
|
sum += bias_data[gy]; |
||||||
|
convolved_image_data[offset] = sum; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,248 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int conv_spv[1859] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x00000124,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00007867,0x00080005,0x0000000c, |
||||||
|
0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000012, |
||||||
|
0x00007967,0x00030005,0x00000017,0x00007a67,0x00050005,0x0000001e,0x68737570,0x636f6c42, |
||||||
|
0x0000006b,0x00050006,0x0000001e,0x00000000,0x685f6e69,0x00000000,0x00050006,0x0000001e, |
||||||
|
0x00000001,0x775f6e69,0x00000000,0x00050006,0x0000001e,0x00000002,0x5f74756f,0x00000068, |
||||||
|
0x00050006,0x0000001e,0x00000003,0x5f74756f,0x00000077,0x00060006,0x0000001e,0x00000004, |
||||||
|
0x69727473,0x685f6564,0x00000000,0x00060006,0x0000001e,0x00000005,0x69727473,0x775f6564, |
||||||
|
0x00000000,0x00050006,0x0000001e,0x00000006,0x5f646170,0x00000068,0x00050006,0x0000001e, |
||||||
|
0x00000007,0x5f646170,0x00000077,0x00060006,0x0000001e,0x00000008,0x746c6966,0x685f7265, |
||||||
|
0x00000000,0x00060006,0x0000001e,0x00000009,0x746c6966,0x775f7265,0x00000000,0x00060006, |
||||||
|
0x0000001e,0x0000000a,0x616c6964,0x6e6f6974,0x0000685f,0x00060006,0x0000001e,0x0000000b, |
||||||
|
0x616c6964,0x6e6f6974,0x0000775f,0x00060006,0x0000001e,0x0000000c,0x6e616863,0x736c656e, |
||||||
|
0x00000000,0x00050006,0x0000001e,0x0000000d,0x63746162,0x00000068,0x00060006,0x0000001e, |
||||||
|
0x0000000e,0x5f736168,0x73616962,0x00000000,0x00040006,0x0000001e,0x0000000f,0x0000004d, |
||||||
|
0x00040006,0x0000001e,0x00000010,0x0000004b,0x00040006,0x0000001e,0x00000011,0x0000004e, |
||||||
|
0x00030005,0x00000020,0x00000070,0x00030005,0x0000003a,0x006d7573,0x00050005,0x0000003c, |
||||||
|
0x7074756f,0x795f7475,0x00000000,0x00050005,0x00000042,0x7074756f,0x785f7475,0x00000000, |
||||||
|
0x00040005,0x00000047,0x5f67726f,0x00000079,0x00040005,0x00000051,0x5f67726f,0x00000078, |
||||||
|
0x00050005,0x0000005b,0x67696577,0x6f5f7468,0x00006666,0x00050005,0x00000061,0x75706e69, |
||||||
|
0x666f5f74,0x00000066,0x00030005,0x00000076,0x00000063,0x00030005,0x00000080,0x00000079, |
||||||
|
0x00030005,0x0000008b,0x00000078,0x00040005,0x000000c4,0x75706e49,0x00003074,0x00060006, |
||||||
|
0x000000c4,0x00000000,0x67616d69,0x61645f65,0x00006174,0x00030005,0x000000c6,0x00000000, |
||||||
|
0x00040005,0x000000d1,0x75706e49,0x00003374,0x00060006,0x000000d1,0x00000000,0x67696577, |
||||||
|
0x645f7468,0x00617461,0x00030005,0x000000d3,0x00000000,0x00040005,0x000000fd,0x7366666f, |
||||||
|
0x00007465,0x00040005,0x00000113,0x75706e49,0x00003174,0x00060006,0x00000113,0x00000000, |
||||||
|
0x73616962,0x7461645f,0x00000061,0x00030005,0x00000115,0x00000000,0x00040005,0x0000011c, |
||||||
|
0x7074754f,0x00007475,0x00090006,0x0000011c,0x00000000,0x766e6f63,0x65766c6f,0x6d695f64, |
||||||
|
0x5f656761,0x61746164,0x00000000,0x00030005,0x0000011e,0x00000000,0x00040047,0x0000000c, |
||||||
|
0x0000000b,0x0000001c,0x00050048,0x0000001e,0x00000000,0x00000023,0x00000000,0x00050048, |
||||||
|
0x0000001e,0x00000001,0x00000023,0x00000004,0x00050048,0x0000001e,0x00000002,0x00000023, |
||||||
|
0x00000008,0x00050048,0x0000001e,0x00000003,0x00000023,0x0000000c,0x00050048,0x0000001e, |
||||||
|
0x00000004,0x00000023,0x00000010,0x00050048,0x0000001e,0x00000005,0x00000023,0x00000014, |
||||||
|
0x00050048,0x0000001e,0x00000006,0x00000023,0x00000018,0x00050048,0x0000001e,0x00000007, |
||||||
|
0x00000023,0x0000001c,0x00050048,0x0000001e,0x00000008,0x00000023,0x00000020,0x00050048, |
||||||
|
0x0000001e,0x00000009,0x00000023,0x00000024,0x00050048,0x0000001e,0x0000000a,0x00000023, |
||||||
|
0x00000028,0x00050048,0x0000001e,0x0000000b,0x00000023,0x0000002c,0x00050048,0x0000001e, |
||||||
|
0x0000000c,0x00000023,0x00000030,0x00050048,0x0000001e,0x0000000d,0x00000023,0x00000034, |
||||||
|
0x00050048,0x0000001e,0x0000000e,0x00000023,0x00000038,0x00050048,0x0000001e,0x0000000f, |
||||||
|
0x00000023,0x0000003c,0x00050048,0x0000001e,0x00000010,0x00000023,0x00000040,0x00050048, |
||||||
|
0x0000001e,0x00000011,0x00000023,0x00000044,0x00030047,0x0000001e,0x00000002,0x00040047, |
||||||
|
0x000000c3,0x00000006,0x00000004,0x00040048,0x000000c4,0x00000000,0x00000018,0x00050048, |
||||||
|
0x000000c4,0x00000000,0x00000023,0x00000000,0x00030047,0x000000c4,0x00000003,0x00040047, |
||||||
|
0x000000c6,0x00000022,0x00000000,0x00040047,0x000000c6,0x00000021,0x00000000,0x00040047, |
||||||
|
0x000000d0,0x00000006,0x00000004,0x00040048,0x000000d1,0x00000000,0x00000018,0x00050048, |
||||||
|
0x000000d1,0x00000000,0x00000023,0x00000000,0x00030047,0x000000d1,0x00000003,0x00040047, |
||||||
|
0x000000d3,0x00000022,0x00000000,0x00040047,0x000000d3,0x00000021,0x00000002,0x00040047, |
||||||
|
0x00000112,0x00000006,0x00000004,0x00040048,0x00000113,0x00000000,0x00000018,0x00050048, |
||||||
|
0x00000113,0x00000000,0x00000023,0x00000000,0x00030047,0x00000113,0x00000003,0x00040047, |
||||||
|
0x00000115,0x00000022,0x00000000,0x00040047,0x00000115,0x00000021,0x00000001,0x00040047, |
||||||
|
0x0000011b,0x00000006,0x00000004,0x00040048,0x0000011c,0x00000000,0x00000019,0x00050048, |
||||||
|
0x0000011c,0x00000000,0x00000023,0x00000000,0x00030047,0x0000011c,0x00000003,0x00040047, |
||||||
|
0x0000011e,0x00000022,0x00000000,0x00040047,0x0000011e,0x00000021,0x00000003,0x00040047, |
||||||
|
0x00000123,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, |
||||||
|
0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007,0x00000006, |
||||||
|
0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009,0x00000003, |
||||||
|
0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000001, |
||||||
|
0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000009, |
||||||
|
0x0004002b,0x00000009,0x00000013,0x00000001,0x0004002b,0x00000009,0x00000018,0x00000002, |
||||||
|
0x00020014,0x0000001c,0x0014001e,0x0000001e,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,0x0000001f, |
||||||
|
0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x0004002b,0x00000006, |
||||||
|
0x00000021,0x0000000f,0x00040020,0x00000022,0x00000009,0x00000006,0x0004002b,0x00000006, |
||||||
|
0x00000029,0x00000011,0x0004002b,0x00000006,0x00000031,0x0000000d,0x00030016,0x00000038, |
||||||
|
0x00000020,0x00040020,0x00000039,0x00000007,0x00000038,0x0004002b,0x00000038,0x0000003b, |
||||||
|
0x00000000,0x0004002b,0x00000006,0x0000003e,0x00000003,0x0004002b,0x00000006,0x00000049, |
||||||
|
0x00000004,0x0004002b,0x00000006,0x0000004d,0x00000006,0x0004002b,0x00000006,0x00000053, |
||||||
|
0x00000005,0x0004002b,0x00000006,0x00000057,0x00000007,0x0004002b,0x00000006,0x0000005d, |
||||||
|
0x00000010,0x0004002b,0x00000006,0x00000063,0x00000000,0x0004002b,0x00000006,0x00000067, |
||||||
|
0x00000001,0x0004002b,0x00000006,0x0000006b,0x0000000c,0x0004002b,0x00000006,0x00000087, |
||||||
|
0x00000008,0x0004002b,0x00000006,0x00000092,0x00000009,0x0004002b,0x00000006,0x00000098, |
||||||
|
0x0000000a,0x0004002b,0x00000006,0x000000ae,0x0000000b,0x0003001d,0x000000c3,0x00000038, |
||||||
|
0x0003001e,0x000000c4,0x000000c3,0x00040020,0x000000c5,0x00000002,0x000000c4,0x0004003b, |
||||||
|
0x000000c5,0x000000c6,0x00000002,0x00040020,0x000000cd,0x00000002,0x00000038,0x0003001d, |
||||||
|
0x000000d0,0x00000038,0x0003001e,0x000000d1,0x000000d0,0x00040020,0x000000d2,0x00000002, |
||||||
|
0x000000d1,0x0004003b,0x000000d2,0x000000d3,0x00000002,0x0004002b,0x00000006,0x0000010c, |
||||||
|
0x0000000e,0x0003001d,0x00000112,0x00000038,0x0003001e,0x00000113,0x00000112,0x00040020, |
||||||
|
0x00000114,0x00000002,0x00000113,0x0004003b,0x00000114,0x00000115,0x00000002,0x0003001d, |
||||||
|
0x0000011b,0x00000038,0x0003001e,0x0000011c,0x0000011b,0x00040020,0x0000011d,0x00000002, |
||||||
|
0x0000011c,0x0004003b,0x0000011d,0x0000011e,0x00000002,0x0004002b,0x00000009,0x00000122, |
||||||
|
0x00000100,0x0006002c,0x0000000a,0x00000123,0x00000122,0x00000013,0x00000013,0x00050036, |
||||||
|
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007, |
||||||
|
0x00000008,0x00000007,0x0004003b,0x00000007,0x00000012,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000017,0x00000007,0x0004003b,0x00000039,0x0000003a,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000003c,0x00000007,0x0004003b,0x00000007,0x00000042,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000047,0x00000007,0x0004003b,0x00000007,0x00000051,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000005b,0x00000007,0x0004003b,0x00000007,0x00000061,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000076,0x00000007,0x0004003b,0x00000007,0x00000080,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000008b,0x00000007,0x0004003b,0x00000007,0x000000fd,0x00000007,0x00050041,0x0000000e, |
||||||
|
0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010,0x0000000f,0x0004007c, |
||||||
|
0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011,0x00050041,0x0000000e, |
||||||
|
0x00000014,0x0000000c,0x00000013,0x0004003d,0x00000009,0x00000015,0x00000014,0x0004007c, |
||||||
|
0x00000006,0x00000016,0x00000015,0x0003003e,0x00000012,0x00000016,0x00050041,0x0000000e, |
||||||
|
0x00000019,0x0000000c,0x00000018,0x0004003d,0x00000009,0x0000001a,0x00000019,0x0004007c, |
||||||
|
0x00000006,0x0000001b,0x0000001a,0x0003003e,0x00000017,0x0000001b,0x0004003d,0x00000006, |
||||||
|
0x0000001d,0x00000008,0x00050041,0x00000022,0x00000023,0x00000020,0x00000021,0x0004003d, |
||||||
|
0x00000006,0x00000024,0x00000023,0x000500b1,0x0000001c,0x00000025,0x0000001d,0x00000024, |
||||||
|
0x000300f7,0x00000027,0x00000000,0x000400fa,0x00000025,0x00000026,0x00000027,0x000200f8, |
||||||
|
0x00000026,0x0004003d,0x00000006,0x00000028,0x00000012,0x00050041,0x00000022,0x0000002a, |
||||||
|
0x00000020,0x00000029,0x0004003d,0x00000006,0x0000002b,0x0000002a,0x000500b1,0x0000001c, |
||||||
|
0x0000002c,0x00000028,0x0000002b,0x000200f9,0x00000027,0x000200f8,0x00000027,0x000700f5, |
||||||
|
0x0000001c,0x0000002d,0x00000025,0x00000005,0x0000002c,0x00000026,0x000300f7,0x0000002f, |
||||||
|
0x00000000,0x000400fa,0x0000002d,0x0000002e,0x0000002f,0x000200f8,0x0000002e,0x0004003d, |
||||||
|
0x00000006,0x00000030,0x00000017,0x00050041,0x00000022,0x00000032,0x00000020,0x00000031, |
||||||
|
0x0004003d,0x00000006,0x00000033,0x00000032,0x000500b1,0x0000001c,0x00000034,0x00000030, |
||||||
|
0x00000033,0x000200f9,0x0000002f,0x000200f8,0x0000002f,0x000700f5,0x0000001c,0x00000035, |
||||||
|
0x0000002d,0x00000027,0x00000034,0x0000002e,0x000300f7,0x00000037,0x00000000,0x000400fa, |
||||||
|
0x00000035,0x00000036,0x00000037,0x000200f8,0x00000036,0x0003003e,0x0000003a,0x0000003b, |
||||||
|
0x0004003d,0x00000006,0x0000003d,0x00000008,0x00050041,0x00000022,0x0000003f,0x00000020, |
||||||
|
0x0000003e,0x0004003d,0x00000006,0x00000040,0x0000003f,0x00050087,0x00000006,0x00000041, |
||||||
|
0x0000003d,0x00000040,0x0003003e,0x0000003c,0x00000041,0x0004003d,0x00000006,0x00000043, |
||||||
|
0x00000008,0x00050041,0x00000022,0x00000044,0x00000020,0x0000003e,0x0004003d,0x00000006, |
||||||
|
0x00000045,0x00000044,0x0005008b,0x00000006,0x00000046,0x00000043,0x00000045,0x0003003e, |
||||||
|
0x00000042,0x00000046,0x0004003d,0x00000006,0x00000048,0x0000003c,0x00050041,0x00000022, |
||||||
|
0x0000004a,0x00000020,0x00000049,0x0004003d,0x00000006,0x0000004b,0x0000004a,0x00050084, |
||||||
|
0x00000006,0x0000004c,0x00000048,0x0000004b,0x00050041,0x00000022,0x0000004e,0x00000020, |
||||||
|
0x0000004d,0x0004003d,0x00000006,0x0000004f,0x0000004e,0x00050082,0x00000006,0x00000050, |
||||||
|
0x0000004c,0x0000004f,0x0003003e,0x00000047,0x00000050,0x0004003d,0x00000006,0x00000052, |
||||||
|
0x00000042,0x00050041,0x00000022,0x00000054,0x00000020,0x00000053,0x0004003d,0x00000006, |
||||||
|
0x00000055,0x00000054,0x00050084,0x00000006,0x00000056,0x00000052,0x00000055,0x00050041, |
||||||
|
0x00000022,0x00000058,0x00000020,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000058, |
||||||
|
0x00050082,0x00000006,0x0000005a,0x00000056,0x00000059,0x0003003e,0x00000051,0x0000005a, |
||||||
|
0x0004003d,0x00000006,0x0000005c,0x00000012,0x00050041,0x00000022,0x0000005e,0x00000020, |
||||||
|
0x0000005d,0x0004003d,0x00000006,0x0000005f,0x0000005e,0x00050084,0x00000006,0x00000060, |
||||||
|
0x0000005c,0x0000005f,0x0003003e,0x0000005b,0x00000060,0x0004003d,0x00000006,0x00000062, |
||||||
|
0x00000017,0x00050041,0x00000022,0x00000064,0x00000020,0x00000063,0x0004003d,0x00000006, |
||||||
|
0x00000065,0x00000064,0x00050084,0x00000006,0x00000066,0x00000062,0x00000065,0x00050041, |
||||||
|
0x00000022,0x00000068,0x00000020,0x00000067,0x0004003d,0x00000006,0x00000069,0x00000068, |
||||||
|
0x00050084,0x00000006,0x0000006a,0x00000066,0x00000069,0x00050041,0x00000022,0x0000006c, |
||||||
|
0x00000020,0x0000006b,0x0004003d,0x00000006,0x0000006d,0x0000006c,0x00050084,0x00000006, |
||||||
|
0x0000006e,0x0000006a,0x0000006d,0x0004003d,0x00000006,0x0000006f,0x00000047,0x00050041, |
||||||
|
0x00000022,0x00000070,0x00000020,0x00000067,0x0004003d,0x00000006,0x00000071,0x00000070, |
||||||
|
0x00050084,0x00000006,0x00000072,0x0000006f,0x00000071,0x0004003d,0x00000006,0x00000073, |
||||||
|
0x00000051,0x00050080,0x00000006,0x00000074,0x00000072,0x00000073,0x00050080,0x00000006, |
||||||
|
0x00000075,0x0000006e,0x00000074,0x0003003e,0x00000061,0x00000075,0x0003003e,0x00000076, |
||||||
|
0x00000063,0x000200f9,0x00000077,0x000200f8,0x00000077,0x000400f6,0x00000079,0x0000007a, |
||||||
|
0x00000000,0x000200f9,0x0000007b,0x000200f8,0x0000007b,0x0004003d,0x00000006,0x0000007c, |
||||||
|
0x00000076,0x00050041,0x00000022,0x0000007d,0x00000020,0x0000006b,0x0004003d,0x00000006, |
||||||
|
0x0000007e,0x0000007d,0x000500b1,0x0000001c,0x0000007f,0x0000007c,0x0000007e,0x000400fa, |
||||||
|
0x0000007f,0x00000078,0x00000079,0x000200f8,0x00000078,0x0003003e,0x00000080,0x00000063, |
||||||
|
0x000200f9,0x00000081,0x000200f8,0x00000081,0x000400f6,0x00000083,0x00000084,0x00000000, |
||||||
|
0x000200f9,0x00000085,0x000200f8,0x00000085,0x0004003d,0x00000006,0x00000086,0x00000080, |
||||||
|
0x00050041,0x00000022,0x00000088,0x00000020,0x00000087,0x0004003d,0x00000006,0x00000089, |
||||||
|
0x00000088,0x000500b1,0x0000001c,0x0000008a,0x00000086,0x00000089,0x000400fa,0x0000008a, |
||||||
|
0x00000082,0x00000083,0x000200f8,0x00000082,0x0003003e,0x0000008b,0x00000063,0x000200f9, |
||||||
|
0x0000008c,0x000200f8,0x0000008c,0x000400f6,0x0000008e,0x0000008f,0x00000000,0x000200f9, |
||||||
|
0x00000090,0x000200f8,0x00000090,0x0004003d,0x00000006,0x00000091,0x0000008b,0x00050041, |
||||||
|
0x00000022,0x00000093,0x00000020,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000093, |
||||||
|
0x000500b1,0x0000001c,0x00000095,0x00000091,0x00000094,0x000400fa,0x00000095,0x0000008d, |
||||||
|
0x0000008e,0x000200f8,0x0000008d,0x0004003d,0x00000006,0x00000096,0x00000047,0x0004003d, |
||||||
|
0x00000006,0x00000097,0x00000080,0x00050041,0x00000022,0x00000099,0x00000020,0x00000098, |
||||||
|
0x0004003d,0x00000006,0x0000009a,0x00000099,0x00050084,0x00000006,0x0000009b,0x00000097, |
||||||
|
0x0000009a,0x00050080,0x00000006,0x0000009c,0x00000096,0x0000009b,0x000500af,0x0000001c, |
||||||
|
0x0000009d,0x0000009c,0x00000063,0x000300f7,0x0000009f,0x00000000,0x000400fa,0x0000009d, |
||||||
|
0x0000009e,0x0000009f,0x000200f8,0x0000009e,0x0004003d,0x00000006,0x000000a0,0x00000047, |
||||||
|
0x0004003d,0x00000006,0x000000a1,0x00000080,0x00050041,0x00000022,0x000000a2,0x00000020, |
||||||
|
0x00000098,0x0004003d,0x00000006,0x000000a3,0x000000a2,0x00050084,0x00000006,0x000000a4, |
||||||
|
0x000000a1,0x000000a3,0x00050080,0x00000006,0x000000a5,0x000000a0,0x000000a4,0x00050041, |
||||||
|
0x00000022,0x000000a6,0x00000020,0x00000063,0x0004003d,0x00000006,0x000000a7,0x000000a6, |
||||||
|
0x000500b1,0x0000001c,0x000000a8,0x000000a5,0x000000a7,0x000200f9,0x0000009f,0x000200f8, |
||||||
|
0x0000009f,0x000700f5,0x0000001c,0x000000a9,0x0000009d,0x0000008d,0x000000a8,0x0000009e, |
||||||
|
0x000300f7,0x000000ab,0x00000000,0x000400fa,0x000000a9,0x000000aa,0x000000ab,0x000200f8, |
||||||
|
0x000000aa,0x0004003d,0x00000006,0x000000ac,0x00000051,0x0004003d,0x00000006,0x000000ad, |
||||||
|
0x0000008b,0x00050041,0x00000022,0x000000af,0x00000020,0x000000ae,0x0004003d,0x00000006, |
||||||
|
0x000000b0,0x000000af,0x00050084,0x00000006,0x000000b1,0x000000ad,0x000000b0,0x00050080, |
||||||
|
0x00000006,0x000000b2,0x000000ac,0x000000b1,0x000500af,0x0000001c,0x000000b3,0x000000b2, |
||||||
|
0x00000063,0x000200f9,0x000000ab,0x000200f8,0x000000ab,0x000700f5,0x0000001c,0x000000b4, |
||||||
|
0x000000a9,0x0000009f,0x000000b3,0x000000aa,0x000300f7,0x000000b6,0x00000000,0x000400fa, |
||||||
|
0x000000b4,0x000000b5,0x000000b6,0x000200f8,0x000000b5,0x0004003d,0x00000006,0x000000b7, |
||||||
|
0x00000051,0x0004003d,0x00000006,0x000000b8,0x0000008b,0x00050041,0x00000022,0x000000b9, |
||||||
|
0x00000020,0x000000ae,0x0004003d,0x00000006,0x000000ba,0x000000b9,0x00050084,0x00000006, |
||||||
|
0x000000bb,0x000000b8,0x000000ba,0x00050080,0x00000006,0x000000bc,0x000000b7,0x000000bb, |
||||||
|
0x00050041,0x00000022,0x000000bd,0x00000020,0x00000067,0x0004003d,0x00000006,0x000000be, |
||||||
|
0x000000bd,0x000500b1,0x0000001c,0x000000bf,0x000000bc,0x000000be,0x000200f9,0x000000b6, |
||||||
|
0x000200f8,0x000000b6,0x000700f5,0x0000001c,0x000000c0,0x000000b4,0x000000ab,0x000000bf, |
||||||
|
0x000000b5,0x000300f7,0x000000c2,0x00000000,0x000400fa,0x000000c0,0x000000c1,0x000000c2, |
||||||
|
0x000200f8,0x000000c1,0x0004003d,0x00000006,0x000000c7,0x00000061,0x0004003d,0x00000006, |
||||||
|
0x000000c8,0x0000008b,0x00050041,0x00000022,0x000000c9,0x00000020,0x000000ae,0x0004003d, |
||||||
|
0x00000006,0x000000ca,0x000000c9,0x00050084,0x00000006,0x000000cb,0x000000c8,0x000000ca, |
||||||
|
0x00050080,0x00000006,0x000000cc,0x000000c7,0x000000cb,0x00060041,0x000000cd,0x000000ce, |
||||||
|
0x000000c6,0x00000063,0x000000cc,0x0004003d,0x00000038,0x000000cf,0x000000ce,0x0004003d, |
||||||
|
0x00000006,0x000000d4,0x0000005b,0x0004003d,0x00000006,0x000000d5,0x0000008b,0x00050080, |
||||||
|
0x00000006,0x000000d6,0x000000d4,0x000000d5,0x00060041,0x000000cd,0x000000d7,0x000000d3, |
||||||
|
0x00000063,0x000000d6,0x0004003d,0x00000038,0x000000d8,0x000000d7,0x00050085,0x00000038, |
||||||
|
0x000000d9,0x000000cf,0x000000d8,0x0004003d,0x00000038,0x000000da,0x0000003a,0x00050081, |
||||||
|
0x00000038,0x000000db,0x000000da,0x000000d9,0x0003003e,0x0000003a,0x000000db,0x000200f9, |
||||||
|
0x000000c2,0x000200f8,0x000000c2,0x000200f9,0x0000008f,0x000200f8,0x0000008f,0x0004003d, |
||||||
|
0x00000006,0x000000dc,0x0000008b,0x00050080,0x00000006,0x000000dd,0x000000dc,0x00000067, |
||||||
|
0x0003003e,0x0000008b,0x000000dd,0x000200f9,0x0000008c,0x000200f8,0x0000008e,0x00050041, |
||||||
|
0x00000022,0x000000de,0x00000020,0x00000067,0x0004003d,0x00000006,0x000000df,0x000000de, |
||||||
|
0x00050041,0x00000022,0x000000e0,0x00000020,0x00000098,0x0004003d,0x00000006,0x000000e1, |
||||||
|
0x000000e0,0x00050084,0x00000006,0x000000e2,0x000000df,0x000000e1,0x0004003d,0x00000006, |
||||||
|
0x000000e3,0x00000061,0x00050080,0x00000006,0x000000e4,0x000000e3,0x000000e2,0x0003003e, |
||||||
|
0x00000061,0x000000e4,0x00050041,0x00000022,0x000000e5,0x00000020,0x00000092,0x0004003d, |
||||||
|
0x00000006,0x000000e6,0x000000e5,0x0004003d,0x00000006,0x000000e7,0x0000005b,0x00050080, |
||||||
|
0x00000006,0x000000e8,0x000000e7,0x000000e6,0x0003003e,0x0000005b,0x000000e8,0x000200f9, |
||||||
|
0x00000084,0x000200f8,0x00000084,0x0004003d,0x00000006,0x000000e9,0x00000080,0x00050080, |
||||||
|
0x00000006,0x000000ea,0x000000e9,0x00000067,0x0003003e,0x00000080,0x000000ea,0x000200f9, |
||||||
|
0x00000081,0x000200f8,0x00000083,0x00050041,0x00000022,0x000000eb,0x00000020,0x00000063, |
||||||
|
0x0004003d,0x00000006,0x000000ec,0x000000eb,0x00050041,0x00000022,0x000000ed,0x00000020, |
||||||
|
0x00000067,0x0004003d,0x00000006,0x000000ee,0x000000ed,0x00050084,0x00000006,0x000000ef, |
||||||
|
0x000000ec,0x000000ee,0x00050041,0x00000022,0x000000f0,0x00000020,0x00000067,0x0004003d, |
||||||
|
0x00000006,0x000000f1,0x000000f0,0x00050041,0x00000022,0x000000f2,0x00000020,0x00000087, |
||||||
|
0x0004003d,0x00000006,0x000000f3,0x000000f2,0x00050084,0x00000006,0x000000f4,0x000000f1, |
||||||
|
0x000000f3,0x00050041,0x00000022,0x000000f5,0x00000020,0x00000098,0x0004003d,0x00000006, |
||||||
|
0x000000f6,0x000000f5,0x00050084,0x00000006,0x000000f7,0x000000f4,0x000000f6,0x00050082, |
||||||
|
0x00000006,0x000000f8,0x000000ef,0x000000f7,0x0004003d,0x00000006,0x000000f9,0x00000061, |
||||||
|
0x00050080,0x00000006,0x000000fa,0x000000f9,0x000000f8,0x0003003e,0x00000061,0x000000fa, |
||||||
|
0x000200f9,0x0000007a,0x000200f8,0x0000007a,0x0004003d,0x00000006,0x000000fb,0x00000076, |
||||||
|
0x00050080,0x00000006,0x000000fc,0x000000fb,0x00000067,0x0003003e,0x00000076,0x000000fc, |
||||||
|
0x000200f9,0x00000077,0x000200f8,0x00000079,0x0004003d,0x00000006,0x000000fe,0x00000017, |
||||||
|
0x00050041,0x00000022,0x000000ff,0x00000020,0x00000021,0x0004003d,0x00000006,0x00000100, |
||||||
|
0x000000ff,0x00050084,0x00000006,0x00000101,0x000000fe,0x00000100,0x00050041,0x00000022, |
||||||
|
0x00000102,0x00000020,0x00000029,0x0004003d,0x00000006,0x00000103,0x00000102,0x00050084, |
||||||
|
0x00000006,0x00000104,0x00000101,0x00000103,0x0004003d,0x00000006,0x00000105,0x00000008, |
||||||
|
0x00050080,0x00000006,0x00000106,0x00000104,0x00000105,0x0004003d,0x00000006,0x00000107, |
||||||
|
0x00000012,0x00050041,0x00000022,0x00000108,0x00000020,0x00000021,0x0004003d,0x00000006, |
||||||
|
0x00000109,0x00000108,0x00050084,0x00000006,0x0000010a,0x00000107,0x00000109,0x00050080, |
||||||
|
0x00000006,0x0000010b,0x00000106,0x0000010a,0x0003003e,0x000000fd,0x0000010b,0x00050041, |
||||||
|
0x00000022,0x0000010d,0x00000020,0x0000010c,0x0004003d,0x00000006,0x0000010e,0x0000010d, |
||||||
|
0x000500aa,0x0000001c,0x0000010f,0x0000010e,0x00000067,0x000300f7,0x00000111,0x00000000, |
||||||
|
0x000400fa,0x0000010f,0x00000110,0x00000111,0x000200f8,0x00000110,0x0004003d,0x00000006, |
||||||
|
0x00000116,0x00000012,0x00060041,0x000000cd,0x00000117,0x00000115,0x00000063,0x00000116, |
||||||
|
0x0004003d,0x00000038,0x00000118,0x00000117,0x0004003d,0x00000038,0x00000119,0x0000003a, |
||||||
|
0x00050081,0x00000038,0x0000011a,0x00000119,0x00000118,0x0003003e,0x0000003a,0x0000011a, |
||||||
|
0x000200f9,0x00000111,0x000200f8,0x00000111,0x0004003d,0x00000006,0x0000011f,0x000000fd, |
||||||
|
0x0004003d,0x00000038,0x00000120,0x0000003a,0x00060041,0x000000cd,0x00000121,0x0000011e, |
||||||
|
0x00000063,0x0000011f,0x0003003e,0x00000121,0x00000120,0x000200f9,0x00000037,0x000200f8, |
||||||
|
0x00000037,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,74 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int in_h; |
||||||
|
int in_w; |
||||||
|
int out_h; |
||||||
|
int out_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int pad_h; |
||||||
|
int pad_w; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int dilation_h; |
||||||
|
int dilation_w; |
||||||
|
int channels; |
||||||
|
int batch; |
||||||
|
int has_bias; |
||||||
|
int M; |
||||||
|
int K; |
||||||
|
int N; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
layout(binding = 1) readonly buffer Input1 { |
||||||
|
float bias_data[]; |
||||||
|
}; |
||||||
|
layout(binding = 2) readonly buffer Input3{ |
||||||
|
float weight_data[]; |
||||||
|
}; |
||||||
|
layout(binding = 3) writeonly buffer Output{ |
||||||
|
float out_buffer[]; |
||||||
|
}; |
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
/* |
||||||
|
Each work item compute batch * multiplier output cell along the output depth dimension and batch |
||||||
|
*/ |
||||||
|
void main() |
||||||
|
{ |
||||||
|
int gx = int(gl_GlobalInvocationID.x); |
||||||
|
int gy = int(gl_GlobalInvocationID.y); |
||||||
|
int gz = int(gl_GlobalInvocationID.z); |
||||||
|
if(gx < p.out_w && gy < p.out_h && gz < p.channels) |
||||||
|
{ |
||||||
|
float sum = 0.0f; |
||||||
|
|
||||||
|
int org_y = gy * p.stride_h - p.pad_h; |
||||||
|
int org_x = gx * p.stride_w - p.pad_w; |
||||||
|
|
||||||
|
int weight_off = gz * p.filter_h * p.filter_w; |
||||||
|
int input_off = gz * p.in_h * p.in_w + org_y * p.in_w + org_x; |
||||||
|
for(int y = 0; y < p.filter_h; y++) |
||||||
|
{ |
||||||
|
for(int x = 0; x < p.filter_w; x++) |
||||||
|
{ |
||||||
|
if(org_y + y * p.dilation_h >= 0 && org_y + y * p.dilation_h < p.in_h && org_x + x * p.dilation_w >= 0 && org_x + x * p.dilation_w < p.in_w) |
||||||
|
{ |
||||||
|
sum += in_buffer[input_off + x * p.dilation_w] * weight_data[weight_off + x]; |
||||||
|
} |
||||||
|
} |
||||||
|
weight_off += p.filter_w; |
||||||
|
input_off += p.in_w * p.dilation_h; |
||||||
|
} |
||||||
|
|
||||||
|
int offset = gz * p.out_h * p.out_w + gy * p.out_w + gx; |
||||||
|
if (p.has_bias == 1) |
||||||
|
out_buffer[offset] = sum + bias_data[gz]; |
||||||
|
else |
||||||
|
out_buffer[offset] = sum; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,222 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int dw_conv_spv[1655] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x000000fe,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00007867,0x00080005,0x0000000c, |
||||||
|
0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000012, |
||||||
|
0x00007967,0x00030005,0x00000017,0x00007a67,0x00050005,0x0000001e,0x68737570,0x636f6c42, |
||||||
|
0x0000006b,0x00050006,0x0000001e,0x00000000,0x685f6e69,0x00000000,0x00050006,0x0000001e, |
||||||
|
0x00000001,0x775f6e69,0x00000000,0x00050006,0x0000001e,0x00000002,0x5f74756f,0x00000068, |
||||||
|
0x00050006,0x0000001e,0x00000003,0x5f74756f,0x00000077,0x00060006,0x0000001e,0x00000004, |
||||||
|
0x69727473,0x685f6564,0x00000000,0x00060006,0x0000001e,0x00000005,0x69727473,0x775f6564, |
||||||
|
0x00000000,0x00050006,0x0000001e,0x00000006,0x5f646170,0x00000068,0x00050006,0x0000001e, |
||||||
|
0x00000007,0x5f646170,0x00000077,0x00060006,0x0000001e,0x00000008,0x746c6966,0x685f7265, |
||||||
|
0x00000000,0x00060006,0x0000001e,0x00000009,0x746c6966,0x775f7265,0x00000000,0x00060006, |
||||||
|
0x0000001e,0x0000000a,0x616c6964,0x6e6f6974,0x0000685f,0x00060006,0x0000001e,0x0000000b, |
||||||
|
0x616c6964,0x6e6f6974,0x0000775f,0x00060006,0x0000001e,0x0000000c,0x6e616863,0x736c656e, |
||||||
|
0x00000000,0x00050006,0x0000001e,0x0000000d,0x63746162,0x00000068,0x00060006,0x0000001e, |
||||||
|
0x0000000e,0x5f736168,0x73616962,0x00000000,0x00040006,0x0000001e,0x0000000f,0x0000004d, |
||||||
|
0x00040006,0x0000001e,0x00000010,0x0000004b,0x00040006,0x0000001e,0x00000011,0x0000004e, |
||||||
|
0x00030005,0x00000020,0x00000070,0x00030005,0x0000003a,0x006d7573,0x00040005,0x0000003c, |
||||||
|
0x5f67726f,0x00000079,0x00040005,0x00000046,0x5f67726f,0x00000078,0x00050005,0x00000050, |
||||||
|
0x67696577,0x6f5f7468,0x00006666,0x00050005,0x0000005a,0x75706e69,0x666f5f74,0x00000066, |
||||||
|
0x00030005,0x0000006b,0x00000079,0x00030005,0x00000075,0x00000078,0x00040005,0x000000ad, |
||||||
|
0x75706e49,0x00003074,0x00060006,0x000000ad,0x00000000,0x625f6e69,0x65666675,0x00000072, |
||||||
|
0x00030005,0x000000af,0x00000000,0x00040005,0x000000ba,0x75706e49,0x00003374,0x00060006, |
||||||
|
0x000000ba,0x00000000,0x67696577,0x645f7468,0x00617461,0x00030005,0x000000bc,0x00000000, |
||||||
|
0x00040005,0x000000d4,0x7366666f,0x00007465,0x00040005,0x000000ea,0x7074754f,0x00007475, |
||||||
|
0x00060006,0x000000ea,0x00000000,0x5f74756f,0x66667562,0x00007265,0x00030005,0x000000ec, |
||||||
|
0x00000000,0x00040005,0x000000f0,0x75706e49,0x00003174,0x00060006,0x000000f0,0x00000000, |
||||||
|
0x73616962,0x7461645f,0x00000061,0x00030005,0x000000f2,0x00000000,0x00040047,0x0000000c, |
||||||
|
0x0000000b,0x0000001c,0x00050048,0x0000001e,0x00000000,0x00000023,0x00000000,0x00050048, |
||||||
|
0x0000001e,0x00000001,0x00000023,0x00000004,0x00050048,0x0000001e,0x00000002,0x00000023, |
||||||
|
0x00000008,0x00050048,0x0000001e,0x00000003,0x00000023,0x0000000c,0x00050048,0x0000001e, |
||||||
|
0x00000004,0x00000023,0x00000010,0x00050048,0x0000001e,0x00000005,0x00000023,0x00000014, |
||||||
|
0x00050048,0x0000001e,0x00000006,0x00000023,0x00000018,0x00050048,0x0000001e,0x00000007, |
||||||
|
0x00000023,0x0000001c,0x00050048,0x0000001e,0x00000008,0x00000023,0x00000020,0x00050048, |
||||||
|
0x0000001e,0x00000009,0x00000023,0x00000024,0x00050048,0x0000001e,0x0000000a,0x00000023, |
||||||
|
0x00000028,0x00050048,0x0000001e,0x0000000b,0x00000023,0x0000002c,0x00050048,0x0000001e, |
||||||
|
0x0000000c,0x00000023,0x00000030,0x00050048,0x0000001e,0x0000000d,0x00000023,0x00000034, |
||||||
|
0x00050048,0x0000001e,0x0000000e,0x00000023,0x00000038,0x00050048,0x0000001e,0x0000000f, |
||||||
|
0x00000023,0x0000003c,0x00050048,0x0000001e,0x00000010,0x00000023,0x00000040,0x00050048, |
||||||
|
0x0000001e,0x00000011,0x00000023,0x00000044,0x00030047,0x0000001e,0x00000002,0x00040047, |
||||||
|
0x000000ac,0x00000006,0x00000004,0x00040048,0x000000ad,0x00000000,0x00000018,0x00050048, |
||||||
|
0x000000ad,0x00000000,0x00000023,0x00000000,0x00030047,0x000000ad,0x00000003,0x00040047, |
||||||
|
0x000000af,0x00000022,0x00000000,0x00040047,0x000000af,0x00000021,0x00000000,0x00040047, |
||||||
|
0x000000b9,0x00000006,0x00000004,0x00040048,0x000000ba,0x00000000,0x00000018,0x00050048, |
||||||
|
0x000000ba,0x00000000,0x00000023,0x00000000,0x00030047,0x000000ba,0x00000003,0x00040047, |
||||||
|
0x000000bc,0x00000022,0x00000000,0x00040047,0x000000bc,0x00000021,0x00000002,0x00040047, |
||||||
|
0x000000e9,0x00000006,0x00000004,0x00040048,0x000000ea,0x00000000,0x00000019,0x00050048, |
||||||
|
0x000000ea,0x00000000,0x00000023,0x00000000,0x00030047,0x000000ea,0x00000003,0x00040047, |
||||||
|
0x000000ec,0x00000022,0x00000000,0x00040047,0x000000ec,0x00000021,0x00000003,0x00040047, |
||||||
|
0x000000ef,0x00000006,0x00000004,0x00040048,0x000000f0,0x00000000,0x00000018,0x00050048, |
||||||
|
0x000000f0,0x00000000,0x00000023,0x00000000,0x00030047,0x000000f0,0x00000003,0x00040047, |
||||||
|
0x000000f2,0x00000022,0x00000000,0x00040047,0x000000f2,0x00000021,0x00000001,0x00040047, |
||||||
|
0x000000fd,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, |
||||||
|
0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007,0x00000006, |
||||||
|
0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009,0x00000003, |
||||||
|
0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000001, |
||||||
|
0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000009, |
||||||
|
0x0004002b,0x00000009,0x00000013,0x00000001,0x0004002b,0x00000009,0x00000018,0x00000002, |
||||||
|
0x00020014,0x0000001c,0x0014001e,0x0000001e,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020,0x0000001f, |
||||||
|
0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x0004002b,0x00000006, |
||||||
|
0x00000021,0x00000003,0x00040020,0x00000022,0x00000009,0x00000006,0x0004002b,0x00000006, |
||||||
|
0x00000029,0x00000002,0x0004002b,0x00000006,0x00000031,0x0000000c,0x00030016,0x00000038, |
||||||
|
0x00000020,0x00040020,0x00000039,0x00000007,0x00000038,0x0004002b,0x00000038,0x0000003b, |
||||||
|
0x00000000,0x0004002b,0x00000006,0x0000003e,0x00000004,0x0004002b,0x00000006,0x00000042, |
||||||
|
0x00000006,0x0004002b,0x00000006,0x00000048,0x00000005,0x0004002b,0x00000006,0x0000004c, |
||||||
|
0x00000007,0x0004002b,0x00000006,0x00000052,0x00000008,0x0004002b,0x00000006,0x00000056, |
||||||
|
0x00000009,0x0004002b,0x00000006,0x0000005c,0x00000000,0x0004002b,0x00000006,0x00000060, |
||||||
|
0x00000001,0x0004002b,0x00000006,0x00000081,0x0000000a,0x0004002b,0x00000006,0x00000097, |
||||||
|
0x0000000b,0x0003001d,0x000000ac,0x00000038,0x0003001e,0x000000ad,0x000000ac,0x00040020, |
||||||
|
0x000000ae,0x00000002,0x000000ad,0x0004003b,0x000000ae,0x000000af,0x00000002,0x00040020, |
||||||
|
0x000000b6,0x00000002,0x00000038,0x0003001d,0x000000b9,0x00000038,0x0003001e,0x000000ba, |
||||||
|
0x000000b9,0x00040020,0x000000bb,0x00000002,0x000000ba,0x0004003b,0x000000bb,0x000000bc, |
||||||
|
0x00000002,0x0004002b,0x00000006,0x000000e3,0x0000000e,0x0003001d,0x000000e9,0x00000038, |
||||||
|
0x0003001e,0x000000ea,0x000000e9,0x00040020,0x000000eb,0x00000002,0x000000ea,0x0004003b, |
||||||
|
0x000000eb,0x000000ec,0x00000002,0x0003001d,0x000000ef,0x00000038,0x0003001e,0x000000f0, |
||||||
|
0x000000ef,0x00040020,0x000000f1,0x00000002,0x000000f0,0x0004003b,0x000000f1,0x000000f2, |
||||||
|
0x00000002,0x0004002b,0x00000009,0x000000fc,0x00000100,0x0006002c,0x0000000a,0x000000fd, |
||||||
|
0x000000fc,0x00000013,0x00000013,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003, |
||||||
|
0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000012,0x00000007,0x0004003b,0x00000007,0x00000017,0x00000007,0x0004003b,0x00000039, |
||||||
|
0x0000003a,0x00000007,0x0004003b,0x00000007,0x0000003c,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000046,0x00000007,0x0004003b,0x00000007,0x00000050,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000005a,0x00000007,0x0004003b,0x00000007,0x0000006b,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000075,0x00000007,0x0004003b,0x00000007,0x000000d4,0x00000007,0x00050041,0x0000000e, |
||||||
|
0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010,0x0000000f,0x0004007c, |
||||||
|
0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011,0x00050041,0x0000000e, |
||||||
|
0x00000014,0x0000000c,0x00000013,0x0004003d,0x00000009,0x00000015,0x00000014,0x0004007c, |
||||||
|
0x00000006,0x00000016,0x00000015,0x0003003e,0x00000012,0x00000016,0x00050041,0x0000000e, |
||||||
|
0x00000019,0x0000000c,0x00000018,0x0004003d,0x00000009,0x0000001a,0x00000019,0x0004007c, |
||||||
|
0x00000006,0x0000001b,0x0000001a,0x0003003e,0x00000017,0x0000001b,0x0004003d,0x00000006, |
||||||
|
0x0000001d,0x00000008,0x00050041,0x00000022,0x00000023,0x00000020,0x00000021,0x0004003d, |
||||||
|
0x00000006,0x00000024,0x00000023,0x000500b1,0x0000001c,0x00000025,0x0000001d,0x00000024, |
||||||
|
0x000300f7,0x00000027,0x00000000,0x000400fa,0x00000025,0x00000026,0x00000027,0x000200f8, |
||||||
|
0x00000026,0x0004003d,0x00000006,0x00000028,0x00000012,0x00050041,0x00000022,0x0000002a, |
||||||
|
0x00000020,0x00000029,0x0004003d,0x00000006,0x0000002b,0x0000002a,0x000500b1,0x0000001c, |
||||||
|
0x0000002c,0x00000028,0x0000002b,0x000200f9,0x00000027,0x000200f8,0x00000027,0x000700f5, |
||||||
|
0x0000001c,0x0000002d,0x00000025,0x00000005,0x0000002c,0x00000026,0x000300f7,0x0000002f, |
||||||
|
0x00000000,0x000400fa,0x0000002d,0x0000002e,0x0000002f,0x000200f8,0x0000002e,0x0004003d, |
||||||
|
0x00000006,0x00000030,0x00000017,0x00050041,0x00000022,0x00000032,0x00000020,0x00000031, |
||||||
|
0x0004003d,0x00000006,0x00000033,0x00000032,0x000500b1,0x0000001c,0x00000034,0x00000030, |
||||||
|
0x00000033,0x000200f9,0x0000002f,0x000200f8,0x0000002f,0x000700f5,0x0000001c,0x00000035, |
||||||
|
0x0000002d,0x00000027,0x00000034,0x0000002e,0x000300f7,0x00000037,0x00000000,0x000400fa, |
||||||
|
0x00000035,0x00000036,0x00000037,0x000200f8,0x00000036,0x0003003e,0x0000003a,0x0000003b, |
||||||
|
0x0004003d,0x00000006,0x0000003d,0x00000012,0x00050041,0x00000022,0x0000003f,0x00000020, |
||||||
|
0x0000003e,0x0004003d,0x00000006,0x00000040,0x0000003f,0x00050084,0x00000006,0x00000041, |
||||||
|
0x0000003d,0x00000040,0x00050041,0x00000022,0x00000043,0x00000020,0x00000042,0x0004003d, |
||||||
|
0x00000006,0x00000044,0x00000043,0x00050082,0x00000006,0x00000045,0x00000041,0x00000044, |
||||||
|
0x0003003e,0x0000003c,0x00000045,0x0004003d,0x00000006,0x00000047,0x00000008,0x00050041, |
||||||
|
0x00000022,0x00000049,0x00000020,0x00000048,0x0004003d,0x00000006,0x0000004a,0x00000049, |
||||||
|
0x00050084,0x00000006,0x0000004b,0x00000047,0x0000004a,0x00050041,0x00000022,0x0000004d, |
||||||
|
0x00000020,0x0000004c,0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050082,0x00000006, |
||||||
|
0x0000004f,0x0000004b,0x0000004e,0x0003003e,0x00000046,0x0000004f,0x0004003d,0x00000006, |
||||||
|
0x00000051,0x00000017,0x00050041,0x00000022,0x00000053,0x00000020,0x00000052,0x0004003d, |
||||||
|
0x00000006,0x00000054,0x00000053,0x00050084,0x00000006,0x00000055,0x00000051,0x00000054, |
||||||
|
0x00050041,0x00000022,0x00000057,0x00000020,0x00000056,0x0004003d,0x00000006,0x00000058, |
||||||
|
0x00000057,0x00050084,0x00000006,0x00000059,0x00000055,0x00000058,0x0003003e,0x00000050, |
||||||
|
0x00000059,0x0004003d,0x00000006,0x0000005b,0x00000017,0x00050041,0x00000022,0x0000005d, |
||||||
|
0x00000020,0x0000005c,0x0004003d,0x00000006,0x0000005e,0x0000005d,0x00050084,0x00000006, |
||||||
|
0x0000005f,0x0000005b,0x0000005e,0x00050041,0x00000022,0x00000061,0x00000020,0x00000060, |
||||||
|
0x0004003d,0x00000006,0x00000062,0x00000061,0x00050084,0x00000006,0x00000063,0x0000005f, |
||||||
|
0x00000062,0x0004003d,0x00000006,0x00000064,0x0000003c,0x00050041,0x00000022,0x00000065, |
||||||
|
0x00000020,0x00000060,0x0004003d,0x00000006,0x00000066,0x00000065,0x00050084,0x00000006, |
||||||
|
0x00000067,0x00000064,0x00000066,0x00050080,0x00000006,0x00000068,0x00000063,0x00000067, |
||||||
|
0x0004003d,0x00000006,0x00000069,0x00000046,0x00050080,0x00000006,0x0000006a,0x00000068, |
||||||
|
0x00000069,0x0003003e,0x0000005a,0x0000006a,0x0003003e,0x0000006b,0x0000005c,0x000200f9, |
||||||
|
0x0000006c,0x000200f8,0x0000006c,0x000400f6,0x0000006e,0x0000006f,0x00000000,0x000200f9, |
||||||
|
0x00000070,0x000200f8,0x00000070,0x0004003d,0x00000006,0x00000071,0x0000006b,0x00050041, |
||||||
|
0x00000022,0x00000072,0x00000020,0x00000052,0x0004003d,0x00000006,0x00000073,0x00000072, |
||||||
|
0x000500b1,0x0000001c,0x00000074,0x00000071,0x00000073,0x000400fa,0x00000074,0x0000006d, |
||||||
|
0x0000006e,0x000200f8,0x0000006d,0x0003003e,0x00000075,0x0000005c,0x000200f9,0x00000076, |
||||||
|
0x000200f8,0x00000076,0x000400f6,0x00000078,0x00000079,0x00000000,0x000200f9,0x0000007a, |
||||||
|
0x000200f8,0x0000007a,0x0004003d,0x00000006,0x0000007b,0x00000075,0x00050041,0x00000022, |
||||||
|
0x0000007c,0x00000020,0x00000056,0x0004003d,0x00000006,0x0000007d,0x0000007c,0x000500b1, |
||||||
|
0x0000001c,0x0000007e,0x0000007b,0x0000007d,0x000400fa,0x0000007e,0x00000077,0x00000078, |
||||||
|
0x000200f8,0x00000077,0x0004003d,0x00000006,0x0000007f,0x0000003c,0x0004003d,0x00000006, |
||||||
|
0x00000080,0x0000006b,0x00050041,0x00000022,0x00000082,0x00000020,0x00000081,0x0004003d, |
||||||
|
0x00000006,0x00000083,0x00000082,0x00050084,0x00000006,0x00000084,0x00000080,0x00000083, |
||||||
|
0x00050080,0x00000006,0x00000085,0x0000007f,0x00000084,0x000500af,0x0000001c,0x00000086, |
||||||
|
0x00000085,0x0000005c,0x000300f7,0x00000088,0x00000000,0x000400fa,0x00000086,0x00000087, |
||||||
|
0x00000088,0x000200f8,0x00000087,0x0004003d,0x00000006,0x00000089,0x0000003c,0x0004003d, |
||||||
|
0x00000006,0x0000008a,0x0000006b,0x00050041,0x00000022,0x0000008b,0x00000020,0x00000081, |
||||||
|
0x0004003d,0x00000006,0x0000008c,0x0000008b,0x00050084,0x00000006,0x0000008d,0x0000008a, |
||||||
|
0x0000008c,0x00050080,0x00000006,0x0000008e,0x00000089,0x0000008d,0x00050041,0x00000022, |
||||||
|
0x0000008f,0x00000020,0x0000005c,0x0004003d,0x00000006,0x00000090,0x0000008f,0x000500b1, |
||||||
|
0x0000001c,0x00000091,0x0000008e,0x00000090,0x000200f9,0x00000088,0x000200f8,0x00000088, |
||||||
|
0x000700f5,0x0000001c,0x00000092,0x00000086,0x00000077,0x00000091,0x00000087,0x000300f7, |
||||||
|
0x00000094,0x00000000,0x000400fa,0x00000092,0x00000093,0x00000094,0x000200f8,0x00000093, |
||||||
|
0x0004003d,0x00000006,0x00000095,0x00000046,0x0004003d,0x00000006,0x00000096,0x00000075, |
||||||
|
0x00050041,0x00000022,0x00000098,0x00000020,0x00000097,0x0004003d,0x00000006,0x00000099, |
||||||
|
0x00000098,0x00050084,0x00000006,0x0000009a,0x00000096,0x00000099,0x00050080,0x00000006, |
||||||
|
0x0000009b,0x00000095,0x0000009a,0x000500af,0x0000001c,0x0000009c,0x0000009b,0x0000005c, |
||||||
|
0x000200f9,0x00000094,0x000200f8,0x00000094,0x000700f5,0x0000001c,0x0000009d,0x00000092, |
||||||
|
0x00000088,0x0000009c,0x00000093,0x000300f7,0x0000009f,0x00000000,0x000400fa,0x0000009d, |
||||||
|
0x0000009e,0x0000009f,0x000200f8,0x0000009e,0x0004003d,0x00000006,0x000000a0,0x00000046, |
||||||
|
0x0004003d,0x00000006,0x000000a1,0x00000075,0x00050041,0x00000022,0x000000a2,0x00000020, |
||||||
|
0x00000097,0x0004003d,0x00000006,0x000000a3,0x000000a2,0x00050084,0x00000006,0x000000a4, |
||||||
|
0x000000a1,0x000000a3,0x00050080,0x00000006,0x000000a5,0x000000a0,0x000000a4,0x00050041, |
||||||
|
0x00000022,0x000000a6,0x00000020,0x00000060,0x0004003d,0x00000006,0x000000a7,0x000000a6, |
||||||
|
0x000500b1,0x0000001c,0x000000a8,0x000000a5,0x000000a7,0x000200f9,0x0000009f,0x000200f8, |
||||||
|
0x0000009f,0x000700f5,0x0000001c,0x000000a9,0x0000009d,0x00000094,0x000000a8,0x0000009e, |
||||||
|
0x000300f7,0x000000ab,0x00000000,0x000400fa,0x000000a9,0x000000aa,0x000000ab,0x000200f8, |
||||||
|
0x000000aa,0x0004003d,0x00000006,0x000000b0,0x0000005a,0x0004003d,0x00000006,0x000000b1, |
||||||
|
0x00000075,0x00050041,0x00000022,0x000000b2,0x00000020,0x00000097,0x0004003d,0x00000006, |
||||||
|
0x000000b3,0x000000b2,0x00050084,0x00000006,0x000000b4,0x000000b1,0x000000b3,0x00050080, |
||||||
|
0x00000006,0x000000b5,0x000000b0,0x000000b4,0x00060041,0x000000b6,0x000000b7,0x000000af, |
||||||
|
0x0000005c,0x000000b5,0x0004003d,0x00000038,0x000000b8,0x000000b7,0x0004003d,0x00000006, |
||||||
|
0x000000bd,0x00000050,0x0004003d,0x00000006,0x000000be,0x00000075,0x00050080,0x00000006, |
||||||
|
0x000000bf,0x000000bd,0x000000be,0x00060041,0x000000b6,0x000000c0,0x000000bc,0x0000005c, |
||||||
|
0x000000bf,0x0004003d,0x00000038,0x000000c1,0x000000c0,0x00050085,0x00000038,0x000000c2, |
||||||
|
0x000000b8,0x000000c1,0x0004003d,0x00000038,0x000000c3,0x0000003a,0x00050081,0x00000038, |
||||||
|
0x000000c4,0x000000c3,0x000000c2,0x0003003e,0x0000003a,0x000000c4,0x000200f9,0x000000ab, |
||||||
|
0x000200f8,0x000000ab,0x000200f9,0x00000079,0x000200f8,0x00000079,0x0004003d,0x00000006, |
||||||
|
0x000000c5,0x00000075,0x00050080,0x00000006,0x000000c6,0x000000c5,0x00000060,0x0003003e, |
||||||
|
0x00000075,0x000000c6,0x000200f9,0x00000076,0x000200f8,0x00000078,0x00050041,0x00000022, |
||||||
|
0x000000c7,0x00000020,0x00000056,0x0004003d,0x00000006,0x000000c8,0x000000c7,0x0004003d, |
||||||
|
0x00000006,0x000000c9,0x00000050,0x00050080,0x00000006,0x000000ca,0x000000c9,0x000000c8, |
||||||
|
0x0003003e,0x00000050,0x000000ca,0x00050041,0x00000022,0x000000cb,0x00000020,0x00000060, |
||||||
|
0x0004003d,0x00000006,0x000000cc,0x000000cb,0x00050041,0x00000022,0x000000cd,0x00000020, |
||||||
|
0x00000081,0x0004003d,0x00000006,0x000000ce,0x000000cd,0x00050084,0x00000006,0x000000cf, |
||||||
|
0x000000cc,0x000000ce,0x0004003d,0x00000006,0x000000d0,0x0000005a,0x00050080,0x00000006, |
||||||
|
0x000000d1,0x000000d0,0x000000cf,0x0003003e,0x0000005a,0x000000d1,0x000200f9,0x0000006f, |
||||||
|
0x000200f8,0x0000006f,0x0004003d,0x00000006,0x000000d2,0x0000006b,0x00050080,0x00000006, |
||||||
|
0x000000d3,0x000000d2,0x00000060,0x0003003e,0x0000006b,0x000000d3,0x000200f9,0x0000006c, |
||||||
|
0x000200f8,0x0000006e,0x0004003d,0x00000006,0x000000d5,0x00000017,0x00050041,0x00000022, |
||||||
|
0x000000d6,0x00000020,0x00000029,0x0004003d,0x00000006,0x000000d7,0x000000d6,0x00050084, |
||||||
|
0x00000006,0x000000d8,0x000000d5,0x000000d7,0x00050041,0x00000022,0x000000d9,0x00000020, |
||||||
|
0x00000021,0x0004003d,0x00000006,0x000000da,0x000000d9,0x00050084,0x00000006,0x000000db, |
||||||
|
0x000000d8,0x000000da,0x0004003d,0x00000006,0x000000dc,0x00000012,0x00050041,0x00000022, |
||||||
|
0x000000dd,0x00000020,0x00000021,0x0004003d,0x00000006,0x000000de,0x000000dd,0x00050084, |
||||||
|
0x00000006,0x000000df,0x000000dc,0x000000de,0x00050080,0x00000006,0x000000e0,0x000000db, |
||||||
|
0x000000df,0x0004003d,0x00000006,0x000000e1,0x00000008,0x00050080,0x00000006,0x000000e2, |
||||||
|
0x000000e0,0x000000e1,0x0003003e,0x000000d4,0x000000e2,0x00050041,0x00000022,0x000000e4, |
||||||
|
0x00000020,0x000000e3,0x0004003d,0x00000006,0x000000e5,0x000000e4,0x000500aa,0x0000001c, |
||||||
|
0x000000e6,0x000000e5,0x00000060,0x000300f7,0x000000e8,0x00000000,0x000400fa,0x000000e6, |
||||||
|
0x000000e7,0x000000f8,0x000200f8,0x000000e7,0x0004003d,0x00000006,0x000000ed,0x000000d4, |
||||||
|
0x0004003d,0x00000038,0x000000ee,0x0000003a,0x0004003d,0x00000006,0x000000f3,0x00000017, |
||||||
|
0x00060041,0x000000b6,0x000000f4,0x000000f2,0x0000005c,0x000000f3,0x0004003d,0x00000038, |
||||||
|
0x000000f5,0x000000f4,0x00050081,0x00000038,0x000000f6,0x000000ee,0x000000f5,0x00060041, |
||||||
|
0x000000b6,0x000000f7,0x000000ec,0x0000005c,0x000000ed,0x0003003e,0x000000f7,0x000000f6, |
||||||
|
0x000200f9,0x000000e8,0x000200f8,0x000000f8,0x0004003d,0x00000006,0x000000f9,0x000000d4, |
||||||
|
0x0004003d,0x00000038,0x000000fa,0x0000003a,0x00060041,0x000000b6,0x000000fb,0x000000ec, |
||||||
|
0x0000005c,0x000000f9,0x0003003e,0x000000fb,0x000000fa,0x000200f9,0x000000e8,0x000200f8, |
||||||
|
0x000000e8,0x000200f9,0x00000037,0x000200f8,0x00000037,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,63 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int thread_num; |
||||||
|
int channels; |
||||||
|
int height; |
||||||
|
int width; |
||||||
|
int filter_len; |
||||||
|
int radius; |
||||||
|
float alpha; |
||||||
|
float bias; |
||||||
|
float negative_beta; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
layout(binding = 1) writeonly buffer Output{ |
||||||
|
float dst_buffer[]; |
||||||
|
}; |
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
void main() |
||||||
|
{ |
||||||
|
int gid = int(gl_GlobalInvocationID.x); |
||||||
|
int gsz = int(gl_NumWorkGroups.x * gl_WorkGroupSize.x); |
||||||
|
for (int index = gid; index < p.thread_num; index += gsz) |
||||||
|
{ |
||||||
|
int x = index % p.width; |
||||||
|
int y = (index / p.width) % p.height; |
||||||
|
int b = index / (p.width * p.height); |
||||||
|
int offset = b * p.channels * p.height * p.width + y * p.width + x; |
||||||
|
int channel_off = p.height * p.width; |
||||||
|
float scale_val; |
||||||
|
int head = 0; |
||||||
|
float accum_scale = 0.0f; |
||||||
|
int min_val = p.radius < p.channels ? p.radius : p.channels; |
||||||
|
while (head < min_val) { |
||||||
|
accum_scale += in_buffer[offset + head * channel_off] * in_buffer[offset + head * channel_off]; |
||||||
|
++head; |
||||||
|
} |
||||||
|
while (head < p.channels) { |
||||||
|
accum_scale += in_buffer[offset + head * channel_off] * in_buffer[offset + head * channel_off]; |
||||||
|
if (head - p.filter_len >= 0) { |
||||||
|
accum_scale -= in_buffer[offset + (head - p.filter_len) * channel_off] |
||||||
|
* in_buffer[offset + (head - p.filter_len) * channel_off]; |
||||||
|
} |
||||||
|
scale_val = p.bias + accum_scale * p.alpha; |
||||||
|
dst_buffer[offset + (head - p.radius) * channel_off] = in_buffer[offset + (head - p.radius) * channel_off] * pow(scale_val, p.negative_beta); |
||||||
|
++head; |
||||||
|
} |
||||||
|
int pos = head - min_val; |
||||||
|
while (pos >= 0 && pos < p.channels) { |
||||||
|
if (head - p.filter_len >= 0) { |
||||||
|
accum_scale -= in_buffer[offset + (head - p.filter_len) * channel_off] |
||||||
|
* in_buffer[offset + (head - p.filter_len) * channel_off]; |
||||||
|
} |
||||||
|
scale_val = p.bias + accum_scale * p.alpha; |
||||||
|
dst_buffer[offset + pos * channel_off] = in_buffer[offset + pos * channel_off] * pow(scale_val, p.negative_beta); |
||||||
|
++head; |
||||||
|
++pos; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,246 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int lrn_spv[1845] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x00000144,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0007000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00000013,0x00060010, |
||||||
|
0x00000004,0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2, |
||||||
|
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00646967,0x00080005, |
||||||
|
0x0000000c,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005, |
||||||
|
0x00000012,0x007a7367,0x00070005,0x00000013,0x4e5f6c67,0x6f576d75,0x72476b72,0x7370756f, |
||||||
|
0x00000000,0x00040005,0x00000019,0x65646e69,0x00000078,0x00050005,0x00000022,0x68737570, |
||||||
|
0x636f6c42,0x0000006b,0x00060006,0x00000022,0x00000000,0x65726874,0x6e5f6461,0x00006d75, |
||||||
|
0x00060006,0x00000022,0x00000001,0x6e616863,0x736c656e,0x00000000,0x00050006,0x00000022, |
||||||
|
0x00000002,0x67696568,0x00007468,0x00050006,0x00000022,0x00000003,0x74646977,0x00000068, |
||||||
|
0x00060006,0x00000022,0x00000004,0x746c6966,0x6c5f7265,0x00006e65,0x00050006,0x00000022, |
||||||
|
0x00000005,0x69646172,0x00007375,0x00050006,0x00000022,0x00000006,0x68706c61,0x00000061, |
||||||
|
0x00050006,0x00000022,0x00000007,0x73616962,0x00000000,0x00070006,0x00000022,0x00000008, |
||||||
|
0x6167656e,0x65766974,0x7465625f,0x00000061,0x00030005,0x00000024,0x00000070,0x00030005, |
||||||
|
0x0000002b,0x00000078,0x00030005,0x00000031,0x00000079,0x00030005,0x0000003a,0x00000062, |
||||||
|
0x00040005,0x00000042,0x7366666f,0x00007465,0x00050005,0x00000055,0x6e616863,0x5f6c656e, |
||||||
|
0x0066666f,0x00040005,0x0000005b,0x64616568,0x00000000,0x00050005,0x0000005d,0x75636361, |
||||||
|
0x63735f6d,0x00656c61,0x00040005,0x0000005f,0x5f6e696d,0x006c6176,0x00040005,0x00000078, |
||||||
|
0x75706e49,0x00003074,0x00060006,0x00000078,0x00000000,0x625f6e69,0x65666675,0x00000072, |
||||||
|
0x00030005,0x0000007a,0x00000000,0x00050005,0x000000c8,0x6c616373,0x61765f65,0x0000006c, |
||||||
|
0x00040005,0x000000d4,0x7074754f,0x00007475,0x00060006,0x000000d4,0x00000000,0x5f747364, |
||||||
|
0x66667562,0x00007265,0x00030005,0x000000d6,0x00000000,0x00030005,0x000000f2,0x00736f70, |
||||||
|
0x00040047,0x0000000c,0x0000000b,0x0000001c,0x00040047,0x00000013,0x0000000b,0x00000018, |
||||||
|
0x00050048,0x00000022,0x00000000,0x00000023,0x00000000,0x00050048,0x00000022,0x00000001, |
||||||
|
0x00000023,0x00000004,0x00050048,0x00000022,0x00000002,0x00000023,0x00000008,0x00050048, |
||||||
|
0x00000022,0x00000003,0x00000023,0x0000000c,0x00050048,0x00000022,0x00000004,0x00000023, |
||||||
|
0x00000010,0x00050048,0x00000022,0x00000005,0x00000023,0x00000014,0x00050048,0x00000022, |
||||||
|
0x00000006,0x00000023,0x00000018,0x00050048,0x00000022,0x00000007,0x00000023,0x0000001c, |
||||||
|
0x00050048,0x00000022,0x00000008,0x00000023,0x00000020,0x00030047,0x00000022,0x00000002, |
||||||
|
0x00040047,0x00000077,0x00000006,0x00000004,0x00040048,0x00000078,0x00000000,0x00000018, |
||||||
|
0x00050048,0x00000078,0x00000000,0x00000023,0x00000000,0x00030047,0x00000078,0x00000003, |
||||||
|
0x00040047,0x0000007a,0x00000022,0x00000000,0x00040047,0x0000007a,0x00000021,0x00000000, |
||||||
|
0x00040047,0x000000d3,0x00000006,0x00000004,0x00040048,0x000000d4,0x00000000,0x00000019, |
||||||
|
0x00050048,0x000000d4,0x00000000,0x00000023,0x00000000,0x00030047,0x000000d4,0x00000003, |
||||||
|
0x00040047,0x000000d6,0x00000022,0x00000000,0x00040047,0x000000d6,0x00000021,0x00000001, |
||||||
|
0x00040047,0x00000143,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003, |
||||||
|
0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007, |
||||||
|
0x00000006,0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009, |
||||||
|
0x00000003,0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c, |
||||||
|
0x00000001,0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001, |
||||||
|
0x00000009,0x0004003b,0x0000000b,0x00000013,0x00000001,0x0004002b,0x00000009,0x00000016, |
||||||
|
0x00000100,0x00030016,0x00000021,0x00000020,0x000b001e,0x00000022,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000021,0x00000021,0x00000021,0x00040020, |
||||||
|
0x00000023,0x00000009,0x00000022,0x0004003b,0x00000023,0x00000024,0x00000009,0x0004002b, |
||||||
|
0x00000006,0x00000025,0x00000000,0x00040020,0x00000026,0x00000009,0x00000006,0x00020014, |
||||||
|
0x00000029,0x0004002b,0x00000006,0x0000002d,0x00000003,0x0004002b,0x00000006,0x00000036, |
||||||
|
0x00000002,0x0004002b,0x00000006,0x00000044,0x00000001,0x00040020,0x0000005c,0x00000007, |
||||||
|
0x00000021,0x0004002b,0x00000021,0x0000005e,0x00000000,0x0004002b,0x00000006,0x00000061, |
||||||
|
0x00000005,0x0003001d,0x00000077,0x00000021,0x0003001e,0x00000078,0x00000077,0x00040020, |
||||||
|
0x00000079,0x00000002,0x00000078,0x0004003b,0x00000079,0x0000007a,0x00000002,0x00040020, |
||||||
|
0x00000080,0x00000002,0x00000021,0x0004002b,0x00000006,0x000000aa,0x00000004,0x0004002b, |
||||||
|
0x00000006,0x000000c9,0x00000007,0x00040020,0x000000ca,0x00000009,0x00000021,0x0004002b, |
||||||
|
0x00000006,0x000000ce,0x00000006,0x0003001d,0x000000d3,0x00000021,0x0003001e,0x000000d4, |
||||||
|
0x000000d3,0x00040020,0x000000d5,0x00000002,0x000000d4,0x0004003b,0x000000d5,0x000000d6, |
||||||
|
0x00000002,0x0004002b,0x00000006,0x000000ea,0x00000008,0x0004002b,0x00000009,0x00000142, |
||||||
|
0x00000001,0x0006002c,0x0000000a,0x00000143,0x00000016,0x00000142,0x00000142,0x00050036, |
||||||
|
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007, |
||||||
|
0x00000008,0x00000007,0x0004003b,0x00000007,0x00000012,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000019,0x00000007,0x0004003b,0x00000007,0x0000002b,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000031,0x00000007,0x0004003b,0x00000007,0x0000003a,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x00000042,0x00000007,0x0004003b,0x00000007,0x00000055,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000005b,0x00000007,0x0004003b,0x0000005c,0x0000005d,0x00000007,0x0004003b,0x00000007, |
||||||
|
0x0000005f,0x00000007,0x0004003b,0x00000007,0x00000060,0x00000007,0x0004003b,0x0000005c, |
||||||
|
0x000000c8,0x00000007,0x0004003b,0x00000007,0x000000f2,0x00000007,0x00050041,0x0000000e, |
||||||
|
0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010,0x0000000f,0x0004007c, |
||||||
|
0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011,0x00050041,0x0000000e, |
||||||
|
0x00000014,0x00000013,0x0000000d,0x0004003d,0x00000009,0x00000015,0x00000014,0x00050084, |
||||||
|
0x00000009,0x00000017,0x00000015,0x00000016,0x0004007c,0x00000006,0x00000018,0x00000017, |
||||||
|
0x0003003e,0x00000012,0x00000018,0x0004003d,0x00000006,0x0000001a,0x00000008,0x0003003e, |
||||||
|
0x00000019,0x0000001a,0x000200f9,0x0000001b,0x000200f8,0x0000001b,0x000400f6,0x0000001d, |
||||||
|
0x0000001e,0x00000000,0x000200f9,0x0000001f,0x000200f8,0x0000001f,0x0004003d,0x00000006, |
||||||
|
0x00000020,0x00000019,0x00050041,0x00000026,0x00000027,0x00000024,0x00000025,0x0004003d, |
||||||
|
0x00000006,0x00000028,0x00000027,0x000500b1,0x00000029,0x0000002a,0x00000020,0x00000028, |
||||||
|
0x000400fa,0x0000002a,0x0000001c,0x0000001d,0x000200f8,0x0000001c,0x0004003d,0x00000006, |
||||||
|
0x0000002c,0x00000019,0x00050041,0x00000026,0x0000002e,0x00000024,0x0000002d,0x0004003d, |
||||||
|
0x00000006,0x0000002f,0x0000002e,0x0005008b,0x00000006,0x00000030,0x0000002c,0x0000002f, |
||||||
|
0x0003003e,0x0000002b,0x00000030,0x0004003d,0x00000006,0x00000032,0x00000019,0x00050041, |
||||||
|
0x00000026,0x00000033,0x00000024,0x0000002d,0x0004003d,0x00000006,0x00000034,0x00000033, |
||||||
|
0x00050087,0x00000006,0x00000035,0x00000032,0x00000034,0x00050041,0x00000026,0x00000037, |
||||||
|
0x00000024,0x00000036,0x0004003d,0x00000006,0x00000038,0x00000037,0x0005008b,0x00000006, |
||||||
|
0x00000039,0x00000035,0x00000038,0x0003003e,0x00000031,0x00000039,0x0004003d,0x00000006, |
||||||
|
0x0000003b,0x00000019,0x00050041,0x00000026,0x0000003c,0x00000024,0x0000002d,0x0004003d, |
||||||
|
0x00000006,0x0000003d,0x0000003c,0x00050041,0x00000026,0x0000003e,0x00000024,0x00000036, |
||||||
|
0x0004003d,0x00000006,0x0000003f,0x0000003e,0x00050084,0x00000006,0x00000040,0x0000003d, |
||||||
|
0x0000003f,0x00050087,0x00000006,0x00000041,0x0000003b,0x00000040,0x0003003e,0x0000003a, |
||||||
|
0x00000041,0x0004003d,0x00000006,0x00000043,0x0000003a,0x00050041,0x00000026,0x00000045, |
||||||
|
0x00000024,0x00000044,0x0004003d,0x00000006,0x00000046,0x00000045,0x00050084,0x00000006, |
||||||
|
0x00000047,0x00000043,0x00000046,0x00050041,0x00000026,0x00000048,0x00000024,0x00000036, |
||||||
|
0x0004003d,0x00000006,0x00000049,0x00000048,0x00050084,0x00000006,0x0000004a,0x00000047, |
||||||
|
0x00000049,0x00050041,0x00000026,0x0000004b,0x00000024,0x0000002d,0x0004003d,0x00000006, |
||||||
|
0x0000004c,0x0000004b,0x00050084,0x00000006,0x0000004d,0x0000004a,0x0000004c,0x0004003d, |
||||||
|
0x00000006,0x0000004e,0x00000031,0x00050041,0x00000026,0x0000004f,0x00000024,0x0000002d, |
||||||
|
0x0004003d,0x00000006,0x00000050,0x0000004f,0x00050084,0x00000006,0x00000051,0x0000004e, |
||||||
|
0x00000050,0x00050080,0x00000006,0x00000052,0x0000004d,0x00000051,0x0004003d,0x00000006, |
||||||
|
0x00000053,0x0000002b,0x00050080,0x00000006,0x00000054,0x00000052,0x00000053,0x0003003e, |
||||||
|
0x00000042,0x00000054,0x00050041,0x00000026,0x00000056,0x00000024,0x00000036,0x0004003d, |
||||||
|
0x00000006,0x00000057,0x00000056,0x00050041,0x00000026,0x00000058,0x00000024,0x0000002d, |
||||||
|
0x0004003d,0x00000006,0x00000059,0x00000058,0x00050084,0x00000006,0x0000005a,0x00000057, |
||||||
|
0x00000059,0x0003003e,0x00000055,0x0000005a,0x0003003e,0x0000005b,0x00000025,0x0003003e, |
||||||
|
0x0000005d,0x0000005e,0x00050041,0x00000026,0x00000062,0x00000024,0x00000061,0x0004003d, |
||||||
|
0x00000006,0x00000063,0x00000062,0x00050041,0x00000026,0x00000064,0x00000024,0x00000044, |
||||||
|
0x0004003d,0x00000006,0x00000065,0x00000064,0x000500b1,0x00000029,0x00000066,0x00000063, |
||||||
|
0x00000065,0x000300f7,0x00000068,0x00000000,0x000400fa,0x00000066,0x00000067,0x0000006b, |
||||||
|
0x000200f8,0x00000067,0x00050041,0x00000026,0x00000069,0x00000024,0x00000061,0x0004003d, |
||||||
|
0x00000006,0x0000006a,0x00000069,0x0003003e,0x00000060,0x0000006a,0x000200f9,0x00000068, |
||||||
|
0x000200f8,0x0000006b,0x00050041,0x00000026,0x0000006c,0x00000024,0x00000044,0x0004003d, |
||||||
|
0x00000006,0x0000006d,0x0000006c,0x0003003e,0x00000060,0x0000006d,0x000200f9,0x00000068, |
||||||
|
0x000200f8,0x00000068,0x0004003d,0x00000006,0x0000006e,0x00000060,0x0003003e,0x0000005f, |
||||||
|
0x0000006e,0x000200f9,0x0000006f,0x000200f8,0x0000006f,0x000400f6,0x00000071,0x00000072, |
||||||
|
0x00000000,0x000200f9,0x00000073,0x000200f8,0x00000073,0x0004003d,0x00000006,0x00000074, |
||||||
|
0x0000005b,0x0004003d,0x00000006,0x00000075,0x0000005f,0x000500b1,0x00000029,0x00000076, |
||||||
|
0x00000074,0x00000075,0x000400fa,0x00000076,0x00000070,0x00000071,0x000200f8,0x00000070, |
||||||
|
0x0004003d,0x00000006,0x0000007b,0x00000042,0x0004003d,0x00000006,0x0000007c,0x0000005b, |
||||||
|
0x0004003d,0x00000006,0x0000007d,0x00000055,0x00050084,0x00000006,0x0000007e,0x0000007c, |
||||||
|
0x0000007d,0x00050080,0x00000006,0x0000007f,0x0000007b,0x0000007e,0x00060041,0x00000080, |
||||||
|
0x00000081,0x0000007a,0x00000025,0x0000007f,0x0004003d,0x00000021,0x00000082,0x00000081, |
||||||
|
0x0004003d,0x00000006,0x00000083,0x00000042,0x0004003d,0x00000006,0x00000084,0x0000005b, |
||||||
|
0x0004003d,0x00000006,0x00000085,0x00000055,0x00050084,0x00000006,0x00000086,0x00000084, |
||||||
|
0x00000085,0x00050080,0x00000006,0x00000087,0x00000083,0x00000086,0x00060041,0x00000080, |
||||||
|
0x00000088,0x0000007a,0x00000025,0x00000087,0x0004003d,0x00000021,0x00000089,0x00000088, |
||||||
|
0x00050085,0x00000021,0x0000008a,0x00000082,0x00000089,0x0004003d,0x00000021,0x0000008b, |
||||||
|
0x0000005d,0x00050081,0x00000021,0x0000008c,0x0000008b,0x0000008a,0x0003003e,0x0000005d, |
||||||
|
0x0000008c,0x0004003d,0x00000006,0x0000008d,0x0000005b,0x00050080,0x00000006,0x0000008e, |
||||||
|
0x0000008d,0x00000044,0x0003003e,0x0000005b,0x0000008e,0x000200f9,0x00000072,0x000200f8, |
||||||
|
0x00000072,0x000200f9,0x0000006f,0x000200f8,0x00000071,0x000200f9,0x0000008f,0x000200f8, |
||||||
|
0x0000008f,0x000400f6,0x00000091,0x00000092,0x00000000,0x000200f9,0x00000093,0x000200f8, |
||||||
|
0x00000093,0x0004003d,0x00000006,0x00000094,0x0000005b,0x00050041,0x00000026,0x00000095, |
||||||
|
0x00000024,0x00000044,0x0004003d,0x00000006,0x00000096,0x00000095,0x000500b1,0x00000029, |
||||||
|
0x00000097,0x00000094,0x00000096,0x000400fa,0x00000097,0x00000090,0x00000091,0x000200f8, |
||||||
|
0x00000090,0x0004003d,0x00000006,0x00000098,0x00000042,0x0004003d,0x00000006,0x00000099, |
||||||
|
0x0000005b,0x0004003d,0x00000006,0x0000009a,0x00000055,0x00050084,0x00000006,0x0000009b, |
||||||
|
0x00000099,0x0000009a,0x00050080,0x00000006,0x0000009c,0x00000098,0x0000009b,0x00060041, |
||||||
|
0x00000080,0x0000009d,0x0000007a,0x00000025,0x0000009c,0x0004003d,0x00000021,0x0000009e, |
||||||
|
0x0000009d,0x0004003d,0x00000006,0x0000009f,0x00000042,0x0004003d,0x00000006,0x000000a0, |
||||||
|
0x0000005b,0x0004003d,0x00000006,0x000000a1,0x00000055,0x00050084,0x00000006,0x000000a2, |
||||||
|
0x000000a0,0x000000a1,0x00050080,0x00000006,0x000000a3,0x0000009f,0x000000a2,0x00060041, |
||||||
|
0x00000080,0x000000a4,0x0000007a,0x00000025,0x000000a3,0x0004003d,0x00000021,0x000000a5, |
||||||
|
0x000000a4,0x00050085,0x00000021,0x000000a6,0x0000009e,0x000000a5,0x0004003d,0x00000021, |
||||||
|
0x000000a7,0x0000005d,0x00050081,0x00000021,0x000000a8,0x000000a7,0x000000a6,0x0003003e, |
||||||
|
0x0000005d,0x000000a8,0x0004003d,0x00000006,0x000000a9,0x0000005b,0x00050041,0x00000026, |
||||||
|
0x000000ab,0x00000024,0x000000aa,0x0004003d,0x00000006,0x000000ac,0x000000ab,0x00050082, |
||||||
|
0x00000006,0x000000ad,0x000000a9,0x000000ac,0x000500af,0x00000029,0x000000ae,0x000000ad, |
||||||
|
0x00000025,0x000300f7,0x000000b0,0x00000000,0x000400fa,0x000000ae,0x000000af,0x000000b0, |
||||||
|
0x000200f8,0x000000af,0x0004003d,0x00000006,0x000000b1,0x00000042,0x0004003d,0x00000006, |
||||||
|
0x000000b2,0x0000005b,0x00050041,0x00000026,0x000000b3,0x00000024,0x000000aa,0x0004003d, |
||||||
|
0x00000006,0x000000b4,0x000000b3,0x00050082,0x00000006,0x000000b5,0x000000b2,0x000000b4, |
||||||
|
0x0004003d,0x00000006,0x000000b6,0x00000055,0x00050084,0x00000006,0x000000b7,0x000000b5, |
||||||
|
0x000000b6,0x00050080,0x00000006,0x000000b8,0x000000b1,0x000000b7,0x00060041,0x00000080, |
||||||
|
0x000000b9,0x0000007a,0x00000025,0x000000b8,0x0004003d,0x00000021,0x000000ba,0x000000b9, |
||||||
|
0x0004003d,0x00000006,0x000000bb,0x00000042,0x0004003d,0x00000006,0x000000bc,0x0000005b, |
||||||
|
0x00050041,0x00000026,0x000000bd,0x00000024,0x000000aa,0x0004003d,0x00000006,0x000000be, |
||||||
|
0x000000bd,0x00050082,0x00000006,0x000000bf,0x000000bc,0x000000be,0x0004003d,0x00000006, |
||||||
|
0x000000c0,0x00000055,0x00050084,0x00000006,0x000000c1,0x000000bf,0x000000c0,0x00050080, |
||||||
|
0x00000006,0x000000c2,0x000000bb,0x000000c1,0x00060041,0x00000080,0x000000c3,0x0000007a, |
||||||
|
0x00000025,0x000000c2,0x0004003d,0x00000021,0x000000c4,0x000000c3,0x00050085,0x00000021, |
||||||
|
0x000000c5,0x000000ba,0x000000c4,0x0004003d,0x00000021,0x000000c6,0x0000005d,0x00050083, |
||||||
|
0x00000021,0x000000c7,0x000000c6,0x000000c5,0x0003003e,0x0000005d,0x000000c7,0x000200f9, |
||||||
|
0x000000b0,0x000200f8,0x000000b0,0x00050041,0x000000ca,0x000000cb,0x00000024,0x000000c9, |
||||||
|
0x0004003d,0x00000021,0x000000cc,0x000000cb,0x0004003d,0x00000021,0x000000cd,0x0000005d, |
||||||
|
0x00050041,0x000000ca,0x000000cf,0x00000024,0x000000ce,0x0004003d,0x00000021,0x000000d0, |
||||||
|
0x000000cf,0x00050085,0x00000021,0x000000d1,0x000000cd,0x000000d0,0x00050081,0x00000021, |
||||||
|
0x000000d2,0x000000cc,0x000000d1,0x0003003e,0x000000c8,0x000000d2,0x0004003d,0x00000006, |
||||||
|
0x000000d7,0x00000042,0x0004003d,0x00000006,0x000000d8,0x0000005b,0x00050041,0x00000026, |
||||||
|
0x000000d9,0x00000024,0x00000061,0x0004003d,0x00000006,0x000000da,0x000000d9,0x00050082, |
||||||
|
0x00000006,0x000000db,0x000000d8,0x000000da,0x0004003d,0x00000006,0x000000dc,0x00000055, |
||||||
|
0x00050084,0x00000006,0x000000dd,0x000000db,0x000000dc,0x00050080,0x00000006,0x000000de, |
||||||
|
0x000000d7,0x000000dd,0x0004003d,0x00000006,0x000000df,0x00000042,0x0004003d,0x00000006, |
||||||
|
0x000000e0,0x0000005b,0x00050041,0x00000026,0x000000e1,0x00000024,0x00000061,0x0004003d, |
||||||
|
0x00000006,0x000000e2,0x000000e1,0x00050082,0x00000006,0x000000e3,0x000000e0,0x000000e2, |
||||||
|
0x0004003d,0x00000006,0x000000e4,0x00000055,0x00050084,0x00000006,0x000000e5,0x000000e3, |
||||||
|
0x000000e4,0x00050080,0x00000006,0x000000e6,0x000000df,0x000000e5,0x00060041,0x00000080, |
||||||
|
0x000000e7,0x0000007a,0x00000025,0x000000e6,0x0004003d,0x00000021,0x000000e8,0x000000e7, |
||||||
|
0x0004003d,0x00000021,0x000000e9,0x000000c8,0x00050041,0x000000ca,0x000000eb,0x00000024, |
||||||
|
0x000000ea,0x0004003d,0x00000021,0x000000ec,0x000000eb,0x0007000c,0x00000021,0x000000ed, |
||||||
|
0x00000001,0x0000001a,0x000000e9,0x000000ec,0x00050085,0x00000021,0x000000ee,0x000000e8, |
||||||
|
0x000000ed,0x00060041,0x00000080,0x000000ef,0x000000d6,0x00000025,0x000000de,0x0003003e, |
||||||
|
0x000000ef,0x000000ee,0x0004003d,0x00000006,0x000000f0,0x0000005b,0x00050080,0x00000006, |
||||||
|
0x000000f1,0x000000f0,0x00000044,0x0003003e,0x0000005b,0x000000f1,0x000200f9,0x00000092, |
||||||
|
0x000200f8,0x00000092,0x000200f9,0x0000008f,0x000200f8,0x00000091,0x0004003d,0x00000006, |
||||||
|
0x000000f3,0x0000005b,0x0004003d,0x00000006,0x000000f4,0x0000005f,0x00050082,0x00000006, |
||||||
|
0x000000f5,0x000000f3,0x000000f4,0x0003003e,0x000000f2,0x000000f5,0x000200f9,0x000000f6, |
||||||
|
0x000200f8,0x000000f6,0x000400f6,0x000000f8,0x000000f9,0x00000000,0x000200f9,0x000000fa, |
||||||
|
0x000200f8,0x000000fa,0x0004003d,0x00000006,0x000000fb,0x000000f2,0x000500af,0x00000029, |
||||||
|
0x000000fc,0x000000fb,0x00000025,0x000300f7,0x000000fe,0x00000000,0x000400fa,0x000000fc, |
||||||
|
0x000000fd,0x000000fe,0x000200f8,0x000000fd,0x0004003d,0x00000006,0x000000ff,0x000000f2, |
||||||
|
0x00050041,0x00000026,0x00000100,0x00000024,0x00000044,0x0004003d,0x00000006,0x00000101, |
||||||
|
0x00000100,0x000500b1,0x00000029,0x00000102,0x000000ff,0x00000101,0x000200f9,0x000000fe, |
||||||
|
0x000200f8,0x000000fe,0x000700f5,0x00000029,0x00000103,0x000000fc,0x000000fa,0x00000102, |
||||||
|
0x000000fd,0x000400fa,0x00000103,0x000000f7,0x000000f8,0x000200f8,0x000000f7,0x0004003d, |
||||||
|
0x00000006,0x00000104,0x0000005b,0x00050041,0x00000026,0x00000105,0x00000024,0x000000aa, |
||||||
|
0x0004003d,0x00000006,0x00000106,0x00000105,0x00050082,0x00000006,0x00000107,0x00000104, |
||||||
|
0x00000106,0x000500af,0x00000029,0x00000108,0x00000107,0x00000025,0x000300f7,0x0000010a, |
||||||
|
0x00000000,0x000400fa,0x00000108,0x00000109,0x0000010a,0x000200f8,0x00000109,0x0004003d, |
||||||
|
0x00000006,0x0000010b,0x00000042,0x0004003d,0x00000006,0x0000010c,0x0000005b,0x00050041, |
||||||
|
0x00000026,0x0000010d,0x00000024,0x000000aa,0x0004003d,0x00000006,0x0000010e,0x0000010d, |
||||||
|
0x00050082,0x00000006,0x0000010f,0x0000010c,0x0000010e,0x0004003d,0x00000006,0x00000110, |
||||||
|
0x00000055,0x00050084,0x00000006,0x00000111,0x0000010f,0x00000110,0x00050080,0x00000006, |
||||||
|
0x00000112,0x0000010b,0x00000111,0x00060041,0x00000080,0x00000113,0x0000007a,0x00000025, |
||||||
|
0x00000112,0x0004003d,0x00000021,0x00000114,0x00000113,0x0004003d,0x00000006,0x00000115, |
||||||
|
0x00000042,0x0004003d,0x00000006,0x00000116,0x0000005b,0x00050041,0x00000026,0x00000117, |
||||||
|
0x00000024,0x000000aa,0x0004003d,0x00000006,0x00000118,0x00000117,0x00050082,0x00000006, |
||||||
|
0x00000119,0x00000116,0x00000118,0x0004003d,0x00000006,0x0000011a,0x00000055,0x00050084, |
||||||
|
0x00000006,0x0000011b,0x00000119,0x0000011a,0x00050080,0x00000006,0x0000011c,0x00000115, |
||||||
|
0x0000011b,0x00060041,0x00000080,0x0000011d,0x0000007a,0x00000025,0x0000011c,0x0004003d, |
||||||
|
0x00000021,0x0000011e,0x0000011d,0x00050085,0x00000021,0x0000011f,0x00000114,0x0000011e, |
||||||
|
0x0004003d,0x00000021,0x00000120,0x0000005d,0x00050083,0x00000021,0x00000121,0x00000120, |
||||||
|
0x0000011f,0x0003003e,0x0000005d,0x00000121,0x000200f9,0x0000010a,0x000200f8,0x0000010a, |
||||||
|
0x00050041,0x000000ca,0x00000122,0x00000024,0x000000c9,0x0004003d,0x00000021,0x00000123, |
||||||
|
0x00000122,0x0004003d,0x00000021,0x00000124,0x0000005d,0x00050041,0x000000ca,0x00000125, |
||||||
|
0x00000024,0x000000ce,0x0004003d,0x00000021,0x00000126,0x00000125,0x00050085,0x00000021, |
||||||
|
0x00000127,0x00000124,0x00000126,0x00050081,0x00000021,0x00000128,0x00000123,0x00000127, |
||||||
|
0x0003003e,0x000000c8,0x00000128,0x0004003d,0x00000006,0x00000129,0x00000042,0x0004003d, |
||||||
|
0x00000006,0x0000012a,0x000000f2,0x0004003d,0x00000006,0x0000012b,0x00000055,0x00050084, |
||||||
|
0x00000006,0x0000012c,0x0000012a,0x0000012b,0x00050080,0x00000006,0x0000012d,0x00000129, |
||||||
|
0x0000012c,0x0004003d,0x00000006,0x0000012e,0x00000042,0x0004003d,0x00000006,0x0000012f, |
||||||
|
0x000000f2,0x0004003d,0x00000006,0x00000130,0x00000055,0x00050084,0x00000006,0x00000131, |
||||||
|
0x0000012f,0x00000130,0x00050080,0x00000006,0x00000132,0x0000012e,0x00000131,0x00060041, |
||||||
|
0x00000080,0x00000133,0x0000007a,0x00000025,0x00000132,0x0004003d,0x00000021,0x00000134, |
||||||
|
0x00000133,0x0004003d,0x00000021,0x00000135,0x000000c8,0x00050041,0x000000ca,0x00000136, |
||||||
|
0x00000024,0x000000ea,0x0004003d,0x00000021,0x00000137,0x00000136,0x0007000c,0x00000021, |
||||||
|
0x00000138,0x00000001,0x0000001a,0x00000135,0x00000137,0x00050085,0x00000021,0x00000139, |
||||||
|
0x00000134,0x00000138,0x00060041,0x00000080,0x0000013a,0x000000d6,0x00000025,0x0000012d, |
||||||
|
0x0003003e,0x0000013a,0x00000139,0x0004003d,0x00000006,0x0000013b,0x0000005b,0x00050080, |
||||||
|
0x00000006,0x0000013c,0x0000013b,0x00000044,0x0003003e,0x0000005b,0x0000013c,0x0004003d, |
||||||
|
0x00000006,0x0000013d,0x000000f2,0x00050080,0x00000006,0x0000013e,0x0000013d,0x00000044, |
||||||
|
0x0003003e,0x000000f2,0x0000013e,0x000200f9,0x000000f9,0x000200f8,0x000000f9,0x000200f9, |
||||||
|
0x000000f6,0x000200f8,0x000000f8,0x000200f9,0x0000001e,0x000200f8,0x0000001e,0x0004003d, |
||||||
|
0x00000006,0x0000013f,0x00000012,0x0004003d,0x00000006,0x00000140,0x00000019,0x00050080, |
||||||
|
0x00000006,0x00000141,0x00000140,0x0000013f,0x0003003e,0x00000019,0x00000141,0x000200f9, |
||||||
|
0x0000001b,0x000200f8,0x0000001d,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,64 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int channels; |
||||||
|
int in_h; |
||||||
|
int in_w; |
||||||
|
int out_h; |
||||||
|
int out_w; |
||||||
|
int padding_h; |
||||||
|
int padding_w; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int total; |
||||||
|
int need_mask; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(binding = 1) writeonly buffer Output{ |
||||||
|
float out_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(binding = 2) writeonly buffer Mask{ |
||||||
|
float mask_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
void main() |
||||||
|
{ |
||||||
|
int global_size = int(gl_WorkGroupSize.x * gl_NumWorkGroups.x); |
||||||
|
int gid = int(gl_GlobalInvocationID.x); |
||||||
|
for (int index = gid; index < p.total; index += global_size) |
||||||
|
{ |
||||||
|
const int pw = index % p.out_w; |
||||||
|
const int ph = (index / p.out_w) % p.out_h; |
||||||
|
const int c = (index / p.out_w / p.out_h) % p.channels; |
||||||
|
const int n = index / p.out_w / p.out_h / p.channels; |
||||||
|
int hstart = ph * p.stride_h - p.padding_h; |
||||||
|
int wstart = pw * p.stride_w - p.padding_w; |
||||||
|
const int hend = min(hstart + p.filter_h, p.in_h); |
||||||
|
const int wend = min(wstart + p.filter_w, p.in_w); |
||||||
|
hstart = max(hstart, 0); |
||||||
|
wstart = max(wstart, 0); |
||||||
|
float maxval = -1./0.; |
||||||
|
int maxidx = -1; |
||||||
|
int off = (n * p.channels + c) * p.in_h * p.in_w; |
||||||
|
for (int h = hstart; h < hend; ++h) { |
||||||
|
for (int w = wstart; w < wend; ++w) { |
||||||
|
if (in_buffer[off + h * p.in_w + w] > maxval) { |
||||||
|
maxidx = h * p.in_w + w; |
||||||
|
maxval = in_buffer[off + maxidx]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
out_buffer[index] = maxval; |
||||||
|
if (p.need_mask == 1) |
||||||
|
mask_buffer[index] = maxidx; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,197 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int max_pool_spv[1449] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x000000df,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0007000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00000015,0x00060010, |
||||||
|
0x00000004,0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2, |
||||||
|
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000008,0x626f6c67,0x735f6c61, |
||||||
|
0x00657a69,0x00070005,0x0000000d,0x4e5f6c67,0x6f576d75,0x72476b72,0x7370756f,0x00000000, |
||||||
|
0x00030005,0x00000014,0x00646967,0x00080005,0x00000015,0x475f6c67,0x61626f6c,0x766e496c, |
||||||
|
0x7461636f,0x496e6f69,0x00000044,0x00040005,0x00000019,0x65646e69,0x00000078,0x00050005, |
||||||
|
0x00000021,0x68737570,0x636f6c42,0x0000006b,0x00060006,0x00000021,0x00000000,0x6e616863, |
||||||
|
0x736c656e,0x00000000,0x00050006,0x00000021,0x00000001,0x685f6e69,0x00000000,0x00050006, |
||||||
|
0x00000021,0x00000002,0x775f6e69,0x00000000,0x00050006,0x00000021,0x00000003,0x5f74756f, |
||||||
|
0x00000068,0x00050006,0x00000021,0x00000004,0x5f74756f,0x00000077,0x00060006,0x00000021, |
||||||
|
0x00000005,0x64646170,0x5f676e69,0x00000068,0x00060006,0x00000021,0x00000006,0x64646170, |
||||||
|
0x5f676e69,0x00000077,0x00060006,0x00000021,0x00000007,0x746c6966,0x685f7265,0x00000000, |
||||||
|
0x00060006,0x00000021,0x00000008,0x746c6966,0x775f7265,0x00000000,0x00060006,0x00000021, |
||||||
|
0x00000009,0x69727473,0x685f6564,0x00000000,0x00060006,0x00000021,0x0000000a,0x69727473, |
||||||
|
0x775f6564,0x00000000,0x00050006,0x00000021,0x0000000b,0x61746f74,0x0000006c,0x00060006, |
||||||
|
0x00000021,0x0000000c,0x6465656e,0x73616d5f,0x0000006b,0x00030005,0x00000023,0x00000070, |
||||||
|
0x00030005,0x0000002a,0x00007770,0x00030005,0x00000030,0x00006870,0x00030005,0x00000039, |
||||||
|
0x00000063,0x00030005,0x00000045,0x0000006e,0x00040005,0x00000050,0x61747368,0x00007472, |
||||||
|
0x00040005,0x0000005a,0x61747377,0x00007472,0x00040005,0x00000064,0x646e6568,0x00000000, |
||||||
|
0x00040005,0x0000006e,0x646e6577,0x00000000,0x00040005,0x0000007e,0x7678616d,0x00006c61, |
||||||
|
0x00040005,0x00000080,0x6978616d,0x00007864,0x00030005,0x00000082,0x0066666f,0x00030005, |
||||||
|
0x0000008f,0x00000068,0x00030005,0x00000099,0x00000077,0x00040005,0x000000a4,0x75706e49, |
||||||
|
0x00003074,0x00060006,0x000000a4,0x00000000,0x625f6e69,0x65666675,0x00000072,0x00030005, |
||||||
|
0x000000a6,0x00000000,0x00040005,0x000000c6,0x7074754f,0x00007475,0x00060006,0x000000c6, |
||||||
|
0x00000000,0x5f74756f,0x66667562,0x00007265,0x00030005,0x000000c8,0x00000000,0x00040005, |
||||||
|
0x000000d3,0x6b73614d,0x00000000,0x00060006,0x000000d3,0x00000000,0x6b73616d,0x6675625f, |
||||||
|
0x00726566,0x00030005,0x000000d5,0x00000000,0x00040047,0x0000000d,0x0000000b,0x00000018, |
||||||
|
0x00040047,0x00000015,0x0000000b,0x0000001c,0x00050048,0x00000021,0x00000000,0x00000023, |
||||||
|
0x00000000,0x00050048,0x00000021,0x00000001,0x00000023,0x00000004,0x00050048,0x00000021, |
||||||
|
0x00000002,0x00000023,0x00000008,0x00050048,0x00000021,0x00000003,0x00000023,0x0000000c, |
||||||
|
0x00050048,0x00000021,0x00000004,0x00000023,0x00000010,0x00050048,0x00000021,0x00000005, |
||||||
|
0x00000023,0x00000014,0x00050048,0x00000021,0x00000006,0x00000023,0x00000018,0x00050048, |
||||||
|
0x00000021,0x00000007,0x00000023,0x0000001c,0x00050048,0x00000021,0x00000008,0x00000023, |
||||||
|
0x00000020,0x00050048,0x00000021,0x00000009,0x00000023,0x00000024,0x00050048,0x00000021, |
||||||
|
0x0000000a,0x00000023,0x00000028,0x00050048,0x00000021,0x0000000b,0x00000023,0x0000002c, |
||||||
|
0x00050048,0x00000021,0x0000000c,0x00000023,0x00000030,0x00030047,0x00000021,0x00000002, |
||||||
|
0x00040047,0x000000a3,0x00000006,0x00000004,0x00040048,0x000000a4,0x00000000,0x00000018, |
||||||
|
0x00050048,0x000000a4,0x00000000,0x00000023,0x00000000,0x00030047,0x000000a4,0x00000003, |
||||||
|
0x00040047,0x000000a6,0x00000022,0x00000000,0x00040047,0x000000a6,0x00000021,0x00000000, |
||||||
|
0x00040047,0x000000c5,0x00000006,0x00000004,0x00040048,0x000000c6,0x00000000,0x00000019, |
||||||
|
0x00050048,0x000000c6,0x00000000,0x00000023,0x00000000,0x00030047,0x000000c6,0x00000003, |
||||||
|
0x00040047,0x000000c8,0x00000022,0x00000000,0x00040047,0x000000c8,0x00000021,0x00000001, |
||||||
|
0x00040047,0x000000d2,0x00000006,0x00000004,0x00040048,0x000000d3,0x00000000,0x00000019, |
||||||
|
0x00050048,0x000000d3,0x00000000,0x00000023,0x00000000,0x00030047,0x000000d3,0x00000003, |
||||||
|
0x00040047,0x000000d5,0x00000022,0x00000000,0x00040047,0x000000d5,0x00000021,0x00000002, |
||||||
|
0x00040047,0x000000de,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003, |
||||||
|
0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007, |
||||||
|
0x00000006,0x00040015,0x00000009,0x00000020,0x00000000,0x0004002b,0x00000009,0x0000000a, |
||||||
|
0x00000100,0x00040017,0x0000000b,0x00000009,0x00000003,0x00040020,0x0000000c,0x00000001, |
||||||
|
0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x0004002b,0x00000009,0x0000000e, |
||||||
|
0x00000000,0x00040020,0x0000000f,0x00000001,0x00000009,0x0004003b,0x0000000c,0x00000015, |
||||||
|
0x00000001,0x000f001e,0x00000021,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006, |
||||||
|
0x00040020,0x00000022,0x00000009,0x00000021,0x0004003b,0x00000022,0x00000023,0x00000009, |
||||||
|
0x0004002b,0x00000006,0x00000024,0x0000000b,0x00040020,0x00000025,0x00000009,0x00000006, |
||||||
|
0x00020014,0x00000028,0x0004002b,0x00000006,0x0000002c,0x00000004,0x0004002b,0x00000006, |
||||||
|
0x00000035,0x00000003,0x0004002b,0x00000006,0x00000041,0x00000000,0x0004002b,0x00000006, |
||||||
|
0x00000052,0x00000009,0x0004002b,0x00000006,0x00000056,0x00000005,0x0004002b,0x00000006, |
||||||
|
0x0000005c,0x0000000a,0x0004002b,0x00000006,0x00000060,0x00000006,0x0004002b,0x00000006, |
||||||
|
0x00000066,0x00000007,0x0004002b,0x00000006,0x0000006a,0x00000001,0x0004002b,0x00000006, |
||||||
|
0x00000070,0x00000008,0x0004002b,0x00000006,0x00000074,0x00000002,0x00030016,0x0000007c, |
||||||
|
0x00000020,0x00040020,0x0000007d,0x00000007,0x0000007c,0x0004002b,0x0000007c,0x0000007f, |
||||||
|
0xff800000,0x0004002b,0x00000006,0x00000081,0xffffffff,0x0003001d,0x000000a3,0x0000007c, |
||||||
|
0x0003001e,0x000000a4,0x000000a3,0x00040020,0x000000a5,0x00000002,0x000000a4,0x0004003b, |
||||||
|
0x000000a5,0x000000a6,0x00000002,0x00040020,0x000000af,0x00000002,0x0000007c,0x0003001d, |
||||||
|
0x000000c5,0x0000007c,0x0003001e,0x000000c6,0x000000c5,0x00040020,0x000000c7,0x00000002, |
||||||
|
0x000000c6,0x0004003b,0x000000c7,0x000000c8,0x00000002,0x0004002b,0x00000006,0x000000cc, |
||||||
|
0x0000000c,0x0003001d,0x000000d2,0x0000007c,0x0003001e,0x000000d3,0x000000d2,0x00040020, |
||||||
|
0x000000d4,0x00000002,0x000000d3,0x0004003b,0x000000d4,0x000000d5,0x00000002,0x0004002b, |
||||||
|
0x00000009,0x000000dd,0x00000001,0x0006002c,0x0000000b,0x000000de,0x0000000a,0x000000dd, |
||||||
|
0x000000dd,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, |
||||||
|
0x0004003b,0x00000007,0x00000008,0x00000007,0x0004003b,0x00000007,0x00000014,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000019,0x00000007,0x0004003b,0x00000007,0x0000002a,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000030,0x00000007,0x0004003b,0x00000007,0x00000039,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000045,0x00000007,0x0004003b,0x00000007,0x00000050,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000005a,0x00000007,0x0004003b,0x00000007,0x00000064,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000006e,0x00000007,0x0004003b,0x0000007d,0x0000007e,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000080,0x00000007,0x0004003b,0x00000007,0x00000082,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000008f,0x00000007,0x0004003b,0x00000007,0x00000099,0x00000007, |
||||||
|
0x00050041,0x0000000f,0x00000010,0x0000000d,0x0000000e,0x0004003d,0x00000009,0x00000011, |
||||||
|
0x00000010,0x00050084,0x00000009,0x00000012,0x0000000a,0x00000011,0x0004007c,0x00000006, |
||||||
|
0x00000013,0x00000012,0x0003003e,0x00000008,0x00000013,0x00050041,0x0000000f,0x00000016, |
||||||
|
0x00000015,0x0000000e,0x0004003d,0x00000009,0x00000017,0x00000016,0x0004007c,0x00000006, |
||||||
|
0x00000018,0x00000017,0x0003003e,0x00000014,0x00000018,0x0004003d,0x00000006,0x0000001a, |
||||||
|
0x00000014,0x0003003e,0x00000019,0x0000001a,0x000200f9,0x0000001b,0x000200f8,0x0000001b, |
||||||
|
0x000400f6,0x0000001d,0x0000001e,0x00000000,0x000200f9,0x0000001f,0x000200f8,0x0000001f, |
||||||
|
0x0004003d,0x00000006,0x00000020,0x00000019,0x00050041,0x00000025,0x00000026,0x00000023, |
||||||
|
0x00000024,0x0004003d,0x00000006,0x00000027,0x00000026,0x000500b1,0x00000028,0x00000029, |
||||||
|
0x00000020,0x00000027,0x000400fa,0x00000029,0x0000001c,0x0000001d,0x000200f8,0x0000001c, |
||||||
|
0x0004003d,0x00000006,0x0000002b,0x00000019,0x00050041,0x00000025,0x0000002d,0x00000023, |
||||||
|
0x0000002c,0x0004003d,0x00000006,0x0000002e,0x0000002d,0x0005008b,0x00000006,0x0000002f, |
||||||
|
0x0000002b,0x0000002e,0x0003003e,0x0000002a,0x0000002f,0x0004003d,0x00000006,0x00000031, |
||||||
|
0x00000019,0x00050041,0x00000025,0x00000032,0x00000023,0x0000002c,0x0004003d,0x00000006, |
||||||
|
0x00000033,0x00000032,0x00050087,0x00000006,0x00000034,0x00000031,0x00000033,0x00050041, |
||||||
|
0x00000025,0x00000036,0x00000023,0x00000035,0x0004003d,0x00000006,0x00000037,0x00000036, |
||||||
|
0x0005008b,0x00000006,0x00000038,0x00000034,0x00000037,0x0003003e,0x00000030,0x00000038, |
||||||
|
0x0004003d,0x00000006,0x0000003a,0x00000019,0x00050041,0x00000025,0x0000003b,0x00000023, |
||||||
|
0x0000002c,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x00050087,0x00000006,0x0000003d, |
||||||
|
0x0000003a,0x0000003c,0x00050041,0x00000025,0x0000003e,0x00000023,0x00000035,0x0004003d, |
||||||
|
0x00000006,0x0000003f,0x0000003e,0x00050087,0x00000006,0x00000040,0x0000003d,0x0000003f, |
||||||
|
0x00050041,0x00000025,0x00000042,0x00000023,0x00000041,0x0004003d,0x00000006,0x00000043, |
||||||
|
0x00000042,0x0005008b,0x00000006,0x00000044,0x00000040,0x00000043,0x0003003e,0x00000039, |
||||||
|
0x00000044,0x0004003d,0x00000006,0x00000046,0x00000019,0x00050041,0x00000025,0x00000047, |
||||||
|
0x00000023,0x0000002c,0x0004003d,0x00000006,0x00000048,0x00000047,0x00050087,0x00000006, |
||||||
|
0x00000049,0x00000046,0x00000048,0x00050041,0x00000025,0x0000004a,0x00000023,0x00000035, |
||||||
|
0x0004003d,0x00000006,0x0000004b,0x0000004a,0x00050087,0x00000006,0x0000004c,0x00000049, |
||||||
|
0x0000004b,0x00050041,0x00000025,0x0000004d,0x00000023,0x00000041,0x0004003d,0x00000006, |
||||||
|
0x0000004e,0x0000004d,0x00050087,0x00000006,0x0000004f,0x0000004c,0x0000004e,0x0003003e, |
||||||
|
0x00000045,0x0000004f,0x0004003d,0x00000006,0x00000051,0x00000030,0x00050041,0x00000025, |
||||||
|
0x00000053,0x00000023,0x00000052,0x0004003d,0x00000006,0x00000054,0x00000053,0x00050084, |
||||||
|
0x00000006,0x00000055,0x00000051,0x00000054,0x00050041,0x00000025,0x00000057,0x00000023, |
||||||
|
0x00000056,0x0004003d,0x00000006,0x00000058,0x00000057,0x00050082,0x00000006,0x00000059, |
||||||
|
0x00000055,0x00000058,0x0003003e,0x00000050,0x00000059,0x0004003d,0x00000006,0x0000005b, |
||||||
|
0x0000002a,0x00050041,0x00000025,0x0000005d,0x00000023,0x0000005c,0x0004003d,0x00000006, |
||||||
|
0x0000005e,0x0000005d,0x00050084,0x00000006,0x0000005f,0x0000005b,0x0000005e,0x00050041, |
||||||
|
0x00000025,0x00000061,0x00000023,0x00000060,0x0004003d,0x00000006,0x00000062,0x00000061, |
||||||
|
0x00050082,0x00000006,0x00000063,0x0000005f,0x00000062,0x0003003e,0x0000005a,0x00000063, |
||||||
|
0x0004003d,0x00000006,0x00000065,0x00000050,0x00050041,0x00000025,0x00000067,0x00000023, |
||||||
|
0x00000066,0x0004003d,0x00000006,0x00000068,0x00000067,0x00050080,0x00000006,0x00000069, |
||||||
|
0x00000065,0x00000068,0x00050041,0x00000025,0x0000006b,0x00000023,0x0000006a,0x0004003d, |
||||||
|
0x00000006,0x0000006c,0x0000006b,0x0007000c,0x00000006,0x0000006d,0x00000001,0x00000027, |
||||||
|
0x00000069,0x0000006c,0x0003003e,0x00000064,0x0000006d,0x0004003d,0x00000006,0x0000006f, |
||||||
|
0x0000005a,0x00050041,0x00000025,0x00000071,0x00000023,0x00000070,0x0004003d,0x00000006, |
||||||
|
0x00000072,0x00000071,0x00050080,0x00000006,0x00000073,0x0000006f,0x00000072,0x00050041, |
||||||
|
0x00000025,0x00000075,0x00000023,0x00000074,0x0004003d,0x00000006,0x00000076,0x00000075, |
||||||
|
0x0007000c,0x00000006,0x00000077,0x00000001,0x00000027,0x00000073,0x00000076,0x0003003e, |
||||||
|
0x0000006e,0x00000077,0x0004003d,0x00000006,0x00000078,0x00000050,0x0007000c,0x00000006, |
||||||
|
0x00000079,0x00000001,0x0000002a,0x00000078,0x00000041,0x0003003e,0x00000050,0x00000079, |
||||||
|
0x0004003d,0x00000006,0x0000007a,0x0000005a,0x0007000c,0x00000006,0x0000007b,0x00000001, |
||||||
|
0x0000002a,0x0000007a,0x00000041,0x0003003e,0x0000005a,0x0000007b,0x0003003e,0x0000007e, |
||||||
|
0x0000007f,0x0003003e,0x00000080,0x00000081,0x0004003d,0x00000006,0x00000083,0x00000045, |
||||||
|
0x00050041,0x00000025,0x00000084,0x00000023,0x00000041,0x0004003d,0x00000006,0x00000085, |
||||||
|
0x00000084,0x00050084,0x00000006,0x00000086,0x00000083,0x00000085,0x0004003d,0x00000006, |
||||||
|
0x00000087,0x00000039,0x00050080,0x00000006,0x00000088,0x00000086,0x00000087,0x00050041, |
||||||
|
0x00000025,0x00000089,0x00000023,0x0000006a,0x0004003d,0x00000006,0x0000008a,0x00000089, |
||||||
|
0x00050084,0x00000006,0x0000008b,0x00000088,0x0000008a,0x00050041,0x00000025,0x0000008c, |
||||||
|
0x00000023,0x00000074,0x0004003d,0x00000006,0x0000008d,0x0000008c,0x00050084,0x00000006, |
||||||
|
0x0000008e,0x0000008b,0x0000008d,0x0003003e,0x00000082,0x0000008e,0x0004003d,0x00000006, |
||||||
|
0x00000090,0x00000050,0x0003003e,0x0000008f,0x00000090,0x000200f9,0x00000091,0x000200f8, |
||||||
|
0x00000091,0x000400f6,0x00000093,0x00000094,0x00000000,0x000200f9,0x00000095,0x000200f8, |
||||||
|
0x00000095,0x0004003d,0x00000006,0x00000096,0x0000008f,0x0004003d,0x00000006,0x00000097, |
||||||
|
0x00000064,0x000500b1,0x00000028,0x00000098,0x00000096,0x00000097,0x000400fa,0x00000098, |
||||||
|
0x00000092,0x00000093,0x000200f8,0x00000092,0x0004003d,0x00000006,0x0000009a,0x0000005a, |
||||||
|
0x0003003e,0x00000099,0x0000009a,0x000200f9,0x0000009b,0x000200f8,0x0000009b,0x000400f6, |
||||||
|
0x0000009d,0x0000009e,0x00000000,0x000200f9,0x0000009f,0x000200f8,0x0000009f,0x0004003d, |
||||||
|
0x00000006,0x000000a0,0x00000099,0x0004003d,0x00000006,0x000000a1,0x0000006e,0x000500b1, |
||||||
|
0x00000028,0x000000a2,0x000000a0,0x000000a1,0x000400fa,0x000000a2,0x0000009c,0x0000009d, |
||||||
|
0x000200f8,0x0000009c,0x0004003d,0x00000006,0x000000a7,0x00000082,0x0004003d,0x00000006, |
||||||
|
0x000000a8,0x0000008f,0x00050041,0x00000025,0x000000a9,0x00000023,0x00000074,0x0004003d, |
||||||
|
0x00000006,0x000000aa,0x000000a9,0x00050084,0x00000006,0x000000ab,0x000000a8,0x000000aa, |
||||||
|
0x00050080,0x00000006,0x000000ac,0x000000a7,0x000000ab,0x0004003d,0x00000006,0x000000ad, |
||||||
|
0x00000099,0x00050080,0x00000006,0x000000ae,0x000000ac,0x000000ad,0x00060041,0x000000af, |
||||||
|
0x000000b0,0x000000a6,0x00000041,0x000000ae,0x0004003d,0x0000007c,0x000000b1,0x000000b0, |
||||||
|
0x0004003d,0x0000007c,0x000000b2,0x0000007e,0x000500ba,0x00000028,0x000000b3,0x000000b1, |
||||||
|
0x000000b2,0x000300f7,0x000000b5,0x00000000,0x000400fa,0x000000b3,0x000000b4,0x000000b5, |
||||||
|
0x000200f8,0x000000b4,0x0004003d,0x00000006,0x000000b6,0x0000008f,0x00050041,0x00000025, |
||||||
|
0x000000b7,0x00000023,0x00000074,0x0004003d,0x00000006,0x000000b8,0x000000b7,0x00050084, |
||||||
|
0x00000006,0x000000b9,0x000000b6,0x000000b8,0x0004003d,0x00000006,0x000000ba,0x00000099, |
||||||
|
0x00050080,0x00000006,0x000000bb,0x000000b9,0x000000ba,0x0003003e,0x00000080,0x000000bb, |
||||||
|
0x0004003d,0x00000006,0x000000bc,0x00000082,0x0004003d,0x00000006,0x000000bd,0x00000080, |
||||||
|
0x00050080,0x00000006,0x000000be,0x000000bc,0x000000bd,0x00060041,0x000000af,0x000000bf, |
||||||
|
0x000000a6,0x00000041,0x000000be,0x0004003d,0x0000007c,0x000000c0,0x000000bf,0x0003003e, |
||||||
|
0x0000007e,0x000000c0,0x000200f9,0x000000b5,0x000200f8,0x000000b5,0x000200f9,0x0000009e, |
||||||
|
0x000200f8,0x0000009e,0x0004003d,0x00000006,0x000000c1,0x00000099,0x00050080,0x00000006, |
||||||
|
0x000000c2,0x000000c1,0x0000006a,0x0003003e,0x00000099,0x000000c2,0x000200f9,0x0000009b, |
||||||
|
0x000200f8,0x0000009d,0x000200f9,0x00000094,0x000200f8,0x00000094,0x0004003d,0x00000006, |
||||||
|
0x000000c3,0x0000008f,0x00050080,0x00000006,0x000000c4,0x000000c3,0x0000006a,0x0003003e, |
||||||
|
0x0000008f,0x000000c4,0x000200f9,0x00000091,0x000200f8,0x00000093,0x0004003d,0x00000006, |
||||||
|
0x000000c9,0x00000019,0x0004003d,0x0000007c,0x000000ca,0x0000007e,0x00060041,0x000000af, |
||||||
|
0x000000cb,0x000000c8,0x00000041,0x000000c9,0x0003003e,0x000000cb,0x000000ca,0x00050041, |
||||||
|
0x00000025,0x000000cd,0x00000023,0x000000cc,0x0004003d,0x00000006,0x000000ce,0x000000cd, |
||||||
|
0x000500aa,0x00000028,0x000000cf,0x000000ce,0x0000006a,0x000300f7,0x000000d1,0x00000000, |
||||||
|
0x000400fa,0x000000cf,0x000000d0,0x000000d1,0x000200f8,0x000000d0,0x0004003d,0x00000006, |
||||||
|
0x000000d6,0x00000019,0x0004003d,0x00000006,0x000000d7,0x00000080,0x0004006f,0x0000007c, |
||||||
|
0x000000d8,0x000000d7,0x00060041,0x000000af,0x000000d9,0x000000d5,0x00000041,0x000000d6, |
||||||
|
0x0003003e,0x000000d9,0x000000d8,0x000200f9,0x000000d1,0x000200f8,0x000000d1,0x000200f9, |
||||||
|
0x0000001e,0x000200f8,0x0000001e,0x0004003d,0x00000006,0x000000da,0x00000008,0x0004003d, |
||||||
|
0x00000006,0x000000db,0x00000019,0x00050080,0x00000006,0x000000dc,0x000000db,0x000000da, |
||||||
|
0x0003003e,0x00000019,0x000000dc,0x000200f9,0x0000001b,0x000200f8,0x0000001d,0x000100fd, |
||||||
|
0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,44 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int nthreads; |
||||||
|
int num_axes; |
||||||
|
int global_size; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
layout(binding = 1) readonly buffer Input1{ |
||||||
|
int permute_order[]; |
||||||
|
}; |
||||||
|
layout(binding = 2) readonly buffer Input2{ |
||||||
|
int old_stride[]; |
||||||
|
}; |
||||||
|
layout(binding = 3) readonly buffer Input3{ |
||||||
|
int new_stride[]; |
||||||
|
}; |
||||||
|
layout(binding = 4) writeonly buffer Output{ |
||||||
|
float out_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
void main() |
||||||
|
{ |
||||||
|
for (int i = int(gl_GlobalInvocationID.x); i < p.nthreads; i += p.global_size) |
||||||
|
{ |
||||||
|
int old_pos = 0; |
||||||
|
int new_pos = i; |
||||||
|
|
||||||
|
for (int j = 0; j < p.num_axes; ++j) |
||||||
|
{ |
||||||
|
int order = permute_order[j]; |
||||||
|
old_pos += (new_pos / new_stride[j]) * old_stride[order]; |
||||||
|
new_pos %= new_stride[j]; |
||||||
|
} |
||||||
|
|
||||||
|
out_buffer[i] = in_buffer[old_pos]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,111 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int permute_spv[765] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x00000069,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00000069,0x00080005,0x0000000c, |
||||||
|
0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005,0x00000018, |
||||||
|
0x68737570,0x636f6c42,0x0000006b,0x00060006,0x00000018,0x00000000,0x7268746e,0x73646165, |
||||||
|
0x00000000,0x00060006,0x00000018,0x00000001,0x5f6d756e,0x73657861,0x00000000,0x00060006, |
||||||
|
0x00000018,0x00000002,0x626f6c67,0x735f6c61,0x00657a69,0x00030005,0x0000001a,0x00000070, |
||||||
|
0x00040005,0x00000021,0x5f646c6f,0x00736f70,0x00040005,0x00000022,0x5f77656e,0x00736f70, |
||||||
|
0x00030005,0x00000024,0x0000006a,0x00040005,0x0000002f,0x6564726f,0x00000072,0x00040005, |
||||||
|
0x00000031,0x75706e49,0x00003174,0x00070006,0x00000031,0x00000000,0x6d726570,0x5f657475, |
||||||
|
0x6564726f,0x00000072,0x00030005,0x00000033,0x00000000,0x00040005,0x0000003a,0x75706e49, |
||||||
|
0x00003374,0x00060006,0x0000003a,0x00000000,0x5f77656e,0x69727473,0x00006564,0x00030005, |
||||||
|
0x0000003c,0x00000000,0x00040005,0x00000042,0x75706e49,0x00003274,0x00060006,0x00000042, |
||||||
|
0x00000000,0x5f646c6f,0x69727473,0x00006564,0x00030005,0x00000044,0x00000000,0x00040005, |
||||||
|
0x00000054,0x7074754f,0x00007475,0x00060006,0x00000054,0x00000000,0x5f74756f,0x66667562, |
||||||
|
0x00007265,0x00030005,0x00000056,0x00000000,0x00040005,0x00000059,0x75706e49,0x00003074, |
||||||
|
0x00060006,0x00000059,0x00000000,0x625f6e69,0x65666675,0x00000072,0x00030005,0x0000005b, |
||||||
|
0x00000000,0x00040047,0x0000000c,0x0000000b,0x0000001c,0x00050048,0x00000018,0x00000000, |
||||||
|
0x00000023,0x00000000,0x00050048,0x00000018,0x00000001,0x00000023,0x00000004,0x00050048, |
||||||
|
0x00000018,0x00000002,0x00000023,0x00000008,0x00030047,0x00000018,0x00000002,0x00040047, |
||||||
|
0x00000030,0x00000006,0x00000004,0x00040048,0x00000031,0x00000000,0x00000018,0x00050048, |
||||||
|
0x00000031,0x00000000,0x00000023,0x00000000,0x00030047,0x00000031,0x00000003,0x00040047, |
||||||
|
0x00000033,0x00000022,0x00000000,0x00040047,0x00000033,0x00000021,0x00000001,0x00040047, |
||||||
|
0x00000039,0x00000006,0x00000004,0x00040048,0x0000003a,0x00000000,0x00000018,0x00050048, |
||||||
|
0x0000003a,0x00000000,0x00000023,0x00000000,0x00030047,0x0000003a,0x00000003,0x00040047, |
||||||
|
0x0000003c,0x00000022,0x00000000,0x00040047,0x0000003c,0x00000021,0x00000003,0x00040047, |
||||||
|
0x00000041,0x00000006,0x00000004,0x00040048,0x00000042,0x00000000,0x00000018,0x00050048, |
||||||
|
0x00000042,0x00000000,0x00000023,0x00000000,0x00030047,0x00000042,0x00000003,0x00040047, |
||||||
|
0x00000044,0x00000022,0x00000000,0x00040047,0x00000044,0x00000021,0x00000002,0x00040047, |
||||||
|
0x00000053,0x00000006,0x00000004,0x00040048,0x00000054,0x00000000,0x00000019,0x00050048, |
||||||
|
0x00000054,0x00000000,0x00000023,0x00000000,0x00030047,0x00000054,0x00000003,0x00040047, |
||||||
|
0x00000056,0x00000022,0x00000000,0x00040047,0x00000056,0x00000021,0x00000004,0x00040047, |
||||||
|
0x00000058,0x00000006,0x00000004,0x00040048,0x00000059,0x00000000,0x00000018,0x00050048, |
||||||
|
0x00000059,0x00000000,0x00000023,0x00000000,0x00030047,0x00000059,0x00000003,0x00040047, |
||||||
|
0x0000005b,0x00000022,0x00000000,0x00040047,0x0000005b,0x00000021,0x00000000,0x00040047, |
||||||
|
0x00000068,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, |
||||||
|
0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007,0x00000006, |
||||||
|
0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009,0x00000003, |
||||||
|
0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000001, |
||||||
|
0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000009, |
||||||
|
0x0005001e,0x00000018,0x00000006,0x00000006,0x00000006,0x00040020,0x00000019,0x00000009, |
||||||
|
0x00000018,0x0004003b,0x00000019,0x0000001a,0x00000009,0x0004002b,0x00000006,0x0000001b, |
||||||
|
0x00000000,0x00040020,0x0000001c,0x00000009,0x00000006,0x00020014,0x0000001f,0x0004002b, |
||||||
|
0x00000006,0x0000002b,0x00000001,0x0003001d,0x00000030,0x00000006,0x0003001e,0x00000031, |
||||||
|
0x00000030,0x00040020,0x00000032,0x00000002,0x00000031,0x0004003b,0x00000032,0x00000033, |
||||||
|
0x00000002,0x00040020,0x00000035,0x00000002,0x00000006,0x0003001d,0x00000039,0x00000006, |
||||||
|
0x0003001e,0x0000003a,0x00000039,0x00040020,0x0000003b,0x00000002,0x0000003a,0x0004003b, |
||||||
|
0x0000003b,0x0000003c,0x00000002,0x0003001d,0x00000041,0x00000006,0x0003001e,0x00000042, |
||||||
|
0x00000041,0x00040020,0x00000043,0x00000002,0x00000042,0x0004003b,0x00000043,0x00000044, |
||||||
|
0x00000002,0x00030016,0x00000052,0x00000020,0x0003001d,0x00000053,0x00000052,0x0003001e, |
||||||
|
0x00000054,0x00000053,0x00040020,0x00000055,0x00000002,0x00000054,0x0004003b,0x00000055, |
||||||
|
0x00000056,0x00000002,0x0003001d,0x00000058,0x00000052,0x0003001e,0x00000059,0x00000058, |
||||||
|
0x00040020,0x0000005a,0x00000002,0x00000059,0x0004003b,0x0000005a,0x0000005b,0x00000002, |
||||||
|
0x00040020,0x0000005d,0x00000002,0x00000052,0x0004002b,0x00000006,0x00000061,0x00000002, |
||||||
|
0x0004002b,0x00000009,0x00000066,0x00000100,0x0004002b,0x00000009,0x00000067,0x00000001, |
||||||
|
0x0006002c,0x0000000a,0x00000068,0x00000066,0x00000067,0x00000067,0x00050036,0x00000002, |
||||||
|
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008, |
||||||
|
0x00000007,0x0004003b,0x00000007,0x00000021,0x00000007,0x0004003b,0x00000007,0x00000022, |
||||||
|
0x00000007,0x0004003b,0x00000007,0x00000024,0x00000007,0x0004003b,0x00000007,0x0000002f, |
||||||
|
0x00000007,0x00050041,0x0000000e,0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009, |
||||||
|
0x00000010,0x0000000f,0x0004007c,0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008, |
||||||
|
0x00000011,0x000200f9,0x00000012,0x000200f8,0x00000012,0x000400f6,0x00000014,0x00000015, |
||||||
|
0x00000000,0x000200f9,0x00000016,0x000200f8,0x00000016,0x0004003d,0x00000006,0x00000017, |
||||||
|
0x00000008,0x00050041,0x0000001c,0x0000001d,0x0000001a,0x0000001b,0x0004003d,0x00000006, |
||||||
|
0x0000001e,0x0000001d,0x000500b1,0x0000001f,0x00000020,0x00000017,0x0000001e,0x000400fa, |
||||||
|
0x00000020,0x00000013,0x00000014,0x000200f8,0x00000013,0x0003003e,0x00000021,0x0000001b, |
||||||
|
0x0004003d,0x00000006,0x00000023,0x00000008,0x0003003e,0x00000022,0x00000023,0x0003003e, |
||||||
|
0x00000024,0x0000001b,0x000200f9,0x00000025,0x000200f8,0x00000025,0x000400f6,0x00000027, |
||||||
|
0x00000028,0x00000000,0x000200f9,0x00000029,0x000200f8,0x00000029,0x0004003d,0x00000006, |
||||||
|
0x0000002a,0x00000024,0x00050041,0x0000001c,0x0000002c,0x0000001a,0x0000002b,0x0004003d, |
||||||
|
0x00000006,0x0000002d,0x0000002c,0x000500b1,0x0000001f,0x0000002e,0x0000002a,0x0000002d, |
||||||
|
0x000400fa,0x0000002e,0x00000026,0x00000027,0x000200f8,0x00000026,0x0004003d,0x00000006, |
||||||
|
0x00000034,0x00000024,0x00060041,0x00000035,0x00000036,0x00000033,0x0000001b,0x00000034, |
||||||
|
0x0004003d,0x00000006,0x00000037,0x00000036,0x0003003e,0x0000002f,0x00000037,0x0004003d, |
||||||
|
0x00000006,0x00000038,0x00000022,0x0004003d,0x00000006,0x0000003d,0x00000024,0x00060041, |
||||||
|
0x00000035,0x0000003e,0x0000003c,0x0000001b,0x0000003d,0x0004003d,0x00000006,0x0000003f, |
||||||
|
0x0000003e,0x00050087,0x00000006,0x00000040,0x00000038,0x0000003f,0x0004003d,0x00000006, |
||||||
|
0x00000045,0x0000002f,0x00060041,0x00000035,0x00000046,0x00000044,0x0000001b,0x00000045, |
||||||
|
0x0004003d,0x00000006,0x00000047,0x00000046,0x00050084,0x00000006,0x00000048,0x00000040, |
||||||
|
0x00000047,0x0004003d,0x00000006,0x00000049,0x00000021,0x00050080,0x00000006,0x0000004a, |
||||||
|
0x00000049,0x00000048,0x0003003e,0x00000021,0x0000004a,0x0004003d,0x00000006,0x0000004b, |
||||||
|
0x00000024,0x00060041,0x00000035,0x0000004c,0x0000003c,0x0000001b,0x0000004b,0x0004003d, |
||||||
|
0x00000006,0x0000004d,0x0000004c,0x0004003d,0x00000006,0x0000004e,0x00000022,0x0005008b, |
||||||
|
0x00000006,0x0000004f,0x0000004e,0x0000004d,0x0003003e,0x00000022,0x0000004f,0x000200f9, |
||||||
|
0x00000028,0x000200f8,0x00000028,0x0004003d,0x00000006,0x00000050,0x00000024,0x00050080, |
||||||
|
0x00000006,0x00000051,0x00000050,0x0000002b,0x0003003e,0x00000024,0x00000051,0x000200f9, |
||||||
|
0x00000025,0x000200f8,0x00000027,0x0004003d,0x00000006,0x00000057,0x00000008,0x0004003d, |
||||||
|
0x00000006,0x0000005c,0x00000021,0x00060041,0x0000005d,0x0000005e,0x0000005b,0x0000001b, |
||||||
|
0x0000005c,0x0004003d,0x00000052,0x0000005f,0x0000005e,0x00060041,0x0000005d,0x00000060, |
||||||
|
0x00000056,0x0000001b,0x00000057,0x0003003e,0x00000060,0x0000005f,0x000200f9,0x00000015, |
||||||
|
0x000200f8,0x00000015,0x00050041,0x0000001c,0x00000062,0x0000001a,0x00000061,0x0004003d, |
||||||
|
0x00000006,0x00000063,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000008,0x00050080, |
||||||
|
0x00000006,0x00000065,0x00000064,0x00000063,0x0003003e,0x00000008,0x00000065,0x000200f9, |
||||||
|
0x00000012,0x000200f8,0x00000014,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,78 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int global_size; |
||||||
|
int nthreads; |
||||||
|
float step_x; |
||||||
|
float step_y; |
||||||
|
int offset_x_size; |
||||||
|
int width_size; |
||||||
|
int layer_w; |
||||||
|
int image_h; |
||||||
|
int image_w; |
||||||
|
int clip; |
||||||
|
int variance_off; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer Input0{ |
||||||
|
float offset_x[]; |
||||||
|
}; |
||||||
|
layout(binding = 1) readonly buffer Input1{ |
||||||
|
float offset_y[]; |
||||||
|
}; |
||||||
|
layout(binding = 2) readonly buffer Input2{ |
||||||
|
float widths[]; |
||||||
|
}; |
||||||
|
layout(binding = 3) readonly buffer Input3{ |
||||||
|
float heights[]; |
||||||
|
}; |
||||||
|
layout(binding = 4) readonly buffer Input4{ |
||||||
|
vec4 variance[]; |
||||||
|
}; |
||||||
|
layout(binding = 5) writeonly buffer Output{ |
||||||
|
vec4 out_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
void main() |
||||||
|
{ |
||||||
|
for (int index = int(gl_GlobalInvocationID.x); index < p.nthreads; index += p.global_size) |
||||||
|
{ |
||||||
|
int w = index % p.layer_w; |
||||||
|
int h = index / p.layer_w; |
||||||
|
int output_offset = index * p.offset_x_size * p.width_size; |
||||||
|
|
||||||
|
float box_w, box_h; |
||||||
|
vec4 outer; |
||||||
|
for (int i = 0; i < p.width_size; ++i) |
||||||
|
{ |
||||||
|
box_w = widths[i]; |
||||||
|
box_h = heights[i]; |
||||||
|
for (int j = 0; j < p.offset_x_size; ++j) |
||||||
|
{ |
||||||
|
float center_x = (w + offset_x[j]) * p.step_x; |
||||||
|
float center_y = (h + offset_y[j]) * p.step_y; |
||||||
|
|
||||||
|
outer.x = (center_x - box_w * 0.5f) / p.image_w; // xmin |
||||||
|
outer.y = (center_y - box_h * 0.5f) / p.image_h; // ymin |
||||||
|
outer.z = (center_x + box_w * 0.5f) / p.image_w; // xmax |
||||||
|
outer.w = (center_y + box_h * 0.5f) / p.image_h; // ymax |
||||||
|
|
||||||
|
// clip |
||||||
|
if (p.clip == 1) |
||||||
|
{ |
||||||
|
vec4 start = vec4(0.f, 0.f, 0.f, 0.f); |
||||||
|
vec4 end = vec4(1.f, 1.f, 1.f, 1.f); |
||||||
|
outer = min(max(outer, start), end); |
||||||
|
} |
||||||
|
|
||||||
|
//set variance |
||||||
|
out_buffer[p.variance_off + output_offset] = variance[0]; |
||||||
|
out_buffer[output_offset] = outer; |
||||||
|
output_offset++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,200 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int prior_box_spv[1480] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x000000db,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00040005,0x00000008,0x65646e69,0x00000078,0x00080005, |
||||||
|
0x0000000c,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005, |
||||||
|
0x00000019,0x68737570,0x636f6c42,0x0000006b,0x00060006,0x00000019,0x00000000,0x626f6c67, |
||||||
|
0x735f6c61,0x00657a69,0x00060006,0x00000019,0x00000001,0x7268746e,0x73646165,0x00000000, |
||||||
|
0x00050006,0x00000019,0x00000002,0x70657473,0x0000785f,0x00050006,0x00000019,0x00000003, |
||||||
|
0x70657473,0x0000795f,0x00070006,0x00000019,0x00000004,0x7366666f,0x785f7465,0x7a69735f, |
||||||
|
0x00000065,0x00060006,0x00000019,0x00000005,0x74646977,0x69735f68,0x0000657a,0x00050006, |
||||||
|
0x00000019,0x00000006,0x6579616c,0x00775f72,0x00050006,0x00000019,0x00000007,0x67616d69, |
||||||
|
0x00685f65,0x00050006,0x00000019,0x00000008,0x67616d69,0x00775f65,0x00050006,0x00000019, |
||||||
|
0x00000009,0x70696c63,0x00000000,0x00070006,0x00000019,0x0000000a,0x69726176,0x65636e61, |
||||||
|
0x66666f5f,0x00000000,0x00030005,0x0000001b,0x00000070,0x00030005,0x00000022,0x00000077, |
||||||
|
0x00030005,0x00000028,0x00000068,0x00060005,0x0000002d,0x7074756f,0x6f5f7475,0x65736666, |
||||||
|
0x00000074,0x00030005,0x00000037,0x00000069,0x00040005,0x00000043,0x5f786f62,0x00000077, |
||||||
|
0x00040005,0x00000045,0x75706e49,0x00003274,0x00050006,0x00000045,0x00000000,0x74646977, |
||||||
|
0x00007368,0x00030005,0x00000047,0x00000000,0x00040005,0x0000004c,0x5f786f62,0x00000068, |
||||||
|
0x00040005,0x0000004e,0x75706e49,0x00003374,0x00050006,0x0000004e,0x00000000,0x67696568, |
||||||
|
0x00737468,0x00030005,0x00000050,0x00000000,0x00030005,0x00000054,0x0000006a,0x00050005, |
||||||
|
0x0000005e,0x746e6563,0x785f7265,0x00000000,0x00040005,0x00000062,0x75706e49,0x00003074, |
||||||
|
0x00060006,0x00000062,0x00000000,0x7366666f,0x785f7465,0x00000000,0x00030005,0x00000064, |
||||||
|
0x00000000,0x00050005,0x0000006e,0x746e6563,0x795f7265,0x00000000,0x00040005,0x00000072, |
||||||
|
0x75706e49,0x00003174,0x00060006,0x00000072,0x00000000,0x7366666f,0x795f7465,0x00000000, |
||||||
|
0x00030005,0x00000074,0x00000000,0x00040005,0x0000007f,0x6574756f,0x00000072,0x00040005, |
||||||
|
0x000000b0,0x72617473,0x00000074,0x00030005,0x000000b3,0x00646e65,0x00040005,0x000000bc, |
||||||
|
0x7074754f,0x00007475,0x00060006,0x000000bc,0x00000000,0x5f74756f,0x66667562,0x00007265, |
||||||
|
0x00030005,0x000000be,0x00000000,0x00040005,0x000000c5,0x75706e49,0x00003474,0x00060006, |
||||||
|
0x000000c5,0x00000000,0x69726176,0x65636e61,0x00000000,0x00030005,0x000000c7,0x00000000, |
||||||
|
0x00040047,0x0000000c,0x0000000b,0x0000001c,0x00050048,0x00000019,0x00000000,0x00000023, |
||||||
|
0x00000000,0x00050048,0x00000019,0x00000001,0x00000023,0x00000004,0x00050048,0x00000019, |
||||||
|
0x00000002,0x00000023,0x00000008,0x00050048,0x00000019,0x00000003,0x00000023,0x0000000c, |
||||||
|
0x00050048,0x00000019,0x00000004,0x00000023,0x00000010,0x00050048,0x00000019,0x00000005, |
||||||
|
0x00000023,0x00000014,0x00050048,0x00000019,0x00000006,0x00000023,0x00000018,0x00050048, |
||||||
|
0x00000019,0x00000007,0x00000023,0x0000001c,0x00050048,0x00000019,0x00000008,0x00000023, |
||||||
|
0x00000020,0x00050048,0x00000019,0x00000009,0x00000023,0x00000024,0x00050048,0x00000019, |
||||||
|
0x0000000a,0x00000023,0x00000028,0x00030047,0x00000019,0x00000002,0x00040047,0x00000044, |
||||||
|
0x00000006,0x00000004,0x00040048,0x00000045,0x00000000,0x00000018,0x00050048,0x00000045, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x00000045,0x00000003,0x00040047,0x00000047, |
||||||
|
0x00000022,0x00000000,0x00040047,0x00000047,0x00000021,0x00000002,0x00040047,0x0000004d, |
||||||
|
0x00000006,0x00000004,0x00040048,0x0000004e,0x00000000,0x00000018,0x00050048,0x0000004e, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x0000004e,0x00000003,0x00040047,0x00000050, |
||||||
|
0x00000022,0x00000000,0x00040047,0x00000050,0x00000021,0x00000003,0x00040047,0x00000061, |
||||||
|
0x00000006,0x00000004,0x00040048,0x00000062,0x00000000,0x00000018,0x00050048,0x00000062, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x00000062,0x00000003,0x00040047,0x00000064, |
||||||
|
0x00000022,0x00000000,0x00040047,0x00000064,0x00000021,0x00000000,0x00040047,0x00000071, |
||||||
|
0x00000006,0x00000004,0x00040048,0x00000072,0x00000000,0x00000018,0x00050048,0x00000072, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x00000072,0x00000003,0x00040047,0x00000074, |
||||||
|
0x00000022,0x00000000,0x00040047,0x00000074,0x00000021,0x00000001,0x00040047,0x000000bb, |
||||||
|
0x00000006,0x00000010,0x00040048,0x000000bc,0x00000000,0x00000019,0x00050048,0x000000bc, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x000000bc,0x00000003,0x00040047,0x000000be, |
||||||
|
0x00000022,0x00000000,0x00040047,0x000000be,0x00000021,0x00000005,0x00040047,0x000000c4, |
||||||
|
0x00000006,0x00000010,0x00040048,0x000000c5,0x00000000,0x00000018,0x00050048,0x000000c5, |
||||||
|
0x00000000,0x00000023,0x00000000,0x00030047,0x000000c5,0x00000003,0x00040047,0x000000c7, |
||||||
|
0x00000022,0x00000000,0x00040047,0x000000c7,0x00000021,0x00000004,0x00040047,0x000000da, |
||||||
|
0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015, |
||||||
|
0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007,0x00000006,0x00040015, |
||||||
|
0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009,0x00000003,0x00040020, |
||||||
|
0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000001,0x0004002b, |
||||||
|
0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000009,0x00030016, |
||||||
|
0x00000018,0x00000020,0x000d001e,0x00000019,0x00000006,0x00000006,0x00000018,0x00000018, |
||||||
|
0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020, |
||||||
|
0x0000001a,0x00000009,0x00000019,0x0004003b,0x0000001a,0x0000001b,0x00000009,0x0004002b, |
||||||
|
0x00000006,0x0000001c,0x00000001,0x00040020,0x0000001d,0x00000009,0x00000006,0x00020014, |
||||||
|
0x00000020,0x0004002b,0x00000006,0x00000024,0x00000006,0x0004002b,0x00000006,0x0000002f, |
||||||
|
0x00000004,0x0004002b,0x00000006,0x00000033,0x00000005,0x0004002b,0x00000006,0x00000038, |
||||||
|
0x00000000,0x00040020,0x00000042,0x00000007,0x00000018,0x0003001d,0x00000044,0x00000018, |
||||||
|
0x0003001e,0x00000045,0x00000044,0x00040020,0x00000046,0x00000002,0x00000045,0x0004003b, |
||||||
|
0x00000046,0x00000047,0x00000002,0x00040020,0x00000049,0x00000002,0x00000018,0x0003001d, |
||||||
|
0x0000004d,0x00000018,0x0003001e,0x0000004e,0x0000004d,0x00040020,0x0000004f,0x00000002, |
||||||
|
0x0000004e,0x0004003b,0x0000004f,0x00000050,0x00000002,0x0003001d,0x00000061,0x00000018, |
||||||
|
0x0003001e,0x00000062,0x00000061,0x00040020,0x00000063,0x00000002,0x00000062,0x0004003b, |
||||||
|
0x00000063,0x00000064,0x00000002,0x0004002b,0x00000006,0x00000069,0x00000002,0x00040020, |
||||||
|
0x0000006a,0x00000009,0x00000018,0x0003001d,0x00000071,0x00000018,0x0003001e,0x00000072, |
||||||
|
0x00000071,0x00040020,0x00000073,0x00000002,0x00000072,0x0004003b,0x00000073,0x00000074, |
||||||
|
0x00000002,0x0004002b,0x00000006,0x00000079,0x00000003,0x00040017,0x0000007d,0x00000018, |
||||||
|
0x00000004,0x00040020,0x0000007e,0x00000007,0x0000007d,0x0004002b,0x00000018,0x00000082, |
||||||
|
0x3f000000,0x0004002b,0x00000006,0x00000085,0x00000008,0x0004002b,0x00000006,0x0000008f, |
||||||
|
0x00000007,0x0004002b,0x00000009,0x00000094,0x00000001,0x0004002b,0x00000009,0x0000009e, |
||||||
|
0x00000002,0x0004002b,0x00000009,0x000000a8,0x00000003,0x0004002b,0x00000006,0x000000aa, |
||||||
|
0x00000009,0x0004002b,0x00000018,0x000000b1,0x00000000,0x0007002c,0x0000007d,0x000000b2, |
||||||
|
0x000000b1,0x000000b1,0x000000b1,0x000000b1,0x0004002b,0x00000018,0x000000b4,0x3f800000, |
||||||
|
0x0007002c,0x0000007d,0x000000b5,0x000000b4,0x000000b4,0x000000b4,0x000000b4,0x0003001d, |
||||||
|
0x000000bb,0x0000007d,0x0003001e,0x000000bc,0x000000bb,0x00040020,0x000000bd,0x00000002, |
||||||
|
0x000000bc,0x0004003b,0x000000bd,0x000000be,0x00000002,0x0004002b,0x00000006,0x000000bf, |
||||||
|
0x0000000a,0x0003001d,0x000000c4,0x0000007d,0x0003001e,0x000000c5,0x000000c4,0x00040020, |
||||||
|
0x000000c6,0x00000002,0x000000c5,0x0004003b,0x000000c6,0x000000c7,0x00000002,0x00040020, |
||||||
|
0x000000c8,0x00000002,0x0000007d,0x0004002b,0x00000009,0x000000d9,0x00000100,0x0006002c, |
||||||
|
0x0000000a,0x000000da,0x000000d9,0x00000094,0x00000094,0x00050036,0x00000002,0x00000004, |
||||||
|
0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000022,0x00000007,0x0004003b,0x00000007,0x00000028,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000002d,0x00000007,0x0004003b,0x00000007,0x00000037,0x00000007, |
||||||
|
0x0004003b,0x00000042,0x00000043,0x00000007,0x0004003b,0x00000042,0x0000004c,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000054,0x00000007,0x0004003b,0x00000042,0x0000005e,0x00000007, |
||||||
|
0x0004003b,0x00000042,0x0000006e,0x00000007,0x0004003b,0x0000007e,0x0000007f,0x00000007, |
||||||
|
0x0004003b,0x0000007e,0x000000b0,0x00000007,0x0004003b,0x0000007e,0x000000b3,0x00000007, |
||||||
|
0x00050041,0x0000000e,0x0000000f,0x0000000c,0x0000000d,0x0004003d,0x00000009,0x00000010, |
||||||
|
0x0000000f,0x0004007c,0x00000006,0x00000011,0x00000010,0x0003003e,0x00000008,0x00000011, |
||||||
|
0x000200f9,0x00000012,0x000200f8,0x00000012,0x000400f6,0x00000014,0x00000015,0x00000000, |
||||||
|
0x000200f9,0x00000016,0x000200f8,0x00000016,0x0004003d,0x00000006,0x00000017,0x00000008, |
||||||
|
0x00050041,0x0000001d,0x0000001e,0x0000001b,0x0000001c,0x0004003d,0x00000006,0x0000001f, |
||||||
|
0x0000001e,0x000500b1,0x00000020,0x00000021,0x00000017,0x0000001f,0x000400fa,0x00000021, |
||||||
|
0x00000013,0x00000014,0x000200f8,0x00000013,0x0004003d,0x00000006,0x00000023,0x00000008, |
||||||
|
0x00050041,0x0000001d,0x00000025,0x0000001b,0x00000024,0x0004003d,0x00000006,0x00000026, |
||||||
|
0x00000025,0x0005008b,0x00000006,0x00000027,0x00000023,0x00000026,0x0003003e,0x00000022, |
||||||
|
0x00000027,0x0004003d,0x00000006,0x00000029,0x00000008,0x00050041,0x0000001d,0x0000002a, |
||||||
|
0x0000001b,0x00000024,0x0004003d,0x00000006,0x0000002b,0x0000002a,0x00050087,0x00000006, |
||||||
|
0x0000002c,0x00000029,0x0000002b,0x0003003e,0x00000028,0x0000002c,0x0004003d,0x00000006, |
||||||
|
0x0000002e,0x00000008,0x00050041,0x0000001d,0x00000030,0x0000001b,0x0000002f,0x0004003d, |
||||||
|
0x00000006,0x00000031,0x00000030,0x00050084,0x00000006,0x00000032,0x0000002e,0x00000031, |
||||||
|
0x00050041,0x0000001d,0x00000034,0x0000001b,0x00000033,0x0004003d,0x00000006,0x00000035, |
||||||
|
0x00000034,0x00050084,0x00000006,0x00000036,0x00000032,0x00000035,0x0003003e,0x0000002d, |
||||||
|
0x00000036,0x0003003e,0x00000037,0x00000038,0x000200f9,0x00000039,0x000200f8,0x00000039, |
||||||
|
0x000400f6,0x0000003b,0x0000003c,0x00000000,0x000200f9,0x0000003d,0x000200f8,0x0000003d, |
||||||
|
0x0004003d,0x00000006,0x0000003e,0x00000037,0x00050041,0x0000001d,0x0000003f,0x0000001b, |
||||||
|
0x00000033,0x0004003d,0x00000006,0x00000040,0x0000003f,0x000500b1,0x00000020,0x00000041, |
||||||
|
0x0000003e,0x00000040,0x000400fa,0x00000041,0x0000003a,0x0000003b,0x000200f8,0x0000003a, |
||||||
|
0x0004003d,0x00000006,0x00000048,0x00000037,0x00060041,0x00000049,0x0000004a,0x00000047, |
||||||
|
0x00000038,0x00000048,0x0004003d,0x00000018,0x0000004b,0x0000004a,0x0003003e,0x00000043, |
||||||
|
0x0000004b,0x0004003d,0x00000006,0x00000051,0x00000037,0x00060041,0x00000049,0x00000052, |
||||||
|
0x00000050,0x00000038,0x00000051,0x0004003d,0x00000018,0x00000053,0x00000052,0x0003003e, |
||||||
|
0x0000004c,0x00000053,0x0003003e,0x00000054,0x00000038,0x000200f9,0x00000055,0x000200f8, |
||||||
|
0x00000055,0x000400f6,0x00000057,0x00000058,0x00000000,0x000200f9,0x00000059,0x000200f8, |
||||||
|
0x00000059,0x0004003d,0x00000006,0x0000005a,0x00000054,0x00050041,0x0000001d,0x0000005b, |
||||||
|
0x0000001b,0x0000002f,0x0004003d,0x00000006,0x0000005c,0x0000005b,0x000500b1,0x00000020, |
||||||
|
0x0000005d,0x0000005a,0x0000005c,0x000400fa,0x0000005d,0x00000056,0x00000057,0x000200f8, |
||||||
|
0x00000056,0x0004003d,0x00000006,0x0000005f,0x00000022,0x0004006f,0x00000018,0x00000060, |
||||||
|
0x0000005f,0x0004003d,0x00000006,0x00000065,0x00000054,0x00060041,0x00000049,0x00000066, |
||||||
|
0x00000064,0x00000038,0x00000065,0x0004003d,0x00000018,0x00000067,0x00000066,0x00050081, |
||||||
|
0x00000018,0x00000068,0x00000060,0x00000067,0x00050041,0x0000006a,0x0000006b,0x0000001b, |
||||||
|
0x00000069,0x0004003d,0x00000018,0x0000006c,0x0000006b,0x00050085,0x00000018,0x0000006d, |
||||||
|
0x00000068,0x0000006c,0x0003003e,0x0000005e,0x0000006d,0x0004003d,0x00000006,0x0000006f, |
||||||
|
0x00000028,0x0004006f,0x00000018,0x00000070,0x0000006f,0x0004003d,0x00000006,0x00000075, |
||||||
|
0x00000054,0x00060041,0x00000049,0x00000076,0x00000074,0x00000038,0x00000075,0x0004003d, |
||||||
|
0x00000018,0x00000077,0x00000076,0x00050081,0x00000018,0x00000078,0x00000070,0x00000077, |
||||||
|
0x00050041,0x0000006a,0x0000007a,0x0000001b,0x00000079,0x0004003d,0x00000018,0x0000007b, |
||||||
|
0x0000007a,0x00050085,0x00000018,0x0000007c,0x00000078,0x0000007b,0x0003003e,0x0000006e, |
||||||
|
0x0000007c,0x0004003d,0x00000018,0x00000080,0x0000005e,0x0004003d,0x00000018,0x00000081, |
||||||
|
0x00000043,0x00050085,0x00000018,0x00000083,0x00000081,0x00000082,0x00050083,0x00000018, |
||||||
|
0x00000084,0x00000080,0x00000083,0x00050041,0x0000001d,0x00000086,0x0000001b,0x00000085, |
||||||
|
0x0004003d,0x00000006,0x00000087,0x00000086,0x0004006f,0x00000018,0x00000088,0x00000087, |
||||||
|
0x00050088,0x00000018,0x00000089,0x00000084,0x00000088,0x00050041,0x00000042,0x0000008a, |
||||||
|
0x0000007f,0x0000000d,0x0003003e,0x0000008a,0x00000089,0x0004003d,0x00000018,0x0000008b, |
||||||
|
0x0000006e,0x0004003d,0x00000018,0x0000008c,0x0000004c,0x00050085,0x00000018,0x0000008d, |
||||||
|
0x0000008c,0x00000082,0x00050083,0x00000018,0x0000008e,0x0000008b,0x0000008d,0x00050041, |
||||||
|
0x0000001d,0x00000090,0x0000001b,0x0000008f,0x0004003d,0x00000006,0x00000091,0x00000090, |
||||||
|
0x0004006f,0x00000018,0x00000092,0x00000091,0x00050088,0x00000018,0x00000093,0x0000008e, |
||||||
|
0x00000092,0x00050041,0x00000042,0x00000095,0x0000007f,0x00000094,0x0003003e,0x00000095, |
||||||
|
0x00000093,0x0004003d,0x00000018,0x00000096,0x0000005e,0x0004003d,0x00000018,0x00000097, |
||||||
|
0x00000043,0x00050085,0x00000018,0x00000098,0x00000097,0x00000082,0x00050081,0x00000018, |
||||||
|
0x00000099,0x00000096,0x00000098,0x00050041,0x0000001d,0x0000009a,0x0000001b,0x00000085, |
||||||
|
0x0004003d,0x00000006,0x0000009b,0x0000009a,0x0004006f,0x00000018,0x0000009c,0x0000009b, |
||||||
|
0x00050088,0x00000018,0x0000009d,0x00000099,0x0000009c,0x00050041,0x00000042,0x0000009f, |
||||||
|
0x0000007f,0x0000009e,0x0003003e,0x0000009f,0x0000009d,0x0004003d,0x00000018,0x000000a0, |
||||||
|
0x0000006e,0x0004003d,0x00000018,0x000000a1,0x0000004c,0x00050085,0x00000018,0x000000a2, |
||||||
|
0x000000a1,0x00000082,0x00050081,0x00000018,0x000000a3,0x000000a0,0x000000a2,0x00050041, |
||||||
|
0x0000001d,0x000000a4,0x0000001b,0x0000008f,0x0004003d,0x00000006,0x000000a5,0x000000a4, |
||||||
|
0x0004006f,0x00000018,0x000000a6,0x000000a5,0x00050088,0x00000018,0x000000a7,0x000000a3, |
||||||
|
0x000000a6,0x00050041,0x00000042,0x000000a9,0x0000007f,0x000000a8,0x0003003e,0x000000a9, |
||||||
|
0x000000a7,0x00050041,0x0000001d,0x000000ab,0x0000001b,0x000000aa,0x0004003d,0x00000006, |
||||||
|
0x000000ac,0x000000ab,0x000500aa,0x00000020,0x000000ad,0x000000ac,0x0000001c,0x000300f7, |
||||||
|
0x000000af,0x00000000,0x000400fa,0x000000ad,0x000000ae,0x000000af,0x000200f8,0x000000ae, |
||||||
|
0x0003003e,0x000000b0,0x000000b2,0x0003003e,0x000000b3,0x000000b5,0x0004003d,0x0000007d, |
||||||
|
0x000000b6,0x0000007f,0x0004003d,0x0000007d,0x000000b7,0x000000b0,0x0007000c,0x0000007d, |
||||||
|
0x000000b8,0x00000001,0x00000028,0x000000b6,0x000000b7,0x0004003d,0x0000007d,0x000000b9, |
||||||
|
0x000000b3,0x0007000c,0x0000007d,0x000000ba,0x00000001,0x00000025,0x000000b8,0x000000b9, |
||||||
|
0x0003003e,0x0000007f,0x000000ba,0x000200f9,0x000000af,0x000200f8,0x000000af,0x00050041, |
||||||
|
0x0000001d,0x000000c0,0x0000001b,0x000000bf,0x0004003d,0x00000006,0x000000c1,0x000000c0, |
||||||
|
0x0004003d,0x00000006,0x000000c2,0x0000002d,0x00050080,0x00000006,0x000000c3,0x000000c1, |
||||||
|
0x000000c2,0x00060041,0x000000c8,0x000000c9,0x000000c7,0x00000038,0x00000038,0x0004003d, |
||||||
|
0x0000007d,0x000000ca,0x000000c9,0x00060041,0x000000c8,0x000000cb,0x000000be,0x00000038, |
||||||
|
0x000000c3,0x0003003e,0x000000cb,0x000000ca,0x0004003d,0x00000006,0x000000cc,0x0000002d, |
||||||
|
0x0004003d,0x0000007d,0x000000cd,0x0000007f,0x00060041,0x000000c8,0x000000ce,0x000000be, |
||||||
|
0x00000038,0x000000cc,0x0003003e,0x000000ce,0x000000cd,0x0004003d,0x00000006,0x000000cf, |
||||||
|
0x0000002d,0x00050080,0x00000006,0x000000d0,0x000000cf,0x0000001c,0x0003003e,0x0000002d, |
||||||
|
0x000000d0,0x000200f9,0x00000058,0x000200f8,0x00000058,0x0004003d,0x00000006,0x000000d1, |
||||||
|
0x00000054,0x00050080,0x00000006,0x000000d2,0x000000d1,0x0000001c,0x0003003e,0x00000054, |
||||||
|
0x000000d2,0x000200f9,0x00000055,0x000200f8,0x00000057,0x000200f9,0x0000003c,0x000200f8, |
||||||
|
0x0000003c,0x0004003d,0x00000006,0x000000d3,0x00000037,0x00050080,0x00000006,0x000000d4, |
||||||
|
0x000000d3,0x0000001c,0x0003003e,0x00000037,0x000000d4,0x000200f9,0x00000039,0x000200f8, |
||||||
|
0x0000003b,0x000200f9,0x00000015,0x000200f8,0x00000015,0x00050041,0x0000001d,0x000000d5, |
||||||
|
0x0000001b,0x00000038,0x0004003d,0x00000006,0x000000d6,0x000000d5,0x0004003d,0x00000006, |
||||||
|
0x000000d7,0x00000008,0x00050080,0x00000006,0x000000d8,0x000000d7,0x000000d6,0x0003003e, |
||||||
|
0x00000008,0x000000d8,0x000200f9,0x00000012,0x000200f8,0x00000014,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,24 @@ |
|||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 32 |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int total; |
||||||
|
float slope; |
||||||
|
} p; |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer inbuf{ |
||||||
|
float in_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(binding = 1) writeonly buffer outbuf{ |
||||||
|
float out_buffer[]; |
||||||
|
}; |
||||||
|
|
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
void main() |
||||||
|
{ |
||||||
|
for (int i = int(gl_GlobalInvocationID.x); i < p.total; i += int(gl_NumWorkGroups.x * gl_WorkGroupSize.x)) |
||||||
|
{ |
||||||
|
float in_val = in_buffer[i]; |
||||||
|
out_buffer[i] = in_val >= 0.f ? in_val : p.slope * in_val; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int relu_spv[502] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x0000004b,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0007000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00000041,0x00060010, |
||||||
|
0x00000004,0x00000011,0x00000020,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2, |
||||||
|
0x00040005,0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00000069,0x00080005, |
||||||
|
0x0000000c,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005, |
||||||
|
0x00000019,0x68737570,0x636f6c42,0x0000006b,0x00050006,0x00000019,0x00000000,0x61746f74, |
||||||
|
0x0000006c,0x00050006,0x00000019,0x00000001,0x706f6c73,0x00000065,0x00030005,0x0000001b, |
||||||
|
0x00000070,0x00040005,0x00000023,0x765f6e69,0x00006c61,0x00040005,0x00000025,0x75626e69, |
||||||
|
0x00000066,0x00060006,0x00000025,0x00000000,0x625f6e69,0x65666675,0x00000072,0x00030005, |
||||||
|
0x00000027,0x00000000,0x00040005,0x0000002d,0x6274756f,0x00006675,0x00060006,0x0000002d, |
||||||
|
0x00000000,0x5f74756f,0x66667562,0x00007265,0x00030005,0x0000002f,0x00000000,0x00070005, |
||||||
|
0x00000041,0x4e5f6c67,0x6f576d75,0x72476b72,0x7370756f,0x00000000,0x00040047,0x0000000c, |
||||||
|
0x0000000b,0x0000001c,0x00050048,0x00000019,0x00000000,0x00000023,0x00000000,0x00050048, |
||||||
|
0x00000019,0x00000001,0x00000023,0x00000004,0x00030047,0x00000019,0x00000002,0x00040047, |
||||||
|
0x00000024,0x00000006,0x00000004,0x00040048,0x00000025,0x00000000,0x00000018,0x00050048, |
||||||
|
0x00000025,0x00000000,0x00000023,0x00000000,0x00030047,0x00000025,0x00000003,0x00040047, |
||||||
|
0x00000027,0x00000022,0x00000000,0x00040047,0x00000027,0x00000021,0x00000000,0x00040047, |
||||||
|
0x0000002c,0x00000006,0x00000004,0x00040048,0x0000002d,0x00000000,0x00000019,0x00050048, |
||||||
|
0x0000002d,0x00000000,0x00000023,0x00000000,0x00030047,0x0000002d,0x00000003,0x00040047, |
||||||
|
0x0000002f,0x00000022,0x00000000,0x00040047,0x0000002f,0x00000021,0x00000001,0x00040047, |
||||||
|
0x00000041,0x0000000b,0x00000018,0x00040047,0x0000004a,0x0000000b,0x00000019,0x00020013, |
||||||
|
0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001, |
||||||
|
0x00040020,0x00000007,0x00000007,0x00000006,0x00040015,0x00000009,0x00000020,0x00000000, |
||||||
|
0x00040017,0x0000000a,0x00000009,0x00000003,0x00040020,0x0000000b,0x00000001,0x0000000a, |
||||||
|
0x0004003b,0x0000000b,0x0000000c,0x00000001,0x0004002b,0x00000009,0x0000000d,0x00000000, |
||||||
|
0x00040020,0x0000000e,0x00000001,0x00000009,0x00030016,0x00000018,0x00000020,0x0004001e, |
||||||
|
0x00000019,0x00000006,0x00000018,0x00040020,0x0000001a,0x00000009,0x00000019,0x0004003b, |
||||||
|
0x0000001a,0x0000001b,0x00000009,0x0004002b,0x00000006,0x0000001c,0x00000000,0x00040020, |
||||||
|
0x0000001d,0x00000009,0x00000006,0x00020014,0x00000020,0x00040020,0x00000022,0x00000007, |
||||||
|
0x00000018,0x0003001d,0x00000024,0x00000018,0x0003001e,0x00000025,0x00000024,0x00040020, |
||||||
|
0x00000026,0x00000002,0x00000025,0x0004003b,0x00000026,0x00000027,0x00000002,0x00040020, |
||||||
|
0x00000029,0x00000002,0x00000018,0x0003001d,0x0000002c,0x00000018,0x0003001e,0x0000002d, |
||||||
|
0x0000002c,0x00040020,0x0000002e,0x00000002,0x0000002d,0x0004003b,0x0000002e,0x0000002f, |
||||||
|
0x00000002,0x0004002b,0x00000018,0x00000033,0x00000000,0x0004002b,0x00000006,0x00000039, |
||||||
|
0x00000001,0x00040020,0x0000003a,0x00000009,0x00000018,0x0004003b,0x0000000b,0x00000041, |
||||||
|
0x00000001,0x0004002b,0x00000009,0x00000044,0x00000020,0x0004002b,0x00000009,0x00000049, |
||||||
|
0x00000001,0x0006002c,0x0000000a,0x0000004a,0x00000044,0x00000049,0x00000049,0x00050036, |
||||||
|
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007, |
||||||
|
0x00000008,0x00000007,0x0004003b,0x00000022,0x00000023,0x00000007,0x0004003b,0x00000022, |
||||||
|
0x00000031,0x00000007,0x00050041,0x0000000e,0x0000000f,0x0000000c,0x0000000d,0x0004003d, |
||||||
|
0x00000009,0x00000010,0x0000000f,0x0004007c,0x00000006,0x00000011,0x00000010,0x0003003e, |
||||||
|
0x00000008,0x00000011,0x000200f9,0x00000012,0x000200f8,0x00000012,0x000400f6,0x00000014, |
||||||
|
0x00000015,0x00000000,0x000200f9,0x00000016,0x000200f8,0x00000016,0x0004003d,0x00000006, |
||||||
|
0x00000017,0x00000008,0x00050041,0x0000001d,0x0000001e,0x0000001b,0x0000001c,0x0004003d, |
||||||
|
0x00000006,0x0000001f,0x0000001e,0x000500b1,0x00000020,0x00000021,0x00000017,0x0000001f, |
||||||
|
0x000400fa,0x00000021,0x00000013,0x00000014,0x000200f8,0x00000013,0x0004003d,0x00000006, |
||||||
|
0x00000028,0x00000008,0x00060041,0x00000029,0x0000002a,0x00000027,0x0000001c,0x00000028, |
||||||
|
0x0004003d,0x00000018,0x0000002b,0x0000002a,0x0003003e,0x00000023,0x0000002b,0x0004003d, |
||||||
|
0x00000006,0x00000030,0x00000008,0x0004003d,0x00000018,0x00000032,0x00000023,0x000500be, |
||||||
|
0x00000020,0x00000034,0x00000032,0x00000033,0x000300f7,0x00000036,0x00000000,0x000400fa, |
||||||
|
0x00000034,0x00000035,0x00000038,0x000200f8,0x00000035,0x0004003d,0x00000018,0x00000037, |
||||||
|
0x00000023,0x0003003e,0x00000031,0x00000037,0x000200f9,0x00000036,0x000200f8,0x00000038, |
||||||
|
0x00050041,0x0000003a,0x0000003b,0x0000001b,0x00000039,0x0004003d,0x00000018,0x0000003c, |
||||||
|
0x0000003b,0x0004003d,0x00000018,0x0000003d,0x00000023,0x00050085,0x00000018,0x0000003e, |
||||||
|
0x0000003c,0x0000003d,0x0003003e,0x00000031,0x0000003e,0x000200f9,0x00000036,0x000200f8, |
||||||
|
0x00000036,0x0004003d,0x00000018,0x0000003f,0x00000031,0x00060041,0x00000029,0x00000040, |
||||||
|
0x0000002f,0x0000001c,0x00000030,0x0003003e,0x00000040,0x0000003f,0x000200f9,0x00000015, |
||||||
|
0x000200f8,0x00000015,0x00050041,0x0000000e,0x00000042,0x00000041,0x0000000d,0x0004003d, |
||||||
|
0x00000009,0x00000043,0x00000042,0x00050084,0x00000009,0x00000045,0x00000043,0x00000044, |
||||||
|
0x0004007c,0x00000006,0x00000046,0x00000045,0x0004003d,0x00000006,0x00000047,0x00000008, |
||||||
|
0x00050080,0x00000006,0x00000048,0x00000047,0x00000046,0x0003003e,0x00000008,0x00000048, |
||||||
|
0x000200f9,0x00000012,0x000200f8,0x00000014,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,78 @@ |
|||||||
|
|
||||||
|
#version 450 |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
layout(binding = 0) readonly buffer buf0{ |
||||||
|
float input_buffer[]; // outer_size * channels * channel_size |
||||||
|
}; |
||||||
|
layout(binding = 1) buffer buf1{ |
||||||
|
float max_buffer[]; // outer_size * channel_size |
||||||
|
}; |
||||||
|
layout(binding = 2) buffer buf2{ |
||||||
|
float sum_buffer[]; // outer_size * channel_size |
||||||
|
}; |
||||||
|
layout(binding = 3) buffer buf3{ |
||||||
|
float output_buffer[]; // outer_size * channels * channel_size |
||||||
|
}; |
||||||
|
layout(push_constant) uniform pushBlock { |
||||||
|
int channel_size; |
||||||
|
int outer_size; |
||||||
|
int channels; |
||||||
|
} p; |
||||||
|
layout(local_size_x = LOCAL_SZ_X, local_size_y = 1, local_size_z = 1) in; |
||||||
|
|
||||||
|
void main() |
||||||
|
{ |
||||||
|
int gid = int(gl_GlobalInvocationID.x); |
||||||
|
if (gid >= p.outer_size) return; |
||||||
|
|
||||||
|
int global_off = gid * p.channels * p.channel_size; |
||||||
|
int reduced_buffer_off = gid * p.channel_size; |
||||||
|
|
||||||
|
// find the max along channel |
||||||
|
int index = global_off; |
||||||
|
for (int i = 0; i < p.channel_size; ++i) |
||||||
|
{ |
||||||
|
max_buffer[reduced_buffer_off + i] = input_buffer[index]; |
||||||
|
index++; |
||||||
|
} |
||||||
|
for (int c = 1; c < p.channels; ++c) |
||||||
|
{ |
||||||
|
for (int i = 0; i < p.channel_size; ++i) |
||||||
|
{ |
||||||
|
max_buffer[reduced_buffer_off + i] = max(max_buffer[reduced_buffer_off + i], input_buffer[index]); |
||||||
|
index++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// substract, exp and accumulate along channel |
||||||
|
for (int i = 0; i < p.channel_size; ++i) |
||||||
|
sum_buffer[reduced_buffer_off + i] = 0.f; |
||||||
|
|
||||||
|
index = global_off; |
||||||
|
for (int c = 0; c < p.channels; ++c) |
||||||
|
{ |
||||||
|
for (int i = 0; i < p.channel_size; ++i) |
||||||
|
{ |
||||||
|
float exp_val = exp(input_buffer[index] - max_buffer[reduced_buffer_off + i]); |
||||||
|
output_buffer[index] = exp_val; |
||||||
|
sum_buffer[reduced_buffer_off + i] += exp_val; |
||||||
|
index++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// divide by computed sum |
||||||
|
index = global_off; |
||||||
|
for (int c = 0; c < p.channels; ++c) |
||||||
|
{ |
||||||
|
for (int i = 0; i < p.channel_size; ++i) |
||||||
|
{ |
||||||
|
float v = output_buffer[index] / sum_buffer[reduced_buffer_off + i]; |
||||||
|
#ifdef LOG_SOFTMAX |
||||||
|
v = log(v); |
||||||
|
#endif |
||||||
|
output_buffer[index] = v; |
||||||
|
index++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,195 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int softmax_spv[1440] = { |
||||||
|
0x07230203,0x00010000,0x00080001,0x000000ec,0x00000000,0x00020011,0x00000001,0x0006000b, |
||||||
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, |
||||||
|
0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000c,0x00060010,0x00000004, |
||||||
|
0x00000011,0x00000100,0x00000001,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, |
||||||
|
0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000008,0x00646967,0x00080005,0x0000000c, |
||||||
|
0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005,0x00000013, |
||||||
|
0x68737570,0x636f6c42,0x0000006b,0x00070006,0x00000013,0x00000000,0x6e616863,0x5f6c656e, |
||||||
|
0x657a6973,0x00000000,0x00060006,0x00000013,0x00000001,0x6574756f,0x69735f72,0x0000657a, |
||||||
|
0x00060006,0x00000013,0x00000002,0x6e616863,0x736c656e,0x00000000,0x00030005,0x00000015, |
||||||
|
0x00000070,0x00050005,0x0000001f,0x626f6c67,0x6f5f6c61,0x00006666,0x00070005,0x00000029, |
||||||
|
0x75646572,0x5f646563,0x66667562,0x6f5f7265,0x00006666,0x00040005,0x0000002e,0x65646e69, |
||||||
|
0x00000078,0x00030005,0x00000030,0x00000069,0x00040005,0x0000003c,0x31667562,0x00000000, |
||||||
|
0x00060006,0x0000003c,0x00000000,0x5f78616d,0x66667562,0x00007265,0x00030005,0x0000003e, |
||||||
|
0x00000000,0x00040005,0x00000043,0x30667562,0x00000000,0x00070006,0x00000043,0x00000000, |
||||||
|
0x75706e69,0x75625f74,0x72656666,0x00000000,0x00030005,0x00000045,0x00000000,0x00030005, |
||||||
|
0x0000004f,0x00000063,0x00030005,0x00000059,0x00000069,0x00030005,0x00000076,0x00000069, |
||||||
|
0x00040005,0x00000081,0x32667562,0x00000000,0x00060006,0x00000081,0x00000000,0x5f6d7573, |
||||||
|
0x66667562,0x00007265,0x00030005,0x00000083,0x00000000,0x00030005,0x0000008c,0x00000063, |
||||||
|
0x00030005,0x00000096,0x00000069,0x00040005,0x000000a1,0x5f707865,0x006c6176,0x00040005, |
||||||
|
0x000000ad,0x33667562,0x00000000,0x00070006,0x000000ad,0x00000000,0x7074756f,0x625f7475, |
||||||
|
0x65666675,0x00000072,0x00030005,0x000000af,0x00000000,0x00030005,0x000000c2,0x00000063, |
||||||
|
0x00030005,0x000000cc,0x00000069,0x00030005,0x000000d6,0x00000076,0x00040047,0x0000000c, |
||||||
|
0x0000000b,0x0000001c,0x00050048,0x00000013,0x00000000,0x00000023,0x00000000,0x00050048, |
||||||
|
0x00000013,0x00000001,0x00000023,0x00000004,0x00050048,0x00000013,0x00000002,0x00000023, |
||||||
|
0x00000008,0x00030047,0x00000013,0x00000002,0x00040047,0x0000003b,0x00000006,0x00000004, |
||||||
|
0x00050048,0x0000003c,0x00000000,0x00000023,0x00000000,0x00030047,0x0000003c,0x00000003, |
||||||
|
0x00040047,0x0000003e,0x00000022,0x00000000,0x00040047,0x0000003e,0x00000021,0x00000001, |
||||||
|
0x00040047,0x00000042,0x00000006,0x00000004,0x00040048,0x00000043,0x00000000,0x00000018, |
||||||
|
0x00050048,0x00000043,0x00000000,0x00000023,0x00000000,0x00030047,0x00000043,0x00000003, |
||||||
|
0x00040047,0x00000045,0x00000022,0x00000000,0x00040047,0x00000045,0x00000021,0x00000000, |
||||||
|
0x00040047,0x00000080,0x00000006,0x00000004,0x00050048,0x00000081,0x00000000,0x00000023, |
||||||
|
0x00000000,0x00030047,0x00000081,0x00000003,0x00040047,0x00000083,0x00000022,0x00000000, |
||||||
|
0x00040047,0x00000083,0x00000021,0x00000002,0x00040047,0x000000ac,0x00000006,0x00000004, |
||||||
|
0x00050048,0x000000ad,0x00000000,0x00000023,0x00000000,0x00030047,0x000000ad,0x00000003, |
||||||
|
0x00040047,0x000000af,0x00000022,0x00000000,0x00040047,0x000000af,0x00000021,0x00000003, |
||||||
|
0x00040047,0x000000eb,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003, |
||||||
|
0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040020,0x00000007,0x00000007, |
||||||
|
0x00000006,0x00040015,0x00000009,0x00000020,0x00000000,0x00040017,0x0000000a,0x00000009, |
||||||
|
0x00000003,0x00040020,0x0000000b,0x00000001,0x0000000a,0x0004003b,0x0000000b,0x0000000c, |
||||||
|
0x00000001,0x0004002b,0x00000009,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001, |
||||||
|
0x00000009,0x0005001e,0x00000013,0x00000006,0x00000006,0x00000006,0x00040020,0x00000014, |
||||||
|
0x00000009,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000009,0x0004002b,0x00000006, |
||||||
|
0x00000016,0x00000001,0x00040020,0x00000017,0x00000009,0x00000006,0x00020014,0x0000001a, |
||||||
|
0x0004002b,0x00000006,0x00000021,0x00000002,0x0004002b,0x00000006,0x00000025,0x00000000, |
||||||
|
0x00030016,0x0000003a,0x00000020,0x0003001d,0x0000003b,0x0000003a,0x0003001e,0x0000003c, |
||||||
|
0x0000003b,0x00040020,0x0000003d,0x00000002,0x0000003c,0x0004003b,0x0000003d,0x0000003e, |
||||||
|
0x00000002,0x0003001d,0x00000042,0x0000003a,0x0003001e,0x00000043,0x00000042,0x00040020, |
||||||
|
0x00000044,0x00000002,0x00000043,0x0004003b,0x00000044,0x00000045,0x00000002,0x00040020, |
||||||
|
0x00000047,0x00000002,0x0000003a,0x0003001d,0x00000080,0x0000003a,0x0003001e,0x00000081, |
||||||
|
0x00000080,0x00040020,0x00000082,0x00000002,0x00000081,0x0004003b,0x00000082,0x00000083, |
||||||
|
0x00000002,0x0004002b,0x0000003a,0x00000087,0x00000000,0x00040020,0x000000a0,0x00000007, |
||||||
|
0x0000003a,0x0003001d,0x000000ac,0x0000003a,0x0003001e,0x000000ad,0x000000ac,0x00040020, |
||||||
|
0x000000ae,0x00000002,0x000000ad,0x0004003b,0x000000ae,0x000000af,0x00000002,0x0004002b, |
||||||
|
0x00000009,0x000000e9,0x00000100,0x0004002b,0x00000009,0x000000ea,0x00000001,0x0006002c, |
||||||
|
0x0000000a,0x000000eb,0x000000e9,0x000000ea,0x000000ea,0x00050036,0x00000002,0x00000004, |
||||||
|
0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000001f,0x00000007,0x0004003b,0x00000007,0x00000029,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000002e,0x00000007,0x0004003b,0x00000007,0x00000030,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x0000004f,0x00000007,0x0004003b,0x00000007,0x00000059,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000076,0x00000007,0x0004003b,0x00000007,0x0000008c,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x00000096,0x00000007,0x0004003b,0x000000a0,0x000000a1,0x00000007, |
||||||
|
0x0004003b,0x00000007,0x000000c2,0x00000007,0x0004003b,0x00000007,0x000000cc,0x00000007, |
||||||
|
0x0004003b,0x000000a0,0x000000d6,0x00000007,0x00050041,0x0000000e,0x0000000f,0x0000000c, |
||||||
|
0x0000000d,0x0004003d,0x00000009,0x00000010,0x0000000f,0x0004007c,0x00000006,0x00000011, |
||||||
|
0x00000010,0x0003003e,0x00000008,0x00000011,0x0004003d,0x00000006,0x00000012,0x00000008, |
||||||
|
0x00050041,0x00000017,0x00000018,0x00000015,0x00000016,0x0004003d,0x00000006,0x00000019, |
||||||
|
0x00000018,0x000500af,0x0000001a,0x0000001b,0x00000012,0x00000019,0x000300f7,0x0000001d, |
||||||
|
0x00000000,0x000400fa,0x0000001b,0x0000001c,0x0000001d,0x000200f8,0x0000001c,0x000100fd, |
||||||
|
0x000200f8,0x0000001d,0x0004003d,0x00000006,0x00000020,0x00000008,0x00050041,0x00000017, |
||||||
|
0x00000022,0x00000015,0x00000021,0x0004003d,0x00000006,0x00000023,0x00000022,0x00050084, |
||||||
|
0x00000006,0x00000024,0x00000020,0x00000023,0x00050041,0x00000017,0x00000026,0x00000015, |
||||||
|
0x00000025,0x0004003d,0x00000006,0x00000027,0x00000026,0x00050084,0x00000006,0x00000028, |
||||||
|
0x00000024,0x00000027,0x0003003e,0x0000001f,0x00000028,0x0004003d,0x00000006,0x0000002a, |
||||||
|
0x00000008,0x00050041,0x00000017,0x0000002b,0x00000015,0x00000025,0x0004003d,0x00000006, |
||||||
|
0x0000002c,0x0000002b,0x00050084,0x00000006,0x0000002d,0x0000002a,0x0000002c,0x0003003e, |
||||||
|
0x00000029,0x0000002d,0x0004003d,0x00000006,0x0000002f,0x0000001f,0x0003003e,0x0000002e, |
||||||
|
0x0000002f,0x0003003e,0x00000030,0x00000025,0x000200f9,0x00000031,0x000200f8,0x00000031, |
||||||
|
0x000400f6,0x00000033,0x00000034,0x00000000,0x000200f9,0x00000035,0x000200f8,0x00000035, |
||||||
|
0x0004003d,0x00000006,0x00000036,0x00000030,0x00050041,0x00000017,0x00000037,0x00000015, |
||||||
|
0x00000025,0x0004003d,0x00000006,0x00000038,0x00000037,0x000500b1,0x0000001a,0x00000039, |
||||||
|
0x00000036,0x00000038,0x000400fa,0x00000039,0x00000032,0x00000033,0x000200f8,0x00000032, |
||||||
|
0x0004003d,0x00000006,0x0000003f,0x00000029,0x0004003d,0x00000006,0x00000040,0x00000030, |
||||||
|
0x00050080,0x00000006,0x00000041,0x0000003f,0x00000040,0x0004003d,0x00000006,0x00000046, |
||||||
|
0x0000002e,0x00060041,0x00000047,0x00000048,0x00000045,0x00000025,0x00000046,0x0004003d, |
||||||
|
0x0000003a,0x00000049,0x00000048,0x00060041,0x00000047,0x0000004a,0x0000003e,0x00000025, |
||||||
|
0x00000041,0x0003003e,0x0000004a,0x00000049,0x0004003d,0x00000006,0x0000004b,0x0000002e, |
||||||
|
0x00050080,0x00000006,0x0000004c,0x0000004b,0x00000016,0x0003003e,0x0000002e,0x0000004c, |
||||||
|
0x000200f9,0x00000034,0x000200f8,0x00000034,0x0004003d,0x00000006,0x0000004d,0x00000030, |
||||||
|
0x00050080,0x00000006,0x0000004e,0x0000004d,0x00000016,0x0003003e,0x00000030,0x0000004e, |
||||||
|
0x000200f9,0x00000031,0x000200f8,0x00000033,0x0003003e,0x0000004f,0x00000016,0x000200f9, |
||||||
|
0x00000050,0x000200f8,0x00000050,0x000400f6,0x00000052,0x00000053,0x00000000,0x000200f9, |
||||||
|
0x00000054,0x000200f8,0x00000054,0x0004003d,0x00000006,0x00000055,0x0000004f,0x00050041, |
||||||
|
0x00000017,0x00000056,0x00000015,0x00000021,0x0004003d,0x00000006,0x00000057,0x00000056, |
||||||
|
0x000500b1,0x0000001a,0x00000058,0x00000055,0x00000057,0x000400fa,0x00000058,0x00000051, |
||||||
|
0x00000052,0x000200f8,0x00000051,0x0003003e,0x00000059,0x00000025,0x000200f9,0x0000005a, |
||||||
|
0x000200f8,0x0000005a,0x000400f6,0x0000005c,0x0000005d,0x00000000,0x000200f9,0x0000005e, |
||||||
|
0x000200f8,0x0000005e,0x0004003d,0x00000006,0x0000005f,0x00000059,0x00050041,0x00000017, |
||||||
|
0x00000060,0x00000015,0x00000025,0x0004003d,0x00000006,0x00000061,0x00000060,0x000500b1, |
||||||
|
0x0000001a,0x00000062,0x0000005f,0x00000061,0x000400fa,0x00000062,0x0000005b,0x0000005c, |
||||||
|
0x000200f8,0x0000005b,0x0004003d,0x00000006,0x00000063,0x00000029,0x0004003d,0x00000006, |
||||||
|
0x00000064,0x00000059,0x00050080,0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d, |
||||||
|
0x00000006,0x00000066,0x00000029,0x0004003d,0x00000006,0x00000067,0x00000059,0x00050080, |
||||||
|
0x00000006,0x00000068,0x00000066,0x00000067,0x00060041,0x00000047,0x00000069,0x0000003e, |
||||||
|
0x00000025,0x00000068,0x0004003d,0x0000003a,0x0000006a,0x00000069,0x0004003d,0x00000006, |
||||||
|
0x0000006b,0x0000002e,0x00060041,0x00000047,0x0000006c,0x00000045,0x00000025,0x0000006b, |
||||||
|
0x0004003d,0x0000003a,0x0000006d,0x0000006c,0x0007000c,0x0000003a,0x0000006e,0x00000001, |
||||||
|
0x00000028,0x0000006a,0x0000006d,0x00060041,0x00000047,0x0000006f,0x0000003e,0x00000025, |
||||||
|
0x00000065,0x0003003e,0x0000006f,0x0000006e,0x0004003d,0x00000006,0x00000070,0x0000002e, |
||||||
|
0x00050080,0x00000006,0x00000071,0x00000070,0x00000016,0x0003003e,0x0000002e,0x00000071, |
||||||
|
0x000200f9,0x0000005d,0x000200f8,0x0000005d,0x0004003d,0x00000006,0x00000072,0x00000059, |
||||||
|
0x00050080,0x00000006,0x00000073,0x00000072,0x00000016,0x0003003e,0x00000059,0x00000073, |
||||||
|
0x000200f9,0x0000005a,0x000200f8,0x0000005c,0x000200f9,0x00000053,0x000200f8,0x00000053, |
||||||
|
0x0004003d,0x00000006,0x00000074,0x0000004f,0x00050080,0x00000006,0x00000075,0x00000074, |
||||||
|
0x00000016,0x0003003e,0x0000004f,0x00000075,0x000200f9,0x00000050,0x000200f8,0x00000052, |
||||||
|
0x0003003e,0x00000076,0x00000025,0x000200f9,0x00000077,0x000200f8,0x00000077,0x000400f6, |
||||||
|
0x00000079,0x0000007a,0x00000000,0x000200f9,0x0000007b,0x000200f8,0x0000007b,0x0004003d, |
||||||
|
0x00000006,0x0000007c,0x00000076,0x00050041,0x00000017,0x0000007d,0x00000015,0x00000025, |
||||||
|
0x0004003d,0x00000006,0x0000007e,0x0000007d,0x000500b1,0x0000001a,0x0000007f,0x0000007c, |
||||||
|
0x0000007e,0x000400fa,0x0000007f,0x00000078,0x00000079,0x000200f8,0x00000078,0x0004003d, |
||||||
|
0x00000006,0x00000084,0x00000029,0x0004003d,0x00000006,0x00000085,0x00000076,0x00050080, |
||||||
|
0x00000006,0x00000086,0x00000084,0x00000085,0x00060041,0x00000047,0x00000088,0x00000083, |
||||||
|
0x00000025,0x00000086,0x0003003e,0x00000088,0x00000087,0x000200f9,0x0000007a,0x000200f8, |
||||||
|
0x0000007a,0x0004003d,0x00000006,0x00000089,0x00000076,0x00050080,0x00000006,0x0000008a, |
||||||
|
0x00000089,0x00000016,0x0003003e,0x00000076,0x0000008a,0x000200f9,0x00000077,0x000200f8, |
||||||
|
0x00000079,0x0004003d,0x00000006,0x0000008b,0x0000001f,0x0003003e,0x0000002e,0x0000008b, |
||||||
|
0x0003003e,0x0000008c,0x00000025,0x000200f9,0x0000008d,0x000200f8,0x0000008d,0x000400f6, |
||||||
|
0x0000008f,0x00000090,0x00000000,0x000200f9,0x00000091,0x000200f8,0x00000091,0x0004003d, |
||||||
|
0x00000006,0x00000092,0x0000008c,0x00050041,0x00000017,0x00000093,0x00000015,0x00000021, |
||||||
|
0x0004003d,0x00000006,0x00000094,0x00000093,0x000500b1,0x0000001a,0x00000095,0x00000092, |
||||||
|
0x00000094,0x000400fa,0x00000095,0x0000008e,0x0000008f,0x000200f8,0x0000008e,0x0003003e, |
||||||
|
0x00000096,0x00000025,0x000200f9,0x00000097,0x000200f8,0x00000097,0x000400f6,0x00000099, |
||||||
|
0x0000009a,0x00000000,0x000200f9,0x0000009b,0x000200f8,0x0000009b,0x0004003d,0x00000006, |
||||||
|
0x0000009c,0x00000096,0x00050041,0x00000017,0x0000009d,0x00000015,0x00000025,0x0004003d, |
||||||
|
0x00000006,0x0000009e,0x0000009d,0x000500b1,0x0000001a,0x0000009f,0x0000009c,0x0000009e, |
||||||
|
0x000400fa,0x0000009f,0x00000098,0x00000099,0x000200f8,0x00000098,0x0004003d,0x00000006, |
||||||
|
0x000000a2,0x0000002e,0x00060041,0x00000047,0x000000a3,0x00000045,0x00000025,0x000000a2, |
||||||
|
0x0004003d,0x0000003a,0x000000a4,0x000000a3,0x0004003d,0x00000006,0x000000a5,0x00000029, |
||||||
|
0x0004003d,0x00000006,0x000000a6,0x00000096,0x00050080,0x00000006,0x000000a7,0x000000a5, |
||||||
|
0x000000a6,0x00060041,0x00000047,0x000000a8,0x0000003e,0x00000025,0x000000a7,0x0004003d, |
||||||
|
0x0000003a,0x000000a9,0x000000a8,0x00050083,0x0000003a,0x000000aa,0x000000a4,0x000000a9, |
||||||
|
0x0006000c,0x0000003a,0x000000ab,0x00000001,0x0000001b,0x000000aa,0x0003003e,0x000000a1, |
||||||
|
0x000000ab,0x0004003d,0x00000006,0x000000b0,0x0000002e,0x0004003d,0x0000003a,0x000000b1, |
||||||
|
0x000000a1,0x00060041,0x00000047,0x000000b2,0x000000af,0x00000025,0x000000b0,0x0003003e, |
||||||
|
0x000000b2,0x000000b1,0x0004003d,0x00000006,0x000000b3,0x00000029,0x0004003d,0x00000006, |
||||||
|
0x000000b4,0x00000096,0x00050080,0x00000006,0x000000b5,0x000000b3,0x000000b4,0x0004003d, |
||||||
|
0x0000003a,0x000000b6,0x000000a1,0x00060041,0x00000047,0x000000b7,0x00000083,0x00000025, |
||||||
|
0x000000b5,0x0004003d,0x0000003a,0x000000b8,0x000000b7,0x00050081,0x0000003a,0x000000b9, |
||||||
|
0x000000b8,0x000000b6,0x00060041,0x00000047,0x000000ba,0x00000083,0x00000025,0x000000b5, |
||||||
|
0x0003003e,0x000000ba,0x000000b9,0x0004003d,0x00000006,0x000000bb,0x0000002e,0x00050080, |
||||||
|
0x00000006,0x000000bc,0x000000bb,0x00000016,0x0003003e,0x0000002e,0x000000bc,0x000200f9, |
||||||
|
0x0000009a,0x000200f8,0x0000009a,0x0004003d,0x00000006,0x000000bd,0x00000096,0x00050080, |
||||||
|
0x00000006,0x000000be,0x000000bd,0x00000016,0x0003003e,0x00000096,0x000000be,0x000200f9, |
||||||
|
0x00000097,0x000200f8,0x00000099,0x000200f9,0x00000090,0x000200f8,0x00000090,0x0004003d, |
||||||
|
0x00000006,0x000000bf,0x0000008c,0x00050080,0x00000006,0x000000c0,0x000000bf,0x00000016, |
||||||
|
0x0003003e,0x0000008c,0x000000c0,0x000200f9,0x0000008d,0x000200f8,0x0000008f,0x0004003d, |
||||||
|
0x00000006,0x000000c1,0x0000001f,0x0003003e,0x0000002e,0x000000c1,0x0003003e,0x000000c2, |
||||||
|
0x00000025,0x000200f9,0x000000c3,0x000200f8,0x000000c3,0x000400f6,0x000000c5,0x000000c6, |
||||||
|
0x00000000,0x000200f9,0x000000c7,0x000200f8,0x000000c7,0x0004003d,0x00000006,0x000000c8, |
||||||
|
0x000000c2,0x00050041,0x00000017,0x000000c9,0x00000015,0x00000021,0x0004003d,0x00000006, |
||||||
|
0x000000ca,0x000000c9,0x000500b1,0x0000001a,0x000000cb,0x000000c8,0x000000ca,0x000400fa, |
||||||
|
0x000000cb,0x000000c4,0x000000c5,0x000200f8,0x000000c4,0x0003003e,0x000000cc,0x00000025, |
||||||
|
0x000200f9,0x000000cd,0x000200f8,0x000000cd,0x000400f6,0x000000cf,0x000000d0,0x00000000, |
||||||
|
0x000200f9,0x000000d1,0x000200f8,0x000000d1,0x0004003d,0x00000006,0x000000d2,0x000000cc, |
||||||
|
0x00050041,0x00000017,0x000000d3,0x00000015,0x00000025,0x0004003d,0x00000006,0x000000d4, |
||||||
|
0x000000d3,0x000500b1,0x0000001a,0x000000d5,0x000000d2,0x000000d4,0x000400fa,0x000000d5, |
||||||
|
0x000000ce,0x000000cf,0x000200f8,0x000000ce,0x0004003d,0x00000006,0x000000d7,0x0000002e, |
||||||
|
0x00060041,0x00000047,0x000000d8,0x000000af,0x00000025,0x000000d7,0x0004003d,0x0000003a, |
||||||
|
0x000000d9,0x000000d8,0x0004003d,0x00000006,0x000000da,0x00000029,0x0004003d,0x00000006, |
||||||
|
0x000000db,0x000000cc,0x00050080,0x00000006,0x000000dc,0x000000da,0x000000db,0x00060041, |
||||||
|
0x00000047,0x000000dd,0x00000083,0x00000025,0x000000dc,0x0004003d,0x0000003a,0x000000de, |
||||||
|
0x000000dd,0x00050088,0x0000003a,0x000000df,0x000000d9,0x000000de,0x0003003e,0x000000d6, |
||||||
|
0x000000df,0x0004003d,0x00000006,0x000000e0,0x0000002e,0x0004003d,0x0000003a,0x000000e1, |
||||||
|
0x000000d6,0x00060041,0x00000047,0x000000e2,0x000000af,0x00000025,0x000000e0,0x0003003e, |
||||||
|
0x000000e2,0x000000e1,0x0004003d,0x00000006,0x000000e3,0x0000002e,0x00050080,0x00000006, |
||||||
|
0x000000e4,0x000000e3,0x00000016,0x0003003e,0x0000002e,0x000000e4,0x000200f9,0x000000d0, |
||||||
|
0x000200f8,0x000000d0,0x0004003d,0x00000006,0x000000e5,0x000000cc,0x00050080,0x00000006, |
||||||
|
0x000000e6,0x000000e5,0x00000016,0x0003003e,0x000000cc,0x000000e6,0x000200f9,0x000000cd, |
||||||
|
0x000200f8,0x000000cf,0x000200f9,0x000000c6,0x000200f8,0x000000c6,0x0004003d,0x00000006, |
||||||
|
0x000000e7,0x000000c2,0x00050080,0x00000006,0x000000e8,0x000000e7,0x00000016,0x0003003e, |
||||||
|
0x000000c2,0x000000e8,0x000200f9,0x000000c3,0x000200f8,0x000000c5,0x000100fd,0x00010038 |
||||||
|
}; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,88 @@ |
|||||||
|
# Iterate all GLSL shaders (with suffix '.comp') in current directory. |
||||||
|
# |
||||||
|
# Use glslangValidator to compile them to SPIR-V shaders and write them |
||||||
|
# into .cpp files as unsigned int array. |
||||||
|
# |
||||||
|
# Also generate a header file 'spv_shader.hpp' to extern declare these shaders. |
||||||
|
|
||||||
|
import re |
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
dir = "./" |
||||||
|
license_decl = \ |
||||||
|
'// This file is part of OpenCV project.\n'\ |
||||||
|
'// It is subject to the license terms in the LICENSE file found in the top-level directory\n'\ |
||||||
|
'// of this distribution and at http://opencv.org/license.html.\n'\ |
||||||
|
'//\n'\ |
||||||
|
'// Copyright (C) 2018, Intel Corporation, all rights reserved.\n'\ |
||||||
|
'// Third party copyrights are property of their respective owners.\n\n' |
||||||
|
precomp = '#include \"../../precomp.hpp\"\n' |
||||||
|
ns_head = '\nnamespace cv { namespace dnn { namespace vkcom {\n\n' |
||||||
|
ns_tail = '\n}}} // namespace cv::dnn::vkcom\n' |
||||||
|
|
||||||
|
headfile = open('spv_shader.hpp', 'w') |
||||||
|
headfile.write(license_decl) |
||||||
|
headfile.write('#ifndef OPENCV_DNN_SPV_SHADER_HPP\n') |
||||||
|
headfile.write('#define OPENCV_DNN_SPV_SHADER_HPP\n\n') |
||||||
|
headfile.write(ns_head) |
||||||
|
|
||||||
|
cmd_remove = '' |
||||||
|
null_out = '' |
||||||
|
if sys.platform.find('win32') != -1: |
||||||
|
cmd_remove = 'del' |
||||||
|
null_out = ' >>nul 2>nul' |
||||||
|
elif sys.platform.find('linux') != -1: |
||||||
|
cmd_remove = 'rm' |
||||||
|
null_out = ' > /dev/null 2>&1' |
||||||
|
|
||||||
|
list = os.listdir(dir) |
||||||
|
for i in range(0, len(list)): |
||||||
|
if (os.path.splitext(list[i])[-1] != '.comp'): |
||||||
|
continue |
||||||
|
prefix = os.path.splitext(list[i])[0]; |
||||||
|
path = os.path.join(dir, list[i]) |
||||||
|
|
||||||
|
|
||||||
|
bin_file = prefix + '.tmp' |
||||||
|
cmd = ' glslangValidator -V ' + path + ' -S comp -o ' + bin_file |
||||||
|
print('compiling') |
||||||
|
if os.system(cmd) != 0: |
||||||
|
continue; |
||||||
|
size = os.path.getsize(bin_file) |
||||||
|
|
||||||
|
spv_txt_file = prefix + '.spv' |
||||||
|
cmd = 'glslangValidator -V ' + path + ' -S comp -o ' + spv_txt_file + ' -x' + null_out |
||||||
|
os.system(cmd) |
||||||
|
|
||||||
|
infile_name = spv_txt_file |
||||||
|
outfile_name = prefix + '_spv.cpp' |
||||||
|
array_name = prefix + '_spv' |
||||||
|
infile = open(infile_name, 'r') |
||||||
|
outfile = open(outfile_name, 'w') |
||||||
|
|
||||||
|
outfile.write(license_decl) |
||||||
|
outfile.write(precomp) |
||||||
|
outfile.write(ns_head) |
||||||
|
# xxx.spv ==> xxx_spv.cpp |
||||||
|
fmt = 'extern const unsigned int %s[%d] = {\n' % (array_name, size/4) |
||||||
|
outfile.write(fmt) |
||||||
|
for eachLine in infile: |
||||||
|
if(re.match(r'^.*\/\/', eachLine)): |
||||||
|
continue |
||||||
|
newline = ' ' + eachLine.replace('\t','') |
||||||
|
outfile.write(newline) |
||||||
|
infile.close() |
||||||
|
outfile.write("};\n") |
||||||
|
outfile.write(ns_tail) |
||||||
|
|
||||||
|
# write a line into header file |
||||||
|
fmt = 'extern const unsigned int %s[%d];\n' % (array_name, size/4) |
||||||
|
headfile.write(fmt) |
||||||
|
|
||||||
|
os.system(cmd_remove + ' ' + bin_file) |
||||||
|
os.system(cmd_remove + ' ' + spv_txt_file) |
||||||
|
|
||||||
|
headfile.write(ns_tail) |
||||||
|
headfile.write('\n#endif /* OPENCV_DNN_SPV_SHADER_HPP */\n') |
||||||
|
headfile.close(); |
@ -0,0 +1,27 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_SPV_SHADER_HPP |
||||||
|
#define OPENCV_DNN_SPV_SHADER_HPP |
||||||
|
|
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
extern const unsigned int dw_conv_spv[1655]; |
||||||
|
extern const unsigned int permute_spv[765]; |
||||||
|
extern const unsigned int lrn_spv[1845]; |
||||||
|
extern const unsigned int concat_spv[541]; |
||||||
|
extern const unsigned int avg_pool_spv[1538]; |
||||||
|
extern const unsigned int softmax_spv[1440]; |
||||||
|
extern const unsigned int prior_box_spv[1480]; |
||||||
|
extern const unsigned int max_pool_spv[1449]; |
||||||
|
extern const unsigned int relu_spv[502]; |
||||||
|
extern const unsigned int conv_spv[1859]; |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif /* OPENCV_DNN_SPV_SHADER_HPP */ |
@ -0,0 +1,85 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/buffer.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
static uint32_t findMemoryType(uint32_t memoryTypeBits, VkMemoryPropertyFlags properties) |
||||||
|
{ |
||||||
|
VkPhysicalDeviceMemoryProperties memoryProperties; |
||||||
|
|
||||||
|
vkGetPhysicalDeviceMemoryProperties(getPhysicalDevice(), &memoryProperties); |
||||||
|
|
||||||
|
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; ++i) { |
||||||
|
if ((memoryTypeBits & (1 << i)) && |
||||||
|
((memoryProperties.memoryTypes[i].propertyFlags & properties) == properties)) |
||||||
|
return i; |
||||||
|
} |
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
bool Buffer::init(size_t size_in_bytes, const char* data) |
||||||
|
{ |
||||||
|
if (buffer_ != VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
printf("Warn: Buffer object already inited\n"); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
VkBufferCreateInfo bufferCreateInfo = {}; |
||||||
|
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
||||||
|
bufferCreateInfo.size = size_in_bytes; |
||||||
|
bufferCreateInfo.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; |
||||||
|
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
||||||
|
VK_CHECK_RESULT(vkCreateBuffer(device_, &bufferCreateInfo, NULL, &buffer_)); |
||||||
|
|
||||||
|
VkMemoryRequirements memoryRequirements; |
||||||
|
vkGetBufferMemoryRequirements(device_, buffer_, &memoryRequirements); |
||||||
|
|
||||||
|
VkMemoryAllocateInfo allocateInfo = {}; |
||||||
|
allocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
||||||
|
allocateInfo.allocationSize = memoryRequirements.size; |
||||||
|
allocateInfo.memoryTypeIndex = findMemoryType(memoryRequirements.memoryTypeBits, |
||||||
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | |
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
||||||
|
VK_CHECK_RESULT(vkAllocateMemory(device_, &allocateInfo, NULL, &memory_)); |
||||||
|
|
||||||
|
if (data) |
||||||
|
{ |
||||||
|
char* dst; |
||||||
|
VK_CHECK_RESULT(vkMapMemory(device_, memory_, 0, size_in_bytes, 0, (void **)&dst)); |
||||||
|
memcpy(dst, data, size_in_bytes); |
||||||
|
vkUnmapMemory(device_, memory_); |
||||||
|
} |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkBindBufferMemory(device_, buffer_, memory_, 0)); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
Buffer::Buffer(VkDevice& device, size_t size_in_bytes, const char* data) |
||||||
|
{ |
||||||
|
device_ = device; |
||||||
|
buffer_ = VK_NULL_HANDLE; |
||||||
|
memory_ = VK_NULL_HANDLE; |
||||||
|
init(size_in_bytes, data); |
||||||
|
} |
||||||
|
|
||||||
|
Buffer::~Buffer() |
||||||
|
{ |
||||||
|
vkFreeMemory(device_, memory_, NULL); |
||||||
|
vkDestroyBuffer(device_, buffer_, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,81 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_COMMON_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_COMMON_HPP |
||||||
|
|
||||||
|
#include <math.h> |
||||||
|
#include <string.h> |
||||||
|
#include <map> |
||||||
|
#include <mutex> |
||||||
|
#include <thread> |
||||||
|
#include <vector> |
||||||
|
#include <iostream> |
||||||
|
#include <sstream> |
||||||
|
#include <algorithm> |
||||||
|
#include <memory> |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
#endif |
||||||
|
#include "opencv2/core/utils/logger.hpp" |
||||||
|
#include "../vulkan/vk_functions.hpp" |
||||||
|
#include "../include/vkcom.hpp" |
||||||
|
#include "../shader/spv_shader.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
enum ShapeIdx |
||||||
|
{ |
||||||
|
kShapeIdxBatch = 0, |
||||||
|
kShapeIdxChannel, |
||||||
|
kShapeIdxHeight, |
||||||
|
kShapeIdxWidth, |
||||||
|
}; |
||||||
|
|
||||||
|
#define VK_CHECK_RESULT(f) \ |
||||||
|
{ \
|
||||||
|
if (f != VK_SUCCESS) \
|
||||||
|
{ \
|
||||||
|
CV_LOG_WARNING(NULL, "Vulkan check failed"); \
|
||||||
|
} \
|
||||||
|
} |
||||||
|
|
||||||
|
#define VKCOM_CHECK_BOOL_RET_VAL(val, ret) \ |
||||||
|
{ \
|
||||||
|
bool res = (val); \
|
||||||
|
if (!res) \
|
||||||
|
{ \
|
||||||
|
CV_LOG_WARNING(NULL, "Check bool failed"); \
|
||||||
|
return ret; \
|
||||||
|
} \
|
||||||
|
} |
||||||
|
|
||||||
|
#define VKCOM_CHECK_POINTER_RET_VOID(p) \ |
||||||
|
{ \
|
||||||
|
if (NULL == (p)) \
|
||||||
|
{ \
|
||||||
|
CV_LOG_WARNING(NULL, "Check pointer failed"); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
} |
||||||
|
|
||||||
|
#define VKCOM_CHECK_POINTER_RET_VAL(p, val) \ |
||||||
|
{ \
|
||||||
|
if (NULL == (p)) \
|
||||||
|
{ \
|
||||||
|
CV_LOG_WARNING(NULL, "Check pointer failed"); \
|
||||||
|
return (val); \
|
||||||
|
} \
|
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_COMMON_HPP
|
@ -0,0 +1,29 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_CONTEXT_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_CONTEXT_HPP |
||||||
|
#include "common.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
struct Context |
||||||
|
{ |
||||||
|
VkDevice device; |
||||||
|
VkQueue queue; |
||||||
|
VkCommandPool cmd_pool; |
||||||
|
std::map<std::string, VkShaderModule> shader_modules; |
||||||
|
int ref; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_CONTEXT_HPP
|
@ -0,0 +1,153 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
std::vector<uint32_t> compile(const std::string& name, |
||||||
|
shaderc_shader_kind kind, |
||||||
|
const std::string& data) |
||||||
|
{ |
||||||
|
std::vector<uint32_t> result; |
||||||
|
#ifdef USE_SHADERC |
||||||
|
shaderc::Compiler compiler; |
||||||
|
shaderc::CompileOptions options; |
||||||
|
|
||||||
|
// Like -DMY_DEFINE=1
|
||||||
|
//options.AddMacroDefinition("MY_DEFINE", "1");
|
||||||
|
options.SetGenerateDebugInfo(); |
||||||
|
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1); |
||||||
|
shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv( |
||||||
|
data.c_str(), data.size(), kind, name.c_str(), options); |
||||||
|
|
||||||
|
if (module.GetCompilationStatus() != |
||||||
|
shaderc_compilation_status_success) { |
||||||
|
std::cerr << module.GetErrorMessage(); |
||||||
|
} |
||||||
|
|
||||||
|
//std::vector<uint32_t> result(module.cbegin(), module.cend());
|
||||||
|
result.assign(module.cbegin(), module.cend()); |
||||||
|
return result; |
||||||
|
#else |
||||||
|
assert(0); |
||||||
|
return result; |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
void bindTensor(VkDevice& device, Tensor& tensor, int binding, VkDescriptorSet descriptor_set) |
||||||
|
{ |
||||||
|
VkDescriptorBufferInfo desc_buffer_info = {}; |
||||||
|
desc_buffer_info.buffer = tensor.getBuffer()->getVkBuffer(); |
||||||
|
desc_buffer_info.offset = 0; |
||||||
|
desc_buffer_info.range = tensor.size(); |
||||||
|
|
||||||
|
VkWriteDescriptorSet write_descriptor_set = {}; |
||||||
|
write_descriptor_set.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
||||||
|
write_descriptor_set.dstSet = descriptor_set; |
||||||
|
write_descriptor_set.dstBinding = binding; |
||||||
|
write_descriptor_set.descriptorCount = 1; |
||||||
|
write_descriptor_set.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; |
||||||
|
write_descriptor_set.pBufferInfo = &desc_buffer_info; |
||||||
|
|
||||||
|
vkUpdateDescriptorSets(device, 1, &write_descriptor_set, 0, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
void computeConvOutputShapeAndPadding(const PaddingMode& padding_mode, |
||||||
|
int& padding_top, int& padding_left, |
||||||
|
const int& in_h, const int& in_w, |
||||||
|
const int& filter_h, const int& filter_w, |
||||||
|
const int& dilation_h, const int& dilation_w, |
||||||
|
const int& stride_h, const int& stride_w, |
||||||
|
int& out_h, int& out_w) |
||||||
|
{ |
||||||
|
if (padding_mode == kPaddingModeValid) |
||||||
|
{ |
||||||
|
padding_top = 0; |
||||||
|
padding_left = 0; |
||||||
|
out_h = ceil((in_h - (filter_h - 1) * dilation_h) / stride_h); |
||||||
|
out_w = ceil((in_w - (filter_w - 1) * dilation_w) / stride_w); |
||||||
|
} |
||||||
|
else if (padding_mode == kPaddingModeSame) |
||||||
|
{ |
||||||
|
padding_top = ((filter_h - 1) * dilation_h + 1) / 2; |
||||||
|
padding_left = ((filter_w - 1) * dilation_w + 1) / 2; |
||||||
|
out_h = ceil(in_h / stride_h); |
||||||
|
out_w = ceil(in_w / stride_w); |
||||||
|
} |
||||||
|
else if (padding_mode == kPaddingModeCaffe) |
||||||
|
{ |
||||||
|
const int filter_h_actual = dilation_h * (filter_h - 1) + 1; |
||||||
|
const int filter_w_actual = dilation_w * (filter_w - 1) + 1; |
||||||
|
out_h = (in_h + 2 * padding_top - filter_h_actual) / stride_h + 1; |
||||||
|
out_w = (in_w + 2 * padding_left - filter_w_actual) / stride_w + 1; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
CV_Error(Error::StsError, format("Invalid padding mode:%d", padding_mode)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void computePoolOutputShape(const PaddingMode& padding_mode, |
||||||
|
const int& padding_top, const int& padding_left, |
||||||
|
const int& in_h, const int& in_w, |
||||||
|
const int& filter_h, const int& filter_w, |
||||||
|
const int& stride_h, const int& stride_w, |
||||||
|
int& out_h, int& out_w) |
||||||
|
{ |
||||||
|
if (padding_mode == kPaddingModeValid) |
||||||
|
{ |
||||||
|
assert(padding_top == 0); |
||||||
|
assert(padding_left == 0); |
||||||
|
out_h = ceil((in_h - (filter_h - 1)) / stride_h); |
||||||
|
out_w = ceil((in_h - (filter_w - 1)) / stride_w); |
||||||
|
} |
||||||
|
else if (padding_mode == kPaddingModeSame) |
||||||
|
{ |
||||||
|
const int padding_top_ = filter_h / 2; |
||||||
|
const int padding_left_ = filter_w / 2; |
||||||
|
CV_Assert(padding_top == padding_top_); |
||||||
|
CV_Assert(padding_left == padding_left_); |
||||||
|
out_h = ceil(in_h / stride_h); |
||||||
|
out_w = ceil(in_h / stride_w); |
||||||
|
} |
||||||
|
else if (padding_mode == kPaddingModeCaffe) |
||||||
|
{ |
||||||
|
int out_h_ = static_cast<int>(ceil(static_cast<float>( |
||||||
|
in_h + 2 * padding_top - filter_h) / stride_h)) + 1; |
||||||
|
int out_w_ = static_cast<int>(ceil(static_cast<float>( |
||||||
|
in_h + 2 * padding_left - filter_w) / stride_w)) + 1; |
||||||
|
|
||||||
|
if (padding_top || padding_left) |
||||||
|
{ |
||||||
|
// If we have padding, ensure that the last pooling starts strictly
|
||||||
|
// inside the image (instead of at the padding); otherwise clip the last.
|
||||||
|
if ((out_h_ - 1) * stride_h >= in_h + padding_top) { |
||||||
|
--out_h_; |
||||||
|
} |
||||||
|
if ((out_w - 1) * stride_h >= in_h + padding_left) { |
||||||
|
--out_w; |
||||||
|
} |
||||||
|
assert((out_h_ - 1) * stride_h < in_h + padding_top); |
||||||
|
assert((out_w_ - 1) * stride_w < in_h + padding_left); |
||||||
|
} |
||||||
|
out_h = out_h_; |
||||||
|
out_w = out_w_; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
CV_Error(Error::StsError, format("Invalid padding mode:%d", padding_mode)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,91 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_INTERNAL_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_INTERNAL_HPP |
||||||
|
|
||||||
|
#include <float.h> |
||||||
|
#include "../include/vkcom.hpp" |
||||||
|
#include "context.hpp" |
||||||
|
|
||||||
|
#ifdef USE_SHADERC |
||||||
|
#include "shaderc/shaderc.hpp" |
||||||
|
#else |
||||||
|
typedef int shaderc_shader_kind; |
||||||
|
#define shaderc_compute_shader 0 |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
Context* getContext(); |
||||||
|
VkPhysicalDevice getPhysicalDevice(); |
||||||
|
std::vector<uint32_t> compile(const std::string& name, |
||||||
|
shaderc_shader_kind kind, |
||||||
|
const std::string& data); |
||||||
|
void bindTensor(VkDevice& device, Tensor& tensor, int binding, VkDescriptorSet descriptor_set); |
||||||
|
void computeConvOutputShapeAndPadding(const PaddingMode& padding_mode, |
||||||
|
int& padding_top, int& padding_left, |
||||||
|
const int& in_h, const int& in_w, |
||||||
|
const int& filter_h, const int& filter_w, |
||||||
|
const int& dilation_h, const int& dilation_w, |
||||||
|
const int& stride_h, const int& stride_w, |
||||||
|
int& out_h, int& out_w); |
||||||
|
void computePoolOutputShape(const PaddingMode& padding_mode, |
||||||
|
const int& padding_top, const int& padding_left, |
||||||
|
const int& in_h, const int& in_w, |
||||||
|
const int& filter_h, const int& filter_w, |
||||||
|
const int& stride_h, const int& stride_w, |
||||||
|
int& out_h, int& out_w); |
||||||
|
|
||||||
|
inline bool checkFormat(Format fmt) |
||||||
|
{ |
||||||
|
return (fmt > -1 && fmt < kFormatNum) ? true : false; |
||||||
|
} |
||||||
|
|
||||||
|
inline size_t elementSize(Format fmt) |
||||||
|
{ |
||||||
|
if (fmt == kFormatFp32 || fmt == kFormatInt32) |
||||||
|
{ |
||||||
|
return 4; |
||||||
|
} |
||||||
|
else if (fmt >= 0 && fmt < kFormatNum) |
||||||
|
{ |
||||||
|
CV_LOG_WARNING(NULL, format("Unsupported format %d", fmt)); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
CV_Error(Error::StsError, format("Invalid format %d", fmt)); |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
inline int shapeCount(const Shape& shape, int start = -1, int end = -1) |
||||||
|
{ |
||||||
|
if (start == -1) start = 0; |
||||||
|
if (end == -1) end = (int)shape.size(); |
||||||
|
|
||||||
|
if (shape.empty()) |
||||||
|
return 0; |
||||||
|
|
||||||
|
int elems = 1; |
||||||
|
assert(start <= (int)shape.size() && |
||||||
|
end <= (int)shape.size() && |
||||||
|
start <= end); |
||||||
|
for(int i = start; i < end; i++) |
||||||
|
{ |
||||||
|
elems *= shape[i]; |
||||||
|
} |
||||||
|
return elems; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_INTERNAL_HPP
|
@ -0,0 +1,186 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_base.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
OpBase::OpBase() |
||||||
|
{ |
||||||
|
ctx_ = getContext(); |
||||||
|
device_ = ctx_->device; |
||||||
|
pipeline_ = VK_NULL_HANDLE; |
||||||
|
cmd_buffer_ = VK_NULL_HANDLE; |
||||||
|
descriptor_pool_ = VK_NULL_HANDLE; |
||||||
|
descriptor_set_ = VK_NULL_HANDLE; |
||||||
|
descriptor_set_layout_ = VK_NULL_HANDLE; |
||||||
|
pipeline_layout_ = VK_NULL_HANDLE; |
||||||
|
module_ = VK_NULL_HANDLE; |
||||||
|
} |
||||||
|
|
||||||
|
OpBase::~OpBase() |
||||||
|
{ |
||||||
|
vkDestroyShaderModule(device_, module_, NULL); |
||||||
|
vkDestroyDescriptorPool(device_, descriptor_pool_, NULL); |
||||||
|
vkDestroyDescriptorSetLayout(device_, descriptor_set_layout_, NULL); |
||||||
|
vkDestroyPipeline(device_, pipeline_, NULL); |
||||||
|
vkDestroyPipelineLayout(device_, pipeline_layout_, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::initVulkanThing(int buffer_num) |
||||||
|
{ |
||||||
|
createDescriptorSetLayout(buffer_num); |
||||||
|
createDescriptorSet(buffer_num); |
||||||
|
createCommandBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::createDescriptorSetLayout(int buffer_num) |
||||||
|
{ |
||||||
|
VkDescriptorSetLayoutBinding bindings[buffer_num] = {}; |
||||||
|
for (int i = 0; i < buffer_num; i++) |
||||||
|
{ |
||||||
|
bindings[i].binding = i; |
||||||
|
bindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; |
||||||
|
bindings[i].descriptorCount = 1; |
||||||
|
bindings[i].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; |
||||||
|
} |
||||||
|
VkDescriptorSetLayoutCreateInfo info = {}; |
||||||
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
||||||
|
info.bindingCount = buffer_num; |
||||||
|
info.pBindings = bindings; |
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device_, &info, NULL, &descriptor_set_layout_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::createDescriptorSet(int buffer_num) |
||||||
|
{ |
||||||
|
VkDescriptorPoolSize pool_size = {}; |
||||||
|
pool_size.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; |
||||||
|
pool_size.descriptorCount = buffer_num; |
||||||
|
|
||||||
|
VkDescriptorPoolCreateInfo info = {}; |
||||||
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
||||||
|
info.maxSets = 1; |
||||||
|
info.poolSizeCount = 1; |
||||||
|
info.pPoolSizes = &pool_size; |
||||||
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device_, &info, NULL, &descriptor_pool_)); |
||||||
|
|
||||||
|
VkDescriptorSetAllocateInfo allocate_info = {}; |
||||||
|
allocate_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
||||||
|
allocate_info.descriptorPool = descriptor_pool_; |
||||||
|
allocate_info.descriptorSetCount = 1; |
||||||
|
allocate_info.pSetLayouts = &descriptor_set_layout_; |
||||||
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device_, &allocate_info, &descriptor_set_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::createShaderModule(const uint32_t* spv, size_t sz, const std::string& source) |
||||||
|
{ |
||||||
|
VkShaderModuleCreateInfo create_info = {}; |
||||||
|
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
||||||
|
if (spv) |
||||||
|
{ |
||||||
|
create_info.pCode = spv; |
||||||
|
create_info.codeSize = sz; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// online compilation
|
||||||
|
std::vector<uint32_t> code; |
||||||
|
code = compile("shader", shaderc_compute_shader, source); |
||||||
|
create_info.pCode = code.data(); |
||||||
|
create_info.codeSize = sizeof(uint32_t) * code.size(); |
||||||
|
} |
||||||
|
VK_CHECK_RESULT(vkCreateShaderModule(device_, &create_info, NULL, &module_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::createPipeline(size_t push_constants_size) |
||||||
|
{ |
||||||
|
// create pipeline
|
||||||
|
VkPipelineShaderStageCreateInfo stage_create_info = {}; |
||||||
|
stage_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
||||||
|
stage_create_info.stage = VK_SHADER_STAGE_COMPUTE_BIT; |
||||||
|
stage_create_info.module = module_; |
||||||
|
stage_create_info.pName = "main"; |
||||||
|
VkPushConstantRange push_constant_ranges[1] = {}; |
||||||
|
push_constant_ranges[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; |
||||||
|
push_constant_ranges[0].offset = 0; |
||||||
|
push_constant_ranges[0].size = push_constants_size; |
||||||
|
|
||||||
|
VkPipelineLayoutCreateInfo pipeline_layout_create_info = {}; |
||||||
|
pipeline_layout_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
||||||
|
if (push_constants_size != 0) |
||||||
|
{ |
||||||
|
pipeline_layout_create_info.pushConstantRangeCount = 1; |
||||||
|
pipeline_layout_create_info.pPushConstantRanges = push_constant_ranges; |
||||||
|
} |
||||||
|
pipeline_layout_create_info.setLayoutCount = 1; |
||||||
|
pipeline_layout_create_info.pSetLayouts = &descriptor_set_layout_; |
||||||
|
VK_CHECK_RESULT(vkCreatePipelineLayout(device_, &pipeline_layout_create_info, |
||||||
|
NULL, &pipeline_layout_)); |
||||||
|
|
||||||
|
VkComputePipelineCreateInfo pipeline_create_info = {}; |
||||||
|
pipeline_create_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; |
||||||
|
pipeline_create_info.stage = stage_create_info; |
||||||
|
pipeline_create_info.layout = pipeline_layout_; |
||||||
|
VK_CHECK_RESULT(vkCreateComputePipelines(device_, VK_NULL_HANDLE, |
||||||
|
1, &pipeline_create_info, |
||||||
|
NULL, &pipeline_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::createCommandBuffer() |
||||||
|
{ |
||||||
|
VkCommandBufferAllocateInfo info = {}; |
||||||
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
||||||
|
info.commandPool = ctx_->cmd_pool; |
||||||
|
info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
||||||
|
info.commandBufferCount = 1; |
||||||
|
VK_CHECK_RESULT(vkAllocateCommandBuffers(device_, &info, &cmd_buffer_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::recordCommandBuffer(void* push_constants, size_t push_constants_size) |
||||||
|
{ |
||||||
|
VkCommandBufferBeginInfo beginInfo = {}; |
||||||
|
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
||||||
|
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
||||||
|
VK_CHECK_RESULT(vkBeginCommandBuffer(cmd_buffer_, &beginInfo)); |
||||||
|
if (push_constants) |
||||||
|
vkCmdPushConstants(cmd_buffer_, pipeline_layout_, |
||||||
|
VK_SHADER_STAGE_COMPUTE_BIT, 0, |
||||||
|
push_constants_size, push_constants); |
||||||
|
vkCmdBindPipeline(cmd_buffer_, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_); |
||||||
|
vkCmdBindDescriptorSets(cmd_buffer_, VK_PIPELINE_BIND_POINT_COMPUTE, |
||||||
|
pipeline_layout_, 0, 1, &descriptor_set_, 0, NULL); |
||||||
|
vkCmdDispatch(cmd_buffer_, group_x_, group_y_, group_z_); |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkEndCommandBuffer(cmd_buffer_)); |
||||||
|
} |
||||||
|
|
||||||
|
void OpBase::runCommandBuffer() |
||||||
|
{ |
||||||
|
VkSubmitInfo submit_info = {}; |
||||||
|
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
||||||
|
submit_info.commandBufferCount = 1; |
||||||
|
submit_info.pCommandBuffers = &cmd_buffer_; |
||||||
|
|
||||||
|
VkFence fence; |
||||||
|
VkFenceCreateInfo fence_create_info_ = {}; |
||||||
|
fence_create_info_.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
||||||
|
fence_create_info_.flags = 0; |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkCreateFence(device_, &fence_create_info_, NULL, &fence)); |
||||||
|
VK_CHECK_RESULT(vkQueueSubmit(ctx_->queue, 1, &submit_info, fence)); |
||||||
|
VK_CHECK_RESULT(vkWaitForFences(device_, 1, &fence, VK_TRUE, 100000000000)); |
||||||
|
vkDestroyFence(device_, fence, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,138 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_concat.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
struct ConcatParam { |
||||||
|
int out_concat_axis; |
||||||
|
int accumulated_concat_axis; |
||||||
|
int concat_size; |
||||||
|
int total_concat_size; |
||||||
|
int thread_num; |
||||||
|
}; |
||||||
|
|
||||||
|
OpConcat::OpConcat(const int axis) |
||||||
|
{ |
||||||
|
init(axis); |
||||||
|
type_ = "Concat"; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConcat::init(const int axis) |
||||||
|
{ |
||||||
|
axis_ = axis; |
||||||
|
#define BUFFER_NUM 2 |
||||||
|
OpBase::initVulkanThing(BUFFER_NUM); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
void OpConcat::reshapeOutTensor(std::vector<Tensor *>& in, Tensor& out) |
||||||
|
{ |
||||||
|
int sum_axis = 0; |
||||||
|
|
||||||
|
for (int i = 0; i < in.size(); ++i) |
||||||
|
{ |
||||||
|
sum_axis += in[i]->dimSize(axis_); |
||||||
|
} |
||||||
|
|
||||||
|
Shape shape = in[0]->getShape(); |
||||||
|
shape[axis_] = sum_axis; |
||||||
|
out.reshape(NULL, shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConcat::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins, outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConcat::forward(std::vector<Tensor>& ins, Tensor& out) |
||||||
|
{ |
||||||
|
int input_num = ins.size(); |
||||||
|
Tensor& first_tensor = ins[0]; |
||||||
|
int sum_axis = first_tensor.dimSize(axis_); |
||||||
|
int dim_num = first_tensor.dimNum(); |
||||||
|
for (int i = 1; i < input_num; ++i) |
||||||
|
{ |
||||||
|
Tensor& tensor = ins[i]; |
||||||
|
assert(tensor.dimNum() == dim_num); |
||||||
|
for (int d = 0; d < dim_num; ++d) |
||||||
|
{ |
||||||
|
if (d == axis_) |
||||||
|
{ |
||||||
|
sum_axis += tensor.dimSize(axis_);; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
assert(first_tensor.dimSize(d) == tensor.dimSize(d)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
assert(out.dimSize(axis_) == sum_axis); |
||||||
|
for (int d = 0; d < dim_num; ++d) |
||||||
|
{ |
||||||
|
if (d != axis_) |
||||||
|
{ |
||||||
|
assert(out.dimSize(d) == first_tensor.dimSize(d)); |
||||||
|
} |
||||||
|
} |
||||||
|
out_concat_axis_ = sum_axis; |
||||||
|
concat_size_ = out.count(axis_ + 1); |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
config_.local_size_x = LOCAL_SZ_X; |
||||||
|
config_.block_height = 1; |
||||||
|
config_.block_width = 1; |
||||||
|
config_.block_depth = 1; |
||||||
|
createShaderModule(concat_spv, sizeof(concat_spv)); |
||||||
|
createPipeline(sizeof(ConcatParam)); |
||||||
|
} |
||||||
|
|
||||||
|
accumulated_concat_axis_ = 0; |
||||||
|
for (int i = 0; i < input_num; i++) |
||||||
|
{ |
||||||
|
bindTensor(device_, ins[i], 0, descriptor_set_); |
||||||
|
bindTensor(device_, out, 1, descriptor_set_); |
||||||
|
total_concat_size_ = ins[i].count(axis_); |
||||||
|
thread_num_ = ins[i].count(); |
||||||
|
computeGroupCount(); |
||||||
|
ConcatParam param = {out_concat_axis_, |
||||||
|
accumulated_concat_axis_, |
||||||
|
concat_size_, |
||||||
|
total_concat_size_, |
||||||
|
thread_num_}; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(ConcatParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
accumulated_concat_axis_ += ins[i].dimSize(axis_); |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConcat::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = alignSize(thread_num_, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,190 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_conv.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
|
||||||
|
struct ShaderParam { |
||||||
|
int in_h; |
||||||
|
int in_w; |
||||||
|
int out_h; |
||||||
|
int out_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int pad_h; |
||||||
|
int pad_w; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int dilation_h; |
||||||
|
int dilation_w; |
||||||
|
int channels; |
||||||
|
int batch; |
||||||
|
int has_bias; |
||||||
|
int M; |
||||||
|
int K; |
||||||
|
int N; |
||||||
|
}; |
||||||
|
|
||||||
|
OpConv::OpConv(const int out_channel, const bool has_bias, |
||||||
|
const int* filter_size, const int* pad, |
||||||
|
const int* stride, const int* dilation, |
||||||
|
const int activation, const int group, |
||||||
|
const int padding_mode) |
||||||
|
{ |
||||||
|
init(out_channel, has_bias, filter_size, pad, |
||||||
|
stride, dilation, activation, group, padding_mode); |
||||||
|
type_ = "Conv"; |
||||||
|
} |
||||||
|
|
||||||
|
void OpConv::reshapeOutTensor(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape in_shape = in.getShape(); |
||||||
|
batch_ = in_shape[kShapeIdxBatch]; |
||||||
|
in_height_ = in_shape[kShapeIdxHeight]; |
||||||
|
in_width_ = in_shape[kShapeIdxWidth]; |
||||||
|
computeConvOutputShapeAndPadding(padding_mode_, padding_top_, padding_left_, |
||||||
|
in_height_, in_width_, |
||||||
|
filter_height_, filter_width_, |
||||||
|
dilation_height_, dilation_width_, |
||||||
|
stride_height_, stride_width_, |
||||||
|
out_height_, out_width_); |
||||||
|
Shape shape = {batch_, out_channel_, out_height_, out_width_}; |
||||||
|
out.reshape(NULL, shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConv::init(const int out_channel, const bool has_bias, |
||||||
|
const int* filter_size, const int* pad, |
||||||
|
const int* stride, const int* dilation, |
||||||
|
const int activation, const int group, |
||||||
|
const int padding_mode) |
||||||
|
{ |
||||||
|
out_channel_ = out_channel; |
||||||
|
filter_height_ = filter_size[0]; |
||||||
|
filter_width_ = filter_size[1]; |
||||||
|
padding_top_ = pad[0]; |
||||||
|
padding_left_ = pad[1]; |
||||||
|
stride_height_ = stride[0]; |
||||||
|
stride_width_ = stride[1]; |
||||||
|
dilation_height_ = dilation[0]; |
||||||
|
dilation_width_ = dilation[1]; |
||||||
|
padding_mode_ = (PaddingMode)padding_mode; |
||||||
|
has_bias_ = has_bias ? 1 : 0; |
||||||
|
activation_ = activation; |
||||||
|
group_ = group; |
||||||
|
|
||||||
|
#define BUFFER_NUM 4 |
||||||
|
OpBase::initVulkanThing(BUFFER_NUM); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConv::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
std::vector<int> shape = {1}; |
||||||
|
Tensor bias(0, shape); |
||||||
|
|
||||||
|
if (has_bias_) |
||||||
|
{ |
||||||
|
assert(blobs.size() == 2); |
||||||
|
bias = blobs[1]; |
||||||
|
} |
||||||
|
|
||||||
|
return forward(ins[0], blobs[0], bias, outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConv::forward(Tensor& in, Tensor& filter_weights, Tensor& bias, Tensor& out) |
||||||
|
{ |
||||||
|
Shape in_shape = in.getShape(); |
||||||
|
Shape out_shape = out.getShape(); |
||||||
|
batch_ = in_shape[kShapeIdxBatch]; |
||||||
|
in_height_ = in_shape[kShapeIdxHeight]; |
||||||
|
in_width_ = in_shape[kShapeIdxWidth]; |
||||||
|
in_channel_= in_shape[kShapeIdxChannel]; |
||||||
|
out_height_ = out_shape[kShapeIdxHeight]; |
||||||
|
out_width_ = out_shape[kShapeIdxWidth]; |
||||||
|
|
||||||
|
dwconv_ = (out_channel_ == in_channel_ && in_channel_ == group_); |
||||||
|
if (dwconv_ == false) |
||||||
|
assert(group_ == 1); // TODO: support group > 1
|
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
config_.local_size_x = LOCAL_SZ_X; |
||||||
|
config_.local_size_y = 1; |
||||||
|
config_.local_size_z = 1; |
||||||
|
config_.block_height = 1; |
||||||
|
config_.block_width = 1; |
||||||
|
config_.block_depth = 1; |
||||||
|
config_.shader_type = kConvShaderTypeBasic; |
||||||
|
|
||||||
|
if (dwconv_) |
||||||
|
createShaderModule(dw_conv_spv, sizeof(dw_conv_spv)); |
||||||
|
else |
||||||
|
createShaderModule(conv_spv, sizeof(conv_spv)); |
||||||
|
createPipeline(sizeof(ShaderParam)); |
||||||
|
computeGroupCount(); |
||||||
|
} |
||||||
|
|
||||||
|
bindTensor(device_, in, 0, descriptor_set_); |
||||||
|
bindTensor(device_, bias, 1, descriptor_set_); |
||||||
|
bindTensor(device_, filter_weights, 2, descriptor_set_); |
||||||
|
bindTensor(device_, out, 3, descriptor_set_); |
||||||
|
|
||||||
|
int M = out_height_ * out_width_; |
||||||
|
int K = filter_height_ * filter_width_ * in_channel_; |
||||||
|
int N = out_channel_; |
||||||
|
ShaderParam param = {in_height_, in_width_, |
||||||
|
out_height_, out_width_, |
||||||
|
stride_height_, stride_width_, |
||||||
|
padding_top_, padding_left_, |
||||||
|
filter_height_, filter_width_, |
||||||
|
dilation_height_, dilation_width_, |
||||||
|
in_channel_, batch_, has_bias_, |
||||||
|
M, K, N}; |
||||||
|
|
||||||
|
recordCommandBuffer((void *)¶m, sizeof(ShaderParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpConv::computeGroupCount() |
||||||
|
{ |
||||||
|
if (dwconv_) |
||||||
|
{ |
||||||
|
group_x_ = alignSize(out_width_, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = alignSize(out_height_, config_.local_size_y) / config_.local_size_y; |
||||||
|
group_z_ = alignSize(in_channel_, config_.local_size_z) / config_.local_size_z; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
int M = out_height_ * out_width_; |
||||||
|
int N = out_channel_; |
||||||
|
|
||||||
|
if (config_.shader_type == kConvShaderTypeBasic) |
||||||
|
{ |
||||||
|
group_x_ = alignSize(M, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = alignSize(N, config_.local_size_y) / config_.local_size_y; |
||||||
|
group_z_ = alignSize(batch_, config_.local_size_z) / config_.local_size_z; |
||||||
|
} |
||||||
|
else |
||||||
|
CV_Assert(0); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,115 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_lrn.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
#define LOCAL_SZ_Y 1 |
||||||
|
#define LOCAL_SZ_Z 1 |
||||||
|
|
||||||
|
struct LRNParam { |
||||||
|
int thread_num; |
||||||
|
int channels; |
||||||
|
int height; |
||||||
|
int width; |
||||||
|
int filter_len; |
||||||
|
int radius; |
||||||
|
float alpha; |
||||||
|
float bias; |
||||||
|
float negative_beta; |
||||||
|
}; |
||||||
|
|
||||||
|
OpLRN::OpLRN(const int radius, const float bias, |
||||||
|
const float alpha, const float beta, |
||||||
|
const bool norm_by_size) |
||||||
|
{ |
||||||
|
init(radius, bias, alpha, beta, norm_by_size); |
||||||
|
type_ = "LRN"; |
||||||
|
} |
||||||
|
|
||||||
|
void OpLRN::reshapeOutTensor(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape shape = in.getShape(); |
||||||
|
out.reshape(NULL, shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpLRN::init(const int radius, const float bias, |
||||||
|
const float alpha, const float beta, |
||||||
|
const bool norm_by_size) |
||||||
|
{ |
||||||
|
radius_ = radius; |
||||||
|
filter_len_ = 2 * radius_ + 1; |
||||||
|
bias_ = bias; |
||||||
|
alpha_ = alpha; |
||||||
|
beta_ = beta; |
||||||
|
norm_by_size_ = norm_by_size; |
||||||
|
OpBase::initVulkanThing(2); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpLRN::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins[0], outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpLRN::forward(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape in_shape = in.getShape(); |
||||||
|
batch_ = in_shape[kShapeIdxBatch]; |
||||||
|
height_ = in_shape[kShapeIdxHeight]; |
||||||
|
width_ = in_shape[kShapeIdxWidth]; |
||||||
|
channels_= in_shape[kShapeIdxChannel]; |
||||||
|
thread_num_ = batch_ * height_ * width_; |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
config_.local_size_x = LOCAL_SZ_X; |
||||||
|
config_.local_size_y = LOCAL_SZ_Y; |
||||||
|
config_.local_size_z = LOCAL_SZ_Z; |
||||||
|
config_.block_height = 1; |
||||||
|
config_.block_width = 1; |
||||||
|
config_.block_depth = 1; |
||||||
|
config_.shader_type = kLRNShaderTypeBasic; |
||||||
|
createShaderModule(lrn_spv, sizeof(lrn_spv)); |
||||||
|
createPipeline(sizeof(LRNParam)); |
||||||
|
computeGroupCount(); |
||||||
|
} |
||||||
|
|
||||||
|
bindTensor(device_, in, 0, descriptor_set_); |
||||||
|
bindTensor(device_, out,1, descriptor_set_); |
||||||
|
|
||||||
|
LRNParam param = {batch_ * height_ * width_, |
||||||
|
channels_, height_, width_, |
||||||
|
filter_len_, radius_, |
||||||
|
alpha_ / (norm_by_size_ ? filter_len_ : 1), |
||||||
|
bias_, -1 * beta_}; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(LRNParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpLRN::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = alignSize(thread_num_, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,163 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include <limits> |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_permute.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
struct PermuteParam { |
||||||
|
int global_size; |
||||||
|
int num_axes; |
||||||
|
int nthreads; |
||||||
|
}; |
||||||
|
|
||||||
|
static bool needForPermutation(std::vector<int>& order) |
||||||
|
{ |
||||||
|
for (int i = 0; i < order.size(); ++i) |
||||||
|
{ |
||||||
|
if (order[i] != i) |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
OpPermute::OpPermute(std::vector<size_t>& order) |
||||||
|
{ |
||||||
|
order_.assign(order.begin(), order.end()); |
||||||
|
dims_ = order.size(); |
||||||
|
need_permute_ = needForPermutation(order_); |
||||||
|
type_ = "Permute"; |
||||||
|
if (need_permute_) |
||||||
|
OpBase::initVulkanThing(5); |
||||||
|
} |
||||||
|
|
||||||
|
void OpPermute::reshapeOutTensor(std::vector<Tensor *>& ins, std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
assert(!ins.empty()); |
||||||
|
assert(ins.size() == outs.size()); |
||||||
|
|
||||||
|
if (need_permute_) |
||||||
|
{ |
||||||
|
assert(dims_ == ins[0]->dimNum()); |
||||||
|
|
||||||
|
Shape shape_before = ins[0]->getShape(); |
||||||
|
Shape shape_after; |
||||||
|
for (size_t i = 0; i < dims_; i++) |
||||||
|
{ |
||||||
|
shape_after.push_back(shape_before[order_[i]]); |
||||||
|
} |
||||||
|
|
||||||
|
for (size_t i = 0; i < ins.size(); i++) |
||||||
|
{ |
||||||
|
assert(ins[i]->dimNum() == 4); |
||||||
|
assert(ins[i]->dimSize(2) == shape_before[2] && ins[i]->dimSize(3) == shape_before[3]); |
||||||
|
assert(ins[i]->count() == shapeCount(shape_after)); |
||||||
|
outs[i].reshape(NULL, shape_after); |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
for(int i = 0; i < ins.size(); i++) |
||||||
|
{ |
||||||
|
Shape in_shape = ins[i]->getShape(); |
||||||
|
outs[i].reshape(NULL, in_shape); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void OpPermute::prepareStrides(const Shape &shape_before, const Shape &shape_after) |
||||||
|
{ |
||||||
|
assert(shape_before.size() == dims_); |
||||||
|
assert(shape_after.size() == dims_); |
||||||
|
|
||||||
|
old_stride_.resize(dims_); |
||||||
|
new_stride_.resize(dims_); |
||||||
|
|
||||||
|
old_stride_[dims_ - 1] = 1; |
||||||
|
new_stride_[dims_ - 1] = 1; |
||||||
|
|
||||||
|
for(int i = dims_ - 2; i >= 0; i--) |
||||||
|
{ |
||||||
|
old_stride_[i] = old_stride_[i + 1] * shape_before[i + 1]; |
||||||
|
new_stride_[i] = new_stride_[i + 1] * shape_after[i + 1]; |
||||||
|
} |
||||||
|
|
||||||
|
Shape shape(1, old_stride_.size()); |
||||||
|
tensor_old_stride_.reshape((const char*)old_stride_.data(), shape, kFormatInt32); |
||||||
|
tensor_new_stride_.reshape((const char*)new_stride_.data(), shape, kFormatInt32); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPermute::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins, outs); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPermute::forward(std::vector<Tensor>& ins, std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
int num_ins = ins.size(); |
||||||
|
in_shape_ = ins[0].getShape(); |
||||||
|
out_shape_ = outs[0].getShape(); |
||||||
|
if (!need_permute_) |
||||||
|
{ |
||||||
|
for (int i = 0; i < num_ins; i++) |
||||||
|
{ |
||||||
|
assert(outs[i].count() == ins[i].count()); |
||||||
|
if (outs[i].getBuffer() != ins[i].getBuffer()) |
||||||
|
ins[i].copyTo(outs[i]); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
createShaderModule(permute_spv, sizeof(permute_spv)); |
||||||
|
createPipeline(sizeof(PermuteParam)); |
||||||
|
} |
||||||
|
|
||||||
|
prepareStrides(ins[0].getShape(), outs[0].getShape()); |
||||||
|
std::vector<int>shape(1, order_.size()); |
||||||
|
tensor_order_.reshape((const char*)order_.data(), shape, kFormatInt32); |
||||||
|
bindTensor(device_, tensor_order_, 1, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_old_stride_, 2, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_new_stride_, 3, descriptor_set_); |
||||||
|
|
||||||
|
nthreads_ = ins[0].count(); |
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
global_size_ = alignSize(nthreads_, LOCAL_SZ_X); |
||||||
|
computeGroupCount(); |
||||||
|
|
||||||
|
PermuteParam param = {global_size_, dims_, nthreads_}; |
||||||
|
for (int i = 0; i < num_ins; i++) |
||||||
|
{ |
||||||
|
bindTensor(device_, ins[i], 0, descriptor_set_); |
||||||
|
bindTensor(device_, outs[i], 4, descriptor_set_); |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(PermuteParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPermute::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = global_size_ / LOCAL_SZ_X; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,160 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include <limits> |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_pool.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
#define LOCAL_SZ_Y 1 |
||||||
|
#define LOCAL_SZ_Z 1 |
||||||
|
|
||||||
|
struct PoolParam { |
||||||
|
int channels; |
||||||
|
int in_height; |
||||||
|
int in_width; |
||||||
|
int out_height; |
||||||
|
int out_width; |
||||||
|
int padding_top; |
||||||
|
int padding_left; |
||||||
|
int filter_h; |
||||||
|
int filter_w; |
||||||
|
int stride_h; |
||||||
|
int stride_w; |
||||||
|
int total; |
||||||
|
int mask_or_padded_area; |
||||||
|
}; |
||||||
|
|
||||||
|
OpPool::OpPool(const int* filter_size, const int* pad, const int* stride, |
||||||
|
const int padding_mode, const PoolType type, |
||||||
|
const bool avg_pool_padded_area) |
||||||
|
{ |
||||||
|
init(filter_size, pad, stride, padding_mode, type, avg_pool_padded_area); |
||||||
|
type_ = "Pool"; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPool::init(const int* filter_size, const int* pad, const int* stride, |
||||||
|
const int padding_mode, const PoolType type, bool avg_pool_padded_area) |
||||||
|
{ |
||||||
|
VKCOM_CHECK_BOOL_RET_VAL(padding_mode >= 0 && padding_mode < kPaddingModeNum, false); |
||||||
|
VKCOM_CHECK_POINTER_RET_VAL(filter_size, false); |
||||||
|
VKCOM_CHECK_POINTER_RET_VAL(pad, false); |
||||||
|
VKCOM_CHECK_POINTER_RET_VAL(stride, false); |
||||||
|
|
||||||
|
filter_height_ = filter_size[0]; |
||||||
|
filter_width_ = filter_size[1]; |
||||||
|
padding_top_ = pad[0]; |
||||||
|
padding_left_ = pad[1]; |
||||||
|
padding_mode_ = (PaddingMode)padding_mode; |
||||||
|
stride_height_ = stride[0]; |
||||||
|
stride_width_ = stride[1]; |
||||||
|
pool_type_ = type; |
||||||
|
avg_pool_padded_area_ = avg_pool_padded_area ? 1 : 0; |
||||||
|
|
||||||
|
if (pool_type_ == kPoolTypeAvg) |
||||||
|
OpBase::initVulkanThing(2); |
||||||
|
else if (pool_type_ == kPoolTypeMax) |
||||||
|
OpBase::initVulkanThing(3); |
||||||
|
else |
||||||
|
assert(0); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
void OpPool::reshapeOutTensor(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape in_shape = in.getShape(); |
||||||
|
batch_ = in_shape[kShapeIdxBatch]; |
||||||
|
channels_ = in_shape[kShapeIdxChannel]; |
||||||
|
in_height_ = in_shape[kShapeIdxHeight]; |
||||||
|
in_width_ = in_shape[kShapeIdxWidth]; |
||||||
|
computePoolOutputShape(padding_mode_, padding_top_, padding_left_, |
||||||
|
in_height_, in_width_, |
||||||
|
filter_height_, filter_width_, |
||||||
|
stride_height_, stride_width_, |
||||||
|
out_height_, out_width_); |
||||||
|
Shape out_shape = {batch_, channels_, out_height_, out_width_}; |
||||||
|
out.reshape(NULL, out_shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPool::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
for (size_t ii = 0; ii < ins.size(); ii++) |
||||||
|
{ |
||||||
|
Tensor& inpMat = ins[ii]; |
||||||
|
int out_index = (pool_type_ == kPoolTypeMax) ? 2 : 1; |
||||||
|
Tensor& outMat = outs[out_index * ii]; |
||||||
|
Tensor maskMat = (pool_type_ == kPoolTypeMax) ? outs[2 * ii + 1] : Tensor(); |
||||||
|
if (!forward(inpMat, outMat, maskMat)) |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPool::forward(Tensor& in, Tensor& out, Tensor& mask) |
||||||
|
{ |
||||||
|
Shape in_shape = in.getShape(); |
||||||
|
Shape out_shape = out.getShape(); |
||||||
|
batch_ = in_shape[kShapeIdxBatch]; |
||||||
|
channels_ = in_shape[kShapeIdxChannel]; |
||||||
|
in_height_ = in_shape[kShapeIdxHeight]; |
||||||
|
in_width_ = in_shape[kShapeIdxWidth]; |
||||||
|
out_height_ = out_shape[kShapeIdxHeight]; |
||||||
|
out_width_ = out_shape[kShapeIdxWidth]; |
||||||
|
need_mask_ = mask.isEmpty() ? 0 : 1; |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
config_.local_size_x = LOCAL_SZ_X; |
||||||
|
config_.local_size_y = LOCAL_SZ_Y; |
||||||
|
config_.local_size_z = LOCAL_SZ_Z; |
||||||
|
config_.block_height = 1; |
||||||
|
config_.block_width = 1; |
||||||
|
config_.block_depth = 1; |
||||||
|
if (pool_type_ == kPoolTypeAvg) |
||||||
|
createShaderModule(avg_pool_spv, sizeof(avg_pool_spv)); |
||||||
|
else |
||||||
|
createShaderModule(max_pool_spv, sizeof(max_pool_spv)); |
||||||
|
createPipeline(sizeof(PoolParam)); |
||||||
|
computeGroupCount(); |
||||||
|
} |
||||||
|
|
||||||
|
bindTensor(device_, in, 0, descriptor_set_); |
||||||
|
bindTensor(device_, out, 1, descriptor_set_); |
||||||
|
if (need_mask_) |
||||||
|
bindTensor(device_, mask, 2, descriptor_set_); |
||||||
|
PoolParam param = {channels_, |
||||||
|
in_height_, in_width_, |
||||||
|
out_height_, out_width_, |
||||||
|
padding_top_, padding_left_, |
||||||
|
filter_height_, filter_width_, |
||||||
|
stride_height_, stride_width_, out.count(), |
||||||
|
pool_type_ == kPoolTypeAvg ? avg_pool_padded_area_ : need_mask_}; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(PoolParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPool::computeGroupCount() |
||||||
|
{ |
||||||
|
#define GLOBAL_SIZE (128 * 128) |
||||||
|
group_x_ = alignSize(GLOBAL_SIZE, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,151 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include <limits> |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_prior_box.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
struct PriorBoxParam { |
||||||
|
int global_size; |
||||||
|
int nthreads; |
||||||
|
float step_x; |
||||||
|
float step_y; |
||||||
|
int offsets_x_size; |
||||||
|
int width_size; |
||||||
|
int layer_w; |
||||||
|
int image_h; |
||||||
|
int image_w; |
||||||
|
int clip; |
||||||
|
int variance_off; |
||||||
|
}; |
||||||
|
|
||||||
|
OpPriorBox::OpPriorBox(float step_x, |
||||||
|
float step_y, |
||||||
|
bool clip, |
||||||
|
int num_priors, |
||||||
|
std::vector<float>& variance, |
||||||
|
std::vector<float>& offsets_x, |
||||||
|
std::vector<float>& offsets_y, |
||||||
|
std::vector<float>& box_widths, |
||||||
|
std::vector<float>& box_heights) |
||||||
|
{ |
||||||
|
step_x_ = step_x; |
||||||
|
step_y_ = step_y; |
||||||
|
clip_ = clip; |
||||||
|
num_priors_ = num_priors; |
||||||
|
variance_ = variance; |
||||||
|
offsets_x_ = offsets_x; |
||||||
|
offsets_y_ = offsets_y; |
||||||
|
box_widths_ = box_widths; |
||||||
|
box_heights_ = box_heights; |
||||||
|
type_ = "PriorBox"; |
||||||
|
#define BUFFER_NUM 6 |
||||||
|
OpBase::initVulkanThing(BUFFER_NUM); |
||||||
|
} |
||||||
|
|
||||||
|
void OpPriorBox::reshapeOutTensor(std::vector<Tensor *>& ins, Tensor& out) |
||||||
|
{ |
||||||
|
assert(!ins.empty()); |
||||||
|
|
||||||
|
Shape in_shape = ins[0]->getShape(); |
||||||
|
int layer_h = in_shape[kShapeIdxHeight]; |
||||||
|
int layer_w = in_shape[kShapeIdxWidth]; |
||||||
|
int out_num = 1; |
||||||
|
int out_channel = 2; |
||||||
|
Shape out_shape = {out_num, out_channel, layer_h * layer_w * num_priors_ * 4}; |
||||||
|
out.reshape(NULL, out_shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPriorBox::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins, outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPriorBox::forward(std::vector<Tensor>& ins, Tensor& out) |
||||||
|
{ |
||||||
|
assert(ins.size() == 2); |
||||||
|
Shape in_shape = ins[0].getShape(); |
||||||
|
Shape img_shape = ins[1].getShape(); |
||||||
|
|
||||||
|
in_h_ = in_shape[kShapeIdxHeight]; |
||||||
|
in_w_ = in_shape[kShapeIdxWidth]; |
||||||
|
img_h_ = img_shape[kShapeIdxHeight]; |
||||||
|
img_w_ = img_shape[kShapeIdxWidth]; |
||||||
|
out_channel_ = out.dimSize(1); |
||||||
|
out_channel_size_ = out.dimSize(2); |
||||||
|
nthreads_ = in_h_ * in_w_; |
||||||
|
global_size_ = alignSize(nthreads_, LOCAL_SZ_X); |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
createShaderModule(prior_box_spv, sizeof(prior_box_spv)); |
||||||
|
createPipeline(sizeof(PriorBoxParam)); |
||||||
|
computeGroupCount(); |
||||||
|
} |
||||||
|
|
||||||
|
std::vector<int>shape; |
||||||
|
shape.push_back(offsets_x_.size()); |
||||||
|
tensor_offsets_x_.reshape((const char*)offsets_x_.data(), shape); |
||||||
|
tensor_offsets_y_.reshape((const char*)offsets_y_.data(), shape); |
||||||
|
|
||||||
|
shape[0] = box_widths_.size(); |
||||||
|
tensor_widths_.reshape((const char*)box_widths_.data(), shape); |
||||||
|
tensor_heights_.reshape((const char*)box_heights_.data(), shape); |
||||||
|
|
||||||
|
float variance[4] = {variance_[0], variance_[0], variance_[0], variance_[0]}; |
||||||
|
if (variance_.size() > 1) |
||||||
|
{ |
||||||
|
assert(variance_.size() == 4); |
||||||
|
for (int i = 1; i < variance_.size(); i++) |
||||||
|
variance[i] = variance_[i]; |
||||||
|
} |
||||||
|
shape[0] = 4; |
||||||
|
tensor_variance_.reshape((const char*)variance, shape); |
||||||
|
|
||||||
|
bindTensor(device_, tensor_offsets_x_, 0, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_offsets_y_, 1, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_widths_, 2, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_heights_, 3, descriptor_set_); |
||||||
|
bindTensor(device_, tensor_variance_, 4, descriptor_set_); |
||||||
|
bindTensor(device_, out, 5, descriptor_set_); |
||||||
|
|
||||||
|
PriorBoxParam param = {global_size_, |
||||||
|
nthreads_, |
||||||
|
step_x_, |
||||||
|
step_y_, |
||||||
|
(int)offsets_x_.size(), |
||||||
|
(int)box_widths_.size(), |
||||||
|
in_w_, |
||||||
|
img_h_, |
||||||
|
img_w_, |
||||||
|
clip_ ? 1 : 0, |
||||||
|
out_channel_size_ / 4}; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(PriorBoxParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpPriorBox::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = global_size_ / LOCAL_SZ_X; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,74 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_relu.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 32 |
||||||
|
|
||||||
|
struct ReLUParam { |
||||||
|
int total; |
||||||
|
float slope; |
||||||
|
}; |
||||||
|
|
||||||
|
OpReLU::OpReLU(const float slope) : slope_(slope) |
||||||
|
{ |
||||||
|
OpBase::initVulkanThing(2); |
||||||
|
type_ = "ReLU"; |
||||||
|
} |
||||||
|
|
||||||
|
void OpReLU::reshapeOutTensor(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape shape = in.getShape(); |
||||||
|
out.reshape(NULL, shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpReLU::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins[0], outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpReLU::forward(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
total_ = in.count(); |
||||||
|
#define maxComputeWorkGroupCount 65535 |
||||||
|
computeGroupCount(); |
||||||
|
createShaderModule(relu_spv, sizeof(relu_spv)); |
||||||
|
createPipeline(sizeof(ReLUParam)); |
||||||
|
} |
||||||
|
|
||||||
|
bindTensor(device_, in, 0, descriptor_set_); |
||||||
|
bindTensor(device_, out, 1, descriptor_set_); |
||||||
|
ReLUParam param = { total_, slope_ }; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(ReLUParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpReLU::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = alignSize(total_, LOCAL_SZ_X) / LOCAL_SZ_X; |
||||||
|
if (group_x_ > maxComputeWorkGroupCount) |
||||||
|
group_x_ = maxComputeWorkGroupCount; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,110 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_softmax.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
#define LOCAL_SZ_X 256 |
||||||
|
#define LOCAL_SZ_Y 1 |
||||||
|
#define LOCAL_SZ_Z 1 |
||||||
|
|
||||||
|
struct SoftmaxParam { |
||||||
|
int channel_size; |
||||||
|
int outer_size; |
||||||
|
int channels; |
||||||
|
}; |
||||||
|
|
||||||
|
OpSoftmax::OpSoftmax(const int axis, const bool log_softmax) |
||||||
|
{ |
||||||
|
init(axis, log_softmax); |
||||||
|
type_ = "Softmax"; |
||||||
|
} |
||||||
|
|
||||||
|
OpSoftmax::~OpSoftmax() |
||||||
|
{ |
||||||
|
if (max_tensor_) |
||||||
|
delete max_tensor_; |
||||||
|
if (sum_tensor_) |
||||||
|
delete sum_tensor_; |
||||||
|
} |
||||||
|
|
||||||
|
void OpSoftmax::reshapeOutTensor(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
Shape shape = in.getShape(); |
||||||
|
out.reshape(NULL, shape); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpSoftmax::init(const int axis, const bool log_softmax) |
||||||
|
{ |
||||||
|
axis_ = axis; |
||||||
|
log_softmax_ = log_softmax; |
||||||
|
max_tensor_ = NULL; |
||||||
|
sum_tensor_ = NULL; |
||||||
|
OpBase::initVulkanThing(4); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpSoftmax::forward(std::vector<Tensor>& ins, |
||||||
|
std::vector<Tensor>& blobs, |
||||||
|
std::vector<Tensor>& outs) |
||||||
|
{ |
||||||
|
return forward(ins[0], outs[0]); |
||||||
|
} |
||||||
|
|
||||||
|
bool OpSoftmax::forward(Tensor& in, Tensor& out) |
||||||
|
{ |
||||||
|
channels_ = in.dimSize(axis_); |
||||||
|
channel_size_ = in.count(axis_+1); |
||||||
|
outer_size_ = in.count(0, axis_); |
||||||
|
|
||||||
|
if (pipeline_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
config_.local_size_x = LOCAL_SZ_X; |
||||||
|
config_.local_size_y = LOCAL_SZ_Y; |
||||||
|
config_.local_size_z = LOCAL_SZ_Z; |
||||||
|
config_.block_height = 1; |
||||||
|
config_.block_width = 1; |
||||||
|
config_.block_depth = 1; |
||||||
|
createShaderModule(softmax_spv, sizeof(softmax_spv)); |
||||||
|
createPipeline(sizeof(SoftmaxParam)); |
||||||
|
computeGroupCount(); |
||||||
|
} |
||||||
|
|
||||||
|
if (max_tensor_ == NULL || sum_tensor_ == NULL) |
||||||
|
{ |
||||||
|
std::vector<int> shape = {outer_size_, channel_size_}; |
||||||
|
max_tensor_ = new Tensor(NULL, shape); |
||||||
|
sum_tensor_ = new Tensor(NULL, shape); |
||||||
|
} |
||||||
|
bindTensor(device_, in, 0, descriptor_set_); |
||||||
|
bindTensor(device_, *max_tensor_, 1, descriptor_set_); |
||||||
|
bindTensor(device_, *sum_tensor_, 2, descriptor_set_); |
||||||
|
bindTensor(device_, out, 3, descriptor_set_); |
||||||
|
SoftmaxParam param = {channel_size_, outer_size_, channels_}; |
||||||
|
recordCommandBuffer((void *)¶m, sizeof(SoftmaxParam)); |
||||||
|
runCommandBuffer(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool OpSoftmax::computeGroupCount() |
||||||
|
{ |
||||||
|
group_x_ = alignSize(outer_size_, config_.local_size_x) / config_.local_size_x; |
||||||
|
group_y_ = 1; |
||||||
|
group_z_ = 1; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,131 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
Tensor::Tensor(Format fmt) : size_in_byte_(0), format_(fmt) |
||||||
|
{ |
||||||
|
Context *ctx = getContext(); |
||||||
|
device_ = ctx->device; |
||||||
|
} |
||||||
|
|
||||||
|
Tensor::Tensor(const char* data, std::vector<int>& shape, Format fmt) |
||||||
|
: size_in_byte_(0), format_(fmt) |
||||||
|
{ |
||||||
|
Context *ctx = getContext(); |
||||||
|
device_ = ctx->device; |
||||||
|
reshape(data, shape); |
||||||
|
} |
||||||
|
|
||||||
|
void* Tensor::map() |
||||||
|
{ |
||||||
|
void *p; |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkMapMemory(device_, buffer_->getVkMemory(), |
||||||
|
0, size_in_byte_, 0, (void **)&p)); |
||||||
|
|
||||||
|
return p; |
||||||
|
} |
||||||
|
|
||||||
|
void Tensor::unMap() |
||||||
|
{ |
||||||
|
vkUnmapMemory(device_, buffer_->getVkMemory()); |
||||||
|
} |
||||||
|
|
||||||
|
Shape Tensor::getShape() const |
||||||
|
{ |
||||||
|
return shape_; |
||||||
|
} |
||||||
|
|
||||||
|
int Tensor::count(const int start_axis, const int end_axis) const |
||||||
|
{ |
||||||
|
return shapeCount(shape_, start_axis, end_axis); |
||||||
|
} |
||||||
|
|
||||||
|
int Tensor::dimSize(const int axis) const |
||||||
|
{ |
||||||
|
CV_Assert(axis >= 0); |
||||||
|
CV_Assert(axis < shape_.size()); |
||||||
|
|
||||||
|
return shape_[axis]; |
||||||
|
} |
||||||
|
|
||||||
|
int Tensor::dimNum() const |
||||||
|
{ |
||||||
|
return shape_.size(); |
||||||
|
} |
||||||
|
|
||||||
|
Tensor Tensor::reshape(const char* data, const std::vector<int>& shape, bool alloc, Format fmt) |
||||||
|
{ |
||||||
|
if (device_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
CV_Error(Error::StsError, "device is NULL"); |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
CV_Assert(shape.size() > 0 && shape.size() <= 6); |
||||||
|
|
||||||
|
if (shape_ != shape) shape_ = shape; |
||||||
|
if (checkFormat(fmt) && fmt != format_) format_ = fmt; |
||||||
|
|
||||||
|
size_t new_size = shapeCount(shape_) * elementSize(format_); |
||||||
|
if (alloc || new_size > size_in_byte_) |
||||||
|
alloc = true; |
||||||
|
size_in_byte_ = new_size; |
||||||
|
|
||||||
|
if (alloc) |
||||||
|
{ |
||||||
|
buffer_.reset(new Buffer(device_, size_in_byte_, data)); |
||||||
|
} |
||||||
|
else if (data) |
||||||
|
{ |
||||||
|
void* p = map(); |
||||||
|
memcpy(p, data, size_in_byte_); |
||||||
|
unMap(); |
||||||
|
} |
||||||
|
|
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
void Tensor::setTo(float val) |
||||||
|
{ |
||||||
|
if (device_ == VK_NULL_HANDLE) |
||||||
|
{ |
||||||
|
CV_Error(Error::StsError, "device is NULL"); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
CV_Assert(format_ == kFormatFp32); |
||||||
|
|
||||||
|
float* p = (float *)map(); |
||||||
|
int cnt = count(); |
||||||
|
for (int i = 0; i < cnt; i++) |
||||||
|
*p++ = val; |
||||||
|
unMap(); |
||||||
|
} |
||||||
|
|
||||||
|
int Tensor::getFormat() const |
||||||
|
{ |
||||||
|
return format_; |
||||||
|
} |
||||||
|
|
||||||
|
void Tensor::copyTo(Tensor& dst) |
||||||
|
{ |
||||||
|
void* p = map(); |
||||||
|
dst.reshape((const char*)p, shape_, format_); |
||||||
|
unMap(); |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,403 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#include "common.hpp" |
||||||
|
#include "internal.hpp" |
||||||
|
#include "../include/op_conv.hpp" |
||||||
|
#include "../include/op_pool.hpp" |
||||||
|
#include "../include/op_lrn.hpp" |
||||||
|
#include "../include/op_concat.hpp" |
||||||
|
#include "../include/op_softmax.hpp" |
||||||
|
#include "../vulkan/vk_loader.hpp" |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
|
||||||
|
static bool enableValidationLayers = false; |
||||||
|
static VkInstance kInstance; |
||||||
|
static VkPhysicalDevice kPhysicalDevice; |
||||||
|
static VkDebugReportCallbackEXT kDebugReportCallback; |
||||||
|
static uint32_t kQueueFamilyIndex; |
||||||
|
std::vector<const char *> kEnabledLayers; |
||||||
|
typedef std::map<std::thread::id, Context*> IdToContextMap; |
||||||
|
IdToContextMap kThreadResources; |
||||||
|
static std::map<std::string, std::vector<uint32_t>> kShaders; |
||||||
|
static int init_count = 0; |
||||||
|
static bool init(); |
||||||
|
static void release(); |
||||||
|
static uint32_t getComputeQueueFamilyIndex(); |
||||||
|
static bool checkExtensionAvailability(const char *extension_name, |
||||||
|
const std::vector<VkExtensionProperties> |
||||||
|
&available_extensions); |
||||||
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debugReportCallbackFn( |
||||||
|
VkDebugReportFlagsEXT flags, |
||||||
|
VkDebugReportObjectTypeEXT objectType, |
||||||
|
uint64_t object, |
||||||
|
size_t location, |
||||||
|
int32_t messageCode, |
||||||
|
const char* pLayerPrefix, |
||||||
|
const char* pMessage, |
||||||
|
void* pUserData); |
||||||
|
|
||||||
|
static void setContext(Context* ctx) |
||||||
|
{ |
||||||
|
cv::AutoLock lock(getInitializationMutex()); |
||||||
|
std::thread::id tid = std::this_thread::get_id(); |
||||||
|
if (kThreadResources.find(tid) != kThreadResources.end()) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
kThreadResources.insert(std::pair<std::thread::id, Context*>(tid, ctx)); |
||||||
|
} |
||||||
|
|
||||||
|
Context* getContext() |
||||||
|
{ |
||||||
|
Context* ctx = NULL; |
||||||
|
|
||||||
|
cv::AutoLock lock(getInitializationMutex()); |
||||||
|
std::thread::id tid = std::this_thread::get_id(); |
||||||
|
IdToContextMap::iterator it = kThreadResources.find(tid); |
||||||
|
if (it != kThreadResources.end()) |
||||||
|
{ |
||||||
|
ctx = it->second; |
||||||
|
} |
||||||
|
return ctx; |
||||||
|
} |
||||||
|
|
||||||
|
static void removeContext() |
||||||
|
{ |
||||||
|
cv::AutoLock lock(getInitializationMutex()); |
||||||
|
std::thread::id tid = std::this_thread::get_id(); |
||||||
|
IdToContextMap::iterator it = kThreadResources.find(tid); |
||||||
|
if (it == kThreadResources.end()) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
kThreadResources.erase(it); |
||||||
|
} |
||||||
|
|
||||||
|
bool initPerThread() |
||||||
|
{ |
||||||
|
VkDevice device; |
||||||
|
VkQueue queue; |
||||||
|
VkCommandPool cmd_pool; |
||||||
|
|
||||||
|
VKCOM_CHECK_BOOL_RET_VAL(init(), false); |
||||||
|
Context* ctx = getContext(); |
||||||
|
if (ctx) |
||||||
|
{ |
||||||
|
ctx->ref++; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
// create device, queue, command pool
|
||||||
|
VkDeviceQueueCreateInfo queueCreateInfo = {}; |
||||||
|
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
||||||
|
queueCreateInfo.queueFamilyIndex = kQueueFamilyIndex; |
||||||
|
queueCreateInfo.queueCount = 1; // create one queue in this family. We don't need more.
|
||||||
|
float queuePriorities = 1.0; // we only have one queue, so this is not that imporant.
|
||||||
|
queueCreateInfo.pQueuePriorities = &queuePriorities; |
||||||
|
|
||||||
|
VkDeviceCreateInfo deviceCreateInfo = {}; |
||||||
|
|
||||||
|
// Specify any desired device features here. We do not need any for this application, though.
|
||||||
|
VkPhysicalDeviceFeatures deviceFeatures = {}; |
||||||
|
|
||||||
|
deviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
||||||
|
deviceCreateInfo.enabledLayerCount = kEnabledLayers.size(); |
||||||
|
deviceCreateInfo.ppEnabledLayerNames = kEnabledLayers.data(); |
||||||
|
deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo; |
||||||
|
deviceCreateInfo.queueCreateInfoCount = 1; |
||||||
|
deviceCreateInfo.pEnabledFeatures = &deviceFeatures; |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkCreateDevice(kPhysicalDevice, &deviceCreateInfo, NULL, &device)); |
||||||
|
|
||||||
|
// Get a handle to the only member of the queue family.
|
||||||
|
vkGetDeviceQueue(device, kQueueFamilyIndex, 0, &queue); |
||||||
|
|
||||||
|
// create command pool
|
||||||
|
VkCommandPoolCreateInfo commandPoolCreateInfo = {}; |
||||||
|
commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
||||||
|
commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
||||||
|
// the queue family of this command pool. All command buffers allocated from this command pool,
|
||||||
|
// must be submitted to queues of this family ONLY.
|
||||||
|
commandPoolCreateInfo.queueFamilyIndex = kQueueFamilyIndex; |
||||||
|
VK_CHECK_RESULT(vkCreateCommandPool(device, &commandPoolCreateInfo, NULL, &cmd_pool)); |
||||||
|
|
||||||
|
ctx = new Context(); |
||||||
|
ctx->device = device; |
||||||
|
ctx->queue = queue; |
||||||
|
ctx->cmd_pool = cmd_pool; |
||||||
|
ctx->ref = 1; |
||||||
|
setContext(ctx); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
void deinitPerThread() |
||||||
|
{ |
||||||
|
Context* ctx = getContext(); |
||||||
|
if (ctx == NULL) |
||||||
|
{ |
||||||
|
release(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (ctx->ref > 1) |
||||||
|
{ |
||||||
|
ctx->ref--; |
||||||
|
} |
||||||
|
else if (ctx->ref == 1) |
||||||
|
{ |
||||||
|
for(auto &kv: ctx->shader_modules) |
||||||
|
{ |
||||||
|
vkDestroyShaderModule(ctx->device, kv.second, NULL); |
||||||
|
} |
||||||
|
ctx->shader_modules.clear(); |
||||||
|
vkDestroyCommandPool(ctx->device, ctx->cmd_pool, NULL); |
||||||
|
vkDestroyDevice(ctx->device, NULL); |
||||||
|
removeContext(); |
||||||
|
delete ctx; |
||||||
|
} |
||||||
|
else |
||||||
|
CV_Assert(0); |
||||||
|
release(); |
||||||
|
} |
||||||
|
|
||||||
|
static bool init() |
||||||
|
{ |
||||||
|
cv::AutoLock lock(getInitializationMutex()); |
||||||
|
|
||||||
|
if (init_count == 0) |
||||||
|
{ |
||||||
|
if(!loadVulkanLibrary()) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
else if (!loadVulkanEntry()) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
else if (!loadVulkanGlobalFunctions()) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
// create VkInstance, VkPhysicalDevice
|
||||||
|
std::vector<const char *> enabledExtensions; |
||||||
|
if (enableValidationLayers) |
||||||
|
{ |
||||||
|
uint32_t layerCount; |
||||||
|
vkEnumerateInstanceLayerProperties(&layerCount, NULL); |
||||||
|
|
||||||
|
std::vector<VkLayerProperties> layerProperties(layerCount); |
||||||
|
vkEnumerateInstanceLayerProperties(&layerCount, layerProperties.data()); |
||||||
|
|
||||||
|
bool foundLayer = false; |
||||||
|
for (VkLayerProperties prop : layerProperties) |
||||||
|
{ |
||||||
|
if (strcmp("VK_LAYER_LUNARG_standard_validation", prop.layerName) == 0) |
||||||
|
{ |
||||||
|
foundLayer = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!foundLayer) |
||||||
|
{ |
||||||
|
throw std::runtime_error("Layer VK_LAYER_LUNARG_standard_validation not supported\n"); |
||||||
|
} |
||||||
|
kEnabledLayers.push_back("VK_LAYER_LUNARG_standard_validation"); |
||||||
|
|
||||||
|
uint32_t extensionCount; |
||||||
|
|
||||||
|
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, NULL); |
||||||
|
std::vector<VkExtensionProperties> extensionProperties(extensionCount); |
||||||
|
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensionProperties.data()); |
||||||
|
|
||||||
|
bool foundExtension = false; |
||||||
|
for (VkExtensionProperties prop : extensionProperties) |
||||||
|
{ |
||||||
|
if (strcmp(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, prop.extensionName) == 0) |
||||||
|
{ |
||||||
|
foundExtension = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!foundExtension) { |
||||||
|
throw std::runtime_error("Extension VK_EXT_DEBUG_REPORT_EXTENSION_NAME not supported\n"); |
||||||
|
} |
||||||
|
enabledExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
||||||
|
} |
||||||
|
|
||||||
|
VkApplicationInfo applicationInfo = {}; |
||||||
|
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
||||||
|
applicationInfo.pApplicationName = "VkCom Library"; |
||||||
|
applicationInfo.applicationVersion = 0; |
||||||
|
applicationInfo.pEngineName = "vkcom"; |
||||||
|
applicationInfo.engineVersion = 0; |
||||||
|
applicationInfo.apiVersion = VK_API_VERSION_1_0;; |
||||||
|
|
||||||
|
VkInstanceCreateInfo createInfo = {}; |
||||||
|
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; |
||||||
|
createInfo.flags = 0; |
||||||
|
createInfo.pApplicationInfo = &applicationInfo; |
||||||
|
|
||||||
|
// Give our desired layers and extensions to vulkan.
|
||||||
|
createInfo.enabledLayerCount = kEnabledLayers.size(); |
||||||
|
createInfo.ppEnabledLayerNames = kEnabledLayers.data(); |
||||||
|
createInfo.enabledExtensionCount = enabledExtensions.size(); |
||||||
|
createInfo.ppEnabledExtensionNames = enabledExtensions.data(); |
||||||
|
|
||||||
|
VK_CHECK_RESULT(vkCreateInstance(&createInfo, NULL, &kInstance)); |
||||||
|
|
||||||
|
if (!loadVulkanFunctions(kInstance)) |
||||||
|
{ |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
if (enableValidationLayers && vkCreateDebugReportCallbackEXT) |
||||||
|
{ |
||||||
|
VkDebugReportCallbackCreateInfoEXT createInfo = {}; |
||||||
|
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; |
||||||
|
createInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | |
||||||
|
VK_DEBUG_REPORT_WARNING_BIT_EXT | |
||||||
|
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; |
||||||
|
createInfo.pfnCallback = &debugReportCallbackFn; |
||||||
|
|
||||||
|
// Create and register callback.
|
||||||
|
VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT(kInstance, &createInfo, |
||||||
|
NULL, &kDebugReportCallback)); |
||||||
|
} |
||||||
|
|
||||||
|
// find physical device
|
||||||
|
uint32_t deviceCount; |
||||||
|
vkEnumeratePhysicalDevices(kInstance, &deviceCount, NULL); |
||||||
|
if (deviceCount == 0) |
||||||
|
{ |
||||||
|
throw std::runtime_error("could not find a device with vulkan support"); |
||||||
|
} |
||||||
|
|
||||||
|
std::vector<VkPhysicalDevice> devices(deviceCount); |
||||||
|
vkEnumeratePhysicalDevices(kInstance, &deviceCount, devices.data()); |
||||||
|
|
||||||
|
for (VkPhysicalDevice device : devices) |
||||||
|
{ |
||||||
|
if (true) |
||||||
|
{ |
||||||
|
kPhysicalDevice = device; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
kQueueFamilyIndex = getComputeQueueFamilyIndex(); |
||||||
|
} |
||||||
|
|
||||||
|
init_count++; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
static void release() |
||||||
|
{ |
||||||
|
cv::AutoLock lock(getInitializationMutex()); |
||||||
|
if (init_count == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
init_count--; |
||||||
|
if (init_count == 0) |
||||||
|
{ |
||||||
|
if (enableValidationLayers) { |
||||||
|
auto func = (PFN_vkDestroyDebugReportCallbackEXT) |
||||||
|
vkGetInstanceProcAddr(kInstance, "vkDestroyDebugReportCallbackEXT"); |
||||||
|
if (func == nullptr) { |
||||||
|
throw std::runtime_error("Could not load vkDestroyDebugReportCallbackEXT"); |
||||||
|
} |
||||||
|
func(kInstance, kDebugReportCallback, NULL); |
||||||
|
} |
||||||
|
kShaders.clear(); |
||||||
|
vkDestroyInstance(kInstance, NULL); |
||||||
|
} |
||||||
|
|
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// Returns the index of a queue family that supports compute operations.
|
||||||
|
static uint32_t getComputeQueueFamilyIndex() |
||||||
|
{ |
||||||
|
uint32_t queueFamilyCount; |
||||||
|
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(kPhysicalDevice, &queueFamilyCount, NULL); |
||||||
|
|
||||||
|
std::vector<VkQueueFamilyProperties> queueFamilies(queueFamilyCount); |
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(kPhysicalDevice, |
||||||
|
&queueFamilyCount, |
||||||
|
queueFamilies.data()); |
||||||
|
|
||||||
|
uint32_t i = 0; |
||||||
|
for (; i < queueFamilies.size(); ++i) |
||||||
|
{ |
||||||
|
VkQueueFamilyProperties props = queueFamilies[i]; |
||||||
|
|
||||||
|
if (props.queueCount > 0 && (props.queueFlags & VK_QUEUE_COMPUTE_BIT)) |
||||||
|
{ |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (i == queueFamilies.size()) |
||||||
|
{ |
||||||
|
throw std::runtime_error("could not find a queue family that supports operations"); |
||||||
|
} |
||||||
|
|
||||||
|
return i; |
||||||
|
} |
||||||
|
|
||||||
|
bool checkExtensionAvailability(const char *extension_name, |
||||||
|
const std::vector<VkExtensionProperties> &available_extensions) |
||||||
|
{ |
||||||
|
for( size_t i = 0; i < available_extensions.size(); ++i ) |
||||||
|
{ |
||||||
|
if( strcmp( available_extensions[i].extensionName, extension_name ) == 0 ) |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL debugReportCallbackFn( |
||||||
|
VkDebugReportFlagsEXT flags, |
||||||
|
VkDebugReportObjectTypeEXT objectType, |
||||||
|
uint64_t object, |
||||||
|
size_t location, |
||||||
|
int32_t messageCode, |
||||||
|
const char* pLayerPrefix, |
||||||
|
const char* pMessage, |
||||||
|
void* pUserData) |
||||||
|
{ |
||||||
|
std::cout << "Debug Report: " << pLayerPrefix << ":" << pMessage << std::endl; |
||||||
|
return VK_FALSE; |
||||||
|
} |
||||||
|
|
||||||
|
// internally used functions
|
||||||
|
VkPhysicalDevice getPhysicalDevice() |
||||||
|
{ |
||||||
|
return kPhysicalDevice; |
||||||
|
} |
||||||
|
|
||||||
|
bool isAvailable() |
||||||
|
{ |
||||||
|
return getContext() != NULL; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,301 @@ |
|||||||
|
#ifndef VK_ENTRY |
||||||
|
#define VK_ENTRY(func) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef VK_GLOBAL_LEVEL_FUNC |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC(func) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef VK_GLOBAL_LEVEL_FUNC_MANDATORY |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC_MANDATORY(func) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef VK_FUNC |
||||||
|
#define VK_FUNC(func) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef VK_FUNC_MANDATORY |
||||||
|
#define VK_FUNC_MANDATORY(func) |
||||||
|
#endif |
||||||
|
|
||||||
|
VK_ENTRY(vkGetInstanceProcAddr) |
||||||
|
VK_GLOBAL_LEVEL_FUNC(vkEnumerateInstanceVersion) |
||||||
|
VK_GLOBAL_LEVEL_FUNC_MANDATORY(vkEnumerateInstanceExtensionProperties) |
||||||
|
VK_GLOBAL_LEVEL_FUNC_MANDATORY(vkEnumerateInstanceLayerProperties) |
||||||
|
VK_GLOBAL_LEVEL_FUNC_MANDATORY(vkCreateInstance) |
||||||
|
VK_FUNC_MANDATORY(vkDestroyInstance) |
||||||
|
VK_FUNC_MANDATORY(vkEnumeratePhysicalDevices) |
||||||
|
VK_FUNC_MANDATORY(vkGetPhysicalDeviceQueueFamilyProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFeatures) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFormatProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceImageFormatProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceMemoryProperties) |
||||||
|
VK_FUNC(vkGetDeviceProcAddr) |
||||||
|
VK_FUNC(vkCreateDevice) |
||||||
|
VK_FUNC(vkDestroyDevice) |
||||||
|
VK_FUNC(vkEnumerateDeviceExtensionProperties) |
||||||
|
VK_FUNC(vkEnumerateDeviceLayerProperties) |
||||||
|
VK_FUNC(vkGetDeviceQueue) |
||||||
|
VK_FUNC(vkQueueSubmit) |
||||||
|
VK_FUNC(vkQueueWaitIdle) |
||||||
|
VK_FUNC(vkDeviceWaitIdle) |
||||||
|
VK_FUNC(vkAllocateMemory) |
||||||
|
VK_FUNC(vkFreeMemory) |
||||||
|
VK_FUNC(vkMapMemory) |
||||||
|
VK_FUNC(vkUnmapMemory) |
||||||
|
VK_FUNC(vkFlushMappedMemoryRanges) |
||||||
|
VK_FUNC(vkInvalidateMappedMemoryRanges) |
||||||
|
VK_FUNC(vkGetDeviceMemoryCommitment) |
||||||
|
VK_FUNC(vkBindBufferMemory) |
||||||
|
VK_FUNC(vkBindImageMemory) |
||||||
|
VK_FUNC(vkGetBufferMemoryRequirements) |
||||||
|
VK_FUNC(vkGetImageMemoryRequirements) |
||||||
|
VK_FUNC(vkGetImageSparseMemoryRequirements) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSparseImageFormatProperties) |
||||||
|
VK_FUNC(vkQueueBindSparse) |
||||||
|
VK_FUNC(vkCreateFence) |
||||||
|
VK_FUNC(vkDestroyFence) |
||||||
|
VK_FUNC(vkResetFences) |
||||||
|
VK_FUNC(vkGetFenceStatus) |
||||||
|
VK_FUNC(vkWaitForFences) |
||||||
|
VK_FUNC(vkCreateSemaphore) |
||||||
|
VK_FUNC(vkDestroySemaphore) |
||||||
|
VK_FUNC(vkCreateEvent) |
||||||
|
VK_FUNC(vkDestroyEvent) |
||||||
|
VK_FUNC(vkGetEventStatus) |
||||||
|
VK_FUNC(vkSetEvent) |
||||||
|
VK_FUNC(vkResetEvent) |
||||||
|
VK_FUNC(vkCreateQueryPool) |
||||||
|
VK_FUNC(vkDestroyQueryPool) |
||||||
|
VK_FUNC(vkGetQueryPoolResults) |
||||||
|
VK_FUNC(vkCreateBuffer) |
||||||
|
VK_FUNC(vkDestroyBuffer) |
||||||
|
VK_FUNC(vkCreateBufferView) |
||||||
|
VK_FUNC(vkDestroyBufferView) |
||||||
|
VK_FUNC(vkCreateImage) |
||||||
|
VK_FUNC(vkDestroyImage) |
||||||
|
VK_FUNC(vkGetImageSubresourceLayout) |
||||||
|
VK_FUNC(vkCreateImageView) |
||||||
|
VK_FUNC(vkDestroyImageView) |
||||||
|
VK_FUNC(vkCreateShaderModule) |
||||||
|
VK_FUNC(vkDestroyShaderModule) |
||||||
|
VK_FUNC(vkCreatePipelineCache) |
||||||
|
VK_FUNC(vkDestroyPipelineCache) |
||||||
|
VK_FUNC(vkGetPipelineCacheData) |
||||||
|
VK_FUNC(vkMergePipelineCaches) |
||||||
|
VK_FUNC(vkCreateGraphicsPipelines) |
||||||
|
VK_FUNC(vkCreateComputePipelines) |
||||||
|
VK_FUNC(vkDestroyPipeline) |
||||||
|
VK_FUNC(vkCreatePipelineLayout) |
||||||
|
VK_FUNC(vkDestroyPipelineLayout) |
||||||
|
VK_FUNC(vkCreateSampler) |
||||||
|
VK_FUNC(vkDestroySampler) |
||||||
|
VK_FUNC(vkCreateDescriptorSetLayout) |
||||||
|
VK_FUNC(vkDestroyDescriptorSetLayout) |
||||||
|
VK_FUNC(vkCreateDescriptorPool) |
||||||
|
VK_FUNC(vkDestroyDescriptorPool) |
||||||
|
VK_FUNC(vkResetDescriptorPool) |
||||||
|
VK_FUNC(vkAllocateDescriptorSets) |
||||||
|
VK_FUNC(vkFreeDescriptorSets) |
||||||
|
VK_FUNC(vkUpdateDescriptorSets) |
||||||
|
VK_FUNC(vkCreateFramebuffer) |
||||||
|
VK_FUNC(vkDestroyFramebuffer) |
||||||
|
VK_FUNC(vkCreateRenderPass) |
||||||
|
VK_FUNC(vkDestroyRenderPass) |
||||||
|
VK_FUNC(vkGetRenderAreaGranularity) |
||||||
|
VK_FUNC(vkCreateCommandPool) |
||||||
|
VK_FUNC(vkDestroyCommandPool) |
||||||
|
VK_FUNC(vkResetCommandPool) |
||||||
|
VK_FUNC(vkAllocateCommandBuffers) |
||||||
|
VK_FUNC(vkFreeCommandBuffers) |
||||||
|
VK_FUNC(vkBeginCommandBuffer) |
||||||
|
VK_FUNC(vkEndCommandBuffer) |
||||||
|
VK_FUNC(vkResetCommandBuffer) |
||||||
|
VK_FUNC(vkCmdBindPipeline) |
||||||
|
VK_FUNC(vkCmdSetViewport) |
||||||
|
VK_FUNC(vkCmdSetScissor) |
||||||
|
VK_FUNC(vkCmdSetLineWidth) |
||||||
|
VK_FUNC(vkCmdSetDepthBias) |
||||||
|
VK_FUNC(vkCmdSetBlendConstants) |
||||||
|
VK_FUNC(vkCmdSetDepthBounds) |
||||||
|
VK_FUNC(vkCmdSetStencilCompareMask) |
||||||
|
VK_FUNC(vkCmdSetStencilWriteMask) |
||||||
|
VK_FUNC(vkCmdSetStencilReference) |
||||||
|
VK_FUNC(vkCmdBindDescriptorSets) |
||||||
|
VK_FUNC(vkCmdBindIndexBuffer) |
||||||
|
VK_FUNC(vkCmdBindVertexBuffers) |
||||||
|
VK_FUNC(vkCmdDraw) |
||||||
|
VK_FUNC(vkCmdDrawIndexed) |
||||||
|
VK_FUNC(vkCmdDrawIndirect) |
||||||
|
VK_FUNC(vkCmdDrawIndexedIndirect) |
||||||
|
VK_FUNC(vkCmdDispatch) |
||||||
|
VK_FUNC(vkCmdDispatchIndirect) |
||||||
|
VK_FUNC(vkCmdCopyBuffer) |
||||||
|
VK_FUNC(vkCmdCopyImage) |
||||||
|
VK_FUNC(vkCmdBlitImage) |
||||||
|
VK_FUNC(vkCmdCopyBufferToImage) |
||||||
|
VK_FUNC(vkCmdCopyImageToBuffer) |
||||||
|
VK_FUNC(vkCmdUpdateBuffer) |
||||||
|
VK_FUNC(vkCmdFillBuffer) |
||||||
|
VK_FUNC(vkCmdClearColorImage) |
||||||
|
VK_FUNC(vkCmdClearDepthStencilImage) |
||||||
|
VK_FUNC(vkCmdClearAttachments) |
||||||
|
VK_FUNC(vkCmdResolveImage) |
||||||
|
VK_FUNC(vkCmdSetEvent) |
||||||
|
VK_FUNC(vkCmdResetEvent) |
||||||
|
VK_FUNC(vkCmdWaitEvents) |
||||||
|
VK_FUNC(vkCmdPipelineBarrier) |
||||||
|
VK_FUNC(vkCmdBeginQuery) |
||||||
|
VK_FUNC(vkCmdEndQuery) |
||||||
|
VK_FUNC(vkCmdResetQueryPool) |
||||||
|
VK_FUNC(vkCmdWriteTimestamp) |
||||||
|
VK_FUNC(vkCmdCopyQueryPoolResults) |
||||||
|
VK_FUNC(vkCmdPushConstants) |
||||||
|
VK_FUNC(vkCmdBeginRenderPass) |
||||||
|
VK_FUNC(vkCmdNextSubpass) |
||||||
|
VK_FUNC(vkCmdEndRenderPass) |
||||||
|
VK_FUNC(vkCmdExecuteCommands) |
||||||
|
VK_FUNC(vkBindBufferMemory2) |
||||||
|
VK_FUNC(vkBindImageMemory2) |
||||||
|
VK_FUNC(vkGetDeviceGroupPeerMemoryFeatures) |
||||||
|
VK_FUNC(vkCmdSetDeviceMask) |
||||||
|
VK_FUNC(vkCmdDispatchBase) |
||||||
|
VK_FUNC(vkEnumeratePhysicalDeviceGroups) |
||||||
|
VK_FUNC(vkGetImageMemoryRequirements2) |
||||||
|
VK_FUNC(vkGetBufferMemoryRequirements2) |
||||||
|
VK_FUNC(vkGetImageSparseMemoryRequirements2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFeatures2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceProperties2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFormatProperties2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceImageFormatProperties2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceQueueFamilyProperties2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceMemoryProperties2) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSparseImageFormatProperties2) |
||||||
|
VK_FUNC(vkTrimCommandPool) |
||||||
|
VK_FUNC(vkGetDeviceQueue2) |
||||||
|
VK_FUNC(vkCreateSamplerYcbcrConversion) |
||||||
|
VK_FUNC(vkDestroySamplerYcbcrConversion) |
||||||
|
VK_FUNC(vkCreateDescriptorUpdateTemplate) |
||||||
|
VK_FUNC(vkDestroyDescriptorUpdateTemplate) |
||||||
|
VK_FUNC(vkUpdateDescriptorSetWithTemplate) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalBufferProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalFenceProperties) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalSemaphoreProperties) |
||||||
|
VK_FUNC(vkGetDescriptorSetLayoutSupport) |
||||||
|
VK_FUNC(vkDestroySurfaceKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceSupportKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceFormatsKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfacePresentModesKHR) |
||||||
|
VK_FUNC(vkCreateSwapchainKHR) |
||||||
|
VK_FUNC(vkDestroySwapchainKHR) |
||||||
|
VK_FUNC(vkGetSwapchainImagesKHR) |
||||||
|
VK_FUNC(vkAcquireNextImageKHR) |
||||||
|
VK_FUNC(vkQueuePresentKHR) |
||||||
|
VK_FUNC(vkGetDeviceGroupPresentCapabilitiesKHR) |
||||||
|
VK_FUNC(vkGetDeviceGroupSurfacePresentModesKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDevicePresentRectanglesKHR) |
||||||
|
VK_FUNC(vkAcquireNextImage2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceDisplayPropertiesKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceDisplayPlanePropertiesKHR) |
||||||
|
VK_FUNC(vkGetDisplayPlaneSupportedDisplaysKHR) |
||||||
|
VK_FUNC(vkGetDisplayModePropertiesKHR) |
||||||
|
VK_FUNC(vkCreateDisplayModeKHR) |
||||||
|
VK_FUNC(vkGetDisplayPlaneCapabilitiesKHR) |
||||||
|
VK_FUNC(vkCreateDisplayPlaneSurfaceKHR) |
||||||
|
VK_FUNC(vkCreateSharedSwapchainsKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFeatures2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceProperties2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceFormatProperties2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceImageFormatProperties2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceQueueFamilyProperties2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceMemoryProperties2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSparseImageFormatProperties2KHR) |
||||||
|
VK_FUNC(vkGetDeviceGroupPeerMemoryFeaturesKHR) |
||||||
|
VK_FUNC(vkCmdSetDeviceMaskKHR) |
||||||
|
VK_FUNC(vkCmdDispatchBaseKHR) |
||||||
|
VK_FUNC(vkTrimCommandPoolKHR) |
||||||
|
VK_FUNC(vkEnumeratePhysicalDeviceGroupsKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalBufferPropertiesKHR) |
||||||
|
VK_FUNC(vkGetMemoryFdKHR) |
||||||
|
VK_FUNC(vkGetMemoryFdPropertiesKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) |
||||||
|
VK_FUNC(vkImportSemaphoreFdKHR) |
||||||
|
VK_FUNC(vkGetSemaphoreFdKHR) |
||||||
|
VK_FUNC(vkCmdPushDescriptorSetKHR) |
||||||
|
VK_FUNC(vkCmdPushDescriptorSetWithTemplateKHR) |
||||||
|
VK_FUNC(vkCreateDescriptorUpdateTemplateKHR) |
||||||
|
VK_FUNC(vkDestroyDescriptorUpdateTemplateKHR) |
||||||
|
VK_FUNC(vkUpdateDescriptorSetWithTemplateKHR) |
||||||
|
VK_FUNC(vkGetSwapchainStatusKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalFencePropertiesKHR) |
||||||
|
VK_FUNC(vkImportFenceFdKHR) |
||||||
|
VK_FUNC(vkGetFenceFdKHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceCapabilities2KHR) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceFormats2KHR) |
||||||
|
VK_FUNC(vkGetImageMemoryRequirements2KHR) |
||||||
|
VK_FUNC(vkGetBufferMemoryRequirements2KHR) |
||||||
|
VK_FUNC(vkGetImageSparseMemoryRequirements2KHR) |
||||||
|
VK_FUNC(vkCreateSamplerYcbcrConversionKHR) |
||||||
|
VK_FUNC(vkDestroySamplerYcbcrConversionKHR) |
||||||
|
VK_FUNC(vkBindBufferMemory2KHR) |
||||||
|
VK_FUNC(vkBindImageMemory2KHR) |
||||||
|
VK_FUNC(vkGetDescriptorSetLayoutSupportKHR) |
||||||
|
VK_FUNC(vkCreateDebugReportCallbackEXT) |
||||||
|
VK_FUNC(vkDestroyDebugReportCallbackEXT) |
||||||
|
VK_FUNC(vkDebugReportMessageEXT) |
||||||
|
VK_FUNC(vkDebugMarkerSetObjectTagEXT) |
||||||
|
VK_FUNC(vkDebugMarkerSetObjectNameEXT) |
||||||
|
VK_FUNC(vkCmdDebugMarkerBeginEXT) |
||||||
|
VK_FUNC(vkCmdDebugMarkerEndEXT) |
||||||
|
VK_FUNC(vkCmdDebugMarkerInsertEXT) |
||||||
|
VK_FUNC(vkCmdDrawIndirectCountAMD) |
||||||
|
VK_FUNC(vkCmdDrawIndexedIndirectCountAMD) |
||||||
|
VK_FUNC(vkGetShaderInfoAMD) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceExternalImageFormatPropertiesNV) |
||||||
|
VK_FUNC(vkCmdProcessCommandsNVX) |
||||||
|
VK_FUNC(vkCmdReserveSpaceForCommandsNVX) |
||||||
|
VK_FUNC(vkCreateIndirectCommandsLayoutNVX) |
||||||
|
VK_FUNC(vkDestroyIndirectCommandsLayoutNVX) |
||||||
|
VK_FUNC(vkCreateObjectTableNVX) |
||||||
|
VK_FUNC(vkDestroyObjectTableNVX) |
||||||
|
VK_FUNC(vkRegisterObjectsNVX) |
||||||
|
VK_FUNC(vkUnregisterObjectsNVX) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX) |
||||||
|
VK_FUNC(vkCmdSetViewportWScalingNV) |
||||||
|
VK_FUNC(vkReleaseDisplayEXT) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceSurfaceCapabilities2EXT) |
||||||
|
VK_FUNC(vkDisplayPowerControlEXT) |
||||||
|
VK_FUNC(vkRegisterDeviceEventEXT) |
||||||
|
VK_FUNC(vkRegisterDisplayEventEXT) |
||||||
|
VK_FUNC(vkGetSwapchainCounterEXT) |
||||||
|
VK_FUNC(vkGetRefreshCycleDurationGOOGLE) |
||||||
|
VK_FUNC(vkGetPastPresentationTimingGOOGLE) |
||||||
|
VK_FUNC(vkCmdSetDiscardRectangleEXT) |
||||||
|
VK_FUNC(vkSetHdrMetadataEXT) |
||||||
|
VK_FUNC(vkSetDebugUtilsObjectNameEXT) |
||||||
|
VK_FUNC(vkSetDebugUtilsObjectTagEXT) |
||||||
|
VK_FUNC(vkQueueBeginDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkQueueEndDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkQueueInsertDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkCmdBeginDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkCmdEndDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkCmdInsertDebugUtilsLabelEXT) |
||||||
|
VK_FUNC(vkCreateDebugUtilsMessengerEXT) |
||||||
|
VK_FUNC(vkDestroyDebugUtilsMessengerEXT) |
||||||
|
VK_FUNC(vkSubmitDebugUtilsMessageEXT) |
||||||
|
VK_FUNC(vkCmdSetSampleLocationsEXT) |
||||||
|
VK_FUNC(vkGetPhysicalDeviceMultisamplePropertiesEXT) |
||||||
|
VK_FUNC(vkCreateValidationCacheEXT) |
||||||
|
VK_FUNC(vkDestroyValidationCacheEXT) |
||||||
|
VK_FUNC(vkMergeValidationCachesEXT) |
||||||
|
VK_FUNC(vkGetValidationCacheDataEXT) |
||||||
|
VK_FUNC(vkGetMemoryHostPointerPropertiesEXT) |
||||||
|
VK_FUNC(vkCmdWriteBufferMarkerAMD) |
||||||
|
|
||||||
|
#undef VK_ENTRY |
||||||
|
#undef VK_GLOBAL_LEVEL_FUNC |
||||||
|
#undef VK_GLOBAL_LEVEL_FUNC_MANDATORY |
||||||
|
#undef VK_FUNC |
||||||
|
#undef VK_FUNC_MANDATORY |
@ -0,0 +1,23 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
|
||||||
|
#define VK_ENTRY(func) PFN_##func func = nullptr; |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC(func) PFN_##func func = nullptr; |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC_MANDATORY(func) PFN_##func func = nullptr; |
||||||
|
#define VK_FUNC(func) PFN_##func func = nullptr; |
||||||
|
#define VK_FUNC_MANDATORY(func) PFN_##func func = nullptr; |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#include "function_list.inl" |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
#endif // HAVE_VULKAN
|
@ -0,0 +1,28 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_VULKAN_VK_FUNCTONS_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_VULKAN_VK_FUNCTONS_HPP |
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
|
||||||
|
#define VK_ENTRY(func) extern PFN_##func func; |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC(func) extern PFN_##func func; |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC_MANDATORY(func) extern PFN_##func func; |
||||||
|
#define VK_FUNC(func) extern PFN_##func func; |
||||||
|
#define VK_FUNC_MANDATORY(func) extern PFN_##func func; |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#include "function_list.inl" |
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
#endif // OPENCV_DNN_VKCOM_VULKAN_VK_FUNCTONS_HPP
|
@ -0,0 +1,124 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#include "../../precomp.hpp" |
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
#include <vulkan/vulkan.h> |
||||||
|
#endif |
||||||
|
#include "vk_functions.hpp" |
||||||
|
|
||||||
|
#if defined(_WIN32) |
||||||
|
#include <windows.h> |
||||||
|
typedef HMODULE VulkanHandle; |
||||||
|
#define DEFAULT_VK_LIBRARY_PATH "vulkan-1.dll" |
||||||
|
#define LOAD_VK_LIBRARY(path) LoadLibrary(path) |
||||||
|
#define FREE_VK_LIBRARY(handle) FreeLibrary(handle) |
||||||
|
#define GET_VK_ENTRY_POINT(handle) \ |
||||||
|
(PFN_vkGetInstanceProcAddr)GetProcAddress(handle, "vkGetInstanceProcAddr"); |
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#if defined(__linux__) |
||||||
|
#include <dlfcn.h> |
||||||
|
#include <stdio.h> |
||||||
|
typedef void* VulkanHandle; |
||||||
|
#define DEFAULT_VK_LIBRARY_PATH "libvulkan.so.1" |
||||||
|
#define LOAD_VK_LIBRARY(path) dlopen(path, RTLD_LAZY | RTLD_GLOBAL) |
||||||
|
#define FREE_VK_LIBRARY(handle) dlclose(handle) |
||||||
|
#define GET_VK_ENTRY_POINT(handle) \ |
||||||
|
(PFN_vkGetInstanceProcAddr)dlsym(handle, "vkGetInstanceProcAddr"); |
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
#ifndef DEFAULT_VK_LIBRARY_PATH |
||||||
|
#define DEFAULT_VK_LIBRARY_PATH "" |
||||||
|
#define LOAD_VK_LIBRARY(path) nullptr |
||||||
|
#define FREE_VK_LIBRARY(handle) |
||||||
|
#define GET_VK_ENTRY_POINT(handle) nullptr |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
static VulkanHandle handle = nullptr; |
||||||
|
|
||||||
|
bool loadVulkanFunctions(VkInstance& instance) |
||||||
|
{ |
||||||
|
#define VK_FUNC(fun) \ |
||||||
|
fun = (PFN_##fun)vkGetInstanceProcAddr(instance, #fun); |
||||||
|
|
||||||
|
#define VK_FUNC_MANDATORY(fun) \ |
||||||
|
VK_FUNC(fun) \
|
||||||
|
if(!fun) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Could not load Vulkan function: %s !\n", #fun); \
|
||||||
|
return false; \
|
||||||
|
} |
||||||
|
|
||||||
|
#include "function_list.inl" |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool loadVulkanGlobalFunctions() |
||||||
|
{ |
||||||
|
#define VK_GLOBAL_LEVEL_FUNC(fun) \ |
||||||
|
fun = (PFN_##fun)vkGetInstanceProcAddr(nullptr, #fun); |
||||||
|
|
||||||
|
#define VK_GLOBAL_LEVEL_FUNC_MANDATORY(fun) \ |
||||||
|
VK_GLOBAL_LEVEL_FUNC(fun) \
|
||||||
|
if(!fun) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Could not load global Vulkan function: %s !\n", #fun); \
|
||||||
|
return false; \
|
||||||
|
} |
||||||
|
|
||||||
|
#include "function_list.inl" |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool loadVulkanEntry() |
||||||
|
{ |
||||||
|
if (handle == nullptr) |
||||||
|
return false; |
||||||
|
|
||||||
|
vkGetInstanceProcAddr = GET_VK_ENTRY_POINT(handle); |
||||||
|
if (!vkGetInstanceProcAddr) |
||||||
|
{ |
||||||
|
fprintf(stderr, "Could not load Vulkan entry function: vkGetInstanceProcAddr!\n"); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool loadVulkanLibrary() |
||||||
|
{ |
||||||
|
if (handle != nullptr) |
||||||
|
return true; |
||||||
|
|
||||||
|
const char* path; |
||||||
|
const char* envPath = getenv("OPENCV_VULKAN_RUNTIME"); |
||||||
|
if (envPath) |
||||||
|
{ |
||||||
|
path = envPath; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
path = DEFAULT_VK_LIBRARY_PATH; |
||||||
|
} |
||||||
|
|
||||||
|
handle = LOAD_VK_LIBRARY(path); |
||||||
|
if( handle == nullptr ) |
||||||
|
{ |
||||||
|
fprintf(stderr, "Could not load Vulkan library: %s!\n", path); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
@ -0,0 +1,21 @@ |
|||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
|
||||||
|
#ifndef OPENCV_DNN_VKCOM_VULKAN_VK_LOADER_HPP |
||||||
|
#define OPENCV_DNN_VKCOM_VULKAN_VK_LOADER_HPP |
||||||
|
|
||||||
|
namespace cv { namespace dnn { namespace vkcom { |
||||||
|
|
||||||
|
#ifdef HAVE_VULKAN |
||||||
|
bool loadVulkanLibrary(); |
||||||
|
bool loadVulkanEntry(); |
||||||
|
bool loadVulkanGlobalFunctions(); |
||||||
|
bool loadVulkanFunctions(VkInstance& instance); |
||||||
|
#endif // HAVE_VULKAN
|
||||||
|
|
||||||
|
}}} // namespace cv::dnn::vkcom
|
||||||
|
#endif // OPENCV_DNN_VKCOM_VULKAN_VK_LOADER_HPP
|
Loading…
Reference in new issue