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 26 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
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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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_fp32(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_fp16_storage = false;
  26. opt.use_fp16_arithmetic = false;
  27. opt.use_packing_layout = false;
  28. ncnn::Layer* op = ncnn::create_layer("Packing");
  29. op->load_param(pd);
  30. ncnn::ModelBinFromMatArray mb(weights.data());
  31. op->load_model(mb);
  32. op->create_pipeline(opt);
  33. ncnn::Mat ap;
  34. ncnn::convert_packing(a, ap, in_elempack, opt);
  35. ncnn::Mat b;
  36. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  37. ncnn::Mat c;
  38. op->forward(ap, c, opt);
  39. op->destroy_pipeline(opt);
  40. delete op;
  41. if (CompareMat(b, c, 0.001) != 0)
  42. {
  43. 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);
  44. return -1;
  45. }
  46. return 0;
  47. }
  48. static int test_packing_cpu_fp16(const ncnn::Mat& a, int in_elempack, int out_elempack)
  49. {
  50. ncnn::ParamDict pd;
  51. pd.set(0, out_elempack);
  52. std::vector<ncnn::Mat> weights(0);
  53. ncnn::Option opt;
  54. opt.num_threads = 1;
  55. opt.use_vulkan_compute = false;
  56. opt.use_int8_inference = false;
  57. opt.use_fp16_storage = true;
  58. opt.use_fp16_arithmetic = true;
  59. opt.use_packing_layout = false;
  60. ncnn::Layer* op = ncnn::create_layer("Packing");
  61. if (!op->support_fp16_storage)
  62. {
  63. delete op;
  64. return 0;
  65. }
  66. op->load_param(pd);
  67. ncnn::ModelBinFromMatArray mb(weights.data());
  68. op->load_model(mb);
  69. op->create_pipeline(opt);
  70. ncnn::Mat a16;
  71. ncnn::cast_float32_to_float16(a, a16, opt);
  72. ncnn::Mat ap;
  73. ncnn::convert_packing(a16, ap, in_elempack, opt);
  74. ncnn::Mat b;
  75. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  76. ncnn::Mat c;
  77. op->forward(ap, c, opt);
  78. op->destroy_pipeline(opt);
  79. delete op;
  80. ncnn::Mat c32;
  81. ncnn::cast_float16_to_float32(c, c32, opt);
  82. if (CompareMat(b, c32, 0.001) != 0)
  83. {
  84. 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);
  85. return -1;
  86. }
  87. return 0;
  88. }
  89. static int test_packing_cpu_int8(const ncnn::Mat& a, int in_elempack, int out_elempack)
  90. {
  91. ncnn::ParamDict pd;
  92. pd.set(0, out_elempack);
  93. std::vector<ncnn::Mat> weights(0);
  94. ncnn::Option opt;
  95. opt.num_threads = 1;
  96. opt.use_vulkan_compute = false;
  97. opt.use_int8_inference = false;
  98. opt.use_fp16_storage = false;
  99. opt.use_fp16_arithmetic = false;
  100. opt.use_packing_layout = false;
  101. ncnn::Layer* op = ncnn::create_layer("Packing");
  102. op->load_param(pd);
  103. ncnn::ModelBinFromMatArray mb(weights.data());
  104. op->load_model(mb);
  105. op->create_pipeline(opt);
  106. ncnn::Mat a8;
  107. if (a.dims == 1) a8 = RandomS8Mat(a.w);
  108. if (a.dims == 2) a8 = RandomS8Mat(a.w, a.h);
  109. if (a.dims == 3) a8 = RandomS8Mat(a.w, a.h, a.c);
  110. if (a.dims == 4) a8 = RandomS8Mat(a.w, a.h, a.d, a.c);
  111. ncnn::Mat ap;
  112. ncnn::convert_packing(a8, ap, in_elempack, opt);
  113. ncnn::Mat b;
  114. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  115. ncnn::Mat c;
  116. op->forward(ap, c, opt);
  117. op->destroy_pipeline(opt);
  118. delete op;
  119. ncnn::Mat b32;
  120. ncnn::cast_int8_to_float32(b, b32, opt);
  121. ncnn::Mat c32;
  122. ncnn::cast_int8_to_float32(c, c32, opt);
  123. if (CompareMat(b32, c32, 0.001) != 0)
  124. {
  125. 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);
  126. return -1;
  127. }
  128. return 0;
  129. }
  130. static int test_packing_cpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  131. {
  132. return 0
  133. || test_packing_cpu_fp32(a, in_elempack, out_elempack)
  134. || test_packing_cpu_fp16(a, in_elempack, out_elempack)
  135. || test_packing_cpu_int8(a, in_elempack, out_elempack);
  136. }
  137. #if NCNN_VULKAN
  138. #include "layer/vulkan/packing_vulkan.h"
  139. static int test_packing_gpu_buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  140. {
  141. ncnn::ParamDict pd;
  142. pd.set(0, out_elempack);
  143. pd.set(2, 1); // cast_type_from
  144. pd.set(3, 1); // cast_type_to
  145. pd.set(4, 0); // storage_type_from
  146. pd.set(5, 0); // storage_type_to
  147. std::vector<ncnn::Mat> weights(0);
  148. ncnn::Option opt;
  149. opt.num_threads = 1;
  150. opt.use_vulkan_compute = true;
  151. opt.use_int8_inference = false;
  152. opt.use_fp16_packed = false;
  153. opt.use_fp16_storage = false;
  154. opt.use_fp16_arithmetic = false;
  155. opt.use_int8_storage = false;
  156. opt.use_int8_arithmetic = false;
  157. opt.use_packing_layout = true;
  158. opt.use_shader_pack8 = true;
  159. opt.use_image_storage = false;
  160. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  161. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  162. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  163. opt.blob_vkallocator = blob_vkallocator;
  164. opt.workspace_vkallocator = blob_vkallocator;
  165. opt.staging_vkallocator = staging_vkallocator;
  166. if (!vkdev->info.support_fp16_packed()) opt.use_fp16_packed = false;
  167. if (!vkdev->info.support_fp16_storage()) opt.use_fp16_storage = false;
  168. ncnn::Layer* op = ncnn::create_layer("Packing");
  169. op->vkdev = vkdev;
  170. op->load_param(pd);
  171. ncnn::ModelBinFromMatArray mb(weights.data());
  172. op->load_model(mb);
  173. op->create_pipeline(opt);
  174. ncnn::Mat ap;
  175. ncnn::convert_packing(a, ap, in_elempack, opt);
  176. ncnn::Mat b;
  177. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  178. ncnn::Mat d;
  179. // forward
  180. ncnn::VkCompute cmd(vkdev);
  181. // upload
  182. ncnn::VkMat a_gpu;
  183. cmd.record_clone(ap, a_gpu, opt);
  184. ncnn::VkMat d_gpu;
  185. op->forward(a_gpu, d_gpu, cmd, opt);
  186. // download
  187. cmd.record_clone(d_gpu, d, opt);
  188. cmd.submit_and_wait();
  189. op->destroy_pipeline(opt);
  190. delete op;
  191. vkdev->reclaim_blob_allocator(blob_vkallocator);
  192. vkdev->reclaim_staging_allocator(staging_vkallocator);
  193. if (CompareMat(b, d, 0.001) != 0)
  194. {
  195. fprintf(stderr, "test_packing_gpu_buffer 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);
  196. return -1;
  197. }
  198. return 0;
  199. }
  200. static int test_packing_gpu_image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  201. {
  202. ncnn::ParamDict pd;
  203. pd.set(0, out_elempack);
  204. pd.set(2, 1); // cast_type_from
  205. pd.set(3, 1); // cast_type_to
  206. pd.set(4, 1); // storage_type_from
  207. pd.set(5, 1); // storage_type_to
  208. std::vector<ncnn::Mat> weights(0);
  209. ncnn::Option opt;
  210. opt.num_threads = 1;
  211. opt.use_vulkan_compute = true;
  212. opt.use_int8_inference = false;
  213. opt.use_fp16_packed = false;
  214. opt.use_fp16_storage = false;
  215. opt.use_fp16_arithmetic = false;
  216. opt.use_int8_storage = false;
  217. opt.use_int8_arithmetic = false;
  218. opt.use_packing_layout = true;
  219. opt.use_shader_pack8 = true;
  220. opt.use_image_storage = true;
  221. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  222. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  223. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  224. opt.blob_vkallocator = blob_vkallocator;
  225. opt.workspace_vkallocator = blob_vkallocator;
  226. opt.staging_vkallocator = staging_vkallocator;
  227. if (!vkdev->info.support_fp16_packed()) opt.use_fp16_packed = false;
  228. if (!vkdev->info.support_fp16_storage()) opt.use_fp16_storage = false;
  229. ncnn::Layer* op = ncnn::create_layer("Packing");
  230. op->vkdev = vkdev;
  231. op->load_param(pd);
  232. ncnn::ModelBinFromMatArray mb(weights.data());
  233. op->load_model(mb);
  234. op->create_pipeline(opt);
  235. ncnn::Mat ap;
  236. ncnn::convert_packing(a, ap, in_elempack, opt);
  237. ncnn::Mat b;
  238. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  239. ncnn::Mat d;
  240. // forward
  241. ncnn::VkCompute cmd(vkdev);
  242. // upload
  243. ncnn::VkImageMat a_gpu;
  244. cmd.record_clone(ap, a_gpu, opt);
  245. ncnn::VkImageMat d_gpu;
  246. op->forward(a_gpu, d_gpu, cmd, opt);
  247. // download
  248. cmd.record_clone(d_gpu, d, opt);
  249. cmd.submit_and_wait();
  250. op->destroy_pipeline(opt);
  251. delete op;
  252. vkdev->reclaim_blob_allocator(blob_vkallocator);
  253. vkdev->reclaim_staging_allocator(staging_vkallocator);
  254. if (CompareMat(b, d, 0.001) != 0)
  255. {
  256. fprintf(stderr, "test_packing_gpu_image 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);
  257. return -1;
  258. }
  259. return 0;
  260. }
  261. static int test_packing_gpu_buffer2image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  262. {
  263. ncnn::ParamDict pd;
  264. pd.set(0, out_elempack);
  265. pd.set(2, 1); // cast_type_from
  266. pd.set(3, 1); // cast_type_to
  267. pd.set(4, 0); // storage_type_from
  268. pd.set(5, 1); // storage_type_to
  269. std::vector<ncnn::Mat> weights(0);
  270. ncnn::Option opt;
  271. opt.num_threads = 1;
  272. opt.use_vulkan_compute = true;
  273. opt.use_int8_inference = false;
  274. opt.use_fp16_packed = false;
  275. opt.use_fp16_storage = false;
  276. opt.use_fp16_arithmetic = false;
  277. opt.use_int8_storage = false;
  278. opt.use_int8_arithmetic = false;
  279. opt.use_packing_layout = true;
  280. opt.use_shader_pack8 = true;
  281. opt.use_image_storage = true;
  282. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  283. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  284. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  285. opt.blob_vkallocator = blob_vkallocator;
  286. opt.workspace_vkallocator = blob_vkallocator;
  287. opt.staging_vkallocator = staging_vkallocator;
  288. if (!vkdev->info.support_fp16_packed()) opt.use_fp16_packed = false;
  289. if (!vkdev->info.support_fp16_storage()) opt.use_fp16_storage = false;
  290. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  291. op->vkdev = vkdev;
  292. op->load_param(pd);
  293. ncnn::ModelBinFromMatArray mb(weights.data());
  294. op->load_model(mb);
  295. op->create_pipeline(opt);
  296. ncnn::Mat ap;
  297. ncnn::convert_packing(a, ap, in_elempack, opt);
  298. ncnn::Mat b;
  299. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  300. ncnn::Mat d;
  301. // forward
  302. ncnn::VkCompute cmd(vkdev);
  303. // upload
  304. ncnn::VkMat a_gpu;
  305. cmd.record_clone(ap, a_gpu, opt);
  306. ncnn::VkImageMat d_gpu;
  307. op->forward(a_gpu, d_gpu, cmd, opt);
  308. // download
  309. cmd.record_clone(d_gpu, d, opt);
  310. cmd.submit_and_wait();
  311. op->destroy_pipeline(opt);
  312. delete op;
  313. vkdev->reclaim_blob_allocator(blob_vkallocator);
  314. vkdev->reclaim_staging_allocator(staging_vkallocator);
  315. if (CompareMat(b, d, 0.001) != 0)
  316. {
  317. fprintf(stderr, "test_packing_gpu_buffer2image 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);
  318. return -1;
  319. }
  320. return 0;
  321. }
  322. static int test_packing_gpu_image2buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  323. {
  324. ncnn::ParamDict pd;
  325. pd.set(0, out_elempack);
  326. pd.set(2, 1); // cast_type_from
  327. pd.set(3, 1); // cast_type_to
  328. pd.set(4, 1); // storage_type_from
  329. pd.set(5, 0); // storage_type_to
  330. std::vector<ncnn::Mat> weights(0);
  331. ncnn::Option opt;
  332. opt.num_threads = 1;
  333. opt.use_vulkan_compute = true;
  334. opt.use_int8_inference = false;
  335. opt.use_fp16_packed = false;
  336. opt.use_fp16_storage = false;
  337. opt.use_fp16_arithmetic = false;
  338. opt.use_int8_storage = false;
  339. opt.use_int8_arithmetic = false;
  340. opt.use_packing_layout = true;
  341. opt.use_shader_pack8 = true;
  342. opt.use_image_storage = true;
  343. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  344. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  345. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  346. opt.blob_vkallocator = blob_vkallocator;
  347. opt.workspace_vkallocator = blob_vkallocator;
  348. opt.staging_vkallocator = staging_vkallocator;
  349. if (!vkdev->info.support_fp16_packed()) opt.use_fp16_packed = false;
  350. if (!vkdev->info.support_fp16_storage()) opt.use_fp16_storage = false;
  351. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  352. op->vkdev = vkdev;
  353. op->load_param(pd);
  354. ncnn::ModelBinFromMatArray mb(weights.data());
  355. op->load_model(mb);
  356. op->create_pipeline(opt);
  357. ncnn::Mat ap;
  358. ncnn::convert_packing(a, ap, in_elempack, opt);
  359. ncnn::Mat b;
  360. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  361. ncnn::Mat d;
  362. // forward
  363. ncnn::VkCompute cmd(vkdev);
  364. // upload
  365. ncnn::VkImageMat a_gpu;
  366. cmd.record_clone(ap, a_gpu, opt);
  367. ncnn::VkMat d_gpu;
  368. op->forward(a_gpu, d_gpu, cmd, opt);
  369. // download
  370. cmd.record_clone(d_gpu, d, opt);
  371. cmd.submit_and_wait();
  372. op->destroy_pipeline(opt);
  373. delete op;
  374. vkdev->reclaim_blob_allocator(blob_vkallocator);
  375. vkdev->reclaim_staging_allocator(staging_vkallocator);
  376. if (CompareMat(b, d, 0.001) != 0)
  377. {
  378. fprintf(stderr, "test_packing_gpu_image2buffer 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);
  379. return -1;
  380. }
  381. return 0;
  382. }
  383. #endif
  384. static int test_packing_0()
  385. {
  386. ncnn::Mat a = RandomMat(9, 7, 10, 16);
  387. ncnn::Mat b = RandomMat(9, 7, 10, 3);
  388. return 0
  389. || test_packing_cpu(a, 1, 1)
  390. || test_packing_cpu(a, 4, 4)
  391. || test_packing_cpu(a, 4, 8)
  392. || test_packing_cpu(a, 1, 4)
  393. || test_packing_cpu(a, 4, 1)
  394. || test_packing_cpu(a, 1, 8)
  395. || test_packing_cpu(a, 8, 1)
  396. || test_packing_cpu(a, 4, 8)
  397. || test_packing_cpu(a, 8, 4)
  398. || test_packing_cpu(a, 1, 16)
  399. || test_packing_cpu(a, 16, 1)
  400. || test_packing_cpu(a, 4, 16)
  401. || test_packing_cpu(a, 16, 4)
  402. || test_packing_cpu(a, 8, 16)
  403. || test_packing_cpu(a, 16, 8)
  404. || test_packing_cpu(b, 1, 1)
  405. || test_packing_cpu(b, 4, 4)
  406. || test_packing_cpu(b, 4, 8)
  407. || test_packing_cpu(b, 1, 4)
  408. || test_packing_cpu(b, 4, 1)
  409. || test_packing_cpu(b, 1, 8)
  410. || test_packing_cpu(b, 8, 1)
  411. || test_packing_cpu(b, 4, 8)
  412. || test_packing_cpu(b, 8, 4)
  413. || test_packing_cpu(b, 1, 16)
  414. || test_packing_cpu(b, 16, 1)
  415. || test_packing_cpu(b, 4, 16)
  416. || test_packing_cpu(b, 16, 4)
  417. || test_packing_cpu(b, 8, 16)
  418. || test_packing_cpu(b, 16, 8)
  419. #if NCNN_VULKAN
  420. || test_packing_gpu_buffer(a, 1, 1)
  421. || test_packing_gpu_buffer(a, 4, 4)
  422. || test_packing_gpu_buffer(a, 8, 8)
  423. || test_packing_gpu_buffer(a, 1, 4)
  424. || test_packing_gpu_buffer(a, 4, 1)
  425. || test_packing_gpu_buffer(a, 1, 8)
  426. || test_packing_gpu_buffer(a, 8, 1)
  427. || test_packing_gpu_buffer(a, 4, 8)
  428. || test_packing_gpu_buffer(a, 8, 4)
  429. || test_packing_gpu_image(a, 1, 1)
  430. || test_packing_gpu_image(a, 4, 4)
  431. || test_packing_gpu_image(a, 8, 8)
  432. || test_packing_gpu_image(a, 1, 4)
  433. || test_packing_gpu_image(a, 4, 1)
  434. || test_packing_gpu_image(a, 1, 8)
  435. || test_packing_gpu_image(a, 8, 1)
  436. || test_packing_gpu_image(a, 4, 8)
  437. || test_packing_gpu_image(a, 8, 4)
  438. || test_packing_gpu_buffer2image(a, 1, 1)
  439. || test_packing_gpu_buffer2image(a, 4, 4)
  440. || test_packing_gpu_buffer2image(a, 8, 8)
  441. || test_packing_gpu_buffer2image(a, 1, 4)
  442. || test_packing_gpu_buffer2image(a, 4, 1)
  443. || test_packing_gpu_buffer2image(a, 1, 8)
  444. || test_packing_gpu_buffer2image(a, 8, 1)
  445. || test_packing_gpu_buffer2image(a, 4, 8)
  446. || test_packing_gpu_buffer2image(a, 8, 4)
  447. || test_packing_gpu_image2buffer(a, 1, 1)
  448. || test_packing_gpu_image2buffer(a, 4, 4)
  449. || test_packing_gpu_image2buffer(a, 8, 8)
  450. || test_packing_gpu_image2buffer(a, 1, 4)
  451. || test_packing_gpu_image2buffer(a, 4, 1)
  452. || test_packing_gpu_image2buffer(a, 1, 8)
  453. || test_packing_gpu_image2buffer(a, 8, 1)
  454. || test_packing_gpu_image2buffer(a, 4, 8)
  455. || test_packing_gpu_image2buffer(a, 8, 4)
  456. #endif // NCNN_VULKAN
  457. ;
  458. }
  459. static int test_packing_1()
  460. {
  461. ncnn::Mat a = RandomMat(9, 10, 16);
  462. ncnn::Mat b = RandomMat(9, 10, 3);
  463. return 0
  464. || test_packing_cpu(a, 1, 1)
  465. || test_packing_cpu(a, 4, 4)
  466. || test_packing_cpu(a, 4, 8)
  467. || test_packing_cpu(a, 1, 4)
  468. || test_packing_cpu(a, 4, 1)
  469. || test_packing_cpu(a, 1, 8)
  470. || test_packing_cpu(a, 8, 1)
  471. || test_packing_cpu(a, 4, 8)
  472. || test_packing_cpu(a, 8, 4)
  473. || test_packing_cpu(a, 1, 16)
  474. || test_packing_cpu(a, 16, 1)
  475. || test_packing_cpu(a, 4, 16)
  476. || test_packing_cpu(a, 16, 4)
  477. || test_packing_cpu(a, 8, 16)
  478. || test_packing_cpu(a, 16, 8)
  479. || test_packing_cpu(b, 1, 1)
  480. || test_packing_cpu(b, 4, 4)
  481. || test_packing_cpu(b, 4, 8)
  482. || test_packing_cpu(b, 1, 4)
  483. || test_packing_cpu(b, 4, 1)
  484. || test_packing_cpu(b, 1, 8)
  485. || test_packing_cpu(b, 8, 1)
  486. || test_packing_cpu(b, 4, 8)
  487. || test_packing_cpu(b, 8, 4)
  488. || test_packing_cpu(b, 1, 16)
  489. || test_packing_cpu(b, 16, 1)
  490. || test_packing_cpu(b, 4, 16)
  491. || test_packing_cpu(b, 16, 4)
  492. || test_packing_cpu(b, 8, 16)
  493. || test_packing_cpu(b, 16, 8)
  494. #if NCNN_VULKAN
  495. || test_packing_gpu_buffer(a, 1, 1)
  496. || test_packing_gpu_buffer(a, 4, 4)
  497. || test_packing_gpu_buffer(a, 8, 8)
  498. || test_packing_gpu_buffer(a, 1, 4)
  499. || test_packing_gpu_buffer(a, 4, 1)
  500. || test_packing_gpu_buffer(a, 1, 8)
  501. || test_packing_gpu_buffer(a, 8, 1)
  502. || test_packing_gpu_buffer(a, 4, 8)
  503. || test_packing_gpu_buffer(a, 8, 4)
  504. || test_packing_gpu_image(a, 1, 1)
  505. || test_packing_gpu_image(a, 4, 4)
  506. || test_packing_gpu_image(a, 8, 8)
  507. || test_packing_gpu_image(a, 1, 4)
  508. || test_packing_gpu_image(a, 4, 1)
  509. || test_packing_gpu_image(a, 1, 8)
  510. || test_packing_gpu_image(a, 8, 1)
  511. || test_packing_gpu_image(a, 4, 8)
  512. || test_packing_gpu_image(a, 8, 4)
  513. || test_packing_gpu_buffer2image(a, 1, 1)
  514. || test_packing_gpu_buffer2image(a, 4, 4)
  515. || test_packing_gpu_buffer2image(a, 8, 8)
  516. || test_packing_gpu_buffer2image(a, 1, 4)
  517. || test_packing_gpu_buffer2image(a, 4, 1)
  518. || test_packing_gpu_buffer2image(a, 1, 8)
  519. || test_packing_gpu_buffer2image(a, 8, 1)
  520. || test_packing_gpu_buffer2image(a, 4, 8)
  521. || test_packing_gpu_buffer2image(a, 8, 4)
  522. || test_packing_gpu_image2buffer(a, 1, 1)
  523. || test_packing_gpu_image2buffer(a, 4, 4)
  524. || test_packing_gpu_image2buffer(a, 8, 8)
  525. || test_packing_gpu_image2buffer(a, 1, 4)
  526. || test_packing_gpu_image2buffer(a, 4, 1)
  527. || test_packing_gpu_image2buffer(a, 1, 8)
  528. || test_packing_gpu_image2buffer(a, 8, 1)
  529. || test_packing_gpu_image2buffer(a, 4, 8)
  530. || test_packing_gpu_image2buffer(a, 8, 4)
  531. #endif // NCNN_VULKAN
  532. ;
  533. }
  534. static int test_packing_2()
  535. {
  536. ncnn::Mat a = RandomMat(19, 16);
  537. return 0
  538. || test_packing_cpu(a, 1, 1)
  539. || test_packing_cpu(a, 4, 4)
  540. || test_packing_cpu(a, 4, 8)
  541. || test_packing_cpu(a, 1, 4)
  542. || test_packing_cpu(a, 4, 1)
  543. || test_packing_cpu(a, 1, 8)
  544. || test_packing_cpu(a, 8, 1)
  545. || test_packing_cpu(a, 4, 8)
  546. || test_packing_cpu(a, 8, 4)
  547. || test_packing_cpu(a, 1, 16)
  548. || test_packing_cpu(a, 16, 1)
  549. || test_packing_cpu(a, 4, 16)
  550. || test_packing_cpu(a, 16, 4)
  551. || test_packing_cpu(a, 8, 16)
  552. || test_packing_cpu(a, 16, 8)
  553. #if NCNN_VULKAN
  554. || test_packing_gpu_buffer(a, 1, 1)
  555. || test_packing_gpu_buffer(a, 4, 4)
  556. || test_packing_gpu_buffer(a, 8, 8)
  557. || test_packing_gpu_buffer(a, 1, 4)
  558. || test_packing_gpu_buffer(a, 4, 1)
  559. || test_packing_gpu_buffer(a, 1, 8)
  560. || test_packing_gpu_buffer(a, 8, 1)
  561. || test_packing_gpu_buffer(a, 4, 8)
  562. || test_packing_gpu_buffer(a, 8, 4)
  563. || test_packing_gpu_image(a, 1, 1)
  564. || test_packing_gpu_image(a, 4, 4)
  565. || test_packing_gpu_image(a, 8, 8)
  566. || test_packing_gpu_image(a, 1, 4)
  567. || test_packing_gpu_image(a, 4, 1)
  568. || test_packing_gpu_image(a, 1, 8)
  569. || test_packing_gpu_image(a, 8, 1)
  570. || test_packing_gpu_image(a, 4, 8)
  571. || test_packing_gpu_image(a, 8, 4)
  572. || test_packing_gpu_buffer2image(a, 1, 1)
  573. || test_packing_gpu_buffer2image(a, 4, 4)
  574. || test_packing_gpu_buffer2image(a, 8, 8)
  575. || test_packing_gpu_buffer2image(a, 1, 4)
  576. || test_packing_gpu_buffer2image(a, 4, 1)
  577. || test_packing_gpu_buffer2image(a, 1, 8)
  578. || test_packing_gpu_buffer2image(a, 8, 1)
  579. || test_packing_gpu_buffer2image(a, 4, 8)
  580. || test_packing_gpu_buffer2image(a, 8, 4)
  581. || test_packing_gpu_image2buffer(a, 1, 1)
  582. || test_packing_gpu_image2buffer(a, 4, 4)
  583. || test_packing_gpu_image2buffer(a, 8, 8)
  584. || test_packing_gpu_image2buffer(a, 1, 4)
  585. || test_packing_gpu_image2buffer(a, 4, 1)
  586. || test_packing_gpu_image2buffer(a, 1, 8)
  587. || test_packing_gpu_image2buffer(a, 8, 1)
  588. || test_packing_gpu_image2buffer(a, 4, 8)
  589. || test_packing_gpu_image2buffer(a, 8, 4)
  590. #endif // NCNN_VULKAN
  591. ;
  592. }
  593. static int test_packing_3()
  594. {
  595. ncnn::Mat a = RandomMat(80);
  596. return 0
  597. || test_packing_cpu(a, 1, 1)
  598. || test_packing_cpu(a, 4, 4)
  599. || test_packing_cpu(a, 4, 8)
  600. || test_packing_cpu(a, 1, 4)
  601. || test_packing_cpu(a, 4, 1)
  602. || test_packing_cpu(a, 1, 8)
  603. || test_packing_cpu(a, 8, 1)
  604. || test_packing_cpu(a, 4, 8)
  605. || test_packing_cpu(a, 8, 4)
  606. || test_packing_cpu(a, 1, 16)
  607. || test_packing_cpu(a, 16, 1)
  608. || test_packing_cpu(a, 4, 16)
  609. || test_packing_cpu(a, 16, 4)
  610. || test_packing_cpu(a, 8, 16)
  611. || test_packing_cpu(a, 16, 8)
  612. #if NCNN_VULKAN
  613. || test_packing_gpu_buffer(a, 1, 1)
  614. || test_packing_gpu_buffer(a, 4, 4)
  615. || test_packing_gpu_buffer(a, 8, 8)
  616. || test_packing_gpu_buffer(a, 1, 4)
  617. || test_packing_gpu_buffer(a, 4, 1)
  618. || test_packing_gpu_buffer(a, 1, 8)
  619. || test_packing_gpu_buffer(a, 8, 1)
  620. || test_packing_gpu_buffer(a, 4, 8)
  621. || test_packing_gpu_buffer(a, 8, 4)
  622. || test_packing_gpu_image(a, 1, 1)
  623. || test_packing_gpu_image(a, 4, 4)
  624. || test_packing_gpu_image(a, 8, 8)
  625. || test_packing_gpu_image(a, 1, 4)
  626. || test_packing_gpu_image(a, 4, 1)
  627. || test_packing_gpu_image(a, 1, 8)
  628. || test_packing_gpu_image(a, 8, 1)
  629. || test_packing_gpu_image(a, 4, 8)
  630. || test_packing_gpu_image(a, 8, 4)
  631. || test_packing_gpu_buffer2image(a, 1, 1)
  632. || test_packing_gpu_buffer2image(a, 4, 4)
  633. || test_packing_gpu_buffer2image(a, 8, 8)
  634. || test_packing_gpu_buffer2image(a, 1, 4)
  635. || test_packing_gpu_buffer2image(a, 4, 1)
  636. || test_packing_gpu_buffer2image(a, 1, 8)
  637. || test_packing_gpu_buffer2image(a, 8, 1)
  638. || test_packing_gpu_buffer2image(a, 4, 8)
  639. || test_packing_gpu_buffer2image(a, 8, 4)
  640. || test_packing_gpu_image2buffer(a, 1, 1)
  641. || test_packing_gpu_image2buffer(a, 4, 4)
  642. || test_packing_gpu_image2buffer(a, 8, 8)
  643. || test_packing_gpu_image2buffer(a, 1, 4)
  644. || test_packing_gpu_image2buffer(a, 4, 1)
  645. || test_packing_gpu_image2buffer(a, 1, 8)
  646. || test_packing_gpu_image2buffer(a, 8, 1)
  647. || test_packing_gpu_image2buffer(a, 4, 8)
  648. || test_packing_gpu_image2buffer(a, 8, 4)
  649. #endif // NCNN_VULKAN
  650. ;
  651. }
  652. int main()
  653. {
  654. SRAND(7767517);
  655. return 0
  656. || test_packing_0()
  657. || test_packing_1()
  658. || test_packing_2()
  659. || test_packing_3();
  660. }