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 18 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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 "testutil.h"
  15. #include "layer/packing.h"
  16. static int test_packing_cpu(const ncnn::Mat& a, int in_elempack, int out_elempack)
  17. {
  18. ncnn::ParamDict pd;
  19. pd.set(0, out_elempack);
  20. std::vector<ncnn::Mat> weights(0);
  21. ncnn::Option opt;
  22. opt.num_threads = 1;
  23. opt.use_vulkan_compute = false;
  24. opt.use_int8_inference = false;
  25. opt.use_packing_layout = false;
  26. ncnn::Layer* op = ncnn::create_layer("Packing");
  27. op->load_param(pd);
  28. ncnn::ModelBinFromMatArray mb(weights.data());
  29. op->load_model(mb);
  30. op->create_pipeline(opt);
  31. ncnn::Mat ap;
  32. ncnn::convert_packing(a, ap, in_elempack);
  33. ncnn::Mat b;
  34. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  35. ncnn::Mat c;
  36. op->forward(ap, c, opt);
  37. op->destroy_pipeline(opt);
  38. delete op;
  39. if (CompareMat(b, c, 0.001) != 0)
  40. {
  41. fprintf(stderr, "test_packing_cpu failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  42. return -1;
  43. }
  44. return 0;
  45. }
  46. #if NCNN_VULKAN
  47. #include "layer/vulkan/packing_vulkan.h"
  48. static int test_packing_gpu_buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  49. {
  50. ncnn::ParamDict pd;
  51. pd.set(0, out_elempack);
  52. pd.set(2, 1);// cast_type_from
  53. pd.set(3, 1);// cast_type_to
  54. pd.set(4, 0);// storage_type_from
  55. pd.set(5, 0);// storage_type_to
  56. std::vector<ncnn::Mat> weights(0);
  57. ncnn::Option opt;
  58. opt.num_threads = 1;
  59. opt.use_vulkan_compute = true;
  60. opt.use_int8_inference = false;
  61. opt.use_fp16_packed = false;
  62. opt.use_fp16_storage = false;
  63. opt.use_fp16_arithmetic = false;
  64. opt.use_int8_storage = false;
  65. opt.use_int8_arithmetic = false;
  66. opt.use_packing_layout = true;
  67. opt.use_shader_pack8 = true;
  68. opt.use_image_storage = false;
  69. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  70. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  71. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  72. opt.blob_vkallocator = blob_vkallocator;
  73. opt.workspace_vkallocator = blob_vkallocator;
  74. opt.staging_vkallocator = staging_vkallocator;
  75. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  76. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  77. ncnn::Layer* op = ncnn::create_layer("Packing");
  78. op->vkdev = vkdev;
  79. op->load_param(pd);
  80. ncnn::ModelBinFromMatArray mb(weights.data());
  81. op->load_model(mb);
  82. op->create_pipeline(opt);
  83. ncnn::Mat ap;
  84. ncnn::convert_packing(a, ap, in_elempack);
  85. ncnn::Mat b;
  86. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  87. ncnn::Mat d;
  88. // forward
  89. ncnn::VkCompute cmd(vkdev);
  90. // upload
  91. ncnn::VkMat a_gpu;
  92. cmd.record_clone(ap, a_gpu, opt);
  93. ncnn::VkMat d_gpu;
  94. op->forward(a_gpu, d_gpu, cmd, opt);
  95. // download
  96. cmd.record_clone(d_gpu, d, opt);
  97. cmd.submit_and_wait();
  98. op->destroy_pipeline(opt);
  99. delete op;
  100. vkdev->reclaim_blob_allocator(blob_vkallocator);
  101. vkdev->reclaim_staging_allocator(staging_vkallocator);
  102. if (CompareMat(b, d, 0.001) != 0)
  103. {
  104. fprintf(stderr, "test_packing_gpu_buffer failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  105. return -1;
  106. }
  107. return 0;
  108. }
  109. static int test_packing_gpu_image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  110. {
  111. ncnn::ParamDict pd;
  112. pd.set(0, out_elempack);
  113. pd.set(2, 1);// cast_type_from
  114. pd.set(3, 1);// cast_type_to
  115. pd.set(4, 1);// storage_type_from
  116. pd.set(5, 1);// storage_type_to
  117. std::vector<ncnn::Mat> weights(0);
  118. ncnn::Option opt;
  119. opt.num_threads = 1;
  120. opt.use_vulkan_compute = true;
  121. opt.use_int8_inference = false;
  122. opt.use_fp16_packed = false;
  123. opt.use_fp16_storage = false;
  124. opt.use_fp16_arithmetic = false;
  125. opt.use_int8_storage = false;
  126. opt.use_int8_arithmetic = false;
  127. opt.use_packing_layout = true;
  128. opt.use_shader_pack8 = true;
  129. opt.use_image_storage = true;
  130. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  131. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  132. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  133. opt.blob_vkallocator = blob_vkallocator;
  134. opt.workspace_vkallocator = blob_vkallocator;
  135. opt.staging_vkallocator = staging_vkallocator;
  136. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  137. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  138. ncnn::Layer* op = ncnn::create_layer("Packing");
  139. op->vkdev = vkdev;
  140. op->load_param(pd);
  141. ncnn::ModelBinFromMatArray mb(weights.data());
  142. op->load_model(mb);
  143. op->create_pipeline(opt);
  144. ncnn::Mat ap;
  145. ncnn::convert_packing(a, ap, in_elempack);
  146. ncnn::Mat b;
  147. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  148. ncnn::Mat d;
  149. // forward
  150. ncnn::VkCompute cmd(vkdev);
  151. // upload
  152. ncnn::VkImageMat a_gpu;
  153. cmd.record_clone(ap, a_gpu, opt);
  154. ncnn::VkImageMat d_gpu;
  155. op->forward(a_gpu, d_gpu, cmd, opt);
  156. // download
  157. cmd.record_clone(d_gpu, d, opt);
  158. cmd.submit_and_wait();
  159. op->destroy_pipeline(opt);
  160. delete op;
  161. vkdev->reclaim_blob_allocator(blob_vkallocator);
  162. vkdev->reclaim_staging_allocator(staging_vkallocator);
  163. if (CompareMat(b, d, 0.001) != 0)
  164. {
  165. fprintf(stderr, "test_packing_gpu_image failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  166. return -1;
  167. }
  168. return 0;
  169. }
  170. static int test_packing_gpu_buffer2image(const ncnn::Mat& a, int in_elempack, int out_elempack)
  171. {
  172. ncnn::ParamDict pd;
  173. pd.set(0, out_elempack);
  174. pd.set(2, 1);// cast_type_from
  175. pd.set(3, 1);// cast_type_to
  176. pd.set(4, 0);// storage_type_from
  177. pd.set(5, 1);// storage_type_to
  178. std::vector<ncnn::Mat> weights(0);
  179. ncnn::Option opt;
  180. opt.num_threads = 1;
  181. opt.use_vulkan_compute = true;
  182. opt.use_int8_inference = false;
  183. opt.use_fp16_packed = false;
  184. opt.use_fp16_storage = false;
  185. opt.use_fp16_arithmetic = false;
  186. opt.use_int8_storage = false;
  187. opt.use_int8_arithmetic = false;
  188. opt.use_packing_layout = true;
  189. opt.use_shader_pack8 = true;
  190. opt.use_image_storage = true;
  191. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  192. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  193. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  194. opt.blob_vkallocator = blob_vkallocator;
  195. opt.workspace_vkallocator = blob_vkallocator;
  196. opt.staging_vkallocator = staging_vkallocator;
  197. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  198. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  199. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  200. op->vkdev = vkdev;
  201. op->load_param(pd);
  202. ncnn::ModelBinFromMatArray mb(weights.data());
  203. op->load_model(mb);
  204. op->create_pipeline(opt);
  205. ncnn::Mat ap;
  206. ncnn::convert_packing(a, ap, in_elempack);
  207. ncnn::Mat b;
  208. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  209. ncnn::Mat d;
  210. // forward
  211. ncnn::VkCompute cmd(vkdev);
  212. // upload
  213. ncnn::VkMat a_gpu;
  214. cmd.record_clone(ap, a_gpu, opt);
  215. ncnn::VkImageMat d_gpu;
  216. op->forward(a_gpu, d_gpu, cmd, opt);
  217. // download
  218. cmd.record_clone(d_gpu, d, opt);
  219. cmd.submit_and_wait();
  220. op->destroy_pipeline(opt);
  221. delete op;
  222. vkdev->reclaim_blob_allocator(blob_vkallocator);
  223. vkdev->reclaim_staging_allocator(staging_vkallocator);
  224. if (CompareMat(b, d, 0.001) != 0)
  225. {
  226. fprintf(stderr, "test_packing_gpu_buffer2image failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  227. return -1;
  228. }
  229. return 0;
  230. }
  231. static int test_packing_gpu_image2buffer(const ncnn::Mat& a, int in_elempack, int out_elempack)
  232. {
  233. ncnn::ParamDict pd;
  234. pd.set(0, out_elempack);
  235. pd.set(2, 1);// cast_type_from
  236. pd.set(3, 1);// cast_type_to
  237. pd.set(4, 1);// storage_type_from
  238. pd.set(5, 0);// storage_type_to
  239. std::vector<ncnn::Mat> weights(0);
  240. ncnn::Option opt;
  241. opt.num_threads = 1;
  242. opt.use_vulkan_compute = true;
  243. opt.use_int8_inference = false;
  244. opt.use_fp16_packed = false;
  245. opt.use_fp16_storage = false;
  246. opt.use_fp16_arithmetic = false;
  247. opt.use_int8_storage = false;
  248. opt.use_int8_arithmetic = false;
  249. opt.use_packing_layout = true;
  250. opt.use_shader_pack8 = true;
  251. opt.use_image_storage = true;
  252. ncnn::VulkanDevice* vkdev = ncnn::get_gpu_device();
  253. ncnn::VkAllocator* blob_vkallocator = vkdev->acquire_blob_allocator();
  254. ncnn::VkAllocator* staging_vkallocator = vkdev->acquire_staging_allocator();
  255. opt.blob_vkallocator = blob_vkallocator;
  256. opt.workspace_vkallocator = blob_vkallocator;
  257. opt.staging_vkallocator = staging_vkallocator;
  258. if (!vkdev->info.support_fp16_packed) opt.use_fp16_packed = false;
  259. if (!vkdev->info.support_fp16_storage) opt.use_fp16_storage = false;
  260. ncnn::Packing_vulkan* op = new ncnn::Packing_vulkan;
  261. op->vkdev = vkdev;
  262. op->load_param(pd);
  263. ncnn::ModelBinFromMatArray mb(weights.data());
  264. op->load_model(mb);
  265. op->create_pipeline(opt);
  266. ncnn::Mat ap;
  267. ncnn::convert_packing(a, ap, in_elempack);
  268. ncnn::Mat b;
  269. ((ncnn::Packing*)op)->ncnn::Packing::forward(ap, b, opt);
  270. ncnn::Mat d;
  271. // forward
  272. ncnn::VkCompute cmd(vkdev);
  273. // upload
  274. ncnn::VkImageMat a_gpu;
  275. cmd.record_clone(ap, a_gpu, opt);
  276. ncnn::VkMat d_gpu;
  277. op->forward(a_gpu, d_gpu, cmd, opt);
  278. // download
  279. cmd.record_clone(d_gpu, d, opt);
  280. cmd.submit_and_wait();
  281. op->destroy_pipeline(opt);
  282. delete op;
  283. vkdev->reclaim_blob_allocator(blob_vkallocator);
  284. vkdev->reclaim_staging_allocator(staging_vkallocator);
  285. if (CompareMat(b, d, 0.001) != 0)
  286. {
  287. fprintf(stderr, "test_packing_gpu_image2buffer failed a.dims=%d a=(%d %d %d) in_elempack=%d out_elempack=%d\n", a.dims, a.w, a.h, a.c, in_elempack, out_elempack);
  288. return -1;
  289. }
  290. return 0;
  291. }
  292. #endif
  293. static int test_packing_0()
  294. {
  295. ncnn::Mat a = RandomMat(3, 5, 16);
  296. return 0
  297. || test_packing_cpu(a, 1, 1)
  298. || test_packing_cpu(a, 4, 4)
  299. || test_packing_cpu(a, 4, 8)
  300. || test_packing_cpu(a, 1, 4)
  301. || test_packing_cpu(a, 4, 1)
  302. || test_packing_cpu(a, 1, 8)
  303. || test_packing_cpu(a, 8, 1)
  304. || test_packing_cpu(a, 4, 8)
  305. || test_packing_cpu(a, 8, 4)
  306. #if NCNN_VULKAN
  307. || test_packing_gpu_buffer(a, 1, 1)
  308. || test_packing_gpu_buffer(a, 4, 4)
  309. || test_packing_gpu_buffer(a, 8, 8)
  310. || test_packing_gpu_buffer(a, 1, 4)
  311. || test_packing_gpu_buffer(a, 4, 1)
  312. || test_packing_gpu_buffer(a, 1, 8)
  313. || test_packing_gpu_buffer(a, 8, 1)
  314. || test_packing_gpu_buffer(a, 4, 8)
  315. || test_packing_gpu_buffer(a, 8, 4)
  316. || test_packing_gpu_image(a, 1, 1)
  317. || test_packing_gpu_image(a, 4, 4)
  318. || test_packing_gpu_image(a, 8, 8)
  319. || test_packing_gpu_image(a, 1, 4)
  320. || test_packing_gpu_image(a, 4, 1)
  321. || test_packing_gpu_image(a, 1, 8)
  322. || test_packing_gpu_image(a, 8, 1)
  323. || test_packing_gpu_image(a, 4, 8)
  324. || test_packing_gpu_image(a, 8, 4)
  325. || test_packing_gpu_buffer2image(a, 1, 1)
  326. || test_packing_gpu_buffer2image(a, 4, 4)
  327. || test_packing_gpu_buffer2image(a, 8, 8)
  328. || test_packing_gpu_buffer2image(a, 1, 4)
  329. || test_packing_gpu_buffer2image(a, 4, 1)
  330. || test_packing_gpu_buffer2image(a, 1, 8)
  331. || test_packing_gpu_buffer2image(a, 8, 1)
  332. || test_packing_gpu_buffer2image(a, 4, 8)
  333. || test_packing_gpu_buffer2image(a, 8, 4)
  334. || test_packing_gpu_image2buffer(a, 1, 1)
  335. || test_packing_gpu_image2buffer(a, 4, 4)
  336. || test_packing_gpu_image2buffer(a, 8, 8)
  337. || test_packing_gpu_image2buffer(a, 1, 4)
  338. || test_packing_gpu_image2buffer(a, 4, 1)
  339. || test_packing_gpu_image2buffer(a, 1, 8)
  340. || test_packing_gpu_image2buffer(a, 8, 1)
  341. || test_packing_gpu_image2buffer(a, 4, 8)
  342. || test_packing_gpu_image2buffer(a, 8, 4)
  343. #endif // NCNN_VULKAN
  344. ;
  345. }
  346. static int test_packing_1()
  347. {
  348. ncnn::Mat a = RandomMat(3, 16);
  349. return 0
  350. || test_packing_cpu(a, 1, 1)
  351. || test_packing_cpu(a, 4, 4)
  352. || test_packing_cpu(a, 4, 8)
  353. || test_packing_cpu(a, 1, 4)
  354. || test_packing_cpu(a, 4, 1)
  355. || test_packing_cpu(a, 1, 8)
  356. || test_packing_cpu(a, 8, 1)
  357. || test_packing_cpu(a, 4, 8)
  358. || test_packing_cpu(a, 8, 4)
  359. #if NCNN_VULKAN
  360. || test_packing_gpu_buffer(a, 1, 1)
  361. || test_packing_gpu_buffer(a, 4, 4)
  362. || test_packing_gpu_buffer(a, 8, 8)
  363. || test_packing_gpu_buffer(a, 1, 4)
  364. || test_packing_gpu_buffer(a, 4, 1)
  365. || test_packing_gpu_buffer(a, 1, 8)
  366. || test_packing_gpu_buffer(a, 8, 1)
  367. || test_packing_gpu_buffer(a, 4, 8)
  368. || test_packing_gpu_buffer(a, 8, 4)
  369. || test_packing_gpu_image(a, 1, 1)
  370. || test_packing_gpu_image(a, 4, 4)
  371. || test_packing_gpu_image(a, 8, 8)
  372. || test_packing_gpu_image(a, 1, 4)
  373. || test_packing_gpu_image(a, 4, 1)
  374. || test_packing_gpu_image(a, 1, 8)
  375. || test_packing_gpu_image(a, 8, 1)
  376. || test_packing_gpu_image(a, 4, 8)
  377. || test_packing_gpu_image(a, 8, 4)
  378. || test_packing_gpu_buffer2image(a, 1, 1)
  379. || test_packing_gpu_buffer2image(a, 4, 4)
  380. || test_packing_gpu_buffer2image(a, 8, 8)
  381. || test_packing_gpu_buffer2image(a, 1, 4)
  382. || test_packing_gpu_buffer2image(a, 4, 1)
  383. || test_packing_gpu_buffer2image(a, 1, 8)
  384. || test_packing_gpu_buffer2image(a, 8, 1)
  385. || test_packing_gpu_buffer2image(a, 4, 8)
  386. || test_packing_gpu_buffer2image(a, 8, 4)
  387. || test_packing_gpu_image2buffer(a, 1, 1)
  388. || test_packing_gpu_image2buffer(a, 4, 4)
  389. || test_packing_gpu_image2buffer(a, 8, 8)
  390. || test_packing_gpu_image2buffer(a, 1, 4)
  391. || test_packing_gpu_image2buffer(a, 4, 1)
  392. || test_packing_gpu_image2buffer(a, 1, 8)
  393. || test_packing_gpu_image2buffer(a, 8, 1)
  394. || test_packing_gpu_image2buffer(a, 4, 8)
  395. || test_packing_gpu_image2buffer(a, 8, 4)
  396. #endif // NCNN_VULKAN
  397. ;
  398. }
  399. static int test_packing_2()
  400. {
  401. ncnn::Mat a = RandomMat(40);
  402. return 0
  403. || test_packing_cpu(a, 1, 1)
  404. || test_packing_cpu(a, 4, 4)
  405. || test_packing_cpu(a, 4, 8)
  406. || test_packing_cpu(a, 1, 4)
  407. || test_packing_cpu(a, 4, 1)
  408. || test_packing_cpu(a, 1, 8)
  409. || test_packing_cpu(a, 8, 1)
  410. || test_packing_cpu(a, 4, 8)
  411. || test_packing_cpu(a, 8, 4)
  412. #if NCNN_VULKAN
  413. || test_packing_gpu_buffer(a, 1, 1)
  414. || test_packing_gpu_buffer(a, 4, 4)
  415. || test_packing_gpu_buffer(a, 8, 8)
  416. || test_packing_gpu_buffer(a, 1, 4)
  417. || test_packing_gpu_buffer(a, 4, 1)
  418. || test_packing_gpu_buffer(a, 1, 8)
  419. || test_packing_gpu_buffer(a, 8, 1)
  420. || test_packing_gpu_buffer(a, 4, 8)
  421. || test_packing_gpu_buffer(a, 8, 4)
  422. || test_packing_gpu_image(a, 1, 1)
  423. || test_packing_gpu_image(a, 4, 4)
  424. || test_packing_gpu_image(a, 8, 8)
  425. || test_packing_gpu_image(a, 1, 4)
  426. || test_packing_gpu_image(a, 4, 1)
  427. || test_packing_gpu_image(a, 1, 8)
  428. || test_packing_gpu_image(a, 8, 1)
  429. || test_packing_gpu_image(a, 4, 8)
  430. || test_packing_gpu_image(a, 8, 4)
  431. || test_packing_gpu_buffer2image(a, 1, 1)
  432. || test_packing_gpu_buffer2image(a, 4, 4)
  433. || test_packing_gpu_buffer2image(a, 8, 8)
  434. || test_packing_gpu_buffer2image(a, 1, 4)
  435. || test_packing_gpu_buffer2image(a, 4, 1)
  436. || test_packing_gpu_buffer2image(a, 1, 8)
  437. || test_packing_gpu_buffer2image(a, 8, 1)
  438. || test_packing_gpu_buffer2image(a, 4, 8)
  439. || test_packing_gpu_buffer2image(a, 8, 4)
  440. || test_packing_gpu_image2buffer(a, 1, 1)
  441. || test_packing_gpu_image2buffer(a, 4, 4)
  442. || test_packing_gpu_image2buffer(a, 8, 8)
  443. || test_packing_gpu_image2buffer(a, 1, 4)
  444. || test_packing_gpu_image2buffer(a, 4, 1)
  445. || test_packing_gpu_image2buffer(a, 1, 8)
  446. || test_packing_gpu_image2buffer(a, 8, 1)
  447. || test_packing_gpu_image2buffer(a, 4, 8)
  448. || test_packing_gpu_image2buffer(a, 8, 4)
  449. #endif // NCNN_VULKAN
  450. ;
  451. }
  452. int main()
  453. {
  454. SRAND(7767517);
  455. return 0
  456. || test_packing_0()
  457. || test_packing_1()
  458. || test_packing_2()
  459. ;
  460. }