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