{"id":331674,"date":"2022-04-08T09:00:20","date_gmt":"2022-04-08T09:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331674"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331674","title":{"rendered":"<span>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c GPU-\u0431\u0443\u0444\u0435\u0440\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 TensorFlow Lite<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041e\u043b\u0435\u0433, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0432 VK \u0412\u0438\u0434\u0435\u043e, \u0432\u043d\u0435\u0434\u0440\u044f\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0432 \u041a\u043b\u0438\u043f\u044b \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c TensorFlow Lite \u0441\u0435\u0442\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u2014 \u043a\u0430\u043a \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 CPU- \u0438 GPU- \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 GPU-\u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 TensorFlow Lite.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ba\/857\/843\/1ba857843494c6b0efca97338d77364e.png\" width=\"2308\" height=\"1294\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ba\/857\/843\/1ba857843494c6b0efca97338d77364e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f Android,\u00a0\u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u043e\u0451\u043c\u00a0<a href=\"https:\/\/github.com\/UnickSoft\/examples\/tree\/master\/lite\/examples\/image_segmentation\/android\">GitHub-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<hr\/>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h3>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u041a\u043b\u0438\u043f\u0430\u0445 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440 \u0441 \u043a\u0430\u043c\u0435\u0440\u044b. \u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u043e\u043d\u0430, \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043b\u0438\u0446\u0430 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043d\u0430 \u044d\u0442\u0438\u0445 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b26\/47e\/89e\/b2647e89efca078cb0a6c05f37c713ef.jpeg\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438\" width=\"720\" height=\"587\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b26\/47e\/89e\/b2647e89efca078cb0a6c05f37c713ef.jpeg\" data-blurred=\"true\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/figcaption><\/figure>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044b \u0444\u043e\u0442\u043e \u0432\u0437\u044f\u0442\u044b\u00a0<a href=\"https:\/\/paper.dropbox.com\/ep\/redirect\/external-link?url=https%3A%2F%2Funsplash.com%2Fphotos%2F7YVZYZeITc8&amp;hmac=4y7VnLzUS%2F0ol8M8MlpE9cl9NyYOwkhNg3vUyagqQzI%3D\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/unsplash.com\/photos\/rDEOVtE7vOs\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>\u041a\u0430\u0434\u0440\u044b \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 GPU-\u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 GPU \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Java API TensorFlow Lite \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u0434 Android \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e CPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u0442\u043e TensorFlow \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 CPU-\u0431\u0443\u0444\u0435\u0440\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c GPU, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u2014 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 GPU \u0432 \u043f\u0430\u043c\u044f\u0442\u044c CPU.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a6c\/53a\/1f7\/a6c53a1f75adc19dde1b094b9d461d9d.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435\" title=\"\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435\" width=\"726\" height=\"183\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a6c\/53a\/1f7\/a6c53a1f75adc19dde1b094b9d461d9d.png\"\/><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435<\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00a0\u0438 \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 CPU \u0438 GPU, \u0447\u0442\u043e\u0431\u044b \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430\u00a0\u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cbf\/003\/b8d\/cbf003b8d13e4dadc0c1c193bc2973bf.png\" width=\"572\" height=\"198\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbf\/003\/b8d\/cbf003b8d13e4dadc0c1c193bc2973bf.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GPU-\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 GPU-\u0431\u0443\u0444\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u0430\u043a \u043a\u0430\u043a GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 GPU-\u0431\u0443\u0444\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0432 TensorFlow \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441 C++ API. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 Android, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 TensorFlow Lite \u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0438\u043c \u0447\u0435\u0440\u0435\u0437 JNI-\u043e\u0431\u0451\u0440\u0442\u043a\u0443.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e C++ API \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 Android, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0437\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u0421\u0431\u043e\u0440\u043a\u0430 TensorFlow Lite<\/h3>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 TensorFlow Lite \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c: <a href=\"https:\/\/www.tensorflow.org\/install\/source_windows\"><u>tensorflow.org\/install\/source_windows<\/u><\/a> \u0438\u043b\u0438\u00a0<a href=\"https:\/\/www.tensorflow.org\/install\/source\"><u>tensorflow.org\/install\/source<\/u><\/a>.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Bazel, \u043f\u0430\u0440\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0434\u043b\u044f Python \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00abWould you like to interactively configure .\/WORKSPACE for Android builds? [y\/N]\u00bb \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u00abYes\u00bb.<\/p>\n<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: libtensorflowlite.so \u0438 libtensorflowlite_gpu_delegate.so. \u041f\u0435\u0440\u0432\u0430\u044f \u2014 \u044d\u0442\u043e \u0441\u0430\u043c TensorFlow Lite, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442.<\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">bazel build \/\/tensorflow\/lite:libtensorflowlite.so \\       --crosstool_top=\/\/external:android\/crosstool \\       --cpu=arm64-v8a \\       --host_crosstool_top=@bazel_tools\/\/tools\/cpp:toolchain \\       --cxxopt=\"-std=gnu++14\" \\       --define=tflite_with_ruy=true \\       --verbose_failures \\       -c opt bazel build \/\/tensorflow\/lite\/delegates\/gpu:libtensorflowlite_gpu_delegate.so \\       --crosstool_top=\/\/external:android\/crosstool \\       --cpu=arm64-v8a \\       --host_crosstool_top=@bazel_tools\/\/tools\/cpp:toolchain \\             --cxxopt=\"-std=gnu++14\" \\       --verbose_failures \\       -c opt<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0442\u0443\u0442:\u00a0<\/p>\n<pre><code class=\"bash\">.\/bazel-out\/${arch}-${lib_suffix}\/bin\/tensorflow\/lite\/libtensorflowlite.so .\/bazel-out\/${arch}-${lib_suffix}\/bin\/tensorflow\/lite\/delegates\/gpu\/libtensorflowlite_gpu_delegate.so<\/code><\/pre>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0432\u0441\u0435 .h-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 tensorflow\/tensorflow\/lite.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Android<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TensorFlow Lite GPU \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c C++ API, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/google\/mediapipe\/blob\/1faeaae7e504657f44544989f9547fc69652e487\/mediapipe\/util\/tflite\/tflite_gpu_runner.cc\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 MediaPipe<\/a>. \u041d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043d\u0451\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<h4>1. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430.<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c <code>tflite::gpu::TFLiteGPURunner<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>tflite::gpu::InferenceOptions<\/code>. \u0417\u0430\u0442\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>BuildFromFlatBuffer<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u0432\u0430 \u0433\u0440\u0430\u0444\u0430 \u0434\u043b\u044f OpenGL \u0438 OpenCL. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0442\u043a\u0443 \u043d\u0430 OpenCL, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u0448\u043b\u043e, \u0442\u043e \u043d\u0430 OpenGL ES. \u041d\u0430 OpenCL, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u043d\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GPU-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043b\u044f OpenGL \u0438\u043b\u0438 OpenCL \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<ul>\n<li>\n<p>OpenGL:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">MP_RETURN_IF_ERROR(    NewInferenceEnvironment(env_options, &amp;gl_environment_, &amp;properties).ok()); MP_RETURN_IF_ERROR(gl_environment_->NewInferenceBuilder(std::move(*graph_gl_),                                                        gl_options, builder).ok());<\/code><\/pre>\n<ul>\n<li>\n<p>OpenCL:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">MP_RETURN_IF_ERROR(cl::NewInferenceEnvironment(env_options, &amp;cl_environment_, &amp;properties).ok()); MP_RETURN_IF_ERROR(cl_environment_->NewInferenceBuilder(    cl_options, std::move(*graph_cl_), builder).ok());<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c GPU \u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0432 \u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0433\u0434\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d OpenGL ES \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 GPU-\u0431\u0443\u0444\u0435\u0440\u044b.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u0451\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">for (int flow_index = 0; flow_index &lt; input_shapes_.size(); ++flow_index) {  MP_RETURN_IF_ERROR(builder->SetInputObjectDef(      flow_index, GetSSBOObjectDef(input_shapes_[flow_index].c)).ok()); } for (int flow_index = 0; flow_index &lt; output_shapes_.size(); ++flow_index) {  MP_RETURN_IF_ERROR(builder->SetOutputObjectDef(      flow_index, GetSSBOObjectDef(output_shapes_[flow_index].c)).ok()); }<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u0437\u0434\u0430\u0451\u043c InferenceRunner:<\/p>\n<pre><code>return builder->Build(&amp;runner_).ok();<\/code><\/pre>\n<h4>2. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h4>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0438 \u0432\u044b\u0445\u043e\u0434 GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 SSBO (<a href=\"https:\/\/www.khronos.org\/opengl\/wiki\/Shader_Storage_Buffer_Object\">Shader Storage Buffer Object<\/a>) \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0442 \u0431\u0443\u0444\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0441 \u0442\u0440\u0435\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0446\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"cpp\">#version 310 es layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D u_Texture0; layout(std430) buffer; layout(binding = 1) buffer Output { float elements[]; } output_data; uniform int u_width; uniform int u_height;  void main() {     ivec2 gid = ivec2(gl_GlobalInvocationID.xy);     if (gid.x >= u_width || gid.y >= u_height) return;     vec3 pixel = texelFetch(u_Texture0, gid, 0).xyz;     int linear_index = 3 * (gid.y * u_width + gid.x);     output_data.elements[linear_index + 0] = pixel.x;     output_data.elements[linear_index + 1] = pixel.y;     output_data.elements[linear_index + 2] = pixel.z;     \/\/output_data.elements[linear_index + 3] = 0.0; }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u043d\u0430\u043b\u0430, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u00ab3\u00bb \u043d\u0430 \u00ab4\u00bb \u0432 \u0441\u0442\u0440\u043e\u043a\u0435: <code>int linear_index = 3 * (gid.y * u_width + gid.x);<\/code>.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440:<\/p>\n<pre><code class=\"java\">GLES31.glActiveTexture(GLES31.GL_TEXTURE0 + 0); GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, textureId); GLES31.glBindBufferRange(GLES31.GL_SHADER_STORAGE_BUFFER, 1, bufferId, 0, bufferSize); GLES31.glDispatchCompute(texWidth \/ 8, texHeight \/ 8, 1); GLES31.glBindBuffer(GLES31.GL_SHADER_STORAGE_BUFFER, 0); GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); GLES31.glMemoryBarrier(GLES31.GL_ALL_BARRIER_BITS);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b TensorFlow \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u0432 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u043d\u0434\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0431\u0443\u0444\u0435\u0440\u044b:<\/p>\n<pre><code class=\"kotlin\">nativeRunner!!.bindInput(0, inputBuffer) nativeRunner!!.bindOutput(0, outputBuffer)<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0431\u0443\u0444\u0435\u0440\u044b, \u0442\u043e \u0431\u0438\u043d\u0434\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<h4>3. \u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0442\u043a\u0438.<\/h4>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u00a0<code>runner_->Run()<\/code>.<\/p>\n<h4>4. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h4>\n<p>\u0412 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0445 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 CPU-\u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u00a0\u043a\u043e\u0434\u0430\u00a0\u0438 \u0437\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/github.com\/UnickSoft\/examples\/tree\/master\/lite\/examples\/image_segmentation\/android\">\u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 GitHub<\/a>. \u042d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 TensorFlow, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u043d\u0430 GPU \u0447\u0435\u0440\u0435\u0437 Java API (\u0441 CPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438) \u0438\u043b\u0438 C++ API (\u0441 GPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438). \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 <code>ImageSegmentationModelExecutorGPUPass<\/code> \u0438 \u0438\u0437 C++ \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 CPU-\u0431\u0443\u0444\u0435\u0440 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u2014 \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u0440\u0438\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0438 \u0441\u0435\u0442\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 Java API (\u0441 CPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438) \u0438 \u0447\u0435\u0440\u0435\u0437 C++ API (\u0441 GPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/892\/576\/b5e\/892576b5ee78f0e87540277080b61d1f.png\" width=\"720\" height=\"680\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/892\/576\/b5e\/892576b5ee78f0e87540277080b61d1f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 Model execution time:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">API<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f Model execution time\u00a0(\u043c\u0441)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Java<\/p>\n<\/td>\n<td>\n<p align=\"left\">120<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">C++<\/p>\n<\/td>\n<td>\n<p align=\"left\">8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <strong>\u0432 15 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/strong>. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u0414\u043b\u044f GPU-\u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0437\u0430\u043c\u0435\u0440\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 CPU \u0432 GPU \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e (Manual push data GPU time \u0438 Manual pull data from GPU time). \u041f\u0440\u0438\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f C++ API \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0436\u0435 \u0432 108 \u043c\u0441, \u0447\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043b\u0438\u0436\u0435 \u043a 120 \u043c\u0441. \u0425\u043e\u0442\u044f \u043f\u043e \u0438\u0434\u0435\u0435 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Java API: \u0432\u0435\u0434\u044c TensorFlow \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 CPU \u0438 GPU. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 12 \u043c\u0441 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 C++ API \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 CPU \u0432 GPU, \u0430 TensorFlow \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 float-\u0431\u0443\u0444\u0435\u0440, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u0430 \u043e\u043d \u0432 4 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443).<\/p>\n<p>\u0418\u0437 \u0437\u0430\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 TensorFlow \u0438 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU, \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0430\u043c\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u2014 \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 5 \u041c\u0431\u0430\u0439\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043c\u0430\u0441\u043a\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0437\u043a\u043e\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u2014 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 (\u0432 15 \u0440\u0430\u0437) \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU. \u041d\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 1,5\u20132 \u0440\u0430\u0437\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0440\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u0442\u043e \u043f\u0440\u044f\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u0430 \u0435\u0449\u0451 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0420\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0435 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 CPU, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:\u00a0<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/54e\/688\/4a3\/54e6884a3e93f9c88dd106be4e18149d.png\" width=\"360\" height=\"676\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/54e\/688\/4a3\/54e6884a3e93f9c88dd106be4e18149d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Model execution time \u0440\u0430\u0432\u043d\u043e 77 \u043c\u0441, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 GPU-\u0432\u0435\u0440\u0441\u0438\u0438, \u0433\u0434\u0435 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043e\u043d\u0443\u0441<\/h3>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f: \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 (\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441\u0442\u0430\u0440\u044b\u0445) \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430\u0445 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0438 \u0434\u043e 10 \u0441\u0435\u043a\u0443\u043d\u0434, \u0445\u043e\u0442\u044f \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u043e\u043b\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041d\u043e \u0435\u0441\u043b\u0438 GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 OpenCL \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0435\u0448\u0430 \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 2\u20133 \u0440\u0430\u0437\u0430. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u0435\u0448 \u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">void SetSerializedBinaryCache(std::vector&lt;uint8_t>&amp;&amp; cache); std::vector&lt;uint8_t> GetSerializedBinaryCache();<\/code><\/pre>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043a\u0435\u0448 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0438 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0427\u0442\u043e \u0441 iOS?<\/h3>\n<p>\u0421\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u0434\u0443 \u0432 MediaPipe \u043f\u043e\u0434 iOS, \u0442\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c Metal-\u0431\u0443\u0444\u0435\u0440\u044b. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0435\u0441\u0442\u044c <a href=\"https:\/\/github.com\/google\/mediapipe\/blob\/710fb3de58dc10b7bc75f9cb758300c9016a5e4f\/mediapipe\/calculators\/tflite\/tflite_inference_calculator.cc\">\u043d\u0430 GitHub<\/a>.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 C++ API \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 TensorFlow Lite. \u042d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0447\u0435\u043c Java API, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c GPU-\u0431\u0443\u0444\u0435\u0440\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 TensorFlow \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 CPU- \u0438 GPU-\u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0438 C++ API \u0434\u0430\u0441\u0442 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435. \u0410 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0435\u0448\u0430 \u0434\u043b\u044f OpenCL \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0435\u0449\u0451 \u0438 \u0441\u0442\u0430\u0440\u0442 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u043d\u0430 GPU.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0432 \u0432\u0430\u0448\u0435\u043c Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 TensorFlow Lite C++ API \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u0440\u0438\u043d\u0435\u0441\u0451\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u043e\u0436\u043d\u043e\u00a0<a href=\"https:\/\/github.com\/UnickSoft\/examples\/tree\/master\/lite\/examples\/image_segmentation\/android\">\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u00a0\u043d\u0430 GitHub<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/vk\/blog\/659643\/\"> https:\/\/habr.com\/ru\/company\/vk\/blog\/659643\/<\/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_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041e\u043b\u0435\u0433, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0432 VK \u0412\u0438\u0434\u0435\u043e, \u0432\u043d\u0435\u0434\u0440\u044f\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0432 \u041a\u043b\u0438\u043f\u044b \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c TensorFlow Lite \u0441\u0435\u0442\u043a\u0443 \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u2014 \u043a\u0430\u043a \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 CPU- \u0438 GPU- \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 GPU-\u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 TensorFlow Lite.\u00a0<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f Android,\u00a0\u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u043e\u0451\u043c\u00a0<a href=\"https:\/\/github.com\/UnickSoft\/examples\/tree\/master\/lite\/examples\/image_segmentation\/android\">GitHub-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<hr\/>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h3>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u041a\u043b\u0438\u043f\u0430\u0445 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440 \u0441 \u043a\u0430\u043c\u0435\u0440\u044b. \u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u043e\u043d\u0430, \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043b\u0438\u0446\u0430 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043d\u0430 \u044d\u0442\u0438\u0445 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445.<\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/figcaption><\/figure>\n<p>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044b \u0444\u043e\u0442\u043e \u0432\u0437\u044f\u0442\u044b\u00a0<a href=\"https:\/\/paper.dropbox.com\/ep\/redirect\/external-link?url=https%3A%2F%2Funsplash.com%2Fphotos%2F7YVZYZeITc8&amp;hmac=4y7VnLzUS%2F0ol8M8MlpE9cl9NyYOwkhNg3vUyagqQzI%3D\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/unsplash.com\/photos\/rDEOVtE7vOs\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>\u041a\u0430\u0434\u0440\u044b \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 GPU-\u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 GPU \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Java API TensorFlow Lite \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u0434 Android \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e CPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u0442\u043e TensorFlow \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 CPU-\u0431\u0443\u0444\u0435\u0440\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c GPU, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u2014 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 GPU \u0432 \u043f\u0430\u043c\u044f\u0442\u044c CPU.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435<\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00a0\u0438 \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 CPU \u0438 GPU, \u0447\u0442\u043e\u0431\u044b \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430\u00a0\u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GPU-\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 GPU-\u0431\u0443\u0444\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u0430\u043a \u043a\u0430\u043a GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 GPU-\u0431\u0443\u0444\u0435\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0432 TensorFlow \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441 C++ API. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 Android, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 TensorFlow Lite \u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0438\u043c \u0447\u0435\u0440\u0435\u0437 JNI-\u043e\u0431\u0451\u0440\u0442\u043a\u0443.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e C++ API \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 Android, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0437\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u0421\u0431\u043e\u0440\u043a\u0430 TensorFlow Lite<\/h3>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 TensorFlow Lite \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c: <a href=\"https:\/\/www.tensorflow.org\/install\/source_windows\"><u>tensorflow.org\/install\/source_windows<\/u><\/a> \u0438\u043b\u0438\u00a0<a href=\"https:\/\/www.tensorflow.org\/install\/source\"><u>tensorflow.org\/install\/source<\/u><\/a>.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Bazel, \u043f\u0430\u0440\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0434\u043b\u044f Python \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00abWould you like to interactively configure .\/WORKSPACE for Android builds? [y\/N]\u00bb \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u00abYes\u00bb.<\/p>\n<p>\u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: libtensorflowlite.so \u0438 libtensorflowlite_gpu_delegate.so. \u041f\u0435\u0440\u0432\u0430\u044f \u2014 \u044d\u0442\u043e \u0441\u0430\u043c TensorFlow Lite, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442.<\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">bazel build \/\/tensorflow\/lite:libtensorflowlite.so \\       --crosstool_top=\/\/external:android\/crosstool \\       --cpu=arm64-v8a \\       --host_crosstool_top=@bazel_tools\/\/tools\/cpp:toolchain \\       --cxxopt=\"-std=gnu++14\" \\       --define=tflite_with_ruy=true \\       --verbose_failures \\       -c opt bazel build \/\/tensorflow\/lite\/delegates\/gpu:libtensorflowlite_gpu_delegate.so \\       --crosstool_top=\/\/external:android\/crosstool \\       --cpu=arm64-v8a \\       --host_crosstool_top=@bazel_tools\/\/tools\/cpp:toolchain \\             --cxxopt=\"-std=gnu++14\" \\       --verbose_failures \\       -c opt<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0442\u0443\u0442:\u00a0<\/p>\n<pre><code class=\"bash\">.\/bazel-out\/${arch}-${lib_suffix}\/bin\/tensorflow\/lite\/libtensorflowlite.so .\/bazel-out\/${arch}-${lib_suffix}\/bin\/tensorflow\/lite\/delegates\/gpu\/libtensorflowlite_gpu_delegate.so<\/code><\/pre>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0432\u0441\u0435 .h-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 tensorflow\/tensorflow\/lite.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Android<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TensorFlow Lite GPU \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c C++ API, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/google\/mediapipe\/blob\/1faeaae7e504657f44544989f9547fc69652e487\/mediapipe\/util\/tflite\/tflite_gpu_runner.cc\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 MediaPipe<\/a>. \u041d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043d\u0451\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<h4>1. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430.<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c <code>tflite::gpu::TFLiteGPURunner<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <code>tflite::gpu::InferenceOptions<\/code>. \u0417\u0430\u0442\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>BuildFromFlatBuffer<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u0432\u0430 \u0433\u0440\u0430\u0444\u0430 \u0434\u043b\u044f OpenGL \u0438 OpenCL. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0442\u043a\u0443 \u043d\u0430 OpenCL, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u0448\u043b\u043e, \u0442\u043e \u043d\u0430 OpenGL ES. \u041d\u0430 OpenCL, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u043d\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 GPU-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043b\u044f OpenGL \u0438\u043b\u0438 OpenCL \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<ul>\n<li>\n<p>OpenGL:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">MP_RETURN_IF_ERROR(    NewInferenceEnvironment(env_options, &amp;gl_environment_, &amp;properties).ok()); MP_RETURN_IF_ERROR(gl_environment_->NewInferenceBuilder(std::move(*graph_gl_),                                                        gl_options, builder).ok());<\/code><\/pre>\n<ul>\n<li>\n<p>OpenCL:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">MP_RETURN_IF_ERROR(cl::NewInferenceEnvironment(env_options, &amp;cl_environment_, &amp;properties).ok()); MP_RETURN_IF_ERROR(cl_environment_->NewInferenceBuilder(    cl_options, std::move(*graph_cl_), builder).ok());<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c GPU \u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0432 \u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0433\u0434\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d OpenGL ES \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 GPU-\u0431\u0443\u0444\u0435\u0440\u044b.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u0451\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">for (int flow_index = 0; flow_index &lt; input_shapes_.size(); ++flow_index) {  MP_RETURN_IF_ERROR(builder->SetInputObjectDef(      flow_index, GetSSBOObjectDef(input_shapes_[flow_index].c)).ok()); } for (int flow_index = 0; flow_index &lt; output_shapes_.size(); ++flow_index) {  MP_RETURN_IF_ERROR(builder->SetOutputObjectDef(      flow_index, GetSSBOObjectDef(output_shapes_[flow_index].c)).ok()); }<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u0437\u0434\u0430\u0451\u043c InferenceRunner:<\/p>\n<pre><code>return builder->Build(&amp;runner_).ok();<\/code><\/pre>\n<h4>2. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h4>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0438 \u0432\u044b\u0445\u043e\u0434 GPU-\u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 SSBO (<a href=\"https:\/\/www.khronos.org\/opengl\/wiki\/Shader_Storage_Buffer_Object\">Shader Storage Buffer Object<\/a>) \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0442 \u0431\u0443\u0444\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432 \u0431\u0443\u0444\u0435\u0440 \u0441 \u0442\u0440\u0435\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0446\u0432\u0435\u0442\u0430:<\/p>\n<pre><code class=\"cpp\">#version 310 es layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D u_Texture0; layout(std430) buffer; layout(binding = 1) buffer Output { float elements[]; } output_data; uniform int u_width; uniform int u_height;  void main() {     ivec2 gid = ivec2(gl_GlobalInvocationID.xy);     if (gid.x >= u_width || gid.y >= u_height) return;     vec3 pixel = texelFetch(u_Texture0, gid, 0).xyz;     int linear_index = 3 * (gid.y * u_width + gid.x);     output_data.elements[linear_index + 0] = pixel.x;     output_data.elements[linear_index + 1] = pixel.y;     output_data.elements[linear_index + 2] = pixel.z;     \/\/output_data.elements[linear_index + 3] = 0.0; }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u043d\u0430\u043b\u0430, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u00ab3\u00bb \u043d\u0430 \u00ab4\u00bb \u0432 \u0441\u0442\u0440\u043e\u043a\u0435: <code>int linear_index = 3 * (gid.y * u_width + gid.x);<\/code>.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440:<\/p>\n<pre><code class=\"java\">GLES31.glActiveTexture(GLES31.GL_TEXTURE0 + 0); GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, textureId); GLES31.glBindBufferRange(GLES31.GL_SHADER_STORAGE_BUFFER, 1, bufferId, 0, bufferSize); GLES31.glDispatchCompute(texWidth \/ 8, texHeight \/ 8, 1); GLES31.glBindBuffer(GLES31.GL_SHADER_STORAGE_BUFFER, 0); GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); GLES31.glMemoryBarrier(GLES31.GL_ALL_BARRIER_BITS);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b TensorFlow \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u0432 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u043d\u0434\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0431\u0443\u0444\u0435\u0440\u044b:<\/p>\n<pre><code class=\"kotlin\">nativeRunner!!.bindInput(0, inputBuffer) nativeRunner!!.bindOutput(0, outputBuffer)<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0431\u0443\u0444\u0435\u0440\u044b, \u0442\u043e \u0431\u0438\u043d\u0434\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<h4>3. \u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0442\u043a\u0438.<\/h4>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u00a0<code>runner_->Run()<\/code>.<\/p>\n<h4>4. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/h4>\n<p>\u0412 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0431\u0443\u0444\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438\u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0445 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 CPU-\u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u00a0\u043a\u043e\u0434\u0430\u00a0\u0438 \u0437\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/github.com\/UnickSoft\/examples\/tree\/master\/lite\/examples\/image_segmentation\/android\">\u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 GitHub<\/a>. \u042d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 TensorFlow, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u043d\u0430 GPU \u0447\u0435\u0440\u0435\u0437 Java API (\u0441 CPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438) \u0438\u043b\u0438 C++ API (\u0441 GPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438). \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 <code>ImageSegmentationModelExecutorGPUPass<\/code> \u0438 \u0438\u0437 C++ \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 CPU-\u0431\u0443\u0444\u0435\u0440 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u2014 \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043c\u0435\u0440\u0438\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0438 \u0441\u0435\u0442\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 Java API (\u0441 CPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438) \u0438 \u0447\u0435\u0440\u0435\u0437 C++ API (\u0441 GPU-\u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438).<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 Model execution time:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">API<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f Model execution time\u00a0(\u043c\u0441)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Java<\/p>\n<\/td>\n<td>\n<p align=\"left\">120<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">C++<\/p>\n<\/td>\n<td>\n<p align=\"left\">8<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <strong>\u0432 15 \u0440\u0430\u0437 \u0431\u044b\u0441\u0442\u0440\u0435\u0435<\/strong>. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u0414\u043b\u044f GPU-\u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0437\u0430\u043c\u0435\u0440\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 CPU \u0432 GPU \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e (Manual push data GPU time \u0438 Manual pull data from GPU time). \u041f\u0440\u0438\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f C++ API \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0436\u0435 \u0432 108 \u043c\u0441, \u0447\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043b\u0438\u0436\u0435 \u043a 120 \u043c\u0441. \u0425\u043e\u0442\u044f \u043f\u043e \u0438\u0434\u0435\u0435 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Java API: \u0432\u0435\u0434\u044c TensorFlow \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 CPU \u0438 GPU. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 12 \u043c\u0441 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 C++ API \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 CPU \u0432 GPU, \u0430 TensorFlow \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 float-\u0431\u0443\u0444\u0435\u0440, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u0430 \u043e\u043d \u0432 4 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443).<\/p>\n<p>\u0418\u0437 \u0437\u0430\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 TensorFlow \u0438 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU, \u0447\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0430\u043c\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u2014 \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 5 \u041c\u0431\u0430\u0439\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043c\u0430\u0441\u043a\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0434\u0432\u0430\u0434\u0446\u0430\u0442\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0437\u043a\u043e\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u2014 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 (\u0432 15 \u0440\u0430\u0437) \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU. \u041d\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 1,5\u20132 \u0440\u0430\u0437\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0440\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c, \u0442\u043e \u043f\u0440\u044f\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 GPU-\u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u0430 \u0435\u0449\u0451 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0420\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0435 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 CPU, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:\u00a0<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>Model execution time \u0440\u0430\u0432\u043d\u043e 77 \u043c\u0441, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 GPU-\u0432\u0435\u0440\u0441\u0438\u0438, \u0433\u0434\u0435 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 GPU \u0438 CPU.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c<\/h><\/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-331674","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331674","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=331674"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331674\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}