{"id":462168,"date":"2025-06-05T15:00:43","date_gmt":"2025-06-05T15:00:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=462168"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=462168","title":{"rendered":"<span>\u0412\u0435\u043a\u0442\u043e\u0440\u044b \u0432 RISC-V \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435: \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 softmax<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421 10 \u043f\u043e 14 \u0430\u043f\u0440\u0435\u043b\u044f 2025 \u0433\u043e\u0434\u0430 \u043f\u0440\u043e\u0448\u0435\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043d\u043b\u0430\u0439\u043d RISC-V <a href=\"https:\/\/community.riscv.org\/events\/details\/risc-v-international-risc-v-academy-presents-risc-v-hackathon-online\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u043a\u0430\u0442\u043e\u043d<\/a>, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0410\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u0435\u0439 RISC-V. \u0423\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c 2 \u0437\u0430\u0434\u0430\u0447\u0438. \u041e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442 Codasip -\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f LLM \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430. \u0414\u0440\u0443\u0433\u0430\u044f \u043e\u0442 Andes &#8212; \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V \u0437\u0430\u0434\u0430\u0447\u0430 \u0441 softmax \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c, \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0443\u0436\u043d\u0430\u044f \u0434\u043b\u044f softmax.<\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <img decoding=\"async\" class=\"formula inline\" source=\"\\mathbf{X}\" alt=\"\\mathbf{X}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/784\/463\/544\/784463544ba0cbd3fc05f211b3e19fba.svg\" width=\"17\" height=\"17\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/784\/463\/544\/784463544ba0cbd3fc05f211b3e19fba.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/784\/463\/544\/784463544ba0cbd3fc05f211b3e19fba.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0434\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. \u0412\u044b\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0438 \u0432 \u0441\u0443\u043c\u043c\u0435 \u0434\u0430\u0435\u0442 1, \u043a\u0430\u043a \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u043b\u044e\u0431\u0430\u044f \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438, \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u0445, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0445\u043e\u0434, \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/230\/d65\/97a\/230d6597aed4db4e9413b2f225d2c377.png\" alt=\"\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043a \u0432\u044b\u0445\u043e\u0434\u0443 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a.\" title=\"\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043a \u0432\u044b\u0445\u043e\u0434\u0443 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a.\" width=\"1024\" height=\"427\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/230\/d65\/97a\/230d6597aed4db4e9413b2f225d2c377.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/230\/d65\/97a\/230d6597aed4db4e9413b2f225d2c377.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043a \u0432\u044b\u0445\u043e\u0434\u0443 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. <a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:Softmax.svg\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>.<\/figcaption><\/div>\n<\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"\\sigma(\\mathbf{X})_i = \\frac{e^{x_i}}{\\sum\\limits_{j=0}^{N}e^{x_j}}\" alt=\"\\sigma(\\mathbf{X})_i = \\frac{e^{x_i}}{\\sum\\limits_{j=0}^{N}e^{x_j}}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d1\/d1f\/d1feb4f2867068e8efae599e08f5847b.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d1\/d1f\/d1feb4f2867068e8efae599e08f5847b.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d1\/d1f\/d1feb4f2867068e8efae599e08f5847b.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a 1, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0431\u043b\u0438\u0436\u0435 \u043a 0.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 float \u0438\u043b\u0438 double \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u201c\u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e\u201d \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u201c\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c\u044e\u201d, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c float \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c inf. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442 \u0432\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 inf \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e inf, \u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c NaN.\u00a0<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0442\u0430\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0441\u0432\u0435\u0440\u0445\u0443 1-\u0435\u0439.<\/p>\n<p>\u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 0 \u0438 \u043d\u0430 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043a 0 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0422.\u043a. \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 0 \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 1, \u0442\u043e \u0432 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 1. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"\\sigma(\\mathbf{X})_i = \\frac{e^{x_i-\\max(\\mathbf{X})}}{\\sum\\limits_{j=0}^{N}e^{x_j-\\max(\\mathbf{X})}}  = \\frac{e^{x_i}e^{-\\max(\\mathbf{X})}}{e^{-\\max(\\mathbf{X})}\\sum\\limits_{j=0}^{N}e^{x_j}} =   \\frac{e^{x_i}}{\\sum\\limits_{j=0}^{N}e^{x_j}}\" alt=\"\\sigma(\\mathbf{X})_i = \\frac{e^{x_i-\\max(\\mathbf{X})}}{\\sum\\limits_{j=0}^{N}e^{x_j-\\max(\\mathbf{X})}}  = \\frac{e^{x_i}e^{-\\max(\\mathbf{X})}}{e^{-\\max(\\mathbf{X})}\\sum\\limits_{j=0}^{N}e^{x_j}} =   \\frac{e^{x_i}}{\\sum\\limits_{j=0}^{N}e^{x_j}}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/89\/894\/8946c1a72414c9e452b5df2ca3d12fa1.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/89\/894\/8946c1a72414c9e452b5df2ca3d12fa1.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/89\/894\/8946c1a72414c9e452b5df2ca3d12fa1.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0412 \u0436\u0435\u043b\u0435\u0437\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432. \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0440\u043e\u0434\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442, \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u0432 \u0438 \u0442\u0440\u0438\u0433\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a CORDIC \u043c\u0435\u0442\u043e\u0434, \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 IEEE 754 float \u0447\u0438\u0441\u0435\u043b <a href=\"https:\/\/ieeexplore.ieee.org\/document\/9106347\/\" rel=\"noopener noreferrer nofollow\">[Muller, 2020]<\/a>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438 \u0441 float \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430\u043c\u0438.<\/p>\n<h2>\u0422\u0440\u044e\u043a\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 IEEE 754 float<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 IEEE 754. \u0418\u0437-\u0437\u0430 \u044d\u0442\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0439. \u041d\u0435\u0431\u0435\u0437\u044b\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Fast_inverse_square_root\" rel=\"noopener noreferrer nofollow\">fast inverse square root<\/a>) \u0438\u0437 \u0434\u0432\u0438\u0436\u043a\u0430 Quake 3 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 IEEE 754 \u0431\u0438\u0442\u044b \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u043e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0447\u0438\u0441\u0435\u043b. \u0427\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0431\u0438\u0442\u0430 \u0437\u043d\u0430\u043a\u0430, \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b. \u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 &#8212; \u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u0438\u0442\u044b 0..22. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 1 \u0434\u043e 2, \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0431\u0438\u0442\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1. \u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442.\u0435. \u0431\u0438\u0442 22 &#8212; \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b <img decoding=\"async\" class=\"formula inline\" source=\"2^{-1}\" alt=\"2^{-1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce7\/4b0\/7ee\/ce74b07ee7aa325effe7ca621b823428.svg\" width=\"30\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce7\/4b0\/7ee\/ce74b07ee7aa325effe7ca621b823428.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce7\/4b0\/7ee\/ce74b07ee7aa325effe7ca621b823428.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0431\u0438\u0442 21 &#8212; \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"2^{-2}\" alt=\"2^{-2}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/186\/093\/663\/1860936637864dc8d34d25116ffcea74.svg\" width=\"30\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/186\/093\/663\/1860936637864dc8d34d25116ffcea74.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/186\/093\/663\/1860936637864dc8d34d25116ffcea74.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0431\u0438\u0442\u0430\u0445 23..30 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043c\u0438\u043d\u0443\u0441 127 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b 255 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 NaN \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0410 \u0435\u0441\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 0, \u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0443\u0431\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 0, \u0430 \u043d\u0435 \u0441 1. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 31-\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0437\u043d\u0430\u043a \u0447\u0438\u0441\u043b\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0432 1, \u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e16\/e86\/7dc\/e16e867dcddb595bf8e8abc736362f84.png\" alt=\"\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u0432 \u0431\u0438\u0442\u0430\u0445. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a.\" title=\"\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u0432 \u0431\u0438\u0442\u0430\u0445. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a.\" width=\"1024\" height=\"131\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e16\/e86\/7dc\/e16e867dcddb595bf8e8abc736362f84.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e16\/e86\/7dc\/e16e867dcddb595bf8e8abc736362f84.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u0432 \u0431\u0438\u0442\u0430\u0445. <a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:Float_example_ru.svg\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>.<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"x\" alt=\"x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2e\/9ba\/7dd\/a2e9ba7ddddb8b9035c7bcc5465d296f.svg\" width=\"11\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2e\/9ba\/7dd\/a2e9ba7ddddb8b9035c7bcc5465d296f.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2e\/9ba\/7dd\/a2e9ba7ddddb8b9035c7bcc5465d296f.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"x = (-1)^s 2^{e - 127} (1 + m)\" alt=\"x = (-1)^s 2^{e - 127} (1 + m)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a1\/73a\/c22\/5a173ac225246f9038b39d5328647716.svg\" width=\"203\" height=\"25\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a1\/73a\/c22\/5a173ac225246f9038b39d5328647716.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a1\/73a\/c22\/5a173ac225246f9038b39d5328647716.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0433\u0434\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"s\" alt=\"s\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/03\/03c\/03c7c0ace395d80182db07ae2c30f034.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/03\/03c\/03c7c0ace395d80182db07ae2c30f034.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/03\/03c\/03c7c0ace395d80182db07ae2c30f034.svg 781w\" loading=\"lazy\" decode=\"async\"\/> &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u0430 \u0437\u043d\u0430\u043a\u0430, <img decoding=\"async\" class=\"formula inline\" source=\"s\" alt=\"s\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/486\/c73\/60f\/486c7360fe9b55da7ea5e2ec11dc9664.svg\" width=\"9\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/486\/c73\/60f\/486c7360fe9b55da7ea5e2ec11dc9664.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/486\/c73\/60f\/486c7360fe9b55da7ea5e2ec11dc9664.svg 781w\" loading=\"lazy\" decode=\"async\"\/> &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b, <img decoding=\"async\" class=\"formula inline\" source=\"m\" alt=\"m\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/e3f\/b68\/bf8e3fb68e4bc457b0977aca1f81f960.svg\" width=\"17\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/e3f\/b68\/bf8e3fb68e4bc457b0977aca1f81f960.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/e3f\/b68\/bf8e3fb68e4bc457b0977aca1f81f960.svg 781w\" loading=\"lazy\" decode=\"async\"\/> &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b.<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0421 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/types\" rel=\"noopener noreferrer nofollow\">float<\/a> \u0442\u0438\u043f \u043a\u0430\u043a \u0440\u0430\u0437 \u043a\u0430\u043a 32-\u0431\u0438\u0442\u043d\u044b\u0439 IEEE 754 \u0444\u043e\u0440\u043c\u0430\u0442. \u041d\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043d\u0430\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 float \u0432 C \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u044b. \u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u0441\u0434\u0432\u0438\u0433\u0438 \u0438 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0435 AND, OR, NOT, XOR \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/c\/language\/operator_arithmetic\" rel=\"noopener noreferrer nofollow\">integer<\/a>. \u0412 C (\u043d\u043e \u043d\u0435 \u0432 C++) \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430 \u043a \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c\u0443 32-\u0431\u0438\u0442\u043d\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e &#8212; \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u043e \u043a\u0430\u043a float \u0447\u0438\u0441\u043b\u043e &#8212; \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e union-\u0430.<\/p>\n<pre><code class=\"cpp\">typedef union { int32_t i32; float f32; } u_float_int_t;<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e float \u0447\u0438\u0441\u0435\u043b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e. \u0421\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c float \u0447\u0438\u0441\u043b\u043e <img decoding=\"async\" class=\"formula inline\" source=\"x\" alt=\"x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc3\/657\/235\/fc3657235fec9b593ea4a182a397c025.svg\" width=\"11\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc3\/657\/235\/fc3657235fec9b593ea4a182a397c025.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc3\/657\/235\/fc3657235fec9b593ea4a182a397c025.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0443 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 <img decoding=\"async\" class=\"formula inline\" source=\"x = x_i + x_f\" alt=\"x = x_i + x_f\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/976\/0d7\/7ca\/9760d77caf60bbe0bc346879a3fa55ea.svg\" width=\"100\" height=\"20\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/976\/0d7\/7ca\/9760d77caf60bbe0bc346879a3fa55ea.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/976\/0d7\/7ca\/9760d77caf60bbe0bc346879a3fa55ea.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u043f\u0440\u0438\u0447\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"x_f\" alt=\"x_f\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5c\/cb0\/975\/a5ccb0975bd914a12001adb28368e67d.svg\" width=\"21\" height=\"17\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5c\/cb0\/975\/a5ccb0975bd914a12001adb28368e67d.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5c\/cb0\/975\/a5ccb0975bd914a12001adb28368e67d.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043b\u0435\u0436\u0438\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1.<\/p>\n<p>\u0412 C \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int x_i = (int) x; float x_f = x - x_i + (x &lt; 0) ? 1 : 0;<\/code><\/pre>\n<p>\u041e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430 \u043a int \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/en.cppreference.com\/w\/c\/language\/conversion.html\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435\u043c<\/a> \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 <code>x<\/code> \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <code>x - x_i<\/code> \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1, \u0430 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c 1. \u0422.\u043a. \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0434\u0430\u043b\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0434\u043b\u044f \u0432\u0437\u044f\u0442\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f 1.<\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0439\u043a\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 x \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c 2: <img decoding=\"async\" class=\"formula inline\" source=\"2^x = 2^{x_i} 2^{x_f}\" alt=\"2^x = 2^{x_i} 2^{x_f}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f1\/387\/2f1\/3f13872f19d4b40f52840beac1074d4e.svg\" width=\"97\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f1\/387\/2f1\/3f13872f19d4b40f52840beac1074d4e.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f1\/387\/2f1\/3f13872f19d4b40f52840beac1074d4e.svg 781w\" loading=\"lazy\" decode=\"async\"\/>.<\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0434\u0432\u043e\u0439\u043a\u0443 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"x_i\" alt=\"x_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5dc\/f4d\/65c\/5dcf4d65cd4a3657e1fa48f64c924cc0.svg\" width=\"18\" height=\"15\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5dc\/f4d\/65c\/5dcf4d65cd4a3657e1fa48f64c924cc0.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5dc\/f4d\/65c\/5dcf4d65cd4a3657e1fa48f64c924cc0.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a <img decoding=\"async\" class=\"formula inline\" source=\"x_i\" alt=\"x_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68a\/054\/fb1\/68a054fb11dfe444a7e900c211ab2ea1.svg\" width=\"18\" height=\"15\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68a\/054\/fb1\/68a054fb11dfe444a7e900c211ab2ea1.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68a\/054\/fb1\/68a054fb11dfe444a7e900c211ab2ea1.svg 781w\" loading=\"lazy\" decode=\"async\"\/> 127, \u0438 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e \u0432\u043b\u0435\u0432\u043e \u043d\u0430 23 \u0431\u0438\u0442\u0430 (\u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"2^23\" alt=\"2^23\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b50\/71a\/c06\/b5071ac0694070436865f5a1f8214f87.svg\" width=\"29\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b50\/71a\/c06\/b5071ac0694070436865f5a1f8214f87.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b50\/71a\/c06\/b5071ac0694070436865f5a1f8214f87.svg 781w\" loading=\"lazy\" decode=\"async\"\/>), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u043a\u0430\u043a float \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"2^{x_i} \\xleftarrow{(float)} (1 \\ll 23)\\cdot(x_i + 127)\" alt=\"2^{x_i} \\xleftarrow{(float)} (1 \\ll 23)\\cdot(x_i + 127)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d4\/19f\/a62\/2d419fa622358280105b9b8d2389e4d0.svg\" width=\"264\" height=\"37\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d4\/19f\/a62\/2d419fa622358280105b9b8d2389e4d0.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d4\/19f\/a62\/2d419fa622358280105b9b8d2389e4d0.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0411\u0438\u0442\u044b \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"2^{x_i}\" alt=\"2^{x_i}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b03\/0cf\/e46\/b030cfe464763db70288ae1572be5302.svg\" width=\"25\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b03\/0cf\/e46\/b030cfe464763db70288ae1572be5302.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b03\/0cf\/e46\/b030cfe464763db70288ae1572be5302.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"2^x\" alt=\"2^x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/474\/db7\/340\/474db7340a8c461e461b6f492d312fc5.svg\" width=\"20\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/474\/db7\/340\/474db7340a8c461e461b6f492d312fc5.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/474\/db7\/340\/474db7340a8c461e461b6f492d312fc5.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0443 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f float \u0447\u0438\u0441\u0435\u043b \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"1 + m  = 2 ^{x_f} \\\\ m = 2^{x_f} - 1\" alt=\"1 + m  = 2 ^{x_f} \\\\ m = 2^{x_f} - 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fec\/1da\/a68\/fec1daa684a98360f26c67f5eaddde14.svg\" width=\"697\" height=\"43\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fec\/1da\/a68\/fec1daa684a98360f26c67f5eaddde14.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fec\/1da\/a68\/fec1daa684a98360f26c67f5eaddde14.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"g(x_f)\" alt=\"g(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e32\/ac0\/21c\/e32ac021c767b56838d033b6ee99d530.svg\" width=\"46\" height=\"23\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e32\/ac0\/21c\/e32ac021c767b56838d033b6ee99d530.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e32\/ac0\/21c\/e32ac021c767b56838d033b6ee99d530.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"2^{x_i}\" alt=\"2^{x_i}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7b\/5c5\/c11\/b7b5c5c11701504a345c2c1453f2987e.svg\" width=\"25\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7b\/5c5\/c11\/b7b5c5c11701504a345c2c1453f2987e.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7b\/5c5\/c11\/b7b5c5c11701504a345c2c1453f2987e.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"2^x = 2^{x_i} 2^{x_f} = \\\\ = 2^{e-127}(1+m)  \\xleftarrow{(float)}(1  \\ll  23) \\cdot (x_i + 127) + g(x_f)\" alt=\"2^x = 2^{x_i} 2^{x_f} = \\\\ = 2^{e-127}(1+m)  \\xleftarrow{(float)}(1  \\ll  23) \\cdot (x_i + 127) + g(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/789\/31e\/6bd\/78931e6bd1f2130ce60dc3e905d20570.svg\" width=\"1232\" height=\"60\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/789\/31e\/6bd\/78931e6bd1f2130ce60dc3e905d20570.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/789\/31e\/6bd\/78931e6bd1f2130ce60dc3e905d20570.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0411\u0438\u0442\u043e\u0432\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"2^x\" alt=\"2^x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba5\/d1f\/5e4\/ba5d1f5e458bcc89a8d2f9363215054c.svg\" width=\"20\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba5\/d1f\/5e4\/ba5d1f5e458bcc89a8d2f9363215054c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba5\/d1f\/5e4\/ba5d1f5e458bcc89a8d2f9363215054c.svg 781w\" loading=\"lazy\" decode=\"async\"\/>.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\" 1 + m \\xrightarrow{(int)} g(x_f)\" alt=\" 1 + m \\xrightarrow{(int)} g(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/192\/2ef\/05c\/1922ef05c08d8e35cc3f037255c9768c.svg\" width=\"148\" height=\"38\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/192\/2ef\/05c\/1922ef05c08d8e35cc3f037255c9768c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/192\/2ef\/05c\/1922ef05c08d8e35cc3f037255c9768c.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0422.\u0435. \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"g(x_f)\" alt=\"g(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f36\/811\/d52\/f36811d52b489e2e242329579781ce72.svg\" width=\"46\" height=\"23\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f36\/811\/d52\/f36811d52b489e2e242329579781ce72.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f36\/811\/d52\/f36811d52b489e2e242329579781ce72.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0440\u0430\u0432\u043d\u0430 \u0446\u0435\u043b\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u0431\u0438\u0442\u044b \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u044d\u0442\u043e \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0438\u0442 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"2^{-23}\" alt=\"2^{-23}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/3a4\/52b\/d333a452b89cf849aafe4dd121c70ac4.svg\" width=\"36\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/3a4\/52b\/d333a452b89cf849aafe4dd121c70ac4.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/3a4\/52b\/d333a452b89cf849aafe4dd121c70ac4.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e float \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0432\u043d\u043e\u0433\u043e <img decoding=\"async\" class=\"formula inline\" source=\"1+m\" alt=\"1+m\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e8\/3a5\/330\/2e83a5330b19cc02472290cf4a81d45a.svg\" width=\"51\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e8\/3a5\/330\/2e83a5330b19cc02472290cf4a81d45a.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e8\/3a5\/330\/2e83a5330b19cc02472290cf4a81d45a.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"2^{23}\" alt=\"2^{23}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8d\/266\/b9d\/a8d266b9db491bb8344e6d9c1ad9b0b3.svg\" width=\"26\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8d\/266\/b9d\/a8d266b9db491bb8344e6d9c1ad9b0b3.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8d\/266\/b9d\/a8d266b9db491bb8344e6d9c1ad9b0b3.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"g(x_f) = \\text{trunc}((1 \\ll 23)\\cdot(1+m)) = \\text{trunc}((1 \\ll 23)\\cdot2^{x_f}) \" alt=\"g(x_f) = \\text{trunc}((1 \\ll 23)\\cdot(1+m)) = \\text{trunc}((1 \\ll 23)\\cdot2^{x_f}) \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1\/17\/17b\/17bd1796a1d82322146653a54fd28258.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1\/17\/17b\/17bd1796a1d82322146653a54fd28258.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1\/17\/17b\/17bd1796a1d82322146653a54fd28258.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c <img decoding=\"async\" class=\"formula inline\" source=\"x_i\" alt=\"x_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bbe\/f9d\/833\/bbef9d8332fa8a6f3017dccff698369d.svg\" width=\"18\" height=\"15\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bbe\/f9d\/833\/bbef9d8332fa8a6f3017dccff698369d.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bbe\/f9d\/833\/bbef9d8332fa8a6f3017dccff698369d.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"2^{23}\" alt=\"2^{23}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b4\/c80\/fb5\/0b4c80fb5643296d8a5468213a33636a.svg\" width=\"26\" height=\"21\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b4\/c80\/fb5\/0b4c80fb5643296d8a5468213a33636a.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b4\/c80\/fb5\/0b4c80fb5643296d8a5468213a33636a.svg 781w\" loading=\"lazy\" decode=\"async\"\/>. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u0441 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e <img decoding=\"async\" class=\"formula inline\" source=\"x\" alt=\"x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/859\/062\/533\/8590625332f4a516835678f2d96721d5.svg\" width=\"11\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/859\/062\/533\/8590625332f4a516835678f2d96721d5.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/859\/062\/533\/8590625332f4a516835678f2d96721d5.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"\\delta(x_f)\" alt=\"\\delta(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0c4\/558\/059\/0c45580597c23241afc87ca89f135b3b.svg\" width=\"45\" height=\"23\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0c4\/558\/059\/0c45580597c23241afc87ca89f135b3b.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0c4\/558\/059\/0c45580597c23241afc87ca89f135b3b.svg 781w\" loading=\"lazy\" decode=\"async\"\/>.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"(1 \\ll 23)(x_i +127) + g(x_f) =  (1 \\ll 23)(x_i +127) + (1 \\ll 23)2^{x_f} = \\\\ =(1 \\ll 23)(x _i + 2^{x_f} + 127) = (1 \\ll 23) (x - x_f  - 1 + 2^{x_f} +127) = \\\\ =(1 \\ll 23)(x - \\delta(x_f) + 127) \\\\ \\delta(x_f) = 1 + x_f - 2^{x_f}\" alt=\"(1 \\ll 23)(x_i +127) + g(x_f) =  (1 \\ll 23)(x_i +127) + (1 \\ll 23)2^{x_f} = \\\\ =(1 \\ll 23)(x _i + 2^{x_f} + 127) = (1 \\ll 23) (x - x_f  - 1 + 2^{x_f} +127) = \\\\ =(1 \\ll 23)(x - \\delta(x_f) + 127) \\\\ \\delta(x_f) = 1 + x_f - 2^{x_f}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/98\/980\/980f4eeb13a1b187eb6c42ceb9bc97af.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/98\/980\/980f4eeb13a1b187eb6c42ceb9bc97af.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/98\/980\/980f4eeb13a1b187eb6c42ceb9bc97af.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"2^{x_f}\" alt=\"2^{x_f}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbe\/10e\/c72\/cbe10ec721dbb0686768c77690c3d5d9.svg\" width=\"27\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbe\/10e\/c72\/cbe10ec721dbb0686768c77690c3d5d9.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbe\/10e\/c72\/cbe10ec721dbb0686768c77690c3d5d9.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, <img decoding=\"async\" class=\"formula inline\" source=\"x_f\" alt=\"x_f\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd4\/9e8\/95f\/fd49e895f35f3e838ca27e8d792337c7.svg\" width=\"21\" height=\"17\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd4\/9e8\/95f\/fd49e895f35f3e838ca27e8d792337c7.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd4\/9e8\/95f\/fd49e895f35f3e838ca27e8d792337c7.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0442 0 \u0434\u043e 1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <img decoding=\"async\" class=\"formula inline\" source=\"2^{x_f}\" alt=\"2^{x_f}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d3\/28b\/5aa\/8d328b5aaefe26abce2a10d9de78b86f.svg\" width=\"27\" height=\"18\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d3\/28b\/5aa\/8d328b5aaefe26abce2a10d9de78b86f.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d3\/28b\/5aa\/8d328b5aaefe26abce2a10d9de78b86f.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u043c, \u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u044b \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 float \u0447\u0438\u0441\u0435\u043b \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0415\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b RISC-V, \u0442\u043e \u0434\u043b\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 RV32I\/RV64I. \u0414\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u0441 float \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u201cF\u201d.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c 5-\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u043b\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"\\delta(x_f)\" alt=\"\\delta(x_f)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/112\/817\/b11\/112817b11d68a685c706221bcb355472.svg\" width=\"45\" height=\"23\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/112\/817\/b11\/112817b11d68a685c706221bcb355472.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/112\/817\/b11\/112817b11d68a685c706221bcb355472.svg 781w\" loading=\"lazy\" decode=\"async\"\/><a href=\"https:\/\/www.sciencedirect.com\/science\/article\/abs\/pii\/S0010218018301652\" rel=\"noopener noreferrer nofollow\">[Perini, 2018]<\/a>:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"\\delta(x_f) = 1 + x_f - 2^{x_f} = s_5 x^5 + s_4 x^4 + s_3 x^3 + s_2 x^2 + s_1 x + s_0\" alt=\"\\delta(x_f) = 1 + x_f - 2^{x_f} = s_5 x^5 + s_4 x^4 + s_3 x^3 + s_2 x^2 + s_1 x + s_0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/53\/534\/5342ca19900e155fea9de45b570fe79c.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/53\/534\/5342ca19900e155fea9de45b570fe79c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/53\/534\/5342ca19900e155fea9de45b570fe79c.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043d\u0430 \u043a\u043e\u043d\u0446\u0430\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"[0, 1]\" alt=\"[0, 1]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87d\/714\/06b\/87d71406b03be3ae74c440bf09222473.svg\" width=\"39\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87d\/714\/06b\/87d71406b03be3ae74c440bf09222473.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87d\/714\/06b\/87d71406b03be3ae74c440bf09222473.svg 781w\" loading=\"lazy\" decode=\"async\"\/>. \u0414\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 5 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 6 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u043d\u043e 6 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 2-x \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445.<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"\\delta\u2019(x_f) = 1 - \\ln2 \\cdot 2^{x_f} = 5 s_5 x^4 + 4 s_4 x^3 + 3 s_3 x^2 + 2 s_2 x + s_1 \\\\ \\delta\u2019\u2019(x_f) = - (\\ln2)^2 2^{x_f} = 20 s_5 x^3 + 12 s_4 x^2 + 6 s_3 x + 4 s_2 \" alt=\"\\delta\u2019(x_f) = 1 - \\ln2 \\cdot 2^{x_f} = 5 s_5 x^4 + 4 s_4 x^3 + 3 s_3 x^2 + 2 s_2 x + s_1 \\\\ \\delta\u2019\u2019(x_f) = - (\\ln2)^2 2^{x_f} = 20 s_5 x^3 + 12 s_4 x^2 + 6 s_3 x + 4 s_2 \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e8\/e83\/e83e87ea3238a6922f45b6947891df05.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e8\/e83\/e83e87ea3238a6922f45b6947891df05.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/e8\/e83\/e83e87ea3238a6922f45b6947891df05.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"\\delta(0) = 0 = s_0 \\\\ \\delta\u2019(0) = 1 - ln2 = s_1 \\\\ \\delta\u2019\u2019(0) = - (\\ln2)^2 = 2s_2 \\\\ \\delta(1) = 0 = s_5 + s_4 + s_3 + s_2 + s_1 +s_0 \\\\ \\delta\u2019(1) = 1 - 2\\ln2  = 5s_5 + 4s_4 +3s_3 +2s_2 + s_1 \\\\ \\delta\u2019\u2019(1) =  -2 (\\ln2)^2 = 20 s_5 + 12 s_4 + 6 s_3 + 4 s_2 \\\\\" alt=\"\\delta(0) = 0 = s_0 \\\\ \\delta\u2019(0) = 1 - ln2 = s_1 \\\\ \\delta\u2019\u2019(0) = - (\\ln2)^2 = 2s_2 \\\\ \\delta(1) = 0 = s_5 + s_4 + s_3 + s_2 + s_1 +s_0 \\\\ \\delta\u2019(1) = 1 - 2\\ln2  = 5s_5 + 4s_4 +3s_3 +2s_2 + s_1 \\\\ \\delta\u2019\u2019(1) =  -2 (\\ln2)^2 = 20 s_5 + 12 s_4 + 6 s_3 + 4 s_2 \\\\\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/798\/195\/efa\/798195efa893ac0ac2aa62074ca74e56.svg\" width=\"697\" height=\"189\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/798\/195\/efa\/798195efa893ac0ac2aa62074ca74e56.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/798\/195\/efa\/798195efa893ac0ac2aa62074ca74e56.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430:<\/p>\n<pre><code class=\"cpp\">   const float s1 = 3.06852819440055e-1f;    const float s2 = -2.40226506959101e-1f;    const float s3 = -5.57129652016652e-2f;    const float s4 = -9.01146535969578e-3f;    const float s5 = -1.90188191959304e-3f;<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 5-\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0439. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u043c 3-\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443. \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 5-\u043e\u0439 \u0438 3-\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0443\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430, \u0434\u0430\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 <a href=\"https:\/\/doi.org\/10.1162\/089976699300016467\" rel=\"noopener noreferrer nofollow\">[Schraudolph, 1999]<\/a>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/834\/fe2\/303\/834fe23034e627e21bd488e22cf71ee6.png\" alt=\"\u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438.\" title=\"\u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438.\" width=\"593\" height=\"432\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/834\/fe2\/303\/834fe23034e627e21bd488e22cf71ee6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/834\/fe2\/303\/834fe23034e627e21bd488e22cf71ee6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438.<\/figcaption><\/div>\n<\/figure>\n<h2>\u0421\u043a\u0430\u043b\u044f\u0440\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 C<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u043a\u0446\u0438\u044e softmax \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u043c C.\u00a0 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0439\u043a\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 C \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">static float fast_pow2(const float in) {    const float yf = in - (int32_t)(in) + 1;    u_float_int_t value;    value.i32 = (int32_t)((1 &lt;&lt; 23) * (in - delta(yf) + 127.0f));    return value.f32; }<\/code><\/pre>\n<p>\u0413\u0434\u0435 <code>delta(x)<\/code> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u043f\u044f\u0442\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c 2 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c <img decoding=\"async\" class=\"formula inline\" source=\"e\" alt=\"e\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f1\/b63\/4a0\/7f1b634a0062f5b2c440edf835189b4c.svg\" width=\"9\" height=\"12\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f1\/b63\/4a0\/7f1b634a0062f5b2c440edf835189b4c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f1\/b63\/4a0\/7f1b634a0062f5b2c440edf835189b4c.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"\\ln2\" alt=\"\\ln2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d3\/22e\/565\/9d322e5659ec0272fe0e2361b44b4bdd.svg\" width=\"29\" height=\"17\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d3\/22e\/565\/9d322e5659ec0272fe0e2361b44b4bdd.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d3\/22e\/565\/9d322e5659ec0272fe0e2361b44b4bdd.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u043d\u0430 C \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int32_t scalar_softmax_f32(const float* in_vec, uint32_t size, float* out_vec) {    float max = in_vec[0];    float sum = 0;    for (int i = 1; i &lt; size; ++i) {        if (in_vec[i] &gt; max) {            max = in_vec[i];        }    }    for (int i = 0; i &lt; size; ++i) {        float value = (in_vec[i] - max) * k1OverLn2;        out_vec[i] = fast_pow2(value);        sum += out_vec[i];    }    for (int i = 0; i &lt; size; ++i) {        out_vec[i] = out_vec[i] \/ sum;    }    return 0; }<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 3 \u044d\u0442\u0430\u043f\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f &#8212; \u043f\u043e\u0438\u0441\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043e\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 \u0441\u0443\u043c\u043c\u0443 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>\u042d\u0442\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u0430\u044f \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 SIMD. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435, \u0447\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b RISC-V \u0441 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 SIMD \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u201cV\u201d.<\/p>\n<h2>RVV \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441 \u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a\u0430\u043c\u0438<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e <a href=\"https:\/\/github.com\/riscvarchive\/riscv-v-spec\" rel=\"noopener noreferrer nofollow\">SIMD \u0432 RISC-V<\/a> \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0434\u0435\u043e\u043b\u043e\u0433\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0412 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>vl<\/code> \u0438 \u0434\u043b\u044f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>vl<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>vsetvl<\/code>. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>vl<\/code> &#8212; <code>vlmax<\/code> &#8212; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 <code><strong>VLEN<\/strong><\/code>, \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <code>SEW<\/code> \u0438 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043d\u0430 \u043e\u0434\u0438\u043d \u0432\u0435\u043a\u0442\u043e\u0440 <code>LMUL<\/code>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code><strong>VLEN<\/strong><\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043d\u0435\u0433\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c. <code>SEW<\/code> \u0440\u0430\u0432\u0435\u043d 32 \u0431\u0438\u0442\u0430\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 softmax \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f 32-\u0431\u0438\u0442\u043d\u044b\u0445 float \u0434\u0430\u043d\u043d\u044b\u0445. \u0410 <code>LMUL<\/code> \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e, \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>vsetvl<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0434\u043b\u0438\u043d\u044b, <code>LMUL<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u043f\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 RISC-V \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e &#8212; 8.<\/p>\n<p>\u0412 C \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u0445 gcc \u0438 clang \u0435\u0441\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>&lt;riscv_vector.h&gt;<\/code> \u0441 <a href=\"https:\/\/github.com\/riscv-non-isa\/rvv-intrinsic-doc\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a\u0430\u043c\u0438<\/a> \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 RISC-V. \u042d\u0442\u043e \u0434\u0430\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f-\u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a <code>vsetvl<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 <code>vl<\/code>. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043a\u0443\u0441\u043a\u0438 \u0434\u043b\u0438\u043d\u043e\u0439 <code>vlmax<\/code>. \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0445\u0432\u043e\u0441\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043a\u0440\u0430\u0442\u043d\u044b\u0439 <code>vlmax<\/code> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430, \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>vsetvl<\/code> \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 <code>vlmax<\/code> \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 <code>vl<\/code> \u043d\u0430 \u044d\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u0430\u043a\u043e\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u044d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/p>\n<p>\u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043f\u043e\u0438\u0441\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">static float rvv_find_max(const float *in_vec, uint32_t size) {    float *cur_pos = (float *)in_vec;    size_t rem_size = size;    size_t vl = __riscv_vsetvl_e32m8(rem_size);    vfloat32m8_t vInput = __riscv_vle32_v_f32m8(cur_pos, vl);      cur_pos += vl;    rem_size -= vl;    while (rem_size &gt; 0) {        vl = __riscv_vsetvl_e32m8(rem_size);        const vfloat32m8_t vNext = __riscv_vle32_v_f32m8(cur_pos, vl);        cur_pos += vl;        rem_size -= vl;        vInput = __riscv_vfmax_vv_f32m8(vInput, vNext, vl);    }      vl = __riscv_vsetvl_e32m1(size);    vfloat32m1_t vMax = __riscv_vfmv_v_f_f32m1(0.0f, vl);      vl = __riscv_vsetvl_e32m8(size);    vMax = __riscv_vfredmax_vs_f32m8_f32m1(vInput, vMax, vl);    float max = __riscv_vfmv_f_s_f32m1_f32(vMax);    return max; }<\/code><\/pre>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440\u044b \u0432 C \u043a\u043e\u0434\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b <code>vfloat32m8_t<\/code>.<\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>vle<\/code>. \u0412 C \u043a\u043e\u0434\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>vl<\/code>. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <code>vfloat32m8_t<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>\u0412 \u0438\u043d\u0442\u0440\u0438\u0437\u0438\u043a\u0430\u0445 \u0432\u0448\u0438\u0442\u044b \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 <code>LMUL<\/code>, \u0430 <code>vl<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a <code>__riscv_vfmax_vv_f32m8<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u042d\u0442\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0432\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u043a\u043b\u0430\u0434\u0435\u0442 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u0438\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0446\u0438\u043a\u043b\u0430, \u0432\u0435\u043a\u0442\u043e\u0440 <code>vInput<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0443\u0441\u043a\u043e\u0432 \u043f\u043e <code>vlmax<\/code> \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 <code>vInput<\/code> \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u00a0 <code>vfredmax<\/code> \u0441\u0432\u0435\u0440\u0442\u043a\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 max.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d3\/4b5\/821\/1d34b5821b6dd782518f29143a1dca74.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.\" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.\" width=\"984\" height=\"381\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1d3\/4b5\/821\/1d34b5821b6dd782518f29143a1dca74.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d3\/4b5\/821\/1d34b5821b6dd782518f29143a1dca74.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.<\/figcaption><\/div>\n<\/figure>\n<p>\u0410\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">static vfloat32m8_t rvv_fast_pow2(const vfloat32m8_t vIn, size_t vl) {    const vfloat32m8_t vFrac = rvv_get_frac(vIn, vl);    const vfloat32m8_t vDelta = rvv_delta(vFrac, vl);    const int32_t pow2_23 = 1 &lt;&lt; 23;      vfloat32m8_t vTmp;    vTmp = __riscv_vfsub_vv_f32m8(vIn, vDelta, vl);    vTmp = __riscv_vfadd_vf_f32m8(vTmp, 127.0f, vl);    vTmp = __riscv_vfmul_vf_f32m8(vTmp, pow2_23, vl);    vint32m8_t vTmp_i32 = __riscv_vmv_v_x_i32m8(0, vl);    vTmp_i32 = __riscv_vfcvt_rtz_x_tu(vTmp_i32, vTmp, vl);    const vfloat32m8_t vResult = __riscv_vreinterpret_v_i32m8_f32m8(vTmp_i32);    return vResult; }<\/code><\/pre>\n<p>\u0434\u043b\u044f \u0432\u0437\u044f\u0442\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 float \u0447\u0438\u0441\u0435\u043b \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a <code>__riscv_vfcvt_f_x_v_f32m8<\/code> &#8212; \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 float \u0432 int.<\/p>\n<pre><code class=\"cpp\">vfloat32m8_t rvv_get_frac(const vfloat32m8_t vIn, size_t vl) {    vint32m8_t vInt = __riscv_vmv_v_x_i32m8(0, vl);    vInt = __riscv_vfcvt_rtz_x_tu(vInt, vIn, vl);    const vfloat32m8_t vIntF = __riscv_vfcvt_f_x_v_f32m8(vInt, vl);    vfloat32m8_t vResult = __riscv_vfsub_vv_f32m8(vIn, vIntF, vl);    vResult = __riscv_vfadd_vf_f32m8(vResult, 1.0f, vl);    return vResult; }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0442 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043a\u0430\u043a float \u0447\u0438\u0441\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a <code>__riscv_vreinterpret_v_i32m8_f32m8<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0441 32-\u0445 \u0431\u0438\u0442\u043d\u044b\u043c\u0438 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043a\u0430\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430 float \u0447\u0438\u0441\u0435\u043b.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d37\/e10\/81b\/d37e1081b82375b9d78152c4d6450422.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.\" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.\" width=\"1071\" height=\"711\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d37\/e10\/81b\/d37e1081b82375b9d78152c4d6450422.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d37\/e10\/81b\/d37e1081b82375b9d78152c4d6450422.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V.<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u043c\u0435\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0439 softmax. \u0412 \u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0435 \u0436\u0435 3 \u0447\u0430\u0441\u0442\u0438: \u043f\u043e\u0438\u0441\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0430 \u0441\u0443\u043c\u043c\u0443 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f softmax \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0441\u0443\u043c\u043c\u0443 \u0432\u0441\u0435\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>vse<\/code>. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0441\u0443\u043c\u043c\u0443. \u0412 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u0441\u0443\u043c\u043c <code>vSum<\/code> \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u043e <code>vlmax<\/code> . \u0412\u0435\u043a\u0442\u043e\u0440 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0434\u0443\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u044b \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"cpp\">int32_t rvv_pure_softmax_f32(const float *in_vec, uint32_t size,                             float *out_vec) {     float max = rvv_find_max(in_vec, size);      float *cur_pos = (float *)in_vec;    float *cur_out_pos = (float *)out_vec;    size_t rem_size = size;      size_t vl = __riscv_vsetvl_e32m8(rem_size);      vfloat32m8_t vSum = __riscv_vfmv_v_f_f32m8(0.0f, vl);      while (rem_size &gt; 0) {        vl = __riscv_vsetvl_e32m8(rem_size);        vfloat32m8_t vData = __riscv_vle32_v_f32m8(cur_pos, vl);          cur_pos += vl;        rem_size -= vl;        \/\/ substract max and scale        vData = __riscv_vfsub_vf_f32m8(vData, max, vl);        vData = __riscv_vfmul_vf_f32m8(vData, k1OverLn2, vl);          \/\/--- pow2_f32 begin ---        vData = rvv_fast_pow2(vData, vl);        \/\/--- pow2_f32 end ---          vSum = __riscv_vfadd_vv_f32m8(vSum, vData, vl);  \/\/ accumulate          \/\/ save value to memory        __riscv_vse32_v_f32m8(cur_out_pos, vData, vl);          cur_out_pos += vl;    }      vl = __riscv_vsetvl_e32m1(1);    vfloat32m1_t vResult = __riscv_vfmv_v_f_f32m1(0.0f, vl);    vl = __riscv_vsetvl_e32m8(size);    vResult = __riscv_vfredosum_vs_f32m8_f32m1(vSum, vResult, vl);    float sum = __riscv_vfmv_f_s_f32m1_f32(vResult);      \/\/ divide the output by sum    rem_size = size;      while (rem_size &gt; 0) {        vl = __riscv_vsetvl_e32m8(rem_size);        vfloat32m8_t vData = __riscv_vle32_v_f32m8(out_vec, vl);        vData = __riscv_vfdiv_vf_f32m8(vData, sum, vl);        __riscv_vse32_v_f32m8(out_vec, vData, vl);        out_vec += vl;        rem_size -= vl;    }     return 0; }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430 \u0435\u0434\u0438\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0445\u0432\u043e\u0441\u0442.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h2>\n<p>\u041d\u0435 \u0438\u043c\u0435\u044f \u043d\u0430 \u0440\u0443\u043a\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441 RISC-V \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0434 RISC-V \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430 <a href=\"https:\/\/github.com\/riscv-software-src\/riscv-isa-sim\" rel=\"noopener noreferrer nofollow\">Spike<\/a>. \u042d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 softmax.<\/p>\n<p>\u0412 <a href=\"https:\/\/github.com\/DuzaBF\/softmax-hackathon\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 softmax-\u0430 \u043f\u043e\u0434 RISC-V \u0438 \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u0432 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435. Spike \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 proxy-kernel, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0438\u0437 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b-\u0445\u043e\u0441\u0442\u0430. \u0421\u043a\u0440\u0438\u043f\u0442 Jupyther Notebook \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0444\u0430\u0439\u043b \u0441 \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 softmax \u043e\u0442 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u0434 \u041e\u0421 Linux \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/perf_event_open.2.html\" rel=\"noopener noreferrer nofollow\">perf<\/a>.<\/p>\n<p>\u0412 C \u043a\u043e\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438 \u043f\u043e\u0434 \u043a\u0430\u043a\u0443\u044e \u041e\u0421 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u044b\u0437\u0432\u0430\u0432 <a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/cpp\/System-specific-Predefined-Macros.html\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/a><code>echo | gcc -dM -E -<\/code> .<\/p>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0434 \u041b\u0438\u043d\u0443\u043a\u0441, \u0432\u043a\u043b\u044e\u0447\u0430\u044f perf, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0443 <code>linux<\/code>.\u0412 \u043f\u0440\u043e\u043a\u0441\u0438 \u044f\u0434\u0440\u0435 Spike-\u0430 perf-\u0430 \u043d\u0435\u0442, \u043d\u043e \u0432 RISC-V \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>rdinstret<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439. \u0418\u043d\u0442\u0440\u0438\u043d\u0437\u0438\u043a\u0430 \u043f\u043e\u0434 \u044d\u0442\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043d\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u043e\u0439.<\/p>\n<pre><code class=\"cpp\">asm volatile(\"rdinstret %0\" : \"=r\"(counter));<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0446\u0438\u044f <code>-march=rv64gc<\/code> \u0442.\u0435. \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 64-\u0431\u0438\u0442\u043d\u044b\u0439 RISC-V \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 (g &#8212; general) \u0438 \u0441\u0436\u0430\u0442\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (c &#8212; compressed). \u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\u00a0 <code>-march=rv64gcv<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 V.<\/p>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 8 \u0440\u0430\u0437.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">spike --isa=rv64gcv pk .\/bin\/riscv-test -f .\/bin\/data -g .\/bin\/golden Softmax size=2048 rdinstret 532637 rdinstret 616609 Used 83972 instructions ------------------ maxAbsDiff = 0.000000 sumSquareErr = 0.000000 squareGolden = 0.000528 snr_result = 114.316017 f_scores = 106.918671  --&gt; Test PASSED! Your scores = 100<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">spike --isa=rv64gcv pk .\/bin\/rvv-test -f .\/bin\/data -g .\/bin\/golden Softmax size=2048 rdinstret 522514 rdinstret 532074 Used 9560 instructions ------------------ maxAbsDiff = 0.000000 sumSquareErr = 0.000000 squareGolden = 0.000528 snr_result = 115.325989 f_scores = 107.389938  --&gt; Test PASSED! Your scores = 100<\/code><\/pre>\n<h2>P.S.<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0439 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 Ara. \u0412 ara \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 softmax. \u0410\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u043d\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043a\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"https:\/\/www.netlib.org\/cephes\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.netlib.org\/cephes\/<\/a> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BF%D0%BF%D1%80%D0%BE%D0%BA%D1%81%D0%B8%D0%BC%D0%B0%D1%86%D0%B8%D1%8F_%D0%9F%D0%B0%D0%B4%D0%B5\" rel=\"noopener noreferrer nofollow\">\u041f\u0430\u0434\u0435<\/a>. \u0411\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u0435\u0439\u043d\u0430 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0431\u0435\u043d\u0447 \u0438 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439, \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0430 \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 \u043d\u0430 RISC-V \u0438 RVV \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u0442 fprox <a href=\"https:\/\/fprox.substack.com\/p\/implementing-softmax-using-risc-v\" rel=\"noopener noreferrer nofollow\">https:\/\/fprox.substack.com\/p\/implementing-softmax-using-risc-v<\/a><\/p>\n<\/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\/articles\/915866\/\"> https:\/\/habr.com\/ru\/articles\/915866\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421 10 \u043f\u043e 14 \u0430\u043f\u0440\u0435\u043b\u044f 2025 \u0433\u043e\u0434\u0430 \u043f\u0440\u043e\u0448\u0435\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043d\u043b\u0430\u0439\u043d RISC-V <a href=\"https:\/\/community.riscv.org\/events\/details\/risc-v-international-risc-v-academy-presents-risc-v-hackathon-online\/\" rel=\"noopener noreferrer nofollow\">\u0445\u0430\u043a\u0430\u0442\u043e\u043d<\/a>, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0410\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u0435\u0439 RISC-V. \u0423\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u043d\u0430 \u0432\u044b\u0431\u043e\u0440 \u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c 2 \u0437\u0430\u0434\u0430\u0447\u0438. \u041e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0442 Codasip -\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f LLM \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430. \u0414\u0440\u0443\u0433\u0430\u044f \u043e\u0442 Andes &#8212; \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f RISC-V \u0437\u0430\u0434\u0430\u0447\u0430 \u0441 softmax \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0439.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c, \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u0443\u0436\u043d\u0430\u044f \u0434\u043b\u044f softmax.<\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439  \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0434\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. \u0412\u044b\u0445\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0438 \u0432 \u0441\u0443\u043c\u043c\u0435 \u0434\u0430\u0435\u0442 1, \u043a\u0430\u043a \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u043b\u044e\u0431\u0430\u044f \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438, \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u0445, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0445\u043e\u0434, \u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u043a \u0432\u044b\u0445\u043e\u0434\u0443 \u0441\u0432\u0451\u0440\u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. <a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:Softmax.svg\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>.<\/figcaption><\/div>\n<\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f softmax \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a 1, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0431\u043b\u0438\u0436\u0435 \u043a 0.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 float \u0438\u043b\u0438 double \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u201c\u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e\u201d \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u201c\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c\u044e\u201d, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c float \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c inf. \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442 \u0432\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 inf \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0431\u043e inf, \u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c NaN.\u00a0<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0442\u0430\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0422\u0430\u043a \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0441\u0432\u0435\u0440\u0445\u0443 1-\u0435\u0439.<\/p>\n<p>\u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 0 \u0438 \u043d\u0430 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043a 0 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0422.\u043a. \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043e\u0434\u043d\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 0 \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 1, \u0442\u043e \u0432 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 1. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u0436\u0435\u043b\u0435\u0437\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432. \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0440\u043e\u0434\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442, \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u0432 \u0438 \u0442\u0440\u0438\u0433\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438. \u041f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a CORDIC \u043c\u0435\u0442\u043e\u0434, \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 IEEE 754 float \u0447\u0438\u0441\u0435\u043b <a href=\"https:\/\/ieeexplore.ieee.org\/document\/9106347\/\" rel=\"noopener noreferrer nofollow\">[Muller, 2020]<\/a>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0441 \u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438 \u0441 float \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430\u043c\u0438.<\/p>\n<h2>\u0422\u0440\u044e\u043a\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 IEEE 754 float<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 IEEE 754. \u0418\u0437-\u0437\u0430 \u044d\u0442\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0439. \u041d\u0435\u0431\u0435\u0437\u044b\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Fast_inverse_square_root\" rel=\"noopener noreferrer nofollow\">fast inverse square root<\/a>) \u0438\u0437 \u0434\u0432\u0438\u0436\u043a\u0430 Quake 3 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 IEEE 754 \u0431\u0438\u0442\u044b \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u043e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0447\u0438\u0441\u0435\u043b. \u0427\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0431\u0438\u0442\u0430 \u0437\u043d\u0430\u043a\u0430, \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b. \u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 &#8212; \u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u0438\u0442\u044b 0..22. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 1 \u0434\u043e 2, \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 \u0431\u0438\u0442\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1. \u041c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442.\u0435. \u0431\u0438\u0442 22 &#8212; \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b , \u0431\u0438\u0442 21 &#8212; \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0438  \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0431\u0438\u0442\u0430\u0445 23..30 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043c\u0438\u043d\u0443\u0441 127 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b 255 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 NaN \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0410 \u0435\u0441\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0430 0, \u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0443\u0431\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 0, \u0430 \u043d\u0435 \u0441 1. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 31-\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0437\u043d\u0430\u043a \u0447\u0438\u0441\u043b\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0432 1, \u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0433\u043e float \u0447\u0438\u0441\u043b\u0430 \u0432 \u0431\u0438\u0442\u0430\u0445. <a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:Float_example_ru.svg\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>.<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430  \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e:<\/p>\n<p>\u0433\u0434\u0435  &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u0430 \u0437\u043d\u0430\u043a\u0430,  &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b,  &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b.<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0421 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/types\" rel=\"noopener noreferrer nofollow\">float<\/a> \u0442\u0438\u043f \u043a\u0430\u043a \u0440\u0430\u0437 \u043a\u0430\u043a 32-\u0431\u0438\u0442\u043d\u044b\u0439 IEEE 754 \u0444\u043e\u0440\u043c\u0430\u0442. \u041d\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043d\u0430\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 float \u0432 C \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u044b. \u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u0441\u0434\u0432\u0438\u0433\u0438 \u0438 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0435 AND, OR, NOT, XOR \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/c\/language\/operator_arithmetic\" rel=\"noopener noreferrer nofollow\">integer<\/a>. \u0412 C (\u043d\u043e \u043d\u0435 \u0432 C++) \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430 \u043a \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c\u0443 32-\u0431\u0438\u0442\u043d\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e &#8212; \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u043e \u043a\u0430\u043a float \u0447\u0438\u0441\u043b\u043e &#8212; \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e union-\u0430.<\/p>\n<pre><code class=\"cpp\">typedef union { int32_t i32; float f32; } u_float_int_t;<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e float \u0447\u0438\u0441\u0435\u043b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e. \u0421\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c float \u0447\u0438\u0441\u043b\u043e  \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0443 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 , \u043f\u0440\u0438\u0447\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c  \u043b\u0435\u0436\u0438\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1.<\/p>\n<p>\u0412 C \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0439 \u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int x_i = (int) x; float x_f = x - x_i + (x &lt; 0) ? 1 : 0;<\/code><\/pre>\n<p>\u041e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0435 float \u0447\u0438\u0441\u043b\u0430 \u043a int \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/en.cppreference.com\/w\/c\/language\/conversion.html\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435\u043c<\/a> \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 <code>x<\/code> \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <code>x - x_i<\/code> \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1, \u0430 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c 1. \u0422.\u043a. \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u0434\u043b\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0434\u0430\u043b\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0434\u043b\u044f \u0432\u0437\u044f\u0442\u0438\u044f \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f 1.<\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0439\u043a\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 x \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c 2: .<\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0434\u0432\u043e\u0439\u043a\u0443 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430  \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a  127, \u0438 \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e \u0432\u043b\u0435\u0432\u043e \u043d\u0430 23 \u0431\u0438\u0442\u0430 (\u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e \u043d\u0430 ), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0438\u0442 \u043a\u0430\u043a float \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>\u0411\u0438\u0442\u044b \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430  \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c  \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0443 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f float \u0447\u0438\u0441\u0435\u043b \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430:<\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 , \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0435 , \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p>\u0411\u0438\u0442\u043e\u0432\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f .<\/p>\n<p>\u0422.\u0435. \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430  \u0440\u0430\u0432\u043d\u0430 \u0446\u0435\u043b\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u0431\u0438\u0442\u044b \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u0430 \u044d\u0442\u043e \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0438\u0442 \u043c\u0430\u043d\u0442\u0438\u0441\u0441\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438 , \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e float \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0432\u043d\u043e\u0433\u043e  \u043d\u0430  \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c  \u043d\u0430 . \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u0441 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e  \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 .<\/p>\n<p>\u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f  \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e,  \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0442 0 \u0434\u043e 1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443  \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u043c, \u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u044b \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 float \u0447\u0438\u0441\u0435\u043b \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0415\u0441\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b RISC-V, \u0442\u043e \u0434\u043b\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438 RV32I\/RV64I. \u0414\u043b\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u0441 float \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u201cF\u201d.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c 5-\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u043b\u044f \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/www.sciencedirect.com\/science\/article\/abs\/pii\/S0010218018301652\" rel=\"noopener noreferrer nofollow\">[Perini, 2018]<\/a>:<\/p>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043d\u0430 \u043a\u043e\u043d\u0446\u0430\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 . \u0414\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 5 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 6 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u043d\u043e 6 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 2-x \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430:<\/p>\n<pre><code class=\"cpp\">   const float s1 = 3.06852819440055e-1f;    const float s2 = -2.40226506959101e-1f;    const float s3 = -5.57129652016652e-2f;    const float s4 = -9.01146535969578e-3f;    const float s5 = -1.90188191959304e-3f;<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 5-\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0439. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u043c 3-\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443. \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 5-\u043e\u0439 \u0438 3-\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0435\u0439, \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0443\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430, \u0434\u0430\u044e\u0449\u0430\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 <a href=\"https:\/\/doi.org\/10.1162\/089976699300016467\" rel=\"noopener noreferrer nofollow\">[Schraudolph, 1999]<\/a>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430\u043c\u0438.<\/figcaption><\/div>\n<\/figure>\n<h2>\u0421\u043a\u0430\u043b\u044f\u0440\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 C<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u043a\u0446\u0438\u044e softmax \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u043c C.\u00a0 \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0439\u043a\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 C \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">static float fast_pow2(const float in) {    const float yf = in - (int32_t)(in) + 1;    u_float_int_t value;    value.i32 = (int32_t)((1 &lt;&lt; 23) * (in - delta(yf) + 127.0f));    return value.f32; }<\/code><\/pre>\n<p>\u0413\u0434\u0435 <code>delta(x)<\/code> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u043f\u044f\u0442\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c 2 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c , \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f softmax \u043d\u0430 C \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int32_t scalar_softmax_f32(const float* in_vec, uint32_t size, float* out_vec) {    float max = in_vec[0];    float sum = 0;    for (int i = 1; i &lt; size; ++i) {        if (in_vec[i] &gt; max) {            max = in_vec[i];        }    }    for (int i = 0; i &lt; size; ++i) {        float value = (in_vec[i] - max) * k1OverLn2;        out_vec[i] = fast_pow2(value);        sum += out_vec[i];    }    for (int i = 0; i &lt; size; ++i) {        out_vec[i] = out_vec[i] \/ sum;    }    return 0; }<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 3 \u044d\u0442\u0430\u043f\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f &#8212; \u043f\u043e\u0438\u0441\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043e\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 \u0441\u0443\u043c\u043c\u0443 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>\u042d\u0442\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-462168","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462168","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=462168"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462168\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}