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