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 12 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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. // Copyright 2020 Tencent
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int packing_cpu_naive(const ncnn::Mat& a, ncnn::Mat& b, int out_elempack)
  5. {
  6. ncnn::ParamDict pd;
  7. pd.set(0, out_elempack);
  8. std::vector<ncnn::Mat> weights(0);
  9. ncnn::Option opt;
  10. opt.num_threads = 1;
  11. ncnn::Layer* op = ncnn::create_layer_naive("Packing");
  12. op->load_param(pd);
  13. ncnn::ModelBinFromMatArray mb(weights.data());
  14. op->load_model(mb);
  15. op->create_pipeline(opt);
  16. op->forward(a, b, opt);
  17. op->destroy_pipeline(opt);
  18. delete op;
  19. return 0;
  20. }
  21. static int test_packing_cpu_fp32(const ncnn::Mat& a, int in_elempack, int out_elempack)
  22. {
  23. ncnn::ParamDict pd;
  24. pd.set(0, out_elempack);
  25. std::vector<ncnn::Mat> weights(0);
  26. ncnn::Option opt;
  27. opt.num_threads = 1;
  28. opt.use_vulkan_compute = false;
  29. opt.use_int8_inference = false;
  30. opt.use_fp16_storage = false;
  31. opt.use_fp16_arithmetic = false;
  32. opt.use_packing_layout = false;
  33. ncnn::Layer* op = ncnn::create_layer_cpu("Packing");
  34. op->load_param(pd);
  35. ncnn::ModelBinFromMatArray mb(weights.data());
  36. op->load_model(mb);
  37. op->create_pipeline(opt);
  38. ncnn::Mat ap;
  39. ncnn::convert_packing(a, ap, in_elempack, opt);
  40. ncnn::Mat b;
  41. packing_cpu_naive(ap, b, out_elempack);
  42. ncnn::Mat c;
  43. op->forward(ap, c, opt);
  44. op->destroy_pipeline(opt);
  45. delete op;
  46. if (CompareMat(b, c, 0.001) != 0)
  47. {
  48. fprintf(stderr, "test_packing_cpu_fp32 failed a.dims=%d a=(%d %d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.d, a.c, in_elempack, out_elempack);
  49. return -1;
  50. }
  51. return 0;
  52. }
  53. static int test_packing_cpu_fp16(const ncnn::Mat& a, int in_elempack, int out_elempack)
  54. {
  55. ncnn::ParamDict pd;
  56. pd.set(0, out_elempack);
  57. std::vector<ncnn::Mat> weights(0);
  58. ncnn::Option opt;
  59. opt.num_threads = 1;
  60. opt.use_vulkan_compute = false;
  61. opt.use_int8_inference = false;
  62. opt.use_fp16_storage = true;
  63. opt.use_fp16_arithmetic = true;
  64. opt.use_packing_layout = false;
  65. ncnn::Layer* op = ncnn::create_layer_cpu("Packing");
  66. if (!op->support_fp16_storage)
  67. {
  68. delete op;
  69. return 0;
  70. }
  71. op->load_param(pd);
  72. ncnn::ModelBinFromMatArray mb(weights.data());
  73. op->load_model(mb);
  74. op->create_pipeline(opt);
  75. ncnn::Mat a16;
  76. ncnn::cast_float32_to_float16(a, a16, opt);
  77. ncnn::Mat ap;
  78. ncnn::convert_packing(a16, ap, in_elempack, opt);
  79. ncnn::Mat b;
  80. packing_cpu_naive(ap, b, out_elempack);
  81. ncnn::Mat c;
  82. op->forward(ap, c, opt);
  83. op->destroy_pipeline(opt);
  84. delete op;
  85. ncnn::Mat c32;
  86. ncnn::cast_float16_to_float32(c, c32, opt);
  87. if (CompareMat(b, c32, 0.001) != 0)
  88. {
  89. fprintf(stderr, "test_packing_cpu_fp16 failed a.dims=%d a=(%d %d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.d, a.c, in_elempack, out_elempack);
  90. return -1;
  91. }
  92. return 0;
  93. }
  94. static int test_packing_cpu_int8(const ncnn::Mat& a, int in_elempack, int out_elempack)
  95. {
  96. ncnn::ParamDict pd;
  97. pd.set(0, out_elempack);
  98. std::vector<ncnn::Mat> weights(0);
  99. ncnn::Option opt;
  100. opt.num_threads = 1;
  101. opt.use_vulkan_compute = false;
  102. opt.use_int8_inference = false;
  103. opt.use_fp16_storage = false;
  104. opt.use_fp16_arithmetic = false;
  105. opt.use_packing_layout = false;
  106. ncnn::Layer* op = ncnn::create_layer_cpu("Packing");
  107. op->load_param(pd);
  108. ncnn::ModelBinFromMatArray mb(weights.data());
  109. op->load_model(mb);
  110. op->create_pipeline(opt);
  111. ncnn::Mat a8;
  112. if (a.dims == 1) a8 = RandomS8Mat(a.w);
  113. if (a.dims == 2) a8 = RandomS8Mat(a.w, a.h);
  114. if (a.dims == 3) a8 = RandomS8Mat(a.w, a.h, a.c);
  115. if (a.dims == 4) a8 = RandomS8Mat(a.w, a.h, a.d, a.c);
  116. ncnn::Mat ap;
  117. ncnn::convert_packing(a8, ap, in_elempack, opt);
  118. ncnn::Mat b;
  119. packing_cpu_naive(ap, b, out_elempack);
  120. ncnn::Mat c;
  121. op->forward(ap, c, opt);
  122. op->destroy_pipeline(opt);
  123. delete op;
  124. ncnn::Mat b32;
  125. ncnn::cast_int8_to_float32(b, b32, opt);
  126. ncnn::Mat c32;
  127. ncnn::cast_int8_to_float32(c, c32, opt);
  128. if (CompareMat(b32, c32, 0.001) != 0)
  129. {
  130. fprintf(stderr, "test_packing_cpu_int8 failed a.dims=%d a=(%d %d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.d, a.c, in_elempack, out_elempack);
  131. return -1;
  132. }
  133. return 0;
  134. }
  135. static int test_packing_cpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  136. {
  137. return 0
  138. || test_packing_cpu_fp32(a, in_elempack, out_elempack)
  139. || test_packing_cpu_fp16(a, in_elempack, out_elempack)
  140. || test_packing_cpu_int8(a, in_elempack, out_elempack);
  141. }
  142. #if NCNN_VULKAN
  143. static int test_packing_gpu_fp32(const ncnn::Mat& a, int in_elempack, int out_elempack)
  144. {
  145. ncnn::ParamDict pd;
  146. pd.set(0, out_elempack);
  147. pd.set(2, 1); // cast_type_from
  148. pd.set(3, 1); // cast_type_to
  149. std::vector<ncnn::Mat> weights(0);
  150. ncnn::Option opt;
  151. opt.num_threads = 1;
  152. opt.use_vulkan_compute = true;
  153. opt.use_int8_inference = false;
  154. opt.use_fp16_packed = false;
  155. opt.use_fp16_storage = false;
  156. opt.use_fp16_arithmetic = false;
  157. opt.use_int8_storage = false;
  158. opt.use_int8_arithmetic = false;
  159. opt.use_packing_layout = true;
  160. opt.use_shader_pack8 = true;
  161. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  162. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  163. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  164. opt.blob_vkallocator = blob_vkallocator;
  165. opt.workspace_vkallocator = blob_vkallocator;
  166. opt.staging_vkallocator = staging_vkallocator;
  167. if (!vkdev->info.support_fp16_packed()) opt.use_fp16_packed = false;
  168. if (!vkdev->info.support_fp16_storage()) opt.use_fp16_storage = false;
  169. ncnn::Layer* op = ncnn::create_layer_vulkan("Packing");
  170. op->vkdev = vkdev;
  171. op->load_param(pd);
  172. ncnn::ModelBinFromMatArray mb(weights.data());
  173. op->load_model(mb);
  174. op->create_pipeline(opt);
  175. ncnn::Mat ap;
  176. ncnn::convert_packing(a, ap, in_elempack, opt);
  177. ncnn::Mat b;
  178. packing_cpu_naive(ap, b, out_elempack);
  179. ncnn::Mat d;
  180. // forward
  181. ncnn::VkCompute cmd(vkdev);
  182. // upload
  183. ncnn::VkMat a_gpu;
  184. cmd.record_clone(ap, a_gpu, opt);
  185. ncnn::VkMat d_gpu;
  186. op->forward(a_gpu, d_gpu, cmd, opt);
  187. // download
  188. cmd.record_clone(d_gpu, d, opt);
  189. cmd.submit_and_wait();
  190. op->destroy_pipeline(opt);
  191. delete op;
  192. vkdev->reclaim_blob_allocator(blob_vkallocator);
  193. vkdev->reclaim_staging_allocator(staging_vkallocator);
  194. if (CompareMat(b, d, 0.001) != 0)
  195. {
  196. fprintf(stderr, "test_packing_gpu failed a.dims=%d a=(%d %d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.d, a.c, in_elempack, out_elempack);
  197. return -1;
  198. }
  199. return 0;
  200. }
  201. static int test_packing_gpu_int8(const ncnn::Mat& a, int in_elempack, int out_elempack)
  202. {
  203. ncnn::ParamDict pd;
  204. pd.set(0, out_elempack);
  205. pd.set(2, 4); // cast_type_from
  206. pd.set(3, 4); // cast_type_to
  207. std::vector<ncnn::Mat> weights(0);
  208. ncnn::Option opt;
  209. opt.num_threads = 1;
  210. opt.use_vulkan_compute = true;
  211. opt.use_int8_inference = false;
  212. opt.use_fp16_packed = false;
  213. opt.use_fp16_storage = false;
  214. opt.use_fp16_arithmetic = false;
  215. opt.use_int8_storage = false;
  216. opt.use_int8_arithmetic = false;
  217. opt.use_packing_layout = true;
  218. opt.use_shader_pack8 = true;
  219. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  220. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  221. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  222. opt.blob_vkallocator = blob_vkallocator;
  223. opt.workspace_vkallocator = blob_vkallocator;
  224. opt.staging_vkallocator = staging_vkallocator;
  225. if (!vkdev->info.support_int8_packed()) opt.use_int8_packed = false;
  226. if (!vkdev->info.support_int8_storage()) opt.use_int8_storage = false;
  227. ncnn::Layer* op = ncnn::create_layer_vulkan("Packing");
  228. op->vkdev = vkdev;
  229. op->load_param(pd);
  230. ncnn::ModelBinFromMatArray mb(weights.data());
  231. op->load_model(mb);
  232. op->create_pipeline(opt);
  233. ncnn::Mat a8;
  234. if (a.dims == 1) a8 = RandomS8Mat(a.w);
  235. if (a.dims == 2) a8 = RandomS8Mat(a.w, a.h);
  236. if (a.dims == 3) a8 = RandomS8Mat(a.w, a.h, a.c);
  237. if (a.dims == 4) a8 = RandomS8Mat(a.w, a.h, a.d, a.c);
  238. ncnn::Mat ap;
  239. ncnn::convert_packing(a8, ap, in_elempack, opt);
  240. ncnn::Mat b;
  241. packing_cpu_naive(ap, b, out_elempack);
  242. ncnn::Mat c;
  243. // forward
  244. ncnn::VkCompute cmd(vkdev);
  245. // upload
  246. ncnn::VkMat a_gpu;
  247. cmd.record_clone(ap, a_gpu, opt);
  248. ncnn::VkMat c_gpu;
  249. op->forward(a_gpu, c_gpu, cmd, opt);
  250. // download
  251. cmd.record_clone(c_gpu, c, opt);
  252. cmd.submit_and_wait();
  253. op->destroy_pipeline(opt);
  254. delete op;
  255. ncnn::Mat b32;
  256. ncnn::cast_int8_to_float32(b, b32, opt);
  257. ncnn::Mat c32;
  258. ncnn::cast_int8_to_float32(c, c32, opt);
  259. if (CompareMat(b32, c32, 0.001) != 0)
  260. {
  261. fprintf(stderr, "test_packing_gpu_int8 failed a.dims=%d a=(%d %d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.d, a.c, in_elempack, out_elempack);
  262. return -1;
  263. }
  264. return 0;
  265. }
  266. static int test_packing_gpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  267. {
  268. return 0
  269. || test_packing_gpu_fp32(a, in_elempack, out_elempack)
  270. || test_packing_gpu_int8(a, in_elempack, out_elempack);
  271. }
  272. #endif
  273. static int test_packing_cpu(const ncnn::Mat& a)
  274. {
  275. return 0
  276. || test_packing_cpu(a, 1, 1)
  277. || test_packing_cpu(a, 4, 4)
  278. || test_packing_cpu(a, 4, 8)
  279. || test_packing_cpu(a, 1, 4)
  280. || test_packing_cpu(a, 4, 1)
  281. || test_packing_cpu(a, 1, 8)
  282. || test_packing_cpu(a, 8, 1)
  283. || test_packing_cpu(a, 4, 8)
  284. || test_packing_cpu(a, 8, 4)
  285. || test_packing_cpu(a, 1, 16)
  286. || test_packing_cpu(a, 16, 1)
  287. || test_packing_cpu(a, 4, 16)
  288. || test_packing_cpu(a, 16, 4)
  289. || test_packing_cpu(a, 8, 16)
  290. || test_packing_cpu(a, 16, 8);
  291. }
  292. #if NCNN_VULKAN
  293. static int test_packing_gpu(const ncnn::Mat& a)
  294. {
  295. return 0
  296. || test_packing_gpu(a, 1, 1)
  297. || test_packing_gpu(a, 4, 4)
  298. || test_packing_gpu(a, 8, 8)
  299. || test_packing_gpu(a, 1, 4)
  300. || test_packing_gpu(a, 4, 1)
  301. || test_packing_gpu(a, 1, 8)
  302. || test_packing_gpu(a, 8, 1)
  303. || test_packing_gpu(a, 4, 8)
  304. || test_packing_gpu(a, 8, 4);
  305. }
  306. #endif // NCNN_VULKAN
  307. static int test_packing_0()
  308. {
  309. ncnn::Mat a = RandomMat(9, 7, 10, 16);
  310. ncnn::Mat b = RandomMat(9, 7, 10, 3);
  311. return 0
  312. || test_packing_cpu(a)
  313. || test_packing_cpu(b)
  314. #if NCNN_VULKAN
  315. || test_packing_gpu(a)
  316. #endif
  317. ;
  318. }
  319. static int test_packing_1()
  320. {
  321. ncnn::Mat a = RandomMat(9, 10, 16);
  322. ncnn::Mat b = RandomMat(9, 10, 3);
  323. return 0
  324. || test_packing_cpu(a)
  325. || test_packing_cpu(b)
  326. #if NCNN_VULKAN
  327. || test_packing_gpu(a)
  328. #endif
  329. ;
  330. }
  331. static int test_packing_2()
  332. {
  333. ncnn::Mat a = RandomMat(19, 16);
  334. return 0
  335. || test_packing_cpu(a)
  336. #if NCNN_VULKAN
  337. || test_packing_gpu(a)
  338. #endif
  339. ;
  340. }
  341. static int test_packing_3()
  342. {
  343. ncnn::Mat a = RandomMat(80);
  344. return 0
  345. || test_packing_cpu(a)
  346. #if NCNN_VULKAN
  347. || test_packing_gpu(a)
  348. #endif
  349. ;
  350. }
  351. int main()
  352. {
  353. SRAND(7767517);
  354. return 0
  355. || test_packing_0()
  356. || test_packing_1()
  357. || test_packing_2()
  358. || test_packing_3();
  359. }