CINXE.COM

Get started with LiteRT  |  Google AI Edge  |  Google AI for Developers

<!doctype html> <html lang="en" dir="ltr"> <head> <meta name="google-signin-client-id" content="157101835696-ooapojlodmuabs2do2vuhhnf90bccmoi.apps.googleusercontent.com"> <meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award"> <meta property="og:site_name" content="Google AI for Developers"> <meta property="og:type" content="website"><meta name="theme-color" content="#1967d2"><meta charset="utf-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="manifest" href="/_pwa/googledevai/manifest.json" crossorigin="use-credentials"> <link rel="preconnect" href="//www.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.gstatic.com" crossorigin> <link rel="preconnect" href="//fonts.googleapis.com" crossorigin> <link rel="preconnect" href="//apis.google.com" crossorigin> <link rel="preconnect" href="//www.google-analytics.com" crossorigin><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"> <link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block"><link rel="stylesheet" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/css/app.css"> <link rel="shortcut icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/favicon-new.png"> <link rel="apple-touch-icon" href="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/touchicon-180-new.png"><link rel="canonical" href="https://ai.google.dev/edge/litert/inference"><link rel="search" type="application/opensearchdescription+xml" title="Google AI for Developers" href="https://ai.google.dev/s/opensearch.xml"> <link rel="alternate" hreflang="en" href="https://ai.google.dev/edge/litert/inference" /><link rel="alternate" hreflang="x-default" href="https://ai.google.dev/edge/litert/inference" /><link rel="alternate" hreflang="ar" href="https://ai.google.dev/edge/litert/inference?hl=ar" /><link rel="alternate" hreflang="bn" href="https://ai.google.dev/edge/litert/inference?hl=bn" /><link rel="alternate" hreflang="zh-Hans" href="https://ai.google.dev/edge/litert/inference?hl=zh-cn" /><link rel="alternate" hreflang="zh-Hant" href="https://ai.google.dev/edge/litert/inference?hl=zh-tw" /><link rel="alternate" hreflang="fa" href="https://ai.google.dev/edge/litert/inference?hl=fa" /><link rel="alternate" hreflang="fr" href="https://ai.google.dev/edge/litert/inference?hl=fr" /><link rel="alternate" hreflang="de" href="https://ai.google.dev/edge/litert/inference?hl=de" /><link rel="alternate" hreflang="he" href="https://ai.google.dev/edge/litert/inference?hl=he" /><link rel="alternate" hreflang="hi" href="https://ai.google.dev/edge/litert/inference?hl=hi" /><link rel="alternate" hreflang="id" href="https://ai.google.dev/edge/litert/inference?hl=id" /><link rel="alternate" hreflang="it" href="https://ai.google.dev/edge/litert/inference?hl=it" /><link rel="alternate" hreflang="ja" href="https://ai.google.dev/edge/litert/inference?hl=ja" /><link rel="alternate" hreflang="ko" href="https://ai.google.dev/edge/litert/inference?hl=ko" /><link rel="alternate" hreflang="pl" href="https://ai.google.dev/edge/litert/inference?hl=pl" /><link rel="alternate" hreflang="pt-BR" href="https://ai.google.dev/edge/litert/inference?hl=pt-br" /><link rel="alternate" hreflang="ru" href="https://ai.google.dev/edge/litert/inference?hl=ru" /><link rel="alternate" hreflang="es-419" href="https://ai.google.dev/edge/litert/inference?hl=es-419" /><link rel="alternate" hreflang="th" href="https://ai.google.dev/edge/litert/inference?hl=th" /><link rel="alternate" hreflang="tr" href="https://ai.google.dev/edge/litert/inference?hl=tr" /><link rel="alternate" hreflang="vi" href="https://ai.google.dev/edge/litert/inference?hl=vi" /><title>Get started with LiteRT &nbsp;|&nbsp; Google AI Edge &nbsp;|&nbsp; Google AI for Developers</title> <meta property="og:title" content="Get started with LiteRT &nbsp;|&nbsp; Google AI Edge &nbsp;|&nbsp; Google AI for Developers"><meta property="og:url" content="https://ai.google.dev/edge/litert/inference"><meta property="og:image" content="https://ai.google.dev/static/site-assets/images/share.png"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="675"><meta property="og:locale" content="en"><meta name="twitter:card" content="summary_large_image"><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Article", "headline": "Get started with LiteRT" } </script><script type="application/ld+json"> { "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Google AI Edge", "item": "https://ai.google.dev/edge" },{ "@type": "ListItem", "position": 2, "name": "Get started with LiteRT", "item": "https://ai.google.dev/edge/litert/inference" }] } </script> <link rel="stylesheet" href="/extras.css"></head> <body class="" template="page" theme="googledevai-theme" type="article" layout="docs" display-toc pending> <devsite-progress type="indeterminate" id="app-progress"></devsite-progress> <section class="devsite-wrapper"> <devsite-cookie-notification-bar></devsite-cookie-notification-bar><devsite-header role="banner" keep-tabs-visible> <div class="devsite-header--inner nocontent"> <div class="devsite-top-logo-row-wrapper-wrapper"> <div class="devsite-top-logo-row-wrapper"> <div class="devsite-top-logo-row"> <button type="button" id="devsite-hamburger-menu" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Navigation menu button" visually-hidden aria-label="Open menu"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="googleAIEdge" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://ai.google.dev/_static/googledevai/images/lockup-new.svg" class="devsite-site-logo" alt="Google AI Edge"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item devsite-has-google-wordmark"> </li> </ul> </span> </div> <div class="devsite-top-logo-row-middle"> <div class="devsite-header-upper-tabs"> <devsite-tabs class="upper-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Upper tabs"> <tab > <a href="https://ai.google.dev/gemini-api" track-metadata-eventdetail="https://ai.google.dev/gemini-api" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - gemini api" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Gemini API" track-name="gemini api" > Gemini API </a> </tab> <tab > <a href="https://ai.google.dev/gemma" track-metadata-eventdetail="https://ai.google.dev/gemma" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - gemma" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Gemma" track-name="gemma" > Gemma </a> </tab> <tab class="devsite-active"> <a href="https://ai.google.dev/edge" track-metadata-eventdetail="https://ai.google.dev/edge" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - google ai edge" track-metadata-module="primary nav" aria-label="Google AI Edge, selected" data-category="Site-Wide Custom Events" data-label="Tab: Google AI Edge" track-name="google ai edge" > Google AI Edge </a> </tab> <tab class="devsite-dropdown "> <span class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - tools" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Tools" track-name="tools" > Tools </span> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for Tools" track-type="nav" track-metadata-eventdetail="" track-metadata-position="nav - tools" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Tools" track-name="tools" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://ai.google.dev/responsible" track-type="nav" track-metadata-eventdetail="https://ai.google.dev/responsible" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Responsible GenAI Toolkit </div> </a> </li> <li class="devsite-nav-item"> <a href="https://colab.google/" track-type="nav" track-metadata-eventdetail="https://colab.google/" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Colab </div> </a> </li> <li class="devsite-nav-item"> <a href="https://firebase.google.com/docs/genkit" track-type="nav" track-metadata-eventdetail="https://firebase.google.com/docs/genkit" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Firebase Genkit </div> </a> </li> <li class="devsite-nav-item"> <a href="https://jax.readthedocs.io/" track-type="nav" track-metadata-eventdetail="https://jax.readthedocs.io/" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> JAX </div> </a> </li> <li class="devsite-nav-item"> <a href="https://keras.io/" track-type="nav" track-metadata-eventdetail="https://keras.io/" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> Keras </div> </a> </li> <li class="devsite-nav-item"> <a href="https://www.tensorflow.org/" track-type="nav" track-metadata-eventdetail="https://www.tensorflow.org/" track-metadata-position="nav - tools" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> TensorFlow </div> </a> </li> </ul> </div> </div> </div> </tab> <tab > <a href="https://discuss.ai.google.dev/" track-metadata-eventdetail="https://discuss.ai.google.dev/" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - community" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" > Community </a> </tab> </nav> </devsite-tabs> </div> <devsite-search enable-signin enable-search enable-suggestions enable-query-completion project-name="Google AI Edge" tenant-name="Google AI for Developers" > <form class="devsite-search-form" action="https://ai.google.dev/s/results" method="GET"> <div class="devsite-search-container"> <button type="button" search-open class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Open search"></button> <div class="devsite-searchbox"> <input aria-activedescendant="" aria-autocomplete="list" aria-label="Search" aria-expanded="false" aria-haspopup="listbox" autocomplete="off" class="devsite-search-field devsite-search-query" name="q" placeholder="Search" role="combobox" type="text" value="" > <div class="devsite-search-image material-icons" aria-hidden="true"> </div> <div class="devsite-search-shortcut-icon-container" aria-hidden="true"> <kbd class="devsite-search-shortcut-icon">/</kbd> </div> </div> </div> </form> <button type="button" search-close class="devsite-search-button devsite-header-icon-button button-flat material-icons" aria-label="Close search"></button> </devsite-search> </div> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="de" >Deutsch</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="fr" >Français</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="it" >Italiano</a> </li> <li role="presentation"> <a role="menuitem" lang="pl" >Polski</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="ru" >Русский</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> <devsite-user enable-profiles id="devsite-user"> <span class="button devsite-top-button" aria-hidden="true" visually-hidden>Sign in</span> </devsite-user> </div> </div> </div> <div class="devsite-collapsible-section "> <div class="devsite-header-background"> <div class="devsite-doc-set-nav-row"> <devsite-tabs class="lower-tabs"> <nav class="devsite-tabs-wrapper" aria-label="Lower tabs"> <tab > <a href="https://ai.google.dev/edge" track-metadata-eventdetail="https://ai.google.dev/edge" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - overview" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Overview" track-name="overview" > Overview </a> </tab> <tab class="devsite-dropdown "> <span class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - mediapipe" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: MediaPipe" track-name="mediapipe" > MediaPipe </span> <a href="#" role="button" aria-haspopup="true" aria-expanded="false" aria-label="Dropdown menu for MediaPipe" track-type="nav" track-metadata-eventdetail="" track-metadata-position="nav - mediapipe" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: MediaPipe" track-name="mediapipe" class="devsite-tabs-dropdown-toggle devsite-icon devsite-icon-arrow-drop-down"></a> <div class="devsite-tabs-dropdown" aria-label="submenu" hidden> <div class="devsite-tabs-dropdown-content"> <div class="devsite-tabs-dropdown-column "> <ul class="devsite-tabs-dropdown-section "> <li class="devsite-nav-item"> <a href="https://ai.google.dev/edge/mediapipe/solutions/guide" track-type="nav" track-metadata-eventdetail="https://ai.google.dev/edge/mediapipe/solutions/guide" track-metadata-position="nav - mediapipe" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> MediaPipe Solutions </div> </a> </li> <li class="devsite-nav-item"> <a href="https://ai.google.dev/edge/mediapipe/framework" track-type="nav" track-metadata-eventdetail="https://ai.google.dev/edge/mediapipe/framework" track-metadata-position="nav - mediapipe" track-metadata-module="tertiary nav" tooltip > <div class="devsite-nav-item-title"> MediaPipe Framework </div> </a> </li> </ul> </div> </div> </div> </tab> <tab class="devsite-active"> <a href="https://ai.google.dev/edge/litert" track-metadata-eventdetail="https://ai.google.dev/edge/litert" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - litert" track-metadata-module="primary nav" aria-label="LiteRT, selected" data-category="Site-Wide Custom Events" data-label="Tab: LiteRT" track-name="litert" > LiteRT </a> </tab> <tab > <a href="https://ai.google.dev/edge/mediapipe/solutions/guide" track-metadata-eventdetail="https://ai.google.dev/edge/mediapipe/solutions/guide" class="devsite-tabs-content gc-analytics-event gemini-hidden-tab" track-type="nav" track-metadata-position="nav - solutions" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Solutions" track-name="solutions" > Solutions </a> </tab> <tab > <a href="https://ai.google.dev/edge/mediapipe/framework" track-metadata-eventdetail="https://ai.google.dev/edge/mediapipe/framework" class="devsite-tabs-content gc-analytics-event gemini-hidden-tab" track-type="nav" track-metadata-position="nav - framework" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Framework" track-name="framework" > Framework </a> </tab> <tab > <a href="https://ai.google.dev/edge/model-explorer" track-metadata-eventdetail="https://ai.google.dev/edge/model-explorer" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - model explorer" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: Model Explorer" track-name="model explorer" > Model Explorer </a> </tab> <tab > <a href="https://ai.google.dev/edge/api" track-metadata-eventdetail="https://ai.google.dev/edge/api" class="devsite-tabs-content gc-analytics-event " track-type="nav" track-metadata-position="nav - api reference" track-metadata-module="primary nav" data-category="Site-Wide Custom Events" data-label="Tab: API Reference" track-name="api reference" > API Reference </a> </tab> </nav> </devsite-tabs> </div> </div> </div> </div> </devsite-header> <devsite-book-nav scrollbars > <div class="devsite-book-nav-filter" > <span class="filter-list-icon material-icons" aria-hidden="true"></span> <input type="text" placeholder="Filter" aria-label="Type to filter" role="searchbox"> <span class="filter-clear-button hidden" data-title="Clear filter" aria-label="Clear filter" role="button" tabindex="0"></span> </div> <nav class="devsite-book-nav devsite-nav nocontent" aria-label="Side menu"> <div class="devsite-mobile-header"> <button type="button" id="devsite-close-nav" class="devsite-header-icon-button button-flat material-icons gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Close navigation" aria-label="Close navigation"> </button> <div class="devsite-product-name-wrapper"> <a href="/" class="devsite-site-logo-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Site logo" track-type="globalNav" track-name="googleAIEdge" track-metadata-position="nav" track-metadata-eventDetail="nav"> <picture> <img src="https://ai.google.dev/_static/googledevai/images/lockup-new.svg" class="devsite-site-logo" alt="Google AI Edge"> </picture> </a> <span class="devsite-product-name"> <ul class="devsite-breadcrumb-list" > <li class="devsite-breadcrumb-item devsite-has-google-wordmark"> </li> </ul> </span> </div> </div> <div class="devsite-book-nav-wrapper"> <div class="devsite-mobile-nav-top"> <ul class="devsite-nav-list"> <li class="devsite-nav-item"> <a href="/gemini-api" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Gemini API" track-name="gemini api" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Gemini API" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Gemini API </span> </a> </li> <li class="devsite-nav-item"> <a href="/gemma" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Gemma" track-name="gemma" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Gemma" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Gemma </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge" class="devsite-nav-title gc-analytics-event devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: Google AI Edge" track-name="google ai edge" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Google AI Edge" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Google AI Edge </span> </a> <ul class="devsite-nav-responsive-tabs"> <li class="devsite-nav-item"> <a href="/edge" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Overview" track-name="overview" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Overview" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Overview </span> </a> </li> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: MediaPipe" track-name="mediapipe" > <span class="devsite-nav-text" tooltip > MediaPipe </span> </span> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu devsite-lower-tab-item"> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: MediaPipe" track-name="mediapipe" > <span class="devsite-nav-text" tooltip menu="MediaPipe"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="MediaPipe"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="/edge/litert" class="devsite-nav-title gc-analytics-event devsite-nav-has-children devsite-nav-active" data-category="Site-Wide Custom Events" data-label="Tab: LiteRT" track-name="litert" data-category="Site-Wide Custom Events" data-label="Responsive Tab: LiteRT" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip menu="_book"> LiteRT </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="_book"> </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge/mediapipe/solutions/guide" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Solutions" track-name="solutions" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Solutions" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Solutions </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge/mediapipe/framework" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: Framework" track-name="framework" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Framework" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Framework </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge/model-explorer" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Model Explorer" track-name="model explorer" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Model Explorer" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Model Explorer </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge/api" class="devsite-nav-title gc-analytics-event devsite-nav-has-children " data-category="Site-Wide Custom Events" data-label="Tab: API Reference" track-name="api reference" data-category="Site-Wide Custom Events" data-label="Responsive Tab: API Reference" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > API Reference </span> <span class="devsite-nav-icon material-icons" data-icon="forward" > </span> </a> </li> </ul> </li> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Tools" track-name="tools" > <span class="devsite-nav-text" tooltip > Tools </span> </span> <ul class="devsite-nav-responsive-tabs devsite-nav-has-menu "> <li class="devsite-nav-item"> <span class="devsite-nav-title" tooltip data-category="Site-Wide Custom Events" data-label="Tab: Tools" track-name="tools" > <span class="devsite-nav-text" tooltip menu="Tools"> More </span> <span class="devsite-nav-icon material-icons" data-icon="forward" menu="Tools"> </span> </span> </li> </ul> </li> <li class="devsite-nav-item"> <a href="https://discuss.ai.google.dev/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Tab: Community" track-name="community" data-category="Site-Wide Custom Events" data-label="Responsive Tab: Community" track-type="globalNav" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Community </span> </a> </li> </ul> </div> <div class="devsite-mobile-nav-bottom"> <ul class="devsite-nav-list" menu="_book"> <li class="devsite-nav-item"><a href="/edge/litert" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/inference" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/inference" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/inference" ><span class="devsite-nav-text" tooltip>Get started</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/migration" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/migration" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/migration" ><span class="devsite-nav-text" tooltip>Migrating from TensorFlow Lite</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Models</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/models/convert_to_flatbuffer" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/convert_to_flatbuffer" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/convert_to_flatbuffer" ><span class="devsite-nav-text" tooltip>Support multiple frameworks</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/models/trained" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/trained" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/trained" ><span class="devsite-nav-text" tooltip>Use trained models</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Convert TensorFlow models</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/models/convert" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/convert" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/convert" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/models/convert_tf" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/convert_tf" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/convert_tf" ><span class="devsite-nav-text" tooltip>Convert TensorFlow models</span></a></li> <li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/models/signatures" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/signatures" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/signatures" ><span class="devsite-nav-text" tooltip>Add Signatures</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Conversion tools</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/models/model_analyzer" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/model_analyzer" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/model_analyzer" ><span class="devsite-nav-text" tooltip>Model Analyzer</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/models/authoring" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/authoring" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/authoring" ><span class="devsite-nav-text" tooltip>Authoring tool</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Model compatibility</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/models/ops_compatibility" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/ops_compatibility" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/ops_compatibility" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/ops_select" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/ops_select" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/ops_select" ><span class="devsite-nav-text" tooltip>Select operators</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/op_select_allowlist" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/op_select_allowlist" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/op_select_allowlist" ><span class="devsite-nav-text" tooltip>Select operators Allowlist</span></a></li><li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Advanced</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/models/ops_custom" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/ops_custom" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/ops_custom" ><span class="devsite-nav-text" tooltip>Custom operators</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/operation_fusion" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/operation_fusion" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/operation_fusion" ><span class="devsite-nav-text" tooltip>Fused operators</span></a></li><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/models/ops_version" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/ops_version" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/ops_version" ><span class="devsite-nav-text" tooltip>Operator versions</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/rnn" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/rnn" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/rnn" ><span class="devsite-nav-text" tooltip>RNN models</span></a></li></ul></div></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Optimize models</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/models/model_optimization" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/model_optimization" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/model_optimization" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/post_training_quantization" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/post_training_quantization" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/post_training_quantization" ><span class="devsite-nav-text" tooltip>Post-training quantization</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/post_training_quant" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/post_training_quant" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/post_training_quant" ><span class="devsite-nav-text" tooltip>Post-training dynamic range quantization</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/post_training_integer_quant" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/post_training_integer_quant" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/post_training_integer_quant" ><span class="devsite-nav-text" tooltip>Post-training integer quantization</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/post_training_float16_quant" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/post_training_float16_quant" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/post_training_float16_quant" ><span class="devsite-nav-text" tooltip>Post-training float16 quantization</span></a></li><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/models/post_training_integer_quant_16x8" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/post_training_integer_quant_16x8" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/post_training_integer_quant_16x8" ><span class="devsite-nav-text" tooltip>Post-training integer quantization with int16 activations</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/quantization_spec" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/quantization_spec" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/quantization_spec" ><span class="devsite-nav-text" tooltip>Quantization specification</span></a></li><li class="devsite-nav-item devsite-nav-nightly"><a href="/edge/litert/models/quantization_debugger" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/quantization_debugger" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/quantization_debugger" ><span class="devsite-nav-text" tooltip>Inspecting quantization errors</span><span class="devsite-nav-icon material-icons" data-icon="nightly" data-title="Nightly build only" aria-hidden="true"></span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Add model metadata</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/models/metadata" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/metadata" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/metadata" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/metadata_writer_tutorial" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/metadata_writer_tutorial" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/metadata_writer_tutorial" ><span class="devsite-nav-text" tooltip>Metadata Writer API</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Design and build models</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/models/build" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/build" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/build" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/best_practices" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/best_practices" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/best_practices" ><span class="devsite-nav-text" tooltip>Performance best practices</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/measurement" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/measurement" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/measurement" ><span class="devsite-nav-text" tooltip>Performance measurement</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/models/ondevice_training" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/ondevice_training" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/ondevice_training" ><span class="devsite-nav-text" tooltip>On-device training</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Convert PyTorch models</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/models/convert_pytorch" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/convert_pytorch" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/convert_pytorch" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/models/pytorch_to_tflite" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/pytorch_to_tflite" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/pytorch_to_tflite" ><span class="devsite-nav-text" tooltip>PyTorch to LiteRT quickstart</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/models/edge_generative" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/edge_generative" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/edge_generative" ><span class="devsite-nav-text" tooltip>Convert generative PyTorch models</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Convert JAX models</span> </div></li> <li class="devsite-nav-item devsite-nav-nightly"><a href="/edge/litert/models/convert_jax" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/convert_jax" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/convert_jax" ><span class="devsite-nav-text" tooltip>Overview</span><span class="devsite-nav-icon material-icons" data-icon="nightly" data-title="Nightly build only" aria-hidden="true"></span></a></li> <li class="devsite-nav-item devsite-nav-nightly"><a href="/edge/litert/models/jax_to_tflite" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/models/jax_to_tflite" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/models/jax_to_tflite" ><span class="devsite-nav-text" tooltip>JAX to LiteRT quickstart</span><span class="devsite-nav-icon material-icons" data-icon="nightly" data-title="Nightly build only" aria-hidden="true"></span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Hardware acceleration</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/performance/delegates" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/performance/delegates" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/performance/delegates" ><span class="devsite-nav-text" tooltip>Delegates</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/performance/gpu" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/performance/gpu" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/performance/gpu" ><span class="devsite-nav-text" tooltip>GPU delegates</span></a></li> <li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/performance/implementing_delegate" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/performance/implementing_delegate" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/performance/implementing_delegate" ><span class="devsite-nav-text" tooltip>Implementing a delegate</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Run on Android</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/android" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Google Play services runtime</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/android/play_services" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/play_services" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/play_services" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/java" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/java" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/java" ><span class="devsite-nav-text" tooltip>Java API</span></a></li><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/android/native" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/native" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/native" ><span class="devsite-nav-text" tooltip>C API</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li></ul></div></li> <li class="devsite-nav-item"><a href="/edge/litert/android/development" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/development" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/development" ><span class="devsite-nav-text" tooltip>Development tools</span></a></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Hardware acceleration</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/android/acceleration_service" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/acceleration_service" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/acceleration_service" ><span class="devsite-nav-text" tooltip>Acceleration service</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/gpu" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/gpu" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/gpu" ><span class="devsite-nav-text" tooltip>GPU with Interpreter API</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/gpu_native" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/gpu_native" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/gpu_native" ><span class="devsite-nav-text" tooltip>GPU with C/C++ API</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/npu" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/npu" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/npu" ><span class="devsite-nav-text" tooltip>NPU delegates</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Models with metadata</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/android/metadata/overview" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/metadata/overview" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/metadata/overview" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/metadata/codegen" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/metadata/codegen" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/metadata/codegen" ><span class="devsite-nav-text" tooltip>Generate model interfaces</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/android/metadata/lite_support" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/android/metadata/lite_support" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/android/metadata/lite_support" ><span class="devsite-nav-text" tooltip>Customize data input and output</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Run on iOS</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/ios/quickstart" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/ios/quickstart" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/ios/quickstart" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/ios/coreml" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/ios/coreml" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/ios/coreml" ><span class="devsite-nav-text" tooltip>Core ML delegate</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/ios/gpu" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/ios/gpu" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/ios/gpu" ><span class="devsite-nav-text" tooltip>GPU delegate</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Run on Micro</span> </div></li> <li class="devsite-nav-item"><a href="/edge/litert/microcontrollers/overview" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/microcontrollers/overview" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/microcontrollers/overview" ><span class="devsite-nav-text" tooltip>Overview</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/microcontrollers/get_started" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/microcontrollers/get_started" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/microcontrollers/get_started" ><span class="devsite-nav-text" tooltip>Get started</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/microcontrollers/python" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/microcontrollers/python" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/microcontrollers/python" ><span class="devsite-nav-text" tooltip>Linux-based devices with Python</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/microcontrollers/library" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/microcontrollers/library" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/microcontrollers/library" ><span class="devsite-nav-text" tooltip>Understand the C++ library</span></a></li> <li class="devsite-nav-item"><a href="/edge/litert/microcontrollers/build_convert" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/microcontrollers/build_convert" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/microcontrollers/build_convert" ><span class="devsite-nav-text" tooltip>Build and convert models</span></a></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Libraries and tools</span> </div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Task Library</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/overview" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/overview" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/overview" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/image_classifier" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/image_classifier" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/image_classifier" ><span class="devsite-nav-text" tooltip>ImageClassifier</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/object_detector" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/object_detector" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/object_detector" ><span class="devsite-nav-text" tooltip>ObjectDetector</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/image_segmenter" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/image_segmenter" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/image_segmenter" ><span class="devsite-nav-text" tooltip>ImageSegmenter</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/image_embedder" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/image_embedder" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/image_embedder" ><span class="devsite-nav-text" tooltip>ImageEmbedder</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/image_searcher" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/image_searcher" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/image_searcher" ><span class="devsite-nav-text" tooltip>ImageSearcher</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/nl_classifier" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/nl_classifier" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/nl_classifier" ><span class="devsite-nav-text" tooltip>NLClassifier</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/bert_nl_classifier" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/bert_nl_classifier" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/bert_nl_classifier" ><span class="devsite-nav-text" tooltip>BertNLClassifier</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/bert_question_answerer" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/bert_question_answerer" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/bert_question_answerer" ><span class="devsite-nav-text" tooltip>BertQuestionAnswerer</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/text_embedder" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/text_embedder" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/text_embedder" ><span class="devsite-nav-text" tooltip>TextEmbedder</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/text_searcher" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/text_searcher" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/text_searcher" ><span class="devsite-nav-text" tooltip>TextSearcher</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/audio_classifier" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/audio_classifier" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/audio_classifier" ><span class="devsite-nav-text" tooltip>AudioClassifier</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/task_library/customized_task_api" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/task_library/customized_task_api" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/task_library/customized_task_api" ><span class="devsite-nav-text" tooltip>Customized API</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-expandable devsite-nav-experimental"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Model Maker</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Images &amp; video</span> </div></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/image_classification" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/image_classification" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/image_classification" ><span class="devsite-nav-text" tooltip>Image classification</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/object_detection" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/object_detection" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/object_detection" ><span class="devsite-nav-text" tooltip>Object detection</span></a></li><li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Text</span> </div></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/text_classification" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/text_classification" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/text_classification" ><span class="devsite-nav-text" tooltip>Text classification</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/question_answer" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/question_answer" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/question_answer" ><span class="devsite-nav-text" tooltip>BERT question &amp; answer</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/text_searcher" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/text_searcher" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/text_searcher" ><span class="devsite-nav-text" tooltip>Text search</span></a></li><li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Audio</span> </div></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/audio_classification" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/audio_classification" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/audio_classification" ><span class="devsite-nav-text" tooltip>Audio classification</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/libraries/modify/speech_recognition" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/libraries/modify/speech_recognition" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/libraries/modify/speech_recognition" ><span class="devsite-nav-text" tooltip>Speech recognition</span></a></li></ul></div></li> <li class="devsite-nav-item devsite-nav-heading"><div class="devsite-nav-title devsite-nav-title-no-path"> <span class="devsite-nav-text" tooltip>Advanced</span> </div></li> <li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Build LiteRT</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/build/android" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/android" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/android" ><span class="devsite-nav-text" tooltip>Build for Android</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/build/ios" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/ios" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/ios" ><span class="devsite-nav-text" tooltip>Build for iOS</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/build/arm" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/arm" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/arm" ><span class="devsite-nav-text" tooltip>Build for ARM</span></a></li><li class="devsite-nav-item devsite-nav-expandable"><div class="devsite-expandable-nav"> <a class="devsite-nav-toggle" aria-hidden="true"></a><div class="devsite-nav-title devsite-nav-title-no-path" tabindex="0" role="button"> <span class="devsite-nav-text" tooltip>Build with CMake</span> </div><ul class="devsite-nav-section"><li class="devsite-nav-item"><a href="/edge/litert/build/cmake" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/cmake" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/cmake" ><span class="devsite-nav-text" tooltip>Overview</span></a></li><li class="devsite-nav-item"><a href="/edge/litert/build/cmake_arm" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/cmake_arm" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/cmake_arm" ><span class="devsite-nav-text" tooltip>Cross compilation for ARM</span></a></li></ul></div></li><li class="devsite-nav-item"><a href="/edge/litert/build/cmake_pip" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/cmake_pip" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/cmake_pip" ><span class="devsite-nav-text" tooltip>Build Python Wheel</span></a></li><li class="devsite-nav-item devsite-nav-experimental"><a href="/edge/litert/build/reduce_binary_size" class="devsite-nav-title gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Book nav link, pathname: /edge/litert/build/reduce_binary_size" track-type="bookNav" track-name="click" track-metadata-eventdetail="/edge/litert/build/reduce_binary_size" ><span class="devsite-nav-text" tooltip>Reduce binary size</span><span class="devsite-nav-icon material-icons" data-icon="experimental" data-title="Experimental!" aria-hidden="true"></span></a></li></ul></div></li> </ul> <ul class="devsite-nav-list" menu="Tools" aria-label="Side menu" hidden> <li class="devsite-nav-item"> <a href="/responsible" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Responsible GenAI Toolkit" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Responsible GenAI Toolkit </span> </a> </li> <li class="devsite-nav-item"> <a href="https://colab.google/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Colab" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Colab </span> </a> </li> <li class="devsite-nav-item"> <a href="https://firebase.google.com/docs/genkit" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Firebase Genkit" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Firebase Genkit </span> </a> </li> <li class="devsite-nav-item"> <a href="https://jax.readthedocs.io/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: JAX" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > JAX </span> </a> </li> <li class="devsite-nav-item"> <a href="https://keras.io/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: Keras" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > Keras </span> </a> </li> <li class="devsite-nav-item"> <a href="https://www.tensorflow.org/" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: TensorFlow" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > TensorFlow </span> </a> </li> </ul> <ul class="devsite-nav-list" menu="MediaPipe" aria-label="Side menu" hidden> <li class="devsite-nav-item"> <a href="/edge/mediapipe/solutions/guide" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: MediaPipe Solutions" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > MediaPipe Solutions </span> </a> </li> <li class="devsite-nav-item"> <a href="/edge/mediapipe/framework" class="devsite-nav-title gc-analytics-event " data-category="Site-Wide Custom Events" data-label="Responsive Tab: MediaPipe Framework" track-type="navMenu" track-metadata-eventDetail="globalMenu" track-metadata-position="nav"> <span class="devsite-nav-text" tooltip > MediaPipe Framework </span> </a> </li> </ul> </div> </div> </nav> </devsite-book-nav> <section id="gc-wrapper"> <main role="main" class="devsite-main-content" has-book-nav has-sidebar > <div class="devsite-sidebar"> <div class="devsite-sidebar-content"> <devsite-toc class="devsite-nav" role="navigation" aria-label="On this page" depth="2" scrollbars ></devsite-toc> <devsite-recommendations-sidebar class="nocontent devsite-nav"> </devsite-recommendations-sidebar> </div> </div> <devsite-content> <article class="devsite-article"> <div class="devsite-banner devsite-banner-announcement nocontent" background="google-blue" > <div class="devsite-banner-message"> <div class="devsite-banner-message-text"> <b>Introducing LiteRT</b>: Google's high-performance runtime for on-device AI, formerly known as TensorFlow Lite. <a class="button button-primary" href="https://developers.googleblog.com/en/tensorflow-lite-is-now-litert">Learn more</a> </div> </div> </div> <div class="devsite-article-meta nocontent" role="navigation"> <ul class="devsite-breadcrumb-list" aria-label="Breadcrumb"> <li class="devsite-breadcrumb-item "> <a href="https://ai.google.dev/" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="1" track-type="globalNav" track-name="breadcrumb" track-metadata-position="1" track-metadata-eventdetail="" > Home </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://ai.google.dev/edge" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="2" track-type="globalNav" track-name="breadcrumb" track-metadata-position="2" track-metadata-eventdetail="Google AI Edge" > Google AI Edge </a> </li> <li class="devsite-breadcrumb-item "> <div class="devsite-breadcrumb-guillemet material-icons" aria-hidden="true"></div> <a href="https://ai.google.dev/edge/litert" class="devsite-breadcrumb-link gc-analytics-event" data-category="Site-Wide Custom Events" data-label="Breadcrumbs" data-value="3" track-type="globalNav" track-name="breadcrumb" track-metadata-position="3" track-metadata-eventdetail="" > LiteRT </a> </li> </ul> <devsite-thumb-rating position="header"> </devsite-thumb-rating> </div> <devsite-feedback position="header" project-name="Google AI Edge" product-id="5336252" bucket="documentation" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="header" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/touchicon-180-new.png" > <button> Send feedback </button> </devsite-feedback> <h1 class="devsite-page-title" tabindex="-1"> Get started with LiteRT </h1> <div class="devsite-page-title-meta"><devsite-view-release-notes></devsite-view-release-notes></div> <devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded > </devsite-toc> <div class="devsite-article-body clearfix "> <p>This guide introduces you to the process of running a LiteRT (short for Lite Runtime) model on-device to make predictions based on input data. This is achieved with the LiteRT interpreter, which uses a static graph ordering and a custom (less-dynamic) memory allocator to ensure minimal load, initialization, and execution latency.</p> <p>LiteRT inference typically follows the following steps:</p> <ol> <li><p><strong>Loading a model</strong>: load the <code translate="no" dir="ltr">.tflite</code> model into memory, which contains the model&#39;s execution graph.</p></li> <li><p><strong>Transforming data</strong>: Transform input data into the expected format and dimensions. Raw input data for the model generally does not match the input data format expected by the model. For example, you might need to resize an image or change the image format to be compatible with the model.</p></li> <li><p><strong>Running inference</strong>: Execute the LiteRT model to make predictions. This step involves using the LiteRT API to execute the model. It involves a few steps such as building the interpreter, and allocating tensors.</p></li> <li><p><strong>Interpreting output</strong>: Interpret the output tensors in a meaningful way that&#39;s useful in your application. For example, a model might return only a list of probabilities. It&#39;s up to you to map the probabilities to relevant categories and format the output.</p></li> </ol> <p>This guide describes how to access the LiteRT interpreter and perform an inference using C++, Java, and Python.</p> <h2 id="supported-platforms" data-text="Supported platforms" tabindex="-1">Supported platforms</h2> <p>TensorFlow inference APIs are provided for most common mobile and embedded platforms such as <a href="#android">Android</a>, <a href="#ios">iOS</a> and <a href="#linux">Linux</a>, in <a href="https://ai.google.dev/edge/api/index#litert_api">multiple programming languages</a>.</p> <p>In most cases, the API design reflects a preference for performance over ease of use. LiteRT is designed for fast inference on small devices, so the APIs avoid unnecessary copies at the expense of convenience.</p> <p>Across all libraries, the LiteRT API lets you to load models, feed inputs, and retrieve inference outputs.</p> <h3 id="android" data-text="Android Platform" tabindex="-1">Android Platform</h3> <p>On Android, LiteRT inference can be performed using either Java or C++ APIs. The Java APIs provide convenience and can be used directly within your Android Activity classes. The C++ APIs offer more flexibility and speed, but may require writing JNI wrappers to move data between Java and C++ layers.</p> <p>See the <a href="#run-c">C++</a> and <a href="#run-java">Java</a> sections for more information, or follow the <a href="https://ai.google.dev/edge/litert/android">Android quickstart</a>.</p> <!-- #### LiteRT Android wrapper code generator Note: LiteRT wrapper code generator is in experimental (beta) phase and only supports Android. For LiteRT model enhanced with [metadata](./android/metadata/overview), developers can use the LiteRT Android wrapper code generator to create platform specific wrapper code. The wrapper code removes the need to interact directly with `ByteBuffer` on Android. Instead, developers can interact with the LiteRT model with typed objects such as `Bitmap` and `Rect`. For more information, refer to the [LiteRT Android wrapper code generator](./android/metadata/codegen). --> <h3 id="ios" data-text="iOS Platform" tabindex="-1">iOS Platform</h3> <p>On iOS, LiteRT is available in <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/swift">Swift</a> and <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/objc">Objective-C</a> iOS libraries. You can also use <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/c_api.h">C API</a> directly in Objective-C code.</p> <p>See the <a href="#run-swift">Swift</a>, <a href="#run-objc">Objective-C</a>, and <a href="#run-c">C API</a> sections, or follow the <a href="https://ai.google.dev/edge/litert/ios/quickstart">iOS quickstart</a>.</p> <h3 id="linux" data-text="Linux Platform" tabindex="-1">Linux Platform</h3> <p>On Linux platforms, you can run inferences using LiteRT APIs available in <a href="#run-c">C++</a>.</p> <h2 id="load-model" data-text="Load and run a model" tabindex="-1">Load and run a model</h2> <p>Loading and running a LiteRT model involves the following steps:</p> <ol> <li>Loading the model into memory.</li> <li>Building an <code translate="no" dir="ltr">Interpreter</code> based on an existing model.</li> <li>Setting input tensor values.</li> <li>Invoking inferences.</li> <li>Outputting tensor values.</li> </ol> <h3 id="run-java" data-text="Android (Java)" tabindex="-1">Android (Java)</h3> <p>The Java API for running inferences with LiteRT is primarily designed for use with Android, so it&#39;s available as an Android library dependency: <code translate="no" dir="ltr">com.google.ai.edge.litert</code>.</p> <p>In Java, you&#39;ll use the <code translate="no" dir="ltr">Interpreter</code> class to load a model and drive model inference. In many cases, this may be the only API you need.</p> <p>You can initialize an <code translate="no" dir="ltr">Interpreter</code> using a FlatBuffers (<code translate="no" dir="ltr">.tflite</code>) file:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-kd">public</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-nd">@NotNull</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">File</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">modelFile</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <p>Or with a <code translate="no" dir="ltr">MappedByteBuffer</code>:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-kd">public</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-nd">@NotNull</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">MappedByteBuffer</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">mappedByteBuffer</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <p>In both cases, you must provide a valid LiteRT model or the API throws <code translate="no" dir="ltr">IllegalArgumentException</code>. If you use <code translate="no" dir="ltr">MappedByteBuffer</code> to initialize an <code translate="no" dir="ltr">Interpreter</code>, it must remain unchanged for the whole lifetime of the <code translate="no" dir="ltr">Interpreter</code>.</p> <p>The preferred way to run inference on a model is to use signatures - Available for models converted starting Tensorflow 2.5</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-k">try</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">new</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">file_of_tensorflowlite_model</span><span class="devsite-syntax-p">))</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Map&lt;String</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Object</span>&gt;<span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">new</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">HashMap</span>&lt;&gt;<span class="devsite-syntax-p">();</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">put</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"input_1"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input1</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">put</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"input_2"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input2</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Map&lt;String</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Object</span>&gt;<span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">new</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">HashMap</span>&lt;&gt;<span class="devsite-syntax-p">();</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">put</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s">"output_1"</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output1</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">runSignature</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-s">"mySignature"</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <p>The <code translate="no" dir="ltr">runSignature</code> method takes three arguments:</p> <ul> <li><p><strong>Inputs</strong> : map for inputs from input name in the signature to an input object.</p></li> <li><p><strong>Outputs</strong> : map for output mapping from output name in signature to output data.</p></li> <li><p><strong>Signature Name</strong> (optional): Signature name (Can be left empty if the model has single signature).</p></li> </ul> <p>Another way to run inferences when the model doesn&#39;t have a defined signatures. Simply call <code translate="no" dir="ltr">Interpreter.run()</code>. For example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-k">try</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">new</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">file_of_a_tensorflowlite_model</span><span class="devsite-syntax-p">))</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">run</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">input</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <p>The <code translate="no" dir="ltr">run()</code> method takes only one input and returns only one output. So if your model has multiple inputs or multiple outputs, instead use:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">runForMultipleInputsOutputs</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">map_of_indices_to_outputs</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <p>In this case, each entry in <code translate="no" dir="ltr">inputs</code> corresponds to an input tensor and <code translate="no" dir="ltr">map_of_indices_to_outputs</code> maps indices of output tensors to the corresponding output data.</p> <p>In both cases, the tensor indices should correspond to the values you gave to the <a href="https://ai.google.dev/edge/litert/models/convert">LiteRT Converter</a> when you created the model. Be aware that the order of tensors in <code translate="no" dir="ltr">input</code> must match the order given to the LiteRT Converter.</p> <p>The <code translate="no" dir="ltr">Interpreter</code> class also provides convenient functions for you to get the index of any model input or output using an operation name:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-kd">public</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">int</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">getInputIndex</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">String</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">opName</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-kd">public</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">int</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">getOutputIndex</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">String</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">opName</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <p>If <code translate="no" dir="ltr">opName</code> is not a valid operation in the model, it throws an <code translate="no" dir="ltr">IllegalArgumentException</code>.</p> <p>Also beware that <code translate="no" dir="ltr">Interpreter</code> owns resources. To avoid memory leak, the resources must be released after use by:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Java"><code translate="no" dir="ltr"><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-na">close</span><span class="devsite-syntax-p">();</span> </code></pre></devsite-code> <p>For an example project with Java, see the <a href="https://github.com/google-ai-edge/litert-samples/tree/main/examples/object_detection/android">Android object detection example app</a>.</p> <h4 id="supported_data_types" data-text="Supported data types" tabindex="-1">Supported data types</h4> <p>To use LiteRT, the data types of the input and output tensors must be one of the following primitive types:</p> <ul> <li><code translate="no" dir="ltr">float</code></li> <li><code translate="no" dir="ltr">int</code></li> <li><code translate="no" dir="ltr">long</code></li> <li><code translate="no" dir="ltr">byte</code></li> </ul> <p><code translate="no" dir="ltr">String</code> types are also supported, but they are encoded differently than the primitive types. In particular, the shape of a string Tensor dictates the number and arrangement of strings in the Tensor, with each element itself being a variable length string. In this sense, the (byte) size of the Tensor cannot be computed from the shape and type alone, and consequently strings cannot be provided as a single, flat <code translate="no" dir="ltr">ByteBuffer</code> argument.</p> <p>If other data types, including boxed types like <code translate="no" dir="ltr">Integer</code> and <code translate="no" dir="ltr">Float</code>, are used, an <code translate="no" dir="ltr">IllegalArgumentException</code> will be thrown.</p> <h5 id="inputs" data-text="Inputs" tabindex="-1">Inputs</h5> <p>Each input should be an array or multi-dimensional array of the supported primitive types, or a raw <code translate="no" dir="ltr">ByteBuffer</code> of the appropriate size. If the input is an array or multi-dimensional array, the associated input tensor will be implicitly resized to the array&#39;s dimensions at inference time. If the input is a ByteBuffer, the caller should first manually resize the associated input tensor (via <code translate="no" dir="ltr">Interpreter.resizeInput()</code>) before running inference.</p> <p>When using <code translate="no" dir="ltr">ByteBuffer</code>, prefer using direct byte buffers, as this allows the <code translate="no" dir="ltr">Interpreter</code> to avoid unnecessary copies. If the <code translate="no" dir="ltr">ByteBuffer</code> is a direct byte buffer, its order must be <code translate="no" dir="ltr">ByteOrder.nativeOrder()</code>. After it is used for a model inference, it must remain unchanged until the model inference is finished.</p> <h5 id="outputs" data-text="Outputs" tabindex="-1">Outputs</h5> <p>Each output should be an array or multi-dimensional array of the supported primitive types, or a ByteBuffer of the appropriate size. Note that some models have dynamic outputs, where the shape of output tensors can vary depending on the input. There&#39;s no straightforward way of handling this with the existing Java inference API, but planned extensions will make this possible.</p> <h3 id="run-swift" data-text="iOS (Swift)" tabindex="-1">iOS (Swift)</h3> <p>The <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/swift">Swift API</a> is available in <code translate="no" dir="ltr">TensorFlowLiteSwift</code> Pod from Cocoapods.</p> <p>First, you need to import <code translate="no" dir="ltr">TensorFlowLite</code> module.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Swift"><code translate="no" dir="ltr"><span class="devsite-syntax-kd">import</span> <span class="devsite-syntax-nc">TensorFlowLite</span> </code></pre></devsite-code><div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Swift"><code translate="no" dir="ltr"><span class="devsite-syntax-c1">// Getting model path</span> <span class="devsite-syntax-k">guard</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">modelPath</span> <span class="devsite-syntax-p">=</span> <span class="devsite-syntax-n">Bundle</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">main</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">path</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">forResource</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-s">"model"</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">ofType</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-s">"tflite"</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-k">else</span> <span class="devsite-syntax-p">{</span> <span class="devsite-syntax-c1">// Error handling...</span> <span class="devsite-syntax-p">}</span> <span class="devsite-syntax-k">do</span> <span class="devsite-syntax-p">{</span> <span class="devsite-syntax-c1">// Initialize an interpreter with the model.</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">interpreter</span> <span class="devsite-syntax-p">=</span> <span class="devsite-syntax-k">try</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">modelPath</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">modelPath</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1">// Allocate memory for the model's input `Tensor`s.</span> <span class="devsite-syntax-k">try</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">allocateTensors</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">inputData</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">Data</span> <span class="devsite-syntax-c1">// Should be initialized</span> <span class="devsite-syntax-c1">// input data preparation...</span> <span class="devsite-syntax-c1">// Copy the input data to the input `Tensor`.</span> <span class="devsite-syntax-k">try</span> <span class="devsite-syntax-kc">self</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">copy</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">inputData</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">toInputAt</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1">// Run inference by invoking the `Interpreter`.</span> <span class="devsite-syntax-k">try</span> <span class="devsite-syntax-kc">self</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">invoke</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1">// Get the output `Tensor`</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">outputTensor</span> <span class="devsite-syntax-p">=</span> <span class="devsite-syntax-k">try</span> <span class="devsite-syntax-kc">self</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">at</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1">// Copy output to `Data` to process the inference results.</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">outputSize</span> <span class="devsite-syntax-p">=</span> <span class="devsite-syntax-n">outputTensor</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">shape</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">dimensions</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-bp">reduce</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-mi">1</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-p">{</span><span class="devsite-syntax-n">x</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">y</span> <span class="devsite-syntax-k">in</span> <span class="devsite-syntax-n">x</span> <span class="devsite-syntax-o">*</span> <span class="devsite-syntax-n">y</span><span class="devsite-syntax-p">})</span> <span class="devsite-syntax-kd">let</span> <span class="devsite-syntax-nv">outputData</span> <span class="devsite-syntax-p">=</span> <span class="devsite-syntax-n">UnsafeMutableBufferPointer&lt;Float32&gt;</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">allocate</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">capacity</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">outputSize</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">outputTensor</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">data</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">copyBytes</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">to</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">outputData</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-k">if</span> <span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span> <span class="devsite-syntax-o">!=</span> <span class="devsite-syntax-kc">nil</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-p">{</span> <span class="devsite-syntax-cm">/* Error handling... */</span> <span class="devsite-syntax-p">}</span> <span class="devsite-syntax-p">}</span> <span class="devsite-syntax-k">catch</span> <span class="devsite-syntax-n">error</span> <span class="devsite-syntax-p">{</span> <span class="devsite-syntax-c1">// Error handling...</span> <span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <h3 id="run-objc" data-text="iOS (Objective-C)" tabindex="-1">iOS (Objective-C)</h3> <p>The <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/objc">Objective-C API</a> is available in <code translate="no" dir="ltr">LiteRTObjC</code> Pod from Cocoapods.</p> <p>First, you need to import <code translate="no" dir="ltr">TensorFlowLiteObjC</code> module.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Objective-C"><code translate="no" dir="ltr"><span class="devsite-syntax-k">@import</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TensorFlowLite</span><span class="devsite-syntax-p">;</span> </code></pre></devsite-code><div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Objective-C"><code translate="no" dir="ltr"><span class="devsite-syntax-bp">NSString</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">modelPath</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[[</span><span class="devsite-syntax-bp">NSBundle</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">mainBundle</span><span class="devsite-syntax-p">]</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">pathForResource</span><span class="devsite-syntax-o">:</span><span class="devsite-syntax-s">@"model"</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nl">ofType</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-s">@"tflite"</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-bp">NSError</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">;</span> <span class="devsite-syntax-c1">// Initialize an interpreter with the model.</span> <span class="devsite-syntax-n">TFLInterpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[[</span><span class="devsite-syntax-n">TFLInterpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">alloc</span><span class="devsite-syntax-p">]</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">initWithModelPath</span><span class="devsite-syntax-o">:</span><span class="devsite-syntax-n">modelPath</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-nl">error</span><span class="devsite-syntax-p">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-c1">// Allocate memory for the model's input `TFLTensor`s.</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">allocateTensorsWithError</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-bp">NSMutableData</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">inputData</span><span class="devsite-syntax-p">;</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Should be initialized</span> <span class="devsite-syntax-c1">// input data preparation...</span> <span class="devsite-syntax-c1">// Get the input `TFLTensor`</span> <span class="devsite-syntax-n">TFLTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">inputTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">inputTensorAtIndex</span><span class="devsite-syntax-o">:</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-c1">// Copy the input data to the input `TFLTensor`.</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">inputTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">copyData</span><span class="devsite-syntax-o">:</span><span class="devsite-syntax-n">inputData</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-c1">// Run inference by invoking the `TFLInterpreter`.</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">invokeWithError</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-c1">// Get the output `TFLTensor`</span> <span class="devsite-syntax-n">TFLTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">outputTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">outputTensorAtIndex</span><span class="devsite-syntax-o">:</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-c1">// Copy output to `NSData` to process the inference results.</span> <span class="devsite-syntax-bp">NSData</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">outputData</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">outputTensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">dataWithError</span><span class="devsite-syntax-o">:</span>&amp;<span class="devsite-syntax-n">error</span><span class="devsite-syntax-p">];</span> <span class="devsite-syntax-k">if</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">error</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">!=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nb">nil</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cm">/* Error handling... */</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">}</span> </code></pre></devsite-code> <h4 id="c_api_in_objective-c_code" data-text="C API in Objective-C code" tabindex="-1">C API in Objective-C code</h4> <p>Objective-C API does not support delegates. In order to use delegates with Objective-C code, you need to directly call underlying <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/c/c_api.h">C API</a>.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="C"><code translate="no" dir="ltr"><span class="devsite-syntax-cp">#include</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-cpf">"tensorflow/lite/c/c_api.h"</span> </code></pre></devsite-code><div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="C"><code translate="no" dir="ltr"><span class="devsite-syntax-n">TfLiteModel</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteModelCreateFromFile</span><span class="devsite-syntax-p">([</span><span class="devsite-syntax-n">modelPath</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">UTF8String</span><span class="devsite-syntax-p">]);</span> <span class="devsite-syntax-n">TfLiteInterpreterOptions</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">options</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteInterpreterOptionsCreate</span><span class="devsite-syntax-p">();</span> <span class="devsite-syntax-c1">// Create the interpreter.</span> <span class="devsite-syntax-n">TfLiteInterpreter</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteInterpreterCreate</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">options</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-c1">// Allocate tensors and populate the input tensor data.</span> <span class="devsite-syntax-n">TfLiteInterpreterAllocateTensors</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">TfLiteTensor</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input_tensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteInterpreterGetInputTensor</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">TfLiteTensorCopyFromBuffer</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">input_tensor</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">data</span><span class="devsite-syntax-p">(),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">size</span><span class="devsite-syntax-p">()</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">sizeof</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-kt">float</span><span class="devsite-syntax-p">));</span> <span class="devsite-syntax-c1">// Execute inference.</span> <span class="devsite-syntax-n">TfLiteInterpreterInvoke</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-c1">// Extract the output tensor data.</span> <span class="devsite-syntax-k">const</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteTensor</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output_tensor</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">TfLiteInterpreterGetOutputTensor</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">TfLiteTensorCopyToBuffer</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">output_tensor</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">data</span><span class="devsite-syntax-p">(),</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">.</span><span class="devsite-syntax-n">size</span><span class="devsite-syntax-p">()</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">sizeof</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-kt">float</span><span class="devsite-syntax-p">));</span> <span class="devsite-syntax-c1">// Dispose of the model and interpreter objects.</span> <span class="devsite-syntax-n">TfLiteInterpreterDelete</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">TfLiteInterpreterOptionsDelete</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">options</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-n">TfLiteModelDelete</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <h3 id="run-c" data-text="C++" tabindex="-1">C++</h3> <p>The C++ API for running inference with LiteRT is compatible with Android, iOS, and Linux platforms. The C++ API on iOS is only available when using bazel.</p> <p>In C++, the model is stored in <a href="https://ai.google.dev/edge/api/tflite/cc/class/tflite/impl/flat-buffer-model"><code translate="no" dir="ltr">FlatBufferModel</code></a> class. It encapsulates a LiteRT model and you can build it in a couple of different ways, depending on where the model is stored:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="C++"><code translate="no" dir="ltr"><span class="devsite-syntax-k">class</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nc">FlatBufferModel</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-p">{</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Build a model based on a file. Return a nullptr in case of failure.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">static</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">std</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">unique_ptr&lt;FlatBufferModel&gt;</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">BuildFromFile</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">const</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">char</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">filename</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">ErrorReporter</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">error_reporter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// Build a model based on a pre-loaded flatbuffer. The caller retains</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// ownership of the buffer and should keep it alive until the returned object</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-c1">// is destroyed. Return a nullptr in case of failure.</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">static</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">std</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">unique_ptr&lt;FlatBufferModel&gt;</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nf">BuildFromBuffer</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-k">const</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">char</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buffer</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-kt">size_t</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">buffer_size</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">ErrorReporter</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">error_reporter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-p">};</span> </code></pre></devsite-code> <p>Now that you have the model as a <code translate="no" dir="ltr">FlatBufferModel</code> object, you can execute it with an <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/interpreter.h"><code translate="no" dir="ltr">Interpreter</code></a>. A single <code translate="no" dir="ltr">FlatBufferModel</code> can be used simultaneously by more than one <code translate="no" dir="ltr">Interpreter</code>.</p> <aside class="caution"><strong>Caution:</strong><span> The <code translate="no" dir="ltr">FlatBufferModel</code> object must remain valid until all instances of <code translate="no" dir="ltr">Interpreter</code> using it have been destroyed.</span></aside> <p>The important parts of the <code translate="no" dir="ltr">Interpreter</code> API are shown in the code snippet below. It should be noted that:</p> <ul> <li>Tensors are represented by integers, in order to avoid string comparisons (and any fixed dependency on string libraries).</li> <li>An interpreter must not be accessed from concurrent threads.</li> <li>Memory allocation for input and output tensors must be triggered by calling <code translate="no" dir="ltr">AllocateTensors()</code> right after resizing tensors.</li> </ul> <p>The simplest usage of LiteRT with C++ looks like this:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="C++"><code translate="no" dir="ltr"><span class="devsite-syntax-c1">// Load the model</span> <span class="devsite-syntax-n">std</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">unique_ptr&lt;tflite</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">FlatBufferModel</span>&gt;<span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">tflite</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">FlatBufferModel</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">BuildFromFile</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">filename</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-c1">// Build the interpreter</span> <span class="devsite-syntax-n">tflite</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">ops</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">builtin</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">BuiltinOpResolver</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">resolver</span><span class="devsite-syntax-p">;</span> <span class="devsite-syntax-n">std</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">unique_ptr&lt;tflite</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">Interpreter</span>&gt;<span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">;</span> <span class="devsite-syntax-n">tflite</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">InterpreterBuilder</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">resolver</span><span class="devsite-syntax-p">)(</span>&amp;<span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-c1">// Resize input tensors, if needed.</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">AllocateTensors</span><span class="devsite-syntax-p">();</span> <span class="devsite-syntax-kt">float</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">input</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">typed_input_tensor&lt;float&gt;</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">);</span> <span class="devsite-syntax-c1">// Fill `input`.</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">Invoke</span><span class="devsite-syntax-p">();</span> <span class="devsite-syntax-kt">float</span><span class="devsite-syntax-o">*</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">typed_output_tensor&lt;float&gt;</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">);</span> </code></pre></devsite-code> <p>For more example code, see <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/minimal/minimal.cc"><code translate="no" dir="ltr">minimal.cc</code></a> and <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/label_image/label_image.cc"><code translate="no" dir="ltr">label_image.cc</code></a>.</p> <h3 id="run-python" data-text="Python" tabindex="-1">Python</h3> <p>The Python API for running inferences uses the <a href="https://ai.google.dev/edge/api/tflite/python/tf/lite/Interpreter"><code translate="no" dir="ltr">Interpreter</code></a> to load a model and run inferences.</p> <p>Install the LiteRT package:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded><code translate="no" dir="ltr">$ python3 -m pip install ai-edge-litert </code></pre></devsite-code> <p>Import the LiteRT Interpreter</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-kn">from</span> <span class="devsite-syntax-nn">ai_edge_litert.interpreter</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">model_path</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">args</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">model</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">file</span><span class="devsite-syntax-p">)</span> </code></pre></devsite-code> <p>The following example shows how to use the Python interpreter to load a FlatBuffers (<code translate="no" dir="ltr">.tflite</code>) file and run inference with random input data:</p> <p>This example is recommended if you&#39;re converting from SavedModel with a defined SignatureDef.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-k">class</span> <span class="devsite-syntax-nc">TestModel</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">Module</span><span class="devsite-syntax-p">):</span> <span class="devsite-syntax-k">def</span> <span class="devsite-syntax-fm">__init__</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-bp">self</span><span class="devsite-syntax-p">):</span> <span class="devsite-syntax-nb">super</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">TestModel</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-bp">self</span><span class="devsite-syntax-p">)</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-fm">__init__</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-nd">@tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">function</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">input_signature</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">TensorSpec</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">shape</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-mi">1</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mi">10</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-n">dtype</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">float32</span><span class="devsite-syntax-p">)])</span> <span class="devsite-syntax-k">def</span> <span class="devsite-syntax-nf">add</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-bp">self</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">x</span><span class="devsite-syntax-p">):</span> <span class="devsite-syntax-w"> </span><span class="devsite-syntax-sd">'''</span> <span class="devsite-syntax-sd"> Simple method that accepts single input 'x' and returns 'x' + 4.</span> <span class="devsite-syntax-sd"> '''</span> <span class="devsite-syntax-c1"># Name the output 'result' for convenience.</span> <span class="devsite-syntax-k">return</span> <span class="devsite-syntax-p">{</span><span class="devsite-syntax-s1">'result'</span> <span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">x</span> <span class="devsite-syntax-o">+</span> <span class="devsite-syntax-mi">4</span><span class="devsite-syntax-p">}</span> <span class="devsite-syntax-n">SAVED_MODEL_PATH</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-s1">'content/saved_models/test_variable'</span> <span class="devsite-syntax-n">TFLITE_FILE_PATH</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-s1">'content/test_variable.tflite'</span> <span class="devsite-syntax-c1"># Save the model</span> <span class="devsite-syntax-n">module</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">TestModel</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># You can omit the signatures argument and a default signature name will be</span> <span class="devsite-syntax-c1"># created with name 'serving_default'.</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">saved_model</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">save</span><span class="devsite-syntax-p">(</span> <span class="devsite-syntax-n">module</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">SAVED_MODEL_PATH</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">signatures</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-s1">'my_signature'</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-n">module</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">add</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_concrete_function</span><span class="devsite-syntax-p">()})</span> <span class="devsite-syntax-c1"># Convert the model using TFLiteConverter</span> <span class="devsite-syntax-n">converter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">lite</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">TFLiteConverter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">from_saved_model</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">SAVED_MODEL_PATH</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">tflite_model</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">converter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">convert</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-k">with</span> <span class="devsite-syntax-nb">open</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">TFLITE_FILE_PATH</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-s1">'wb'</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-k">as</span> <span class="devsite-syntax-n">f</span><span class="devsite-syntax-p">:</span> <span class="devsite-syntax-n">f</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">write</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">tflite_model</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1"># Load the LiteRT model in LiteRT Interpreter</span> <span class="devsite-syntax-kn">from</span> <span class="devsite-syntax-nn">ai_edge_litert.interpreter</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-n">interpreter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">TFLITE_FILE_PATH</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1"># There is only 1 signature defined in the model,</span> <span class="devsite-syntax-c1"># so it will return it by default.</span> <span class="devsite-syntax-c1"># If there are multiple signatures then we can pass the name.</span> <span class="devsite-syntax-n">my_signature</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_signature_runner</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># my_signature is callable with input as arguments.</span> <span class="devsite-syntax-n">output</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">my_signature</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">x</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">constant</span><span class="devsite-syntax-p">([</span><span class="devsite-syntax-mf">1.0</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-n">shape</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-mi">1</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-mi">10</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-n">dtype</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">float32</span><span class="devsite-syntax-p">))</span> <span class="devsite-syntax-c1"># 'output' is dictionary with all outputs from the inference.</span> <span class="devsite-syntax-c1"># In this case we have single output 'result'.</span> <span class="devsite-syntax-nb">print</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">output</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-s1">'result'</span><span class="devsite-syntax-p">])</span> </code></pre></devsite-code> <p>Another example if the model doesn&#39;t have <code translate="no" dir="ltr">SignatureDefs</code> defined.</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-nn">numpy</span> <span class="devsite-syntax-k">as</span> <span class="devsite-syntax-nn">np</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-nn">tensorflow</span> <span class="devsite-syntax-k">as</span> <span class="devsite-syntax-nn">tf</span> <span class="devsite-syntax-c1"># Load the LiteRT model and allocate tensors.</span> <span class="devsite-syntax-kn">from</span> <span class="devsite-syntax-nn">ai_edge_litert.interpreter</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-n">interpreter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">TFLITE_FILE_PATH</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">allocate_tensors</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># Get input and output tensors.</span> <span class="devsite-syntax-n">input_details</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_input_details</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-n">output_details</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_output_details</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># Test the model on random input data.</span> <span class="devsite-syntax-n">input_shape</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">input_details</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">][</span><span class="devsite-syntax-s1">'shape'</span><span class="devsite-syntax-p">]</span> <span class="devsite-syntax-n">input_data</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">np</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">array</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">np</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">random</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">random_sample</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">input_shape</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-n">dtype</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">np</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">float32</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">set_tensor</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">input_details</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">][</span><span class="devsite-syntax-s1">'index'</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-n">input_data</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">invoke</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># The function `get_tensor()` returns a copy of the tensor data.</span> <span class="devsite-syntax-c1"># Use `tensor()` in order to get a pointer to the tensor.</span> <span class="devsite-syntax-n">output_data</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_tensor</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">output_details</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">][</span><span class="devsite-syntax-s1">'index'</span><span class="devsite-syntax-p">])</span> <span class="devsite-syntax-nb">print</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">output_data</span><span class="devsite-syntax-p">)</span> </code></pre></devsite-code> <p>As an alternative to loading the model as a pre-converted <code translate="no" dir="ltr">.tflite</code> file, you can combine your code with the <a href="https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/lite/python/lite.py#L1948-L2216">LiteRT Compiler</a> , allowing you to convert your Keras model into the LiteRT format and then run inference:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-nn">numpy</span> <span class="devsite-syntax-k">as</span> <span class="devsite-syntax-nn">np</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-nn">tensorflow</span> <span class="devsite-syntax-k">as</span> <span class="devsite-syntax-nn">tf</span> <span class="devsite-syntax-n">img</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">keras</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">Input</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">shape</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-mi">64</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mi">64</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mi">3</span><span class="devsite-syntax-p">),</span> <span class="devsite-syntax-n">name</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s2">"img"</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">const</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">constant</span><span class="devsite-syntax-p">([</span><span class="devsite-syntax-mf">1.</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mf">2.</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mf">3.</span><span class="devsite-syntax-p">])</span> <span class="devsite-syntax-o">+</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">constant</span><span class="devsite-syntax-p">([</span><span class="devsite-syntax-mf">1.</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mf">4.</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mf">4.</span><span class="devsite-syntax-p">])</span> <span class="devsite-syntax-n">val</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">img</span> <span class="devsite-syntax-o">+</span> <span class="devsite-syntax-n">const</span> <span class="devsite-syntax-n">out</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">identity</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">val</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">name</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s2">"out"</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1"># Convert to LiteRT format</span> <span class="devsite-syntax-n">converter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">lite</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">TFLiteConverter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">from_keras_model</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">tf</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">keras</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">models</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">Model</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">inputs</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">img</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-n">outputs</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">[</span><span class="devsite-syntax-n">out</span><span class="devsite-syntax-p">]))</span> <span class="devsite-syntax-n">tflite_model</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">converter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">convert</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># Load the LiteRT model and allocate tensors.</span> <span class="devsite-syntax-kn">from</span> <span class="devsite-syntax-nn">ai_edge_litert.interpreter</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-n">interpreter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">model_content</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">tflite_model</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">allocate_tensors</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># Continue to get tensors and so forth, as shown above...</span> </code></pre></devsite-code> <p>For more Python sample code, see <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/python/label_image.py"><code translate="no" dir="ltr">label_image.py</code></a>.</p> <aside class="tip"><strong>Tip:</strong><span> Run <code translate="no" dir="ltr">help(Interpreter)</code> in the Python terminal to get detailed documentation about the interpreter.</span></aside> <h2 id="run-inference" data-text="Run inference with dynamic shape model" tabindex="-1">Run inference with dynamic shape model</h2> <p>If you want to run a model with dynamic input shape, resize the input shape before running inference. Otherwise, the <code translate="no" dir="ltr">None</code> shape in Tensorflow models will be replaced by a placeholder of <code translate="no" dir="ltr">1</code> in LiteRT models.</p> <p>The following examples show how to resize the input shape before running inference in different languages. All the examples assume that the input shape is defined as <code translate="no" dir="ltr">[1/None, 10]</code>, and need to be resized to <code translate="no" dir="ltr">[3, 10]</code>.</p> <p>C++ example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="C++"><code translate="no" dir="ltr"><span class="devsite-syntax-c1">// Resize input tensors before allocate tensors</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">ResizeInputTensor</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-cm">/*tensor_index=*/</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-n">std</span><span class="devsite-syntax-o">::</span><span class="devsite-syntax-n">vector&lt;int&gt;</span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-mi">3</span><span class="devsite-syntax-p">,</span><span class="devsite-syntax-mi">10</span><span class="devsite-syntax-p">});</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">-</span>&gt;<span class="devsite-syntax-n">AllocateTensors</span><span class="devsite-syntax-p">();</span> </code></pre></devsite-code> <p>Python example:</p> <div></div><devsite-code><pre class="devsite-click-to-copy" translate="no" dir="ltr" is-upgraded syntax="Python"><code translate="no" dir="ltr"><span class="devsite-syntax-c1"># Load the LiteRT model in LiteRT Interpreter</span> <span class="devsite-syntax-kn">from</span> <span class="devsite-syntax-nn">ai_edge_litert.interpreter</span> <span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">Interpreter</span> <span class="devsite-syntax-n">interpreter</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">Interpreter</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">model_path</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-n">TFLITE_FILE_PATH</span><span class="devsite-syntax-p">)</span> <span class="devsite-syntax-c1"># Resize input shape for dynamic shape model and allocate tensor</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">resize_tensor_input</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_input_details</span><span class="devsite-syntax-p">()[</span><span class="devsite-syntax-mi">0</span><span class="devsite-syntax-p">][</span><span class="devsite-syntax-s1">'index'</span><span class="devsite-syntax-p">],</span> <span class="devsite-syntax-p">[</span><span class="devsite-syntax-mi">3</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-mi">10</span><span class="devsite-syntax-p">])</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">allocate_tensors</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-c1"># Get input and output tensors.</span> <span class="devsite-syntax-n">input_details</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_input_details</span><span class="devsite-syntax-p">()</span> <span class="devsite-syntax-n">output_details</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">interpreter</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">get_output_details</span><span class="devsite-syntax-p">()</span> </code></pre></devsite-code> </div> <devsite-thumb-rating position="footer"> </devsite-thumb-rating> <devsite-feedback position="footer" project-name="Google AI Edge" product-id="5336252" bucket="documentation" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="footer" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/touchicon-180-new.png" > <button> Send feedback </button> </devsite-feedback> <div class="devsite-floating-action-buttons"> </div> </article> <devsite-content-footer class="nocontent"> <p>Except as otherwise noted, the content of this page is licensed under the <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 License</a>, and code samples are licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>. For details, see the <a href="https://developers.google.com/site-policies">Google Developers Site Policies</a>. Java is a registered trademark of Oracle and/or its affiliates.</p> <p>Last updated 2024-09-24 UTC.</p> </devsite-content-footer> <devsite-notification > </devsite-notification> <div class="devsite-content-data"> <template class="devsite-thumb-rating-feedback"> <devsite-feedback position="thumb-rating" project-name="Google AI Edge" product-id="5336252" bucket="documentation" context="" version="t-devsite-webserver-20241114-r00-rc02.464921008191574316" data-label="Send Feedback Button" track-type="feedback" track-name="sendFeedbackLink" track-metadata-position="thumb-rating" class="nocontent" project-icon="https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/touchicon-180-new.png" > <button> Need to tell us more? </button> </devsite-feedback> </template> <template class="devsite-content-data-template"> [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-24 UTC."],[],[]] </template> </div> </devsite-content> </main> <devsite-footer-promos class="devsite-footer"> </devsite-footer-promos> <devsite-footer-linkboxes class="devsite-footer"> <nav class="devsite-footer-linkboxes nocontent" aria-label="Footer links"> </nav> </devsite-footer-linkboxes> <devsite-footer-utility class="devsite-footer"> <div class="devsite-footer-utility nocontent"> <nav class="devsite-footer-utility-links" aria-label="Utility links"> <ul class="devsite-footer-utility-list"> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/terms" data-category="Site-Wide Custom Events" data-label="Footer Terms link" > Terms </a> </li> <li class="devsite-footer-utility-item "> <a class="devsite-footer-utility-link gc-analytics-event" href="//policies.google.com/privacy" data-category="Site-Wide Custom Events" data-label="Footer Privacy link" > Privacy </a> </li> <li class="devsite-footer-utility-item glue-cookie-notification-bar-control"> <a class="devsite-footer-utility-link gc-analytics-event" href="#" data-category="Site-Wide Custom Events" data-label="Footer Manage cookies link" aria-hidden="true" > Manage cookies </a> </li> </ul> <devsite-language-selector> <ul role="presentation"> <li role="presentation"> <a role="menuitem" lang="en" >English</a> </li> <li role="presentation"> <a role="menuitem" lang="de" >Deutsch</a> </li> <li role="presentation"> <a role="menuitem" lang="es_419" >Español – América Latina</a> </li> <li role="presentation"> <a role="menuitem" lang="fr" >Français</a> </li> <li role="presentation"> <a role="menuitem" lang="id" >Indonesia</a> </li> <li role="presentation"> <a role="menuitem" lang="it" >Italiano</a> </li> <li role="presentation"> <a role="menuitem" lang="pl" >Polski</a> </li> <li role="presentation"> <a role="menuitem" lang="pt_br" >Português – Brasil</a> </li> <li role="presentation"> <a role="menuitem" lang="vi" >Tiếng Việt</a> </li> <li role="presentation"> <a role="menuitem" lang="tr" >Türkçe</a> </li> <li role="presentation"> <a role="menuitem" lang="ru" >Русский</a> </li> <li role="presentation"> <a role="menuitem" lang="he" >עברית</a> </li> <li role="presentation"> <a role="menuitem" lang="ar" >العربيّة</a> </li> <li role="presentation"> <a role="menuitem" lang="fa" >فارسی</a> </li> <li role="presentation"> <a role="menuitem" lang="hi" >हिंदी</a> </li> <li role="presentation"> <a role="menuitem" lang="bn" >বাংলা</a> </li> <li role="presentation"> <a role="menuitem" lang="th" >ภาษาไทย</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_cn" >中文 – 简体</a> </li> <li role="presentation"> <a role="menuitem" lang="zh_tw" >中文 – 繁體</a> </li> <li role="presentation"> <a role="menuitem" lang="ja" >日本語</a> </li> <li role="presentation"> <a role="menuitem" lang="ko" >한국어</a> </li> </ul> </devsite-language-selector> </nav> </div> </devsite-footer-utility> <devsite-panel></devsite-panel> </section></section> <devsite-sitemask></devsite-sitemask> <devsite-snackbar></devsite-snackbar> <devsite-tooltip ></devsite-tooltip> <devsite-heading-link></devsite-heading-link> <devsite-analytics> <script type="application/json" analytics>[]</script> <script type="application/json" tag-management>{&#34;at&#34;: &#34;True&#34;, &#34;ga4&#34;: [], &#34;ga4p&#34;: [], &#34;gtm&#34;: [{&#34;id&#34;: &#34;GTM-TC2MQKS8&#34;, &#34;purpose&#34;: 0}], &#34;parameters&#34;: {&#34;internalUser&#34;: &#34;False&#34;, &#34;language&#34;: {&#34;machineTranslated&#34;: &#34;False&#34;, &#34;requested&#34;: &#34;en&#34;, &#34;served&#34;: &#34;en&#34;}, &#34;pageType&#34;: &#34;article&#34;, &#34;projectName&#34;: &#34;Google AI Edge&#34;, &#34;signedIn&#34;: &#34;False&#34;, &#34;tenant&#34;: &#34;googledevai&#34;, &#34;recommendations&#34;: {&#34;sourcePage&#34;: &#34;&#34;, &#34;sourceType&#34;: 0, &#34;sourceRank&#34;: 0, &#34;sourceIdenticalDescriptions&#34;: 0, &#34;sourceTitleWords&#34;: 0, &#34;sourceDescriptionWords&#34;: 0, &#34;experiment&#34;: &#34;&#34;}, &#34;experiment&#34;: {&#34;ids&#34;: &#34;&#34;}}}</script> </devsite-analytics> <devsite-badger></devsite-badger> <script nonce="IXyxH4aDkbqB9MKuYXAWx5uULXnbVt"> (function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i; t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0]; E.parentNode.insertBefore(t,E);})(window, document, 'script', 'https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/js/app_loader.js', '[59,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai","https://googledevai-dot-devsite-v2-prod-3p.appspot.com",null,null,["/_pwa/googledevai/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v870e399c64f7c43c99a3043db4b3a74327bb93d0914e84a0c3dba90bbfd67625/googledevai/images/favicon-new.png","/_static/googledevai/images/lockup-new.svg","https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,116,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyCNm9YxQumEXwGJgTDjxoxXK6m1F-9720Q","AIzaSyCc76DZePGtoyUjqKrLdsMGk_ry7sljLbY","ai.google.dev","AIzaSyB9bqgQ2t11WJsOX8qNsCQ6U-w91mmqF-I","AIzaSyAdYnStPdzjcJJtQ0mvIaeaMKj7_t6J_Fg",null,null,null,["Cloud__enable_legacy_calculator_redirect","Profiles__enable_release_notes_notifications","Search__enable_ai_eligibility_checks","DevPro__enable_developer_subscriptions","Cloud__enable_cloudx_experiment_ids","Profiles__enable_awarding_url","MiscFeatureFlags__emergency_css","Profiles__enable_dashboard_curated_recommendations","Profiles__enable_recognition_badges","MiscFeatureFlags__enable_view_transitions","TpcFeatures__enable_mirror_tenant_redirects","CloudShell__cloud_code_overflow_menu","MiscFeatureFlags__developers_footer_dark_image","Cloud__enable_llm_concierge_chat","MiscFeatureFlags__developers_footer_image","EngEduTelemetry__enable_engedu_telemetry","Cloud__enable_cloud_shell","Concierge__enable_pushui","DevPro__enable_cloud_innovators_plus","Profiles__require_profile_eligibility_for_signin","Profiles__enable_profile_collections","MiscFeatureFlags__enable_explain_this_code","Analytics__enable_clearcut_logging","Profiles__enable_page_saving","Profiles__enable_completecodelab_endpoint","Cloud__enable_cloud_facet_chat","BookNav__enable_tenant_cache_key","OnSwitch__enable","Search__enable_dynamic_content_confidential_banner","MiscFeatureFlags__enable_variable_operator","Profiles__enable_public_developer_profiles","Cloud__enable_free_trial_server_call","Search__enable_suggestions_from_borg","Cloud__enable_cloud_shell_fte_user_flow","Profiles__enable_developer_profiles_callout","MiscFeatureFlags__enable_project_variables","CloudShell__cloud_shell_button","Experiments__reqs_query_experiments","Cloud__enable_cloudx_ping","TpcFeatures__enable_required_headers","Search__enable_page_map","Profiles__enable_complete_playlist_endpoint","MiscFeatureFlags__enable_firebase_utm","Cloud__enable_cloud_dlp_service"],null,null,"AIzaSyA58TaKli1DculwmAmbpzLVGuWc8eCQgQc","https://developerscontentserving-pa.googleapis.com","AIzaSyDWBU60w0P9hEkr29kkksYs8Z7gvZ8u_wc","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[59,"googledevai","Google AI for Developers","ai.google.dev",null,"googledevai-dot-devsite-v2-prod-3p.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],null,null,null,null,[1],[1,1,null,1,1]],null,[73,null,null,null,null,null,"/images/lockup-new.svg","/images/touchicon-180-new.png",null,null,null,null,1,1,null,null,null,null,null,null,null,1,null,null,null,"/images/lockup-dark-theme-new.svg",[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[],[1,1]],[[null,null,null,null,null,["GTM-TC2MQKS8"],null,null,null,null,null,[["GTM-TC2MQKS8",1]],1]],null,4]]') </script> <devsite-a11y-announce></devsite-a11y-announce> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10