{"id":351259,"date":"2023-08-04T15:00:43","date_gmt":"2023-08-04T15:00:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=351259"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=351259","title":{"rendered":"<span>OnnxStream: \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/751912\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/fg\/e_\/ss\/fge_ssrs4sm9dfh1boluzidoy6q.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/fg\/e_\/ss\/fge_ssrs4sm9dfh1boluzidoy6q.jpeg\" data-blurred=\"true\"\/><\/div>\n<p><\/a><br \/>  \u0417\u0430\u0434\u0430\u0447\u0430 \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <a href=\"https:\/\/github.com\/CompVis\/stable-diffusion\">Stable Diffusion<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0443\u044e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c c \u043f\u043e\u0447\u0442\u0438 1 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430 <a href=\"https:\/\/www.raspberrypi.com\/products\/raspberry-pi-zero-2-w\/\">Raspberry Pi Zero 2<\/a> \u0441 512 \u041c\u0411 RAM, \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u043a\u0430\u0447\u043a\u0438 \u0438 \u043d\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u0434\u0438\u0441\u043a. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0451\u043c RAM\/VRAM \u0434\u043b\u044f Stable Diffusion \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 8 \u0413\u0411.<a name=\"habracut\"><\/a><\/p>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0432\u0441\u0451 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f RAM. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u0430\u0442\u044e\u0440\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438: OnnxStream.<\/p>\n<p>  OnnxStream \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0438\u0434\u0435\u0435 \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043e\u0442 <code>WeightsProvider<\/code>. <\/p>\n<p>  <code>WeightsProvider<\/code> \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0432\u0438\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 <code>WeightsProvider<\/code> \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 HTTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0438 \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043d\u0430 \u0434\u0438\u0441\u043a (\u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0441\u043b\u043e\u0432\u043e Stream \u0432 OnnxStream). \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u0432\u0430 <code>WeightsProvider<\/code>:<br \/>  <code>DiskNoCache<\/code> \u0438 <code>DiskPrefetch<\/code>.<\/p>\n<p>  OnnxStream \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0434\u0430\u0436\u0435 \u0432 55 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c OnnxRuntime, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0432\u0441\u0435\u0433\u043e \u0432 0,5-2 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 (\u043d\u0430 CPU, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b \u00ab\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u00bb \u043d\u0438\u0436\u0435).<\/p>\n<h2><font color=\"#3AC1EF\">\u258d Stable Diffusion<\/font><\/h2>\n<p>  \u042d\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Stable Diffusion, \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c \u0432 \u044d\u0442\u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c OnnxStream \u043f\u0440\u0438 \u0440\u0430\u0437\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 VAE. \u0414\u0435\u043a\u043e\u0434\u0435\u0440 VAE \u2014 \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c Stable Diffusion, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0432\u043c\u0435\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c Raspberry Pi Zero 2 \u043d\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0439, \u043d\u0438 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u0432 \u0438 \u0441\u0432\u0451\u0440\u0442\u043e\u043a. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435 (8 \u0431\u0438\u0442).<\/p>\n<p>  \u0422\u0440\u0435\u0442\u044c\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 RPI Zero 2 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0437\u0430 3 \u0447\u0430\u0441\u0430. \u041f\u0435\u0440\u0432\u043e\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u043d\u0430 \u043c\u043e\u0451\u043c \u041f\u041a \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0445 \u0436\u0435 \u043b\u0430\u0442\u0435\u043d\u0442\u043e\u0432 (latents), \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 RPI Zero 2:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/94\/rr\/gn\/94rrgnuq9t_qhllc6cyxo5dtj0c.png\" data-src=\"https:\/\/habrastorage.org\/webt\/94\/rr\/gn\/94rrgnuq9t_qhllc6cyxo5dtj0c.png\"\/><\/div>\n<p><i><font color=\"#999999\">\u0414\u0435\u043a\u043e\u0434\u0435\u0440 VAE \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e W16A16<\/font><\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/41\/ho\/3j\/41ho3jdi54rvj4kpb2goaa3rxdg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/41\/ho\/3j\/41ho3jdi54rvj4kpb2goaa3rxdg.png\"\/><\/div>\n<p><i><font color=\"#999999\">\u0414\u0435\u043a\u043e\u0434\u0435\u0440 VAE \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e W8A32<\/font><\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/z6\/jr\/v1\/z6jrv1i0hni232qvtlhbbbc607o.png\" data-src=\"https:\/\/habrastorage.org\/webt\/z6\/jr\/v1\/z6jrv1i0hni232qvtlhbbbc607o.png\"\/><\/div>\n<p><i><font color=\"#999999\">\u0414\u0435\u043a\u043e\u0434\u0435\u0440 VAE \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e W8A8 (\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e RPI Zero 2 \u0433\u0434\u0435-\u0442\u043e \u0437\u0430 3 \u0447\u0430\u0441\u0430)<\/font><\/i><\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 OnnxStream<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0442\u0434\u0435\u043b\u0451\u043d \u043e\u0442 <code>WeightsProvider<\/code>.<\/li>\n<li><code>WeightsProvider<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <code>DiskNoCache<\/code>, <code>DiskPrefetch<\/code> \u0438\u043b\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c.<\/li>\n<li>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f.<\/li>\n<li>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435 (8 \u0431\u0438\u0442 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430, \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435, \u043f\u043e \u043f\u0435\u0440\u0446\u0435\u043d\u0442\u0438\u043b\u044e).<\/li>\n<li>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435 (W8A8 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430, \u0430\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435, \u043f\u043e \u043f\u0435\u0440\u0446\u0435\u043d\u0442\u0438\u043b\u044e).<\/li>\n<li>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/li>\n<li>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 FP16 (\u0441 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u043e\u0439 FP16 \u0438\u043b\u0438 \u0431\u0435\u0437 \u043d\u0435\u0451).<\/li>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e 24 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 ONNX (\u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0435).<\/li>\n<li>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u043c\u0438.<\/li>\n<li>\u041e\u0434\u0438\u043d \u0444\u0430\u0439\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 + \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/li>\n<li>\u0412\u044b\u0437\u043e\u0432\u044b XNNPACK \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b \u0432 \u043a\u043b\u0430\u0441\u0441 <code>XnnPack<\/code> (\u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0437\u0430\u043c\u0435\u043d\u044b).<\/li>\n<\/ul>\n<p>  OnnxStream \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 XNNPACK \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 (\u0443\u0441\u043a\u043e\u0440\u0435\u043d\u043d\u044b\u0445) \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432: MatMul, Convolution, \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0435 Add\/Sub\/Mul\/Div, Sigmoid \u0438 Softmax.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/font><\/h2>\n<p>  Stable Diffusion \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439: \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 (672 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 123 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432), UNET (2050 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 854 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432) \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 VAE (276 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 49 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432). \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 \u0440\u0430\u0432\u0435\u043d 1, \u043f\u043e\u043b\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 10 \u0448\u0430\u0433\u043e\u0432, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 Euler Ancestral), \u0442\u0440\u0435\u0431\u0443\u0435\u0442 2 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0448\u0438\u0444\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, 20 (\u0442\u043e \u0435\u0441\u0442\u044c 2*10) \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 UNET \u0438 1 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 VAE.<\/p>\n<p>  \u042d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u0440\u0451\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Stable Diffusion \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c <code>Peak Working Set Size<\/code> \u0432 Windows \u0438\u043b\u0438 <code>Maximum Resident Set Size<\/code> \u0432 Linux).<\/p>\n<div class=\"scrollable-table\">\n<table>\n<tbody>\n<tr>\n<td>\u041c\u043e\u0434\u0435\u043b\u044c\/\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/td>\n<td>\u041f\u0435\u0440\u0432\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 <\/td>\n<td>\u0412\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/td>\n<td>\u0422\u0440\u0435\u0442\u044c\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/td>\n<\/tr>\n<tr>\n<td>FP16 UNET \/ OnnxStream<\/td>\n<td>0,133 \u0413\u0411 \u2014 18,2 \u0441\u0435\u043a<\/td>\n<td>0,133 \u0413\u0411 \u2014 18,7 \u0441\u0435\u043a<\/td>\n<td>0,133 \u0413\u0411 \u2014 19,8 \u0441\u0435\u043a<\/td>\n<\/tr>\n<tr>\n<td>FP16 UNET \/ OnnxRuntime<\/td>\n<td>5,085 \u0413\u0411 \u2014 12,8 \u0441\u0435\u043a<\/td>\n<td>7,353 \u0413\u0411 \u2014 7,28 \u0441\u0435\u043a<\/td>\n<td>7,353 \u0413\u0411 \u2014 7,96 \u0441\u0435\u043a<\/td>\n<\/tr>\n<tr>\n<td>FP32 Text Enc \/ OnnxStream<\/td>\n<td>0,147 \u0413\u0411 \u2014 1,26 \u0441\u0435\u043a<\/td>\n<td>0,147 \u0413\u0411 \u2014 1,19 \u0441\u0435\u043a<\/td>\n<td>0,147 \u0413\u0411 \u2014 1,19 \u0441\u0435\u043a<\/td>\n<\/tr>\n<tr>\n<td>FP32 Text Enc \/ OnnxRuntime<\/td>\n<td>0,641 \u0413\u0411 \u2014 1,02 \u0441\u0435\u043a<\/td>\n<td>0,641 \u0413\u0411 \u2014 0,06 \u0441\u0435\u043a<\/td>\n<td>0,641 \u0413\u0411 \u2014 0,07 \u0441\u0435\u043a<\/td>\n<\/tr>\n<tr>\n<td>FP32 VAE Dec \/ OnnxStream<\/td>\n<td>1,004 \u0413\u0411 \u2014 20,9 \u0441\u0435\u043a<\/td>\n<td>1,004 \u0413\u0411 \u2014 20,6 \u0441\u0435\u043a<\/td>\n<td>1,004 \u0413\u0411 \u2014 21,2 \u0441\u0435\u043a<\/td>\n<\/tr>\n<tr>\n<td>FP32 VAE Dec \/ OnnxRuntime<\/td>\n<td>1,330 \u0413\u0411 \u2014 11,2 \u0441\u0435\u043a<\/td>\n<td>2,026 \u0413\u0411 \u2014 10,1 \u0441\u0435\u043a<\/td>\n<td>2,026 \u0413\u0411 \u2014 11,1 \u0441\u0435\u043a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 UNET (\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e FP16 \u0441 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u043e\u0439 FP16) OnnxStream \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0434\u0430\u0436\u0435 \u0432 55 \u0440\u0430\u0437 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c OnnxRuntime, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0432 0,5-2 \u0440\u0430\u0437\u0430 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 OnnxRuntime \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0435\u0432\u043e\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0451 InferenceSession \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445. \u0414\u043b\u044f OnnxStream \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043a\u0430\u043a \u00ab\u0440\u0430\u0437\u043e\u0433\u0440\u0435\u0432\u00bb \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0433\u043e\u0442\u043e\u0432\u0435 (\u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u0435\u0441\u043e\u0432 \u0432 \u041e\u0421).<\/li>\n<li>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e OnnxStream \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0432\u043e\u0434 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0430 != 1 \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e OnnxRuntime \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 UNET \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0438\u0444\u0444\u0443\u0437\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 2.<\/li>\n<li>\u0412 \u043c\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 <code>SessionOptions<\/code> \u0432 OnnxRuntime (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>EnableCpuMemArena<\/code> \u0438 <code>ExecutionMode<\/code>) \u043d\u0435 \u0432\u0435\u0434\u0451\u0442 \u043a \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/li>\n<li>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c OnnxRuntime \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 NCNN (\u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a), \u043a\u0430\u043a \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0438 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0432\u043e\u0434\u0430.<\/li>\n<li>\u0422\u0435\u0441\u0442\u044b \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b \u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438: Windows Server 2019, 16GB RAM, 8750H CPU (AVX2), 970 EVO Plus SSD, 8 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0434\u0435\u0440 \u043d\u0430 VMWare.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f\u00bb (attention slicing) \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 UNET \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f W8A8 \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 VAE \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 RPI Zero 2.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0442\u0435\u043c\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0441\u043b\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e \u00ab\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f\u00bb. \u0418\u0434\u0435\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <code>Q @ K^T<\/code> \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0445 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 UNET. <\/p>\n<p>  \u041f\u0440\u0438 8 \u043b\u0443\u0447\u0430\u0445 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0432 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <code>Q<\/code> \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 (8,4096,40), \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <code>K^T<\/code> \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 (8,40,4096): \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 MatMul \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 (8,4096,4096), \u0442\u043e \u0435\u0441\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043d\u0437\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 512 \u041c\u0411 (\u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e FP32):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/nq\/hp\/nw\/nqhpnwsnfnphtp37rkmekikiy_i.png\" data-src=\"https:\/\/habrastorage.org\/webt\/nq\/hp\/nw\/nqhpnwsnfnphtp37rkmekikiy_i.png\"\/><\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c <code>Q<\/code> \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. <code>Q_sliced<\/code> \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 (1,x,40), \u0433\u0434\u0435 x \u0440\u0430\u0432\u0435\u043d 4096 (\u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435), \u043f\u043e\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043d\u0430 <code>onnxstream::Model::m_attention_fused_ops_parts<\/code> (\u0441 \u043f\u0440\u0435\u0434\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 2, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c). \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u0451\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043e\u0431\u044a\u0451\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e UNET \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 1,1 \u0413\u0411 \u0434\u043e 300 \u041c\u0411 (\u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e FP32). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u0438 \u044f\u0432\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 FlashAttention. \u041e\u0434\u043d\u0430\u043a\u043e FlashAttention \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b (AVX, NEON \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435), \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0445\u043e\u0434\u044f XnnPack.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 OnnxStream<\/font><\/h2>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0432 <code>path_to_model_folder\/model.txt<\/code>: (\u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 <i>model.txt<\/i>. OnnxStream \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0432\u0435\u0441\u0430 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0440\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 <i>.bin<\/i>)<\/p>\n<pre><code class=\"bash\">#include \"onnxstream.h\"  using namespace onnxstream;  int main() {     Model model;      \/\/     \/\/ \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Model:     \/\/     \/\/ model.set_weights_provider( ... ); \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u0432\u0435\u0441\u043e\u0432 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e DiskPrefetchWeightsProvider)     \/\/ model.read_range_data( ... ); \/\/ \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u043e\u0442\u0440\u0435\u0437\u0430\u043d\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0439 \u043a\u0432\u0430\u043d\u0442\u0443\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438)     \/\/ model.write_range_data( ... ); \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 (\u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u043b\u0438\u0431\u0440\u043e\u0432\u043a\u0438)     \/\/ model.m_range_data_calibrate = true; \/\/ \u043a\u0430\u043b\u0438\u0431\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c     \/\/ model.m_use_fp16_arithmetic = true; \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443 FP16 (\u043f\u0440\u0438\u0433\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u0435\u0441\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 FP16)     \/\/ model.m_use_uint8_arithmetic = true; \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443 UINT8      \/\/ model.m_use_uint8_qdq = true; \/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u0438\u0435 UINT8 (\u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438)     \/\/ model.m_fuse_ops_in_attention = true; \/\/ \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f     \/\/ model.m_attention_fused_ops_parts = ... ; \/\/ \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u00ab\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f\u00bb \u0432\u044b\u0448\u0435        model.read_file(\"path_to_model_folder\/model.txt\");      tensor_vector&lt;float> data;          ... \/\/ \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 tensor_vector \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u00abtensor_vector\u00bb - \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0434\u043b\u044f std::vector \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u043e\u043c.      Tensor t;     t.m_name = \"input\";     t.m_shape = { 1, 4, 64, 64 };     t.set_vector(std::move(data));     model.push_tensor(std::move(t));      model.run();          auto&amp; result = model.m_data[0].get_vector&lt;float>();          ... \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430: \u00abresult\u00bb - \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0430 (\u0430 \u0442\u0430\u043a\u0436\u0435 tensor_vector&lt;float>).      return 0; }<\/code><\/pre>\n<p>  \u0424\u0430\u0439\u043b <i>model.txt<\/i> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ASCII \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u0430\u043a\u043e\u043c \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 ONNX. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u0451\u0440\u0442\u043a\u0443 \u0432 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"bash\">Conv_4:Conv*input:input_2E_1(1,4,64,64);post_5F_quant_5F_conv_2E_weight_nchw.bin(uint8[0.0035054587850383684,134]:4,4,1,1);post_5F_quant_5F_conv_2E_bias.bin(float32:4)*output:input(1,4,64,64)*dilations:1,1;group:1;kernel_shape:1,1;pads:0,0,0,0;strides:1,1 <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430 <i>model.txt<\/i> \u0438 \u0435\u0433\u043e \u0432\u0435\u0441\u043e\u0432 (\u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0440\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 <i>.bin<\/i>) \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 ONNX \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 OnnxStream \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u043d\u043e\u0442 (\u0441 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u043e\u0439) (<i>onnx2txt.ipynb<\/i>).<\/p>\n<p>  \u041f\u0440\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435 Pytorch <code>nn.Module<\/code> (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u0432 ONNX \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 OnnxStream \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u0435-\u0447\u0442\u043e \u0443\u0447\u0435\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430 <code>torch.onnx.export<\/code>, <code>dynamic_axes<\/code> \u043d\u0443\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 OnnxStream \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0432\u043e\u0434 \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u043e\u0439.<\/li>\n<li>\u041d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c <a href=\"https:\/\/github.com\/daquexian\/onnx-simplifier\">ONNX Simplifier<\/a> \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 ONNX \u0434\u043e \u0435\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b <i>model.txt<\/i>.<\/li>\n<\/ol>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 Stable Diffusion \u0432 Linux\/Mac\/Windows<\/font><\/h2>\n<p>  <\/p>\n<ul>\n<li><i>\u0422\u043e\u043b\u044c\u043a\u043e Windows<\/i>: \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443: <i>Visual Studio Tools<\/i> > <i>x64 Native Tools Command Prompt<\/i>.<\/li>\n<li><i>\u0422\u043e\u043b\u044c\u043a\u043e Mac<\/i>: \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 cmake: <code>brew install cmake<\/code>.<\/li>\n<\/ul>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c <a href=\"https:\/\/github.com\/google\/XNNPACK\">XNNPACK<\/a>.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 XnnPack \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u044f \u0432\u043a\u043b\u044e\u0447\u0438\u043b <code>git checkout<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e OnnxStream \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0439 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 XnnPack:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/google\/XNNPACK.git cd XNNPACK git rev-list -n 1 --before=\"2023-06-27 00:00\" master git checkout &lt;COMMIT_ID_FROM_THE_PREVIOUS_COMMAND> mkdir build cd build cmake -DXNNPACK_BUILD_TESTS=OFF -DXNNPACK_BUILD_BENCHMARKS=OFF .. cmake --build . --config Release<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 Stable Diffusion:<\/p>\n<p>  <i>&lt;\u041a\u0410\u0422\u0410\u041b\u041e\u0413_\u041a\u0423\u0414\u0410_\u0411\u042b\u041b_\u041a\u041b\u041e\u041d\u0418\u0420\u041e\u0412\u0410\u041d_XNNPACK><\/i>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <i>\/home\/vito\/Desktop\/XNNPACK<\/i> \u0438\u043b\u0438 <i>C:\\Projects\\SD\\XNNPACK<\/i> (\u0432 Windows):<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/vitoplantamura\/OnnxStream.git cd OnnxStream cd src mkdir build cd build cmake -DXNNPACK_DIR=&lt;DIRECTORY_WHERE_XNNPACK_WAS_CLONED> .. cmake --build . --config Release<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0412\u0435\u0441\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <i>Releases<\/i> <a href=\"https:\/\/github.com\/vitoplantamura\/OnnxStream\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>. \u041e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 Stable Diffusion:<\/p>\n<pre><code class=\"bash\">--models-path       \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 Stable Diffusion. --ops-printf        \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 stdout. --output            \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b PNG. --decode-latents    \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u0438\u0444\u0444\u0443\u0437\u0438\u044e \u0438 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043b\u0430\u0442\u0435\u043d\u0442\u043e\u0432. --prompt            \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 (\u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439) \u0437\u0430\u043f\u0440\u043e\u0441. --neg-prompt        \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 (\u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439) \u0437\u0430\u043f\u0440\u043e\u0441. --steps             \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432 \u0434\u0438\u0444\u0444\u0443\u0437\u0438\u0438. --save-latents      \u043f\u043e\u0441\u043b\u0435 \u0434\u0438\u0444\u0444\u0443\u0437\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043b\u0430\u0442\u0435\u043d\u0442\u044b \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435. --decoder-calibrate \u043a\u0430\u043b\u0438\u0431\u0440\u0443\u0435\u0442 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u0435\u043e\u043a\u0434\u0435\u0440\u0430 VAE. --decoder-fp16      \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e FP16 \u0434\u0435\u043a\u043e\u0434\u0435\u0440\u0430 VAE. --rpi               \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 Raspberry Pi Zero 2.<\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Stable Diffusion \u0432 <code>sd.cpp<\/code> \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 <a href=\"https:\/\/github.com\/fengwang\/Stable-Diffusion-NCNN\">\u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/EdVince\/Stable-Diffusion-NCNN\">\u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a> @EdVince. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f OnnxStream \u0432\u043c\u0435\u0441\u0442\u043e NCNN.<\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/t.me\/ruvds_community\">Telegram-\u043a\u0430\u043d\u0430\u043b \u0441 \u0440\u043e\u0437\u044b\u0433\u0440\u044b\u0448\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043e\u0432, \u043d\u043e\u0432\u043e\u0441\u0442\u044f\u043c\u0438 IT \u0438 \u043f\u043e\u0441\u0442\u0430\u043c\u0438 \u043e \u0440\u0435\u0442\u0440\u043e\u0438\u0433\u0440\u0430\u0445 ?\ufe0f<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=onnxstream_minimizaciya_potrebleniya_pamyati_pri_generacii_izobrazhenij\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_p\/_h\/lv\/_p_hlvd2tv0cv9tny8tdytzfhje.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_p\/_h\/lv\/_p_hlvd2tv0cv9tny8tdytzfhje.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/751912\/\"> https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/751912\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/751912\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/fg\/e_\/ss\/fge_ssrs4sm9dfh1boluzidoy6q.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/fg\/e_\/ss\/fge_ssrs4sm9dfh1boluzidoy6q.jpeg\" data-blurred=\"true\"\/><\/div>\n<p><\/a><br \/>  \u0417\u0430\u0434\u0430\u0447\u0430 \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <a href=\"https:\/\/github.com\/CompVis\/stable-diffusion\">Stable Diffusion<\/a>, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0443\u044e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c c \u043f\u043e\u0447\u0442\u0438 1 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430 <a href=\"https:\/\/www.raspberrypi.com\/products\/raspberry-pi-zero-2-w\/\">Raspberry Pi Zero 2<\/a> \u0441 512 \u041c\u0411 RAM, \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u043a\u0430\u0447\u043a\u0438 \u0438 \u043d\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u0434\u0438\u0441\u043a. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0451\u043c RAM\/VRAM \u0434\u043b\u044f Stable Diffusion \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 8 \u0413\u0411.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-351259","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=351259"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351259\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}