You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_packing.cpp 19 kB

adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
X86 Elempack 8 AVX implementations. (#1853) * added avx implementations of FC and Max pool * Specify AVX2 * Small fixes and using Fused avx activations * fix type casting * fixing some CI errors * Fix code format * fix pooling test * remove vector typedef * More compile fixes * remove vector typedef * set c++ version to 17 * Force c++ 17 * Fixing mathfun * Try and workaround typedef issues * typefix * Remove typedef * switch to static inline * attempting to fix msvc bug * Verified MSVX FIX * Fixing clang build * commit before switch * More avx and packing implementation * Fix ctest * starting the depthwise pack 8 implementation * Unrolled loop * add depthwise pack 8 implementations * Working 1x1 pack 8 implementation added * revert incorrect changes * added conact elempack 8 * more elempack enabled layers added and started on the conversion of the winograd pack4 conv 3x3 * Added code formatting * fix styling * Unroll loops * unrolling loops * Added more elempac layers for mobilenet v3 * revert commit * fix code style * remove arm neon references * remove pack4 references * More cleanup * added packing avx code * fixing linux build ctests * remove usage of aligned loads * More aligned mem ops removed * Cleanup, revert some files and remove not working winograd and shufflechannel implementation * add stackoverflow referal * Fix windows build * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * implement requested chaanges * remove reshape * revert arm file change * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * fix unterminated directive Co-authored-by: Restyled.io <commits@restyled.io>
6 years ago
X86 Elempack 8 AVX implementations. (#1853) * added avx implementations of FC and Max pool * Specify AVX2 * Small fixes and using Fused avx activations * fix type casting * fixing some CI errors * Fix code format * fix pooling test * remove vector typedef * More compile fixes * remove vector typedef * set c++ version to 17 * Force c++ 17 * Fixing mathfun * Try and workaround typedef issues * typefix * Remove typedef * switch to static inline * attempting to fix msvc bug * Verified MSVX FIX * Fixing clang build * commit before switch * More avx and packing implementation * Fix ctest * starting the depthwise pack 8 implementation * Unrolled loop * add depthwise pack 8 implementations * Working 1x1 pack 8 implementation added * revert incorrect changes * added conact elempack 8 * more elempack enabled layers added and started on the conversion of the winograd pack4 conv 3x3 * Added code formatting * fix styling * Unroll loops * unrolling loops * Added more elempac layers for mobilenet v3 * revert commit * fix code style * remove arm neon references * remove pack4 references * More cleanup * added packing avx code * fixing linux build ctests * remove usage of aligned loads * More aligned mem ops removed * Cleanup, revert some files and remove not working winograd and shufflechannel implementation * add stackoverflow referal * Fix windows build * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * implement requested chaanges * remove reshape * revert arm file change * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * fix unterminated directive Co-authored-by: Restyled.io <commits@restyled.io>
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
X86 Elempack 8 AVX implementations. (#1853) * added avx implementations of FC and Max pool * Specify AVX2 * Small fixes and using Fused avx activations * fix type casting * fixing some CI errors * Fix code format * fix pooling test * remove vector typedef * More compile fixes * remove vector typedef * set c++ version to 17 * Force c++ 17 * Fixing mathfun * Try and workaround typedef issues * typefix * Remove typedef * switch to static inline * attempting to fix msvc bug * Verified MSVX FIX * Fixing clang build * commit before switch * More avx and packing implementation * Fix ctest * starting the depthwise pack 8 implementation * Unrolled loop * add depthwise pack 8 implementations * Working 1x1 pack 8 implementation added * revert incorrect changes * added conact elempack 8 * more elempack enabled layers added and started on the conversion of the winograd pack4 conv 3x3 * Added code formatting * fix styling * Unroll loops * unrolling loops * Added more elempac layers for mobilenet v3 * revert commit * fix code style * remove arm neon references * remove pack4 references * More cleanup * added packing avx code * fixing linux build ctests * remove usage of aligned loads * More aligned mem ops removed * Cleanup, revert some files and remove not working winograd and shufflechannel implementation * add stackoverflow referal * Fix windows build * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * implement requested chaanges * remove reshape * revert arm file change * Restyled by clang-format * Restyled by astyle * Restyled by clang-format * Restyled by astyle * fix unterminated directive Co-authored-by: Restyled.io <commits@restyled.io>
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
adreno image shader + fp16 + fp16a (#1714) * wip * wip * fix * image and imageview can not be destroyed until command execution ends * fast copy path for tightly packed data * wip * texture load works * 1d 3d image * record clone image, multiple commands share one image reference * upload download image * layer forward accept vkimagemat * vkimagemat graph works * staging vkimagemat for passing dynamic parameters, macro for fp32+image shader, padding image shader * vkimagemat elemsize * convolution test pass * conv1x1s1 image shader * fast staging image allocator from host memory, pooling image shader * convolutiondepthwise image shader * innerproduct image shader * packing image shader * crop deconvolution image shader * resolve spirv binding types * image fp16 and fp16a, cast image shader * eltwise image shader * wip * absval image shader * deconvolutiondepthwise image shader * concat image shader, squeezenet works * noop split image shader * uniform precision hint * layer support_image_storage * wip * vulkan device utility operator * command is storage and packing option aware * fallback to cpu on image allocation failed, mobilenetssd works * flatten image shader, enable more test * ci test * check imgfp32 imgfp16 imgfp16a features * fix ci test * fix ci test * upgrade swiftshader * wip * opt aggressive * imgfp16p * opt none * convolution winograd image shader * fix flush range, fast copy path for continous buffer * minor fix * fix innerproduct * wip ... * wip * cast fix * packing test * wip * image fp16p is fp16p * wip * silence * more line info * code clean * softmax image shader
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #include "layer/packing.h"
  15. #include "testutil.h"
  16. static int test_packing_cpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  17. {
  18. ncnn::ParamDict pd;
  19. pd.set(0, out_elempack);
  20. std::vector<ncnn::Mat> weights(0);
  21. ncnn::Option opt;
  22. opt.num_threads = 1;
  23. opt.use_vulkan_compute = false;
  24. opt.use_int8_inference = false;
  25. opt.use_packing_layout = false;
  26. ncnn::Layer* op = ncnn::create_layer("Packing");
  27. op->load_param(pd);
  28. ncnn::ModelBinFromMatArray mb(weights.data());
  29. op->load_model(mb);
  30. op->create_pipeline(opt);
  31. ncnn::Mat ap;
  32. ncnn::convert_packing(a, ap, in_elempack);
  33. ncnn::Mat b;
  34. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  35. ncnn::Mat c;
  36. op->forward(ap, c, opt);
  37. op->destroy_pipeline(opt);
  38. delete op;
  39. if (CompareMat(b, c, 0.001) != 0)
  40. {
  41. fprintf(stderr, "test_packing_cpu failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  42. return -1;
  43. }
  44. return 0;
  45. }
  46. #if NCNN_VULKAN
  47. #include "layer/vulkan/packing_vulkan.h"
  48. static int test_packing_gpu_buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  49. {
  50. ncnn::ParamDict pd;
  51. pd.set(0, out_elempack);
  52. pd.set(2, 1); // cast_type_from
  53. pd.set(3, 1); // cast_type_to
  54. pd.set(4, 0); // storage_type_from
  55. pd.set(5, 0); // storage_type_to
  56. std::vector<ncnn::Mat> weights(0);
  57. ncnn::Option opt;
  58. opt.num_threads = 1;
  59. opt.use_vulkan_compute = true;
  60. opt.use_int8_inference = false;
  61. opt.use_fp16_packed = false;
  62. opt.use_fp16_storage = false;
  63. opt.use_fp16_arithmetic = false;
  64. opt.use_int8_storage = false;
  65. opt.use_int8_arithmetic = false;
  66. opt.use_packing_layout = true;
  67. opt.use_shader_pack8 = true;
  68. opt.use_image_storage = false;
  69. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  70. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  71. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  72. opt.blob_vkallocator = blob_vkallocator;
  73. opt.workspace_vkallocator = blob_vkallocator;
  74. opt.staging_vkallocator = staging_vkallocator;
  75. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  76. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  77. ncnn::Layer* op = ncnn::create_layer("Packing");
  78. op->vkdev = vkdev;
  79. op->load_param(pd);
  80. ncnn::ModelBinFromMatArray mb(weights.data());
  81. op->load_model(mb);
  82. op->create_pipeline(opt);
  83. ncnn::Mat ap;
  84. ncnn::convert_packing(a, ap, in_elempack);
  85. ncnn::Mat b;
  86. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  87. ncnn::Mat d;
  88. // forward
  89. ncnn::VkCompute cmd(vkdev);
  90. // upload
  91. ncnn::VkMat a_gpu;
  92. cmd.record_clone(ap, a_gpu, opt);
  93. ncnn::VkMat d_gpu;
  94. op->forward(a_gpu, d_gpu, cmd, opt);
  95. // download
  96. cmd.record_clone(d_gpu, d, opt);
  97. cmd.submit_and_wait();
  98. op->destroy_pipeline(opt);
  99. delete op;
  100. vkdev->reclaim_blob_allocator(blob_vkallocator);
  101. vkdev->reclaim_staging_allocator(staging_vkallocator);
  102. if (CompareMat(b, d, 0.001) != 0)
  103. {
  104. fprintf(stderr, "test_packing_gpu_buffer failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  105. return -1;
  106. }
  107. return 0;
  108. }
  109. static int test_packing_gpu_image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  110. {
  111. ncnn::ParamDict pd;
  112. pd.set(0, out_elempack);
  113. pd.set(2, 1); // cast_type_from
  114. pd.set(3, 1); // cast_type_to
  115. pd.set(4, 1); // storage_type_from
  116. pd.set(5, 1); // storage_type_to
  117. std::vector<ncnn::Mat> weights(0);
  118. ncnn::Option opt;
  119. opt.num_threads = 1;
  120. opt.use_vulkan_compute = true;
  121. opt.use_int8_inference = false;
  122. opt.use_fp16_packed = false;
  123. opt.use_fp16_storage = false;
  124. opt.use_fp16_arithmetic = false;
  125. opt.use_int8_storage = false;
  126. opt.use_int8_arithmetic = false;
  127. opt.use_packing_layout = true;
  128. opt.use_shader_pack8 = true;
  129. opt.use_image_storage = true;
  130. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  131. if (vkdev->info.bug_layout_binding_id_alias)
  132. return 0;
  133. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  134. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  135. opt.blob_vkallocator = blob_vkallocator;
  136. opt.workspace_vkallocator = blob_vkallocator;
  137. opt.staging_vkallocator = staging_vkallocator;
  138. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  139. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  140. ncnn::Layer* op = ncnn::create_layer("Packing");
  141. op->vkdev = vkdev;
  142. op->load_param(pd);
  143. ncnn::ModelBinFromMatArray mb(weights.data());
  144. op->load_model(mb);
  145. op->create_pipeline(opt);
  146. ncnn::Mat ap;
  147. ncnn::convert_packing(a, ap, in_elempack);
  148. ncnn::Mat b;
  149. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  150. ncnn::Mat d;
  151. // forward
  152. ncnn::VkCompute cmd(vkdev);
  153. // upload
  154. ncnn::VkImageMat a_gpu;
  155. cmd.record_clone(ap, a_gpu, opt);
  156. ncnn::VkImageMat d_gpu;
  157. op->forward(a_gpu, d_gpu, cmd, opt);
  158. // download
  159. cmd.record_clone(d_gpu, d, opt);
  160. cmd.submit_and_wait();
  161. op->destroy_pipeline(opt);
  162. delete op;
  163. vkdev->reclaim_blob_allocator(blob_vkallocator);
  164. vkdev->reclaim_staging_allocator(staging_vkallocator);
  165. if (CompareMat(b, d, 0.001) != 0)
  166. {
  167. fprintf(stderr, "test_packing_gpu_image failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  168. return -1;
  169. }
  170. return 0;
  171. }
  172. static int test_packing_gpu_buffer2image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  173. {
  174. ncnn::ParamDict pd;
  175. pd.set(0, out_elempack);
  176. pd.set(2, 1); // cast_type_from
  177. pd.set(3, 1); // cast_type_to
  178. pd.set(4, 0); // storage_type_from
  179. pd.set(5, 1); // storage_type_to
  180. std::vector<ncnn::Mat> weights(0);
  181. ncnn::Option opt;
  182. opt.num_threads = 1;
  183. opt.use_vulkan_compute = true;
  184. opt.use_int8_inference = false;
  185. opt.use_fp16_packed = false;
  186. opt.use_fp16_storage = false;
  187. opt.use_fp16_arithmetic = false;
  188. opt.use_int8_storage = false;
  189. opt.use_int8_arithmetic = false;
  190. opt.use_packing_layout = true;
  191. opt.use_shader_pack8 = true;
  192. opt.use_image_storage = true;
  193. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  194. if (vkdev->info.bug_layout_binding_id_alias)
  195. return 0;
  196. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  197. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  198. opt.blob_vkallocator = blob_vkallocator;
  199. opt.workspace_vkallocator = blob_vkallocator;
  200. opt.staging_vkallocator = staging_vkallocator;
  201. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  202. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  203. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  204. op->vkdev = vkdev;
  205. op->load_param(pd);
  206. ncnn::ModelBinFromMatArray mb(weights.data());
  207. op->load_model(mb);
  208. op->create_pipeline(opt);
  209. ncnn::Mat ap;
  210. ncnn::convert_packing(a, ap, in_elempack);
  211. ncnn::Mat b;
  212. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  213. ncnn::Mat d;
  214. // forward
  215. ncnn::VkCompute cmd(vkdev);
  216. // upload
  217. ncnn::VkMat a_gpu;
  218. cmd.record_clone(ap, a_gpu, opt);
  219. ncnn::VkImageMat d_gpu;
  220. op->forward(a_gpu, d_gpu, cmd, opt);
  221. // download
  222. cmd.record_clone(d_gpu, d, opt);
  223. cmd.submit_and_wait();
  224. op->destroy_pipeline(opt);
  225. delete op;
  226. vkdev->reclaim_blob_allocator(blob_vkallocator);
  227. vkdev->reclaim_staging_allocator(staging_vkallocator);
  228. if (CompareMat(b, d, 0.001) != 0)
  229. {
  230. fprintf(stderr, "test_packing_gpu_buffer2image failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  231. return -1;
  232. }
  233. return 0;
  234. }
  235. static int test_packing_gpu_image2buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  236. {
  237. ncnn::ParamDict pd;
  238. pd.set(0, out_elempack);
  239. pd.set(2, 1); // cast_type_from
  240. pd.set(3, 1); // cast_type_to
  241. pd.set(4, 1); // storage_type_from
  242. pd.set(5, 0); // storage_type_to
  243. std::vector<ncnn::Mat> weights(0);
  244. ncnn::Option opt;
  245. opt.num_threads = 1;
  246. opt.use_vulkan_compute = true;
  247. opt.use_int8_inference = false;
  248. opt.use_fp16_packed = false;
  249. opt.use_fp16_storage = false;
  250. opt.use_fp16_arithmetic = false;
  251. opt.use_int8_storage = false;
  252. opt.use_int8_arithmetic = false;
  253. opt.use_packing_layout = true;
  254. opt.use_shader_pack8 = true;
  255. opt.use_image_storage = true;
  256. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  257. if (vkdev->info.bug_layout_binding_id_alias)
  258. return 0;
  259. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  260. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  261. opt.blob_vkallocator = blob_vkallocator;
  262. opt.workspace_vkallocator = blob_vkallocator;
  263. opt.staging_vkallocator = staging_vkallocator;
  264. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  265. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  266. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  267. op->vkdev = vkdev;
  268. op->load_param(pd);
  269. ncnn::ModelBinFromMatArray mb(weights.data());
  270. op->load_model(mb);
  271. op->create_pipeline(opt);
  272. ncnn::Mat ap;
  273. ncnn::convert_packing(a, ap, in_elempack);
  274. ncnn::Mat b;
  275. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  276. ncnn::Mat d;
  277. // forward
  278. ncnn::VkCompute cmd(vkdev);
  279. // upload
  280. ncnn::VkImageMat a_gpu;
  281. cmd.record_clone(ap, a_gpu, opt);
  282. ncnn::VkMat d_gpu;
  283. op->forward(a_gpu, d_gpu, cmd, opt);
  284. // download
  285. cmd.record_clone(d_gpu, d, opt);
  286. cmd.submit_and_wait();
  287. op->destroy_pipeline(opt);
  288. delete op;
  289. vkdev->reclaim_blob_allocator(blob_vkallocator);
  290. vkdev->reclaim_staging_allocator(staging_vkallocator);
  291. if (CompareMat(b, d, 0.001) != 0)
  292. {
  293. fprintf(stderr, "test_packing_gpu_image2buffer failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  294. return -1;
  295. }
  296. return 0;
  297. }
  298. #endif
  299. static int test_packing_0()
  300. {
  301. ncnn::Mat a = RandomMat(9, 10, 16);
  302. ncnn::Mat b = RandomMat(9, 10, 3);
  303. return 0
  304. || test_packing_cpu(a, 1, 1)
  305. || test_packing_cpu(a, 4, 4)
  306. || test_packing_cpu(a, 4, 8)
  307. || test_packing_cpu(a, 1, 4)
  308. || test_packing_cpu(a, 4, 1)
  309. || test_packing_cpu(a, 1, 8)
  310. || test_packing_cpu(a, 8, 1)
  311. || test_packing_cpu(a, 4, 8)
  312. || test_packing_cpu(a, 8, 4)
  313. || test_packing_cpu(b, 1, 1)
  314. || test_packing_cpu(b, 4, 4)
  315. || test_packing_cpu(b, 4, 8)
  316. || test_packing_cpu(b, 1, 4)
  317. || test_packing_cpu(b, 4, 1)
  318. || test_packing_cpu(b, 1, 8)
  319. || test_packing_cpu(b, 8, 1)
  320. || test_packing_cpu(b, 4, 8)
  321. || test_packing_cpu(b, 8, 4)
  322. #if NCNN_VULKAN
  323. || test_packing_gpu_buffer(a, 1, 1)
  324. || test_packing_gpu_buffer(a, 4, 4)
  325. || test_packing_gpu_buffer(a, 8, 8)
  326. || test_packing_gpu_buffer(a, 1, 4)
  327. || test_packing_gpu_buffer(a, 4, 1)
  328. || test_packing_gpu_buffer(a, 1, 8)
  329. || test_packing_gpu_buffer(a, 8, 1)
  330. || test_packing_gpu_buffer(a, 4, 8)
  331. || test_packing_gpu_buffer(a, 8, 4)
  332. || test_packing_gpu_image(a, 1, 1)
  333. || test_packing_gpu_image(a, 4, 4)
  334. || test_packing_gpu_image(a, 8, 8)
  335. || test_packing_gpu_image(a, 1, 4)
  336. || test_packing_gpu_image(a, 4, 1)
  337. || test_packing_gpu_image(a, 1, 8)
  338. || test_packing_gpu_image(a, 8, 1)
  339. || test_packing_gpu_image(a, 4, 8)
  340. || test_packing_gpu_image(a, 8, 4)
  341. || test_packing_gpu_buffer2image(a, 1, 1)
  342. || test_packing_gpu_buffer2image(a, 4, 4)
  343. || test_packing_gpu_buffer2image(a, 8, 8)
  344. || test_packing_gpu_buffer2image(a, 1, 4)
  345. || test_packing_gpu_buffer2image(a, 4, 1)
  346. || test_packing_gpu_buffer2image(a, 1, 8)
  347. || test_packing_gpu_buffer2image(a, 8, 1)
  348. || test_packing_gpu_buffer2image(a, 4, 8)
  349. || test_packing_gpu_buffer2image(a, 8, 4)
  350. || test_packing_gpu_image2buffer(a, 1, 1)
  351. || test_packing_gpu_image2buffer(a, 4, 4)
  352. || test_packing_gpu_image2buffer(a, 8, 8)
  353. || test_packing_gpu_image2buffer(a, 1, 4)
  354. || test_packing_gpu_image2buffer(a, 4, 1)
  355. || test_packing_gpu_image2buffer(a, 1, 8)
  356. || test_packing_gpu_image2buffer(a, 8, 1)
  357. || test_packing_gpu_image2buffer(a, 4, 8)
  358. || test_packing_gpu_image2buffer(a, 8, 4)
  359. #endif // NCNN_VULKAN
  360. ;
  361. }
  362. static int test_packing_1()
  363. {
  364. ncnn::Mat a = RandomMat(9, 16);
  365. return 0
  366. || test_packing_cpu(a, 1, 1)
  367. || test_packing_cpu(a, 4, 4)
  368. || test_packing_cpu(a, 4, 8)
  369. || test_packing_cpu(a, 1, 4)
  370. || test_packing_cpu(a, 4, 1)
  371. || test_packing_cpu(a, 1, 8)
  372. || test_packing_cpu(a, 8, 1)
  373. || test_packing_cpu(a, 4, 8)
  374. || test_packing_cpu(a, 8, 4)
  375. #if NCNN_VULKAN
  376. || test_packing_gpu_buffer(a, 1, 1)
  377. || test_packing_gpu_buffer(a, 4, 4)
  378. || test_packing_gpu_buffer(a, 8, 8)
  379. || test_packing_gpu_buffer(a, 1, 4)
  380. || test_packing_gpu_buffer(a, 4, 1)
  381. || test_packing_gpu_buffer(a, 1, 8)
  382. || test_packing_gpu_buffer(a, 8, 1)
  383. || test_packing_gpu_buffer(a, 4, 8)
  384. || test_packing_gpu_buffer(a, 8, 4)
  385. || test_packing_gpu_image(a, 1, 1)
  386. || test_packing_gpu_image(a, 4, 4)
  387. || test_packing_gpu_image(a, 8, 8)
  388. || test_packing_gpu_image(a, 1, 4)
  389. || test_packing_gpu_image(a, 4, 1)
  390. || test_packing_gpu_image(a, 1, 8)
  391. || test_packing_gpu_image(a, 8, 1)
  392. || test_packing_gpu_image(a, 4, 8)
  393. || test_packing_gpu_image(a, 8, 4)
  394. || test_packing_gpu_buffer2image(a, 1, 1)
  395. || test_packing_gpu_buffer2image(a, 4, 4)
  396. || test_packing_gpu_buffer2image(a, 8, 8)
  397. || test_packing_gpu_buffer2image(a, 1, 4)
  398. || test_packing_gpu_buffer2image(a, 4, 1)
  399. || test_packing_gpu_buffer2image(a, 1, 8)
  400. || test_packing_gpu_buffer2image(a, 8, 1)
  401. || test_packing_gpu_buffer2image(a, 4, 8)
  402. || test_packing_gpu_buffer2image(a, 8, 4)
  403. || test_packing_gpu_image2buffer(a, 1, 1)
  404. || test_packing_gpu_image2buffer(a, 4, 4)
  405. || test_packing_gpu_image2buffer(a, 8, 8)
  406. || test_packing_gpu_image2buffer(a, 1, 4)
  407. || test_packing_gpu_image2buffer(a, 4, 1)
  408. || test_packing_gpu_image2buffer(a, 1, 8)
  409. || test_packing_gpu_image2buffer(a, 8, 1)
  410. || test_packing_gpu_image2buffer(a, 4, 8)
  411. || test_packing_gpu_image2buffer(a, 8, 4)
  412. #endif // NCNN_VULKAN
  413. ;
  414. }
  415. static int test_packing_2()
  416. {
  417. ncnn::Mat a = RandomMat(40);
  418. return 0
  419. || test_packing_cpu(a, 1, 1)
  420. || test_packing_cpu(a, 4, 4)
  421. || test_packing_cpu(a, 4, 8)
  422. || test_packing_cpu(a, 1, 4)
  423. || test_packing_cpu(a, 4, 1)
  424. || test_packing_cpu(a, 1, 8)
  425. || test_packing_cpu(a, 8, 1)
  426. || test_packing_cpu(a, 4, 8)
  427. || test_packing_cpu(a, 8, 4)
  428. #if NCNN_VULKAN
  429. || test_packing_gpu_buffer(a, 1, 1)
  430. || test_packing_gpu_buffer(a, 4, 4)
  431. || test_packing_gpu_buffer(a, 8, 8)
  432. || test_packing_gpu_buffer(a, 1, 4)
  433. || test_packing_gpu_buffer(a, 4, 1)
  434. || test_packing_gpu_buffer(a, 1, 8)
  435. || test_packing_gpu_buffer(a, 8, 1)
  436. || test_packing_gpu_buffer(a, 4, 8)
  437. || test_packing_gpu_buffer(a, 8, 4)
  438. || test_packing_gpu_image(a, 1, 1)
  439. || test_packing_gpu_image(a, 4, 4)
  440. || test_packing_gpu_image(a, 8, 8)
  441. || test_packing_gpu_image(a, 1, 4)
  442. || test_packing_gpu_image(a, 4, 1)
  443. || test_packing_gpu_image(a, 1, 8)
  444. || test_packing_gpu_image(a, 8, 1)
  445. || test_packing_gpu_image(a, 4, 8)
  446. || test_packing_gpu_image(a, 8, 4)
  447. || test_packing_gpu_buffer2image(a, 1, 1)
  448. || test_packing_gpu_buffer2image(a, 4, 4)
  449. || test_packing_gpu_buffer2image(a, 8, 8)
  450. || test_packing_gpu_buffer2image(a, 1, 4)
  451. || test_packing_gpu_buffer2image(a, 4, 1)
  452. || test_packing_gpu_buffer2image(a, 1, 8)
  453. || test_packing_gpu_buffer2image(a, 8, 1)
  454. || test_packing_gpu_buffer2image(a, 4, 8)
  455. || test_packing_gpu_buffer2image(a, 8, 4)
  456. || test_packing_gpu_image2buffer(a, 1, 1)
  457. || test_packing_gpu_image2buffer(a, 4, 4)
  458. || test_packing_gpu_image2buffer(a, 8, 8)
  459. || test_packing_gpu_image2buffer(a, 1, 4)
  460. || test_packing_gpu_image2buffer(a, 4, 1)
  461. || test_packing_gpu_image2buffer(a, 1, 8)
  462. || test_packing_gpu_image2buffer(a, 8, 1)
  463. || test_packing_gpu_image2buffer(a, 4, 8)
  464. || test_packing_gpu_image2buffer(a, 8, 4)
  465. #endif // NCNN_VULKAN
  466. ;
  467. }
  468. int main()
  469. {
  470. SRAND(7767517);
  471. return 0
  472. || test_packing_0()
  473. || test_packing_1()
  474. || test_packing_2();
  475. }