import{S as ys,i as bs,s as Ms,e as s,k as h,w as m,t as l,M as gs,c as n,d as o,m as f,a as r,x as w,h as a,b as c,G as t,g as p,y,L as Ts,q as b,o as M,B as g,v as vs}from"../chunks/vendor-hf-doc-builder.js";import{I as Mt}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as R}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as _s}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";function Js(ca){let E,gt,X,B,Ce,q,wo,Le,yo,Tt,P,vt,$,bo,D,Mo,go,_t,je,To,Jt,d,vo,ze,_o,Jo,Ne,Uo,jo,O,Qe,ko,Eo,Ye,Xo,Zo,Se,Go,Ao,He,Wo,Io,qe,Ro,Bo,Pe,$o,Fo,Ut,T,xo,K,Vo,Co,ee,Lo,zo,te,No,Qo,oe,Yo,So,jt,ke,Ho,kt,Z,F,De,le,qo,Oe,Po,Et,Ee,Do,Xt,ae,Zt,x,Oo,Ke,Ko,el,Gt,se,At,Xe,tl,Wt,ne,It,_,ol,et,ll,al,tt,sl,nl,Rt,re,Bt,G,V,ot,ie,rl,lt,il,$t,C,pl,at,cl,hl,Ft,pe,xt,Ze,fl,Vt,ce,Ct,L,dl,st,ul,ml,Lt,A,z,nt,he,wl,rt,yl,zt,J,bl,it,Ml,gl,fe,Tl,vl,Nt,N,_l,pt,Jl,Ul,Qt,U,jl,ct,kl,El,ht,Xl,Zl,Yt,de,St,Q,Gl,ft,Al,Wl,Ht,ue,qt,Ge,Il,Pt,me,Dt,Y,Rl,dt,Bl,$l,Ot,Ae,Fl,Kt,W,S,ut,we,xl,mt,Vl,eo,We,Cl,to,v,j,ye,Ll,zl,be,Nl,Ql,Me,Yl,Sl,Hl,Ie,ge,ql,Pl,Dl,Re,Te,Ol,Kl,ea,Be,ta,I,wt,ve,oa,la,yt,_e,aa,sa,bt,Je,na,oo;return q=new Mt({}),P=new _s({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tf_xla.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/tf_xla.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/tf_xla.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tf_xla.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/tf_xla.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/tf_xla.ipynb"}]}}),le=new Mt({}),ae=new R({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbCUyMCUzRCUyMHRmLmtlcmFzLlNlcXVlbnRpYWwoJTBBJTIwJTIwJTIwJTIwJTVCdGYua2VyYXMubGF5ZXJzLkRlbnNlKDEwJTJDJTIwaW5wdXRfc2hhcGUlM0QoMTAlMkMpJTJDJTIwYWN0aXZhdGlvbiUzRCUyMnJlbHUlMjIpJTJDJTIwdGYua2VyYXMubGF5ZXJzLkRlbnNlKDUlMkMlMjBhY3RpdmF0aW9uJTNEJTIyc29mdG1heCUyMiklNUQlMEEp",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

model = tf.keras.Sequential(
    [tf.keras.layers.Dense(<span class="hljs-number">10</span>, input_shape=(<span class="hljs-number">10</span>,), activation=<span class="hljs-string">&quot;relu&quot;</span>), tf.keras.layers.Dense(<span class="hljs-number">5</span>, activation=<span class="hljs-string">&quot;softmax&quot;</span>)]
)`}}),se=new R({props:{code:"JTIzJTIwR2VuZXJhdGUlMjByYW5kb20lMjBpbnB1dHMlMjBmb3IlMjB0aGUlMjBtb2RlbC4lMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFpbnB1dF92ZWN0b3JfZGltJTIwJTNEJTIwMTAlMEFyYW5kb21faW5wdXRzJTIwJTNEJTIwdGYucmFuZG9tLm5vcm1hbCgoYmF0Y2hfc2l6ZSUyQyUyMGlucHV0X3ZlY3Rvcl9kaW0pKSUwQSUwQSUyMyUyMFJ1biUyMGElMjBmb3J3YXJkJTIwcGFzcy4lMEFfJTIwJTNEJTIwbW9kZWwocmFuZG9tX2lucHV0cyk=",highlighted:`<span class="hljs-comment"># Generate random inputs for the model.</span>
batch_size = <span class="hljs-number">16</span>
input_vector_dim = <span class="hljs-number">10</span>
random_inputs = tf.random.normal((batch_size, input_vector_dim))

<span class="hljs-comment"># Run a forward pass.</span>
_ = model(random_inputs)`}}),ne=new R({props:{code:"eGxhX2ZuJTIwJTNEJTIwdGYuZnVuY3Rpb24obW9kZWwlMkMlMjBqaXRfY29tcGlsZSUzRFRydWUpJTBBXyUyMCUzRCUyMHhsYV9mbihyYW5kb21faW5wdXRzKQ==",highlighted:`xla_fn = tf.function(model, jit_compile=<span class="hljs-literal">True</span>)
_ = xla_fn(random_inputs)`}}),re=new R({props:{code:"bXlfeGxhX2ZuJTIwJTNEJTIwdGYuZnVuY3Rpb24obW9kZWwubXlfeGxhX2ZuJTJDJTIwaml0X2NvbXBpbGUlM0RUcnVlKQ==",highlighted:'my_xla_fn = tf.function(model.my_xla_fn, jit_compile=<span class="hljs-literal">True</span>)'}}),ie=new Mt({}),pe=new R({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMC0tdXBncmFkZQ==",highlighted:"pip install transformers --upgrade"}}),ce=new R({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEElMjMlMjBXaWxsJTIwZXJyb3IlMjBpZiUyMHRoZSUyMG1pbmltYWwlMjB2ZXJzaW9uJTIwb2YlMjBUcmFuc2Zvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZC4lMEFmcm9tJTIwdHJhbnNmb3JtZXJzLnV0aWxzJTIwaW1wb3J0JTIwY2hlY2tfbWluX3ZlcnNpb24lMEElMEFjaGVja19taW5fdmVyc2lvbiglMjI0LjIxLjAlMjIpJTBBJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiUyQyUyMHBhZGRpbmdfc2lkZSUzRCUyMmxlZnQlMjIlMkMlMjBwYWRfdG9rZW4lM0QlMjIlM0MlMkZzJTNFJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFpbnB1dF9zdHJpbmclMjAlM0QlMjAlNUIlMjJUZW5zb3JGbG93JTIwaXMlMjIlNUQlMEElMEElMjMlMjBPbmUlMjBsaW5lJTIwdG8lMjBjcmVhdGUlMjBhbiUyMFhMQSUyMGdlbmVyYXRpb24lMjBmdW5jdGlvbiUwQXhsYV9nZW5lcmF0ZSUyMCUzRCUyMHRmLmZ1bmN0aW9uKG1vZGVsLmdlbmVyYXRlJTJDJTIwaml0X2NvbXBpbGUlM0RUcnVlKSUwQSUwQXRva2VuaXplZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplcihpbnB1dF9zdHJpbmclMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQWdlbmVyYXRlZF90b2tlbnMlMjAlM0QlMjB4bGFfZ2VuZXJhdGUoKip0b2tlbml6ZWRfaW5wdXQlMkMlMjBudW1fYmVhbXMlM0QyKSUwQSUwQWRlY29kZWRfdGV4dCUyMCUzRCUyMHRva2VuaXplci5kZWNvZGUoZ2VuZXJhdGVkX3Rva2VucyU1QjAlNUQlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklMEFwcmludChmJTIyR2VuZXJhdGVkJTIwLS0lMjAlN0JkZWNvZGVkX3RleHQlN0QlMjIpJTBBJTIzJTIwR2VuZXJhdGVkJTIwLS0lMjBUZW5zb3JGbG93JTIwaXMlMjBhbiUyMG9wZW4tc291cmNlJTJDJTIwb3Blbi1zb3VyY2UlMkMlMjBkaXN0cmlidXRlZC1zb3VyY2UlMjBhcHBsaWNhdGlvbiUyMCUyMyUyMGZyYW1ld29yayUyMGZvciUyMHRoZQ==",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForCausalLM

<span class="hljs-comment"># Will error if the minimal version of Transformers is not installed.</span>
<span class="hljs-keyword">from</span> transformers.utils <span class="hljs-keyword">import</span> check_min_version

check_min_version(<span class="hljs-string">&quot;4.21.0&quot;</span>)


tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>, padding_side=<span class="hljs-string">&quot;left&quot;</span>, pad_token=<span class="hljs-string">&quot;&lt;/s&gt;&quot;</span>)
model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
input_string = [<span class="hljs-string">&quot;TensorFlow is&quot;</span>]

<span class="hljs-comment"># One line to create an XLA generation function</span>
xla_generate = tf.function(model.generate, jit_compile=<span class="hljs-literal">True</span>)

tokenized_input = tokenizer(input_string, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
generated_tokens = xla_generate(**tokenized_input, num_beams=<span class="hljs-number">2</span>)

decoded_text = tokenizer.decode(generated_tokens[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Generated -- <span class="hljs-subst">{decoded_text}</span>&quot;</span>)
<span class="hljs-comment"># Generated -- TensorFlow is an open-source, open-source, distributed-source application # framework for the</span>`}}),he=new Mt({}),de=new R({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyJTJDJTIwcGFkZGluZ19zaWRlJTNEJTIybGVmdCUyMiUyQyUyMHBhZF90b2tlbiUzRCUyMiUzQyUyRnMlM0UlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJncHQyJTIyKSUwQWlucHV0X3N0cmluZyUyMCUzRCUyMCU1QiUyMlRlbnNvckZsb3clMjBpcyUyMiU1RCUwQSUwQXhsYV9nZW5lcmF0ZSUyMCUzRCUyMHRmLmZ1bmN0aW9uKG1vZGVsLmdlbmVyYXRlJTJDJTIwaml0X2NvbXBpbGUlM0RUcnVlKSUwQSUwQSUyMyUyMEhlcmUlMkMlMjB3ZSUyMGNhbGwlMjB0aGUlMjB0b2tlbml6ZXIlMjB3aXRoJTIwcGFkZGluZyUyMG9wdGlvbnMuJTBBdG9rZW5pemVkX2lucHV0JTIwJTNEJTIwdG9rZW5pemVyKGlucHV0X3N0cmluZyUyQyUyMHBhZF90b19tdWx0aXBsZV9vZiUzRDglMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBJTBBZ2VuZXJhdGVkX3Rva2VucyUyMCUzRCUyMHhsYV9nZW5lcmF0ZSgqKnRva2VuaXplZF9pbnB1dCUyQyUyMG51bV9iZWFtcyUzRDIpJTBBZGVjb2RlZF90ZXh0JTIwJTNEJTIwdG9rZW5pemVyLmRlY29kZShnZW5lcmF0ZWRfdG9rZW5zJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSUwQXByaW50KGYlMjJHZW5lcmF0ZWQlMjAtLSUyMCU3QmRlY29kZWRfdGV4dCU3RCUyMik=",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>, padding_side=<span class="hljs-string">&quot;left&quot;</span>, pad_token=<span class="hljs-string">&quot;&lt;/s&gt;&quot;</span>)
model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
input_string = [<span class="hljs-string">&quot;TensorFlow is&quot;</span>]

xla_generate = tf.function(model.generate, jit_compile=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Here, we call the tokenizer with padding options.</span>
tokenized_input = tokenizer(input_string, pad_to_multiple_of=<span class="hljs-number">8</span>, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

generated_tokens = xla_generate(**tokenized_input, num_beams=<span class="hljs-number">2</span>)
decoded_text = tokenizer.decode(generated_tokens[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Generated -- <span class="hljs-subst">{decoded_text}</span>&quot;</span>)`}}),ue=new R({props:{code:"aW1wb3J0JTIwdGltZSUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiUyQyUyMHBhZGRpbmdfc2lkZSUzRCUyMmxlZnQlMjIlMkMlMjBwYWRfdG9rZW4lM0QlMjIlM0MlMkZzJTNFJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEElMEF4bGFfZ2VuZXJhdGUlMjAlM0QlMjB0Zi5mdW5jdGlvbihtb2RlbC5nZW5lcmF0ZSUyQyUyMGppdF9jb21waWxlJTNEVHJ1ZSklMEElMEFmb3IlMjBpbnB1dF9zdHJpbmclMjBpbiUyMCU1QiUyMlRlbnNvckZsb3clMjBpcyUyMiUyQyUyMCUyMlRlbnNvckZsb3clMjBpcyUyMGElMjIlMkMlMjAlMjJURkxpdGUlMjBpcyUyMGElMjIlNUQlM0ElMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfaW5wdXQlMjAlM0QlMjB0b2tlbml6ZXIoaW5wdXRfc3RyaW5nJTJDJTIwcGFkX3RvX211bHRpcGxlX29mJTNEOCUyQyUyMHBhZGRpbmclM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEElMjAlMjAlMjAlMjBzdGFydCUyMCUzRCUyMHRpbWUudGltZV9ucygpJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdGVkX3Rva2VucyUyMCUzRCUyMHhsYV9nZW5lcmF0ZSgqKnRva2VuaXplZF9pbnB1dCUyQyUyMG51bV9iZWFtcyUzRDIpJTBBJTIwJTIwJTIwJTIwZW5kJTIwJTNEJTIwdGltZS50aW1lX25zKCklMEElMjAlMjAlMjAlMjBwcmludChmJTIyRXhlY3V0aW9uJTIwdGltZSUyMC0tJTIwJTdCKGVuZCUyMC0lMjBzdGFydCklMjAlMkYlMjAxZTYlM0EuMWYlN0QlMjBtcyU1Q24lMjIp",highlighted:`<span class="hljs-keyword">import</span> time
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>, padding_side=<span class="hljs-string">&quot;left&quot;</span>, pad_token=<span class="hljs-string">&quot;&lt;/s&gt;&quot;</span>)
model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

xla_generate = tf.function(model.generate, jit_compile=<span class="hljs-literal">True</span>)

<span class="hljs-keyword">for</span> input_string <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;TensorFlow is&quot;</span>, <span class="hljs-string">&quot;TensorFlow is a&quot;</span>, <span class="hljs-string">&quot;TFLite is a&quot;</span>]:
    tokenized_input = tokenizer(input_string, pad_to_multiple_of=<span class="hljs-number">8</span>, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
    start = time.time_ns()
    generated_tokens = xla_generate(**tokenized_input, num_beams=<span class="hljs-number">2</span>)
    end = time.time_ns()
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Execution time -- <span class="hljs-subst">{(end - start) / <span class="hljs-number">1e6</span>:<span class="hljs-number">.1</span>f}</span> ms\\n&quot;</span>)`}}),me=new R({props:{code:"RXhlY3V0aW9uJTIwdGltZSUyMC0tJTIwMzA4MTkuNiUyMG1zJTBBJTBBRXhlY3V0aW9uJTIwdGltZSUyMC0tJTIwNzkuMCUyMG1zJTBBJTBBRXhlY3V0aW9uJTIwdGltZSUyMC0tJTIwNzguOSUyMG1z",highlighted:`Execution time -- 30819.6 ms

Execution time -- 79.0 ms

Execution time -- 78.9 ms`}}),we=new Mt({}),{c(){E=s("meta"),gt=h(),X=s("h1"),B=s("a"),Ce=s("span"),m(q.$$.fragment),wo=h(),Le=s("span"),yo=l("XLA Integration for TensorFlow Models"),Tt=h(),m(P.$$.fragment),vt=h(),$=s("p"),bo=l("Accelerated Linear Algebra, dubbed XLA, is a compiler for accelerating the runtime of TensorFlow Models. From the "),D=s("a"),Mo=l("official documentation"),go=l(":"),_t=h(),je=s("p"),To=l("XLA (Accelerated Linear Algebra) is a domain-specific compiler for linear algebra that can accelerate TensorFlow models with potentially no source code changes."),Jt=h(),d=s("p"),vo=l("Using XLA in TensorFlow is simple \u2013 it comes packaged inside the "),ze=s("code"),_o=l("tensorflow"),Jo=l(" library, and it can be triggered with the "),Ne=s("code"),Uo=l("jit_compile"),jo=l(" argument in any graph-creating function such as "),O=s("a"),Qe=s("code"),ko=l("tf.function"),Eo=l(". When using Keras methods like "),Ye=s("code"),Xo=l("fit()"),Zo=l(" and "),Se=s("code"),Go=l("predict()"),Ao=l(", you can enable XLA simply by passing the "),He=s("code"),Wo=l("jit_compile"),Io=l(" argument to "),qe=s("code"),Ro=l("model.compile()"),Bo=l(". However, XLA is not limited to these methods - it can also be used to accelerate any arbitrary "),Pe=s("code"),$o=l("tf.function"),Fo=l("."),Ut=h(),T=s("p"),xo=l("Several TensorFlow methods in \u{1F917} Transformers have been rewritten to be XLA-compatible, including text generation for models such as "),K=s("a"),Vo=l("GPT2"),Co=l(", "),ee=s("a"),Lo=l("T5"),zo=l(" and "),te=s("a"),No=l("OPT"),Qo=l(", as well as speech processing for models such as "),oe=s("a"),Yo=l("Whisper"),So=l("."),jt=h(),ke=s("p"),Ho=l("While the exact amount of speed-up is very much model-dependent, for TensorFlow text generation models inside \u{1F917} Transformers, we noticed a speed-up of ~100x. This document will explain how you can use XLA for these models to get the maximum amount of performance. We\u2019ll also provide links to additional resources if you\u2019re interested to learn more about the benchmarks and our design philosophy behind the XLA integration."),kt=h(),Z=s("h2"),F=s("a"),De=s("span"),m(le.$$.fragment),qo=h(),Oe=s("span"),Po=l("Running TF functions with XLA"),Et=h(),Ee=s("p"),Do=l("Let us consider the following model in TensorFlow:"),Xt=h(),m(ae.$$.fragment),Zt=h(),x=s("p"),Oo=l("The above model accepts inputs having a dimension of "),Ke=s("code"),Ko=l("(10, )"),el=l(". We can use the model for running a forward pass like so:"),Gt=h(),m(se.$$.fragment),At=h(),Xe=s("p"),tl=l("In order to run the forward pass with an XLA-compiled function, we\u2019d need to do:"),Wt=h(),m(ne.$$.fragment),It=h(),_=s("p"),ol=l("The default "),et=s("code"),ll=l("call()"),al=l(" function of the "),tt=s("code"),sl=l("model"),nl=l(" is used for compiling the XLA graph. But if there\u2019s any other model function you want to compile into XLA that\u2019s also possible with:"),Rt=h(),m(re.$$.fragment),Bt=h(),G=s("h2"),V=s("a"),ot=s("span"),m(ie.$$.fragment),rl=h(),lt=s("span"),il=l("Running a TF text generation model with XLA from \u{1F917} Transformers"),$t=h(),C=s("p"),pl=l("To enable XLA-accelerated generation within \u{1F917} Transformers, you need to have a recent version of "),at=s("code"),cl=l("transformers"),hl=l(" installed. You can install it by running:"),Ft=h(),m(pe.$$.fragment),xt=h(),Ze=s("p"),fl=l("And then you can run the following code:"),Vt=h(),m(ce.$$.fragment),Ct=h(),L=s("p"),dl=l("As you can notice, enabling XLA on "),st=s("code"),ul=l("generate()"),ml=l(" is just a single line of code. The rest of the code remains unchanged. However, there are a couple of gotchas in the above code snippet that are specific to XLA. You need to be aware of those to realize the speed-ups that XLA can bring in. We discuss these in the following section."),Lt=h(),A=s("h2"),z=s("a"),nt=s("span"),m(he.$$.fragment),wl=h(),rt=s("span"),yl=l("Gotchas to be aware of"),zt=h(),J=s("p"),bl=l("When you are executing an XLA-enabled function (like "),it=s("code"),Ml=l("xla_generate()"),gl=l(" above) for the first time, it will internally try to infer the computation graph, which is time-consuming.  This process is known as "),fe=s("a"),Tl=l("\u201Ctracing\u201D"),vl=l("."),Nt=h(),N=s("p"),_l=l("You might notice that the generation time is not fast. Successive calls of "),pt=s("code"),Jl=l("xla_generate()"),Ul=l(" (or any other XLA-enabled function) won\u2019t have to infer the computation graph, given the inputs to the function follow the same shape with which the computation graph was initially built. While this is not a problem for modalities with fixed input shapes (e.g., images), you must pay attention if you are working with variable input shape modalities (e.g., text)."),Qt=h(),U=s("p"),jl=l("To ensure "),ct=s("code"),kl=l("xla_generate()"),El=l(" always operates with the same input shapes, you can specify the "),ht=s("code"),Xl=l("padding"),Zl=l(" arguments when calling the tokenizer."),Yt=h(),m(de.$$.fragment),St=h(),Q=s("p"),Gl=l("This way, you can ensure that the inputs to "),ft=s("code"),Al=l("xla_generate()"),Wl=l(" will always receive inputs with the shape it was traced with and thus leading to speed-ups in the generation time. You can verify this with the code below:"),Ht=h(),m(ue.$$.fragment),qt=h(),Ge=s("p"),Il=l("On a Tesla T4 GPU, you can expect the outputs like so:"),Pt=h(),m(me.$$.fragment),Dt=h(),Y=s("p"),Rl=l("The first call to "),dt=s("code"),Bl=l("xla_generate()"),$l=l(" is time-consuming because of tracing, but the successive calls are orders of magnitude faster. Keep in mind that any change in the generation options at any point with trigger re-tracing and thus leading to slow-downs in the generation time."),Ot=h(),Ae=s("p"),Fl=l("We didn\u2019t cover all the text generation options \u{1F917} Transformers provides in this document. We encourage you to read the documentation for advanced use cases."),Kt=h(),W=s("h2"),S=s("a"),ut=s("span"),m(we.$$.fragment),xl=h(),mt=s("span"),Vl=l("Additional Resources"),eo=h(),We=s("p"),Cl=l("Here, we leave you with some additional resources if you want to delve deeper into XLA in \u{1F917} Transformers and in general."),to=h(),v=s("ul"),j=s("li"),ye=s("a"),Ll=l("This Colab Notebook"),zl=l(" provides an interactive demonstration if you want to fiddle with the XLA-compatible encoder-decoder (like "),be=s("a"),Nl=l("T5"),Ql=l(") and decoder-only (like "),Me=s("a"),Yl=l("GPT2"),Sl=l(") text generation models."),Hl=h(),Ie=s("li"),ge=s("a"),ql=l("This blog post"),Pl=l(" provides an overview of the comparison benchmarks for XLA-compatible models along with a friendly introduction to XLA in TensorFlow."),Dl=h(),Re=s("li"),Te=s("a"),Ol=l("This blog post"),Kl=l(" discusses our design philosophy behind adding XLA support to the TensorFlow models in \u{1F917} Transformers."),ea=h(),Be=s("li"),ta=l("Recommended posts for learning more about XLA and TensorFlow graphs in general:"),I=s("ul"),wt=s("li"),ve=s("a"),oa=l("XLA: Optimizing Compiler for Machine Learning"),la=h(),yt=s("li"),_e=s("a"),aa=l("Introduction to graphs and tf.function"),sa=h(),bt=s("li"),Je=s("a"),na=l("Better performance with tf.function"),this.h()},l(e){const i=gs('[data-svelte="svelte-1phssyn"]',document.head);E=n(i,"META",{name:!0,content:!0}),i.forEach(o),gt=f(e),X=n(e,"H1",{class:!0});var lo=r(X);B=n(lo,"A",{id:!0,class:!0,href:!0});var ha=r(B);Ce=n(ha,"SPAN",{});var fa=r(Ce);w(q.$$.fragment,fa),fa.forEach(o),ha.forEach(o),wo=f(lo),Le=n(lo,"SPAN",{});var da=r(Le);yo=a(da,"XLA Integration for TensorFlow Models"),da.forEach(o),lo.forEach(o),Tt=f(e),w(P.$$.fragment,e),vt=f(e),$=n(e,"P",{});var ao=r($);bo=a(ao,"Accelerated Linear Algebra, dubbed XLA, is a compiler for accelerating the runtime of TensorFlow Models. From the "),D=n(ao,"A",{href:!0,rel:!0});var ua=r(D);Mo=a(ua,"official documentation"),ua.forEach(o),go=a(ao,":"),ao.forEach(o),_t=f(e),je=n(e,"P",{});var ma=r(je);To=a(ma,"XLA (Accelerated Linear Algebra) is a domain-specific compiler for linear algebra that can accelerate TensorFlow models with potentially no source code changes."),ma.forEach(o),Jt=f(e),d=n(e,"P",{});var u=r(d);vo=a(u,"Using XLA in TensorFlow is simple \u2013 it comes packaged inside the "),ze=n(u,"CODE",{});var wa=r(ze);_o=a(wa,"tensorflow"),wa.forEach(o),Jo=a(u," library, and it can be triggered with the "),Ne=n(u,"CODE",{});var ya=r(Ne);Uo=a(ya,"jit_compile"),ya.forEach(o),jo=a(u," argument in any graph-creating function such as "),O=n(u,"A",{href:!0,rel:!0});var ba=r(O);Qe=n(ba,"CODE",{});var Ma=r(Qe);ko=a(Ma,"tf.function"),Ma.forEach(o),ba.forEach(o),Eo=a(u,". When using Keras methods like "),Ye=n(u,"CODE",{});var ga=r(Ye);Xo=a(ga,"fit()"),ga.forEach(o),Zo=a(u," and "),Se=n(u,"CODE",{});var Ta=r(Se);Go=a(Ta,"predict()"),Ta.forEach(o),Ao=a(u,", you can enable XLA simply by passing the "),He=n(u,"CODE",{});var va=r(He);Wo=a(va,"jit_compile"),va.forEach(o),Io=a(u," argument to "),qe=n(u,"CODE",{});var _a=r(qe);Ro=a(_a,"model.compile()"),_a.forEach(o),Bo=a(u,". However, XLA is not limited to these methods - it can also be used to accelerate any arbitrary "),Pe=n(u,"CODE",{});var Ja=r(Pe);$o=a(Ja,"tf.function"),Ja.forEach(o),Fo=a(u,"."),u.forEach(o),Ut=f(e),T=n(e,"P",{});var k=r(T);xo=a(k,"Several TensorFlow methods in \u{1F917} Transformers have been rewritten to be XLA-compatible, including text generation for models such as "),K=n(k,"A",{href:!0,rel:!0});var Ua=r(K);Vo=a(Ua,"GPT2"),Ua.forEach(o),Co=a(k,", "),ee=n(k,"A",{href:!0,rel:!0});var ja=r(ee);Lo=a(ja,"T5"),ja.forEach(o),zo=a(k," and "),te=n(k,"A",{href:!0,rel:!0});var ka=r(te);No=a(ka,"OPT"),ka.forEach(o),Qo=a(k,", as well as speech processing for models such as "),oe=n(k,"A",{href:!0,rel:!0});var Ea=r(oe);Yo=a(Ea,"Whisper"),Ea.forEach(o),So=a(k,"."),k.forEach(o),jt=f(e),ke=n(e,"P",{});var Xa=r(ke);Ho=a(Xa,"While the exact amount of speed-up is very much model-dependent, for TensorFlow text generation models inside \u{1F917} Transformers, we noticed a speed-up of ~100x. This document will explain how you can use XLA for these models to get the maximum amount of performance. We\u2019ll also provide links to additional resources if you\u2019re interested to learn more about the benchmarks and our design philosophy behind the XLA integration."),Xa.forEach(o),kt=f(e),Z=n(e,"H2",{class:!0});var so=r(Z);F=n(so,"A",{id:!0,class:!0,href:!0});var Za=r(F);De=n(Za,"SPAN",{});var Ga=r(De);w(le.$$.fragment,Ga),Ga.forEach(o),Za.forEach(o),qo=f(so),Oe=n(so,"SPAN",{});var Aa=r(Oe);Po=a(Aa,"Running TF functions with XLA"),Aa.forEach(o),so.forEach(o),Et=f(e),Ee=n(e,"P",{});var Wa=r(Ee);Do=a(Wa,"Let us consider the following model in TensorFlow:"),Wa.forEach(o),Xt=f(e),w(ae.$$.fragment,e),Zt=f(e),x=n(e,"P",{});var no=r(x);Oo=a(no,"The above model accepts inputs having a dimension of "),Ke=n(no,"CODE",{});var Ia=r(Ke);Ko=a(Ia,"(10, )"),Ia.forEach(o),el=a(no,". We can use the model for running a forward pass like so:"),no.forEach(o),Gt=f(e),w(se.$$.fragment,e),At=f(e),Xe=n(e,"P",{});var Ra=r(Xe);tl=a(Ra,"In order to run the forward pass with an XLA-compiled function, we\u2019d need to do:"),Ra.forEach(o),Wt=f(e),w(ne.$$.fragment,e),It=f(e),_=n(e,"P",{});var $e=r(_);ol=a($e,"The default "),et=n($e,"CODE",{});var Ba=r(et);ll=a(Ba,"call()"),Ba.forEach(o),al=a($e," function of the "),tt=n($e,"CODE",{});var $a=r(tt);sl=a($a,"model"),$a.forEach(o),nl=a($e," is used for compiling the XLA graph. But if there\u2019s any other model function you want to compile into XLA that\u2019s also possible with:"),$e.forEach(o),Rt=f(e),w(re.$$.fragment,e),Bt=f(e),G=n(e,"H2",{class:!0});var ro=r(G);V=n(ro,"A",{id:!0,class:!0,href:!0});var Fa=r(V);ot=n(Fa,"SPAN",{});var xa=r(ot);w(ie.$$.fragment,xa),xa.forEach(o),Fa.forEach(o),rl=f(ro),lt=n(ro,"SPAN",{});var Va=r(lt);il=a(Va,"Running a TF text generation model with XLA from \u{1F917} Transformers"),Va.forEach(o),ro.forEach(o),$t=f(e),C=n(e,"P",{});var io=r(C);pl=a(io,"To enable XLA-accelerated generation within \u{1F917} Transformers, you need to have a recent version of "),at=n(io,"CODE",{});var Ca=r(at);cl=a(Ca,"transformers"),Ca.forEach(o),hl=a(io," installed. You can install it by running:"),io.forEach(o),Ft=f(e),w(pe.$$.fragment,e),xt=f(e),Ze=n(e,"P",{});var La=r(Ze);fl=a(La,"And then you can run the following code:"),La.forEach(o),Vt=f(e),w(ce.$$.fragment,e),Ct=f(e),L=n(e,"P",{});var po=r(L);dl=a(po,"As you can notice, enabling XLA on "),st=n(po,"CODE",{});var za=r(st);ul=a(za,"generate()"),za.forEach(o),ml=a(po," is just a single line of code. The rest of the code remains unchanged. However, there are a couple of gotchas in the above code snippet that are specific to XLA. You need to be aware of those to realize the speed-ups that XLA can bring in. We discuss these in the following section."),po.forEach(o),Lt=f(e),A=n(e,"H2",{class:!0});var co=r(A);z=n(co,"A",{id:!0,class:!0,href:!0});var Na=r(z);nt=n(Na,"SPAN",{});var Qa=r(nt);w(he.$$.fragment,Qa),Qa.forEach(o),Na.forEach(o),wl=f(co),rt=n(co,"SPAN",{});var Ya=r(rt);yl=a(Ya,"Gotchas to be aware of"),Ya.forEach(o),co.forEach(o),zt=f(e),J=n(e,"P",{});var Fe=r(J);bl=a(Fe,"When you are executing an XLA-enabled function (like "),it=n(Fe,"CODE",{});var Sa=r(it);Ml=a(Sa,"xla_generate()"),Sa.forEach(o),gl=a(Fe," above) for the first time, it will internally try to infer the computation graph, which is time-consuming.  This process is known as "),fe=n(Fe,"A",{href:!0,rel:!0});var Ha=r(fe);Tl=a(Ha,"\u201Ctracing\u201D"),Ha.forEach(o),vl=a(Fe,"."),Fe.forEach(o),Nt=f(e),N=n(e,"P",{});var ho=r(N);_l=a(ho,"You might notice that the generation time is not fast. Successive calls of "),pt=n(ho,"CODE",{});var qa=r(pt);Jl=a(qa,"xla_generate()"),qa.forEach(o),Ul=a(ho," (or any other XLA-enabled function) won\u2019t have to infer the computation graph, given the inputs to the function follow the same shape with which the computation graph was initially built. While this is not a problem for modalities with fixed input shapes (e.g., images), you must pay attention if you are working with variable input shape modalities (e.g., text)."),ho.forEach(o),Qt=f(e),U=n(e,"P",{});var xe=r(U);jl=a(xe,"To ensure "),ct=n(xe,"CODE",{});var Pa=r(ct);kl=a(Pa,"xla_generate()"),Pa.forEach(o),El=a(xe," always operates with the same input shapes, you can specify the "),ht=n(xe,"CODE",{});var Da=r(ht);Xl=a(Da,"padding"),Da.forEach(o),Zl=a(xe," arguments when calling the tokenizer."),xe.forEach(o),Yt=f(e),w(de.$$.fragment,e),St=f(e),Q=n(e,"P",{});var fo=r(Q);Gl=a(fo,"This way, you can ensure that the inputs to "),ft=n(fo,"CODE",{});var Oa=r(ft);Al=a(Oa,"xla_generate()"),Oa.forEach(o),Wl=a(fo," will always receive inputs with the shape it was traced with and thus leading to speed-ups in the generation time. You can verify this with the code below:"),fo.forEach(o),Ht=f(e),w(ue.$$.fragment,e),qt=f(e),Ge=n(e,"P",{});var Ka=r(Ge);Il=a(Ka,"On a Tesla T4 GPU, you can expect the outputs like so:"),Ka.forEach(o),Pt=f(e),w(me.$$.fragment,e),Dt=f(e),Y=n(e,"P",{});var uo=r(Y);Rl=a(uo,"The first call to "),dt=n(uo,"CODE",{});var es=r(dt);Bl=a(es,"xla_generate()"),es.forEach(o),$l=a(uo," is time-consuming because of tracing, but the successive calls are orders of magnitude faster. Keep in mind that any change in the generation options at any point with trigger re-tracing and thus leading to slow-downs in the generation time."),uo.forEach(o),Ot=f(e),Ae=n(e,"P",{});var ts=r(Ae);Fl=a(ts,"We didn\u2019t cover all the text generation options \u{1F917} Transformers provides in this document. We encourage you to read the documentation for advanced use cases."),ts.forEach(o),Kt=f(e),W=n(e,"H2",{class:!0});var mo=r(W);S=n(mo,"A",{id:!0,class:!0,href:!0});var os=r(S);ut=n(os,"SPAN",{});var ls=r(ut);w(we.$$.fragment,ls),ls.forEach(o),os.forEach(o),xl=f(mo),mt=n(mo,"SPAN",{});var as=r(mt);Vl=a(as,"Additional Resources"),as.forEach(o),mo.forEach(o),eo=f(e),We=n(e,"P",{});var ss=r(We);Cl=a(ss,"Here, we leave you with some additional resources if you want to delve deeper into XLA in \u{1F917} Transformers and in general."),ss.forEach(o),to=f(e),v=n(e,"UL",{});var H=r(v);j=n(H,"LI",{});var Ue=r(j);ye=n(Ue,"A",{href:!0,rel:!0});var ns=r(ye);Ll=a(ns,"This Colab Notebook"),ns.forEach(o),zl=a(Ue," provides an interactive demonstration if you want to fiddle with the XLA-compatible encoder-decoder (like "),be=n(Ue,"A",{href:!0,rel:!0});var rs=r(be);Nl=a(rs,"T5"),rs.forEach(o),Ql=a(Ue,") and decoder-only (like "),Me=n(Ue,"A",{href:!0,rel:!0});var is=r(Me);Yl=a(is,"GPT2"),is.forEach(o),Sl=a(Ue,") text generation models."),Ue.forEach(o),Hl=f(H),Ie=n(H,"LI",{});var ra=r(Ie);ge=n(ra,"A",{href:!0,rel:!0});var ps=r(ge);ql=a(ps,"This blog post"),ps.forEach(o),Pl=a(ra," provides an overview of the comparison benchmarks for XLA-compatible models along with a friendly introduction to XLA in TensorFlow."),ra.forEach(o),Dl=f(H),Re=n(H,"LI",{});var ia=r(Re);Te=n(ia,"A",{href:!0,rel:!0});var cs=r(Te);Ol=a(cs,"This blog post"),cs.forEach(o),Kl=a(ia," discusses our design philosophy behind adding XLA support to the TensorFlow models in \u{1F917} Transformers."),ia.forEach(o),ea=f(H),Be=n(H,"LI",{});var pa=r(Be);ta=a(pa,"Recommended posts for learning more about XLA and TensorFlow graphs in general:"),I=n(pa,"UL",{});var Ve=r(I);wt=n(Ve,"LI",{});var hs=r(wt);ve=n(hs,"A",{href:!0,rel:!0});var fs=r(ve);oa=a(fs,"XLA: Optimizing Compiler for Machine Learning"),fs.forEach(o),hs.forEach(o),la=f(Ve),yt=n(Ve,"LI",{});var ds=r(yt);_e=n(ds,"A",{href:!0,rel:!0});var us=r(_e);aa=a(us,"Introduction to graphs and tf.function"),us.forEach(o),ds.forEach(o),sa=f(Ve),bt=n(Ve,"LI",{});var ms=r(bt);Je=n(ms,"A",{href:!0,rel:!0});var ws=r(Je);na=a(ws,"Better performance with tf.function"),ws.forEach(o),ms.forEach(o),Ve.forEach(o),pa.forEach(o),H.forEach(o),this.h()},h(){c(E,"name","hf:doc:metadata"),c(E,"content",JSON.stringify(Us)),c(B,"id","xla-integration-for-tensorflow-models"),c(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(B,"href","#xla-integration-for-tensorflow-models"),c(X,"class","relative group"),c(D,"href","https://www.tensorflow.org/xla"),c(D,"rel","nofollow"),c(O,"href","https://www.tensorflow.org/guide/intro_to_graphs"),c(O,"rel","nofollow"),c(K,"href","https://huggingface.co/docs/transformers/model_doc/gpt2"),c(K,"rel","nofollow"),c(ee,"href","https://huggingface.co/docs/transformers/model_doc/t5"),c(ee,"rel","nofollow"),c(te,"href","https://huggingface.co/docs/transformers/model_doc/opt"),c(te,"rel","nofollow"),c(oe,"href","https://huggingface.co/docs/transformers/model_doc/whisper"),c(oe,"rel","nofollow"),c(F,"id","running-tf-functions-with-xla"),c(F,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(F,"href","#running-tf-functions-with-xla"),c(Z,"class","relative group"),c(V,"id","running-a-tf-text-generation-model-with-xla-from-transformers"),c(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(V,"href","#running-a-tf-text-generation-model-with-xla-from-transformers"),c(G,"class","relative group"),c(z,"id","gotchas-to-be-aware-of"),c(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(z,"href","#gotchas-to-be-aware-of"),c(A,"class","relative group"),c(fe,"href","https://www.tensorflow.org/guide/intro_to_graphs#when_is_a_function_tracing"),c(fe,"rel","nofollow"),c(S,"id","additional-resources"),c(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(S,"href","#additional-resources"),c(W,"class","relative group"),c(ye,"href","https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/91_tf_xla_generate.ipynb"),c(ye,"rel","nofollow"),c(be,"href","https://huggingface.co/docs/transformers/model_doc/t5"),c(be,"rel","nofollow"),c(Me,"href","https://huggingface.co/docs/transformers/model_doc/gpt2"),c(Me,"rel","nofollow"),c(ge,"href","https://huggingface.co/blog/tf-xla-generate"),c(ge,"rel","nofollow"),c(Te,"href","https://blog.tensorflow.org/2022/11/how-hugging-face-improved-text-generation-performance-with-xla.html"),c(Te,"rel","nofollow"),c(ve,"href","https://www.tensorflow.org/xla"),c(ve,"rel","nofollow"),c(_e,"href","https://www.tensorflow.org/guide/intro_to_graphs"),c(_e,"rel","nofollow"),c(Je,"href","https://www.tensorflow.org/guide/function"),c(Je,"rel","nofollow")},m(e,i){t(document.head,E),p(e,gt,i),p(e,X,i),t(X,B),t(B,Ce),y(q,Ce,null),t(X,wo),t(X,Le),t(Le,yo),p(e,Tt,i),y(P,e,i),p(e,vt,i),p(e,$,i),t($,bo),t($,D),t(D,Mo),t($,go),p(e,_t,i),p(e,je,i),t(je,To),p(e,Jt,i),p(e,d,i),t(d,vo),t(d,ze),t(ze,_o),t(d,Jo),t(d,Ne),t(Ne,Uo),t(d,jo),t(d,O),t(O,Qe),t(Qe,ko),t(d,Eo),t(d,Ye),t(Ye,Xo),t(d,Zo),t(d,Se),t(Se,Go),t(d,Ao),t(d,He),t(He,Wo),t(d,Io),t(d,qe),t(qe,Ro),t(d,Bo),t(d,Pe),t(Pe,$o),t(d,Fo),p(e,Ut,i),p(e,T,i),t(T,xo),t(T,K),t(K,Vo),t(T,Co),t(T,ee),t(ee,Lo),t(T,zo),t(T,te),t(te,No),t(T,Qo),t(T,oe),t(oe,Yo),t(T,So),p(e,jt,i),p(e,ke,i),t(ke,Ho),p(e,kt,i),p(e,Z,i),t(Z,F),t(F,De),y(le,De,null),t(Z,qo),t(Z,Oe),t(Oe,Po),p(e,Et,i),p(e,Ee,i),t(Ee,Do),p(e,Xt,i),y(ae,e,i),p(e,Zt,i),p(e,x,i),t(x,Oo),t(x,Ke),t(Ke,Ko),t(x,el),p(e,Gt,i),y(se,e,i),p(e,At,i),p(e,Xe,i),t(Xe,tl),p(e,Wt,i),y(ne,e,i),p(e,It,i),p(e,_,i),t(_,ol),t(_,et),t(et,ll),t(_,al),t(_,tt),t(tt,sl),t(_,nl),p(e,Rt,i),y(re,e,i),p(e,Bt,i),p(e,G,i),t(G,V),t(V,ot),y(ie,ot,null),t(G,rl),t(G,lt),t(lt,il),p(e,$t,i),p(e,C,i),t(C,pl),t(C,at),t(at,cl),t(C,hl),p(e,Ft,i),y(pe,e,i),p(e,xt,i),p(e,Ze,i),t(Ze,fl),p(e,Vt,i),y(ce,e,i),p(e,Ct,i),p(e,L,i),t(L,dl),t(L,st),t(st,ul),t(L,ml),p(e,Lt,i),p(e,A,i),t(A,z),t(z,nt),y(he,nt,null),t(A,wl),t(A,rt),t(rt,yl),p(e,zt,i),p(e,J,i),t(J,bl),t(J,it),t(it,Ml),t(J,gl),t(J,fe),t(fe,Tl),t(J,vl),p(e,Nt,i),p(e,N,i),t(N,_l),t(N,pt),t(pt,Jl),t(N,Ul),p(e,Qt,i),p(e,U,i),t(U,jl),t(U,ct),t(ct,kl),t(U,El),t(U,ht),t(ht,Xl),t(U,Zl),p(e,Yt,i),y(de,e,i),p(e,St,i),p(e,Q,i),t(Q,Gl),t(Q,ft),t(ft,Al),t(Q,Wl),p(e,Ht,i),y(ue,e,i),p(e,qt,i),p(e,Ge,i),t(Ge,Il),p(e,Pt,i),y(me,e,i),p(e,Dt,i),p(e,Y,i),t(Y,Rl),t(Y,dt),t(dt,Bl),t(Y,$l),p(e,Ot,i),p(e,Ae,i),t(Ae,Fl),p(e,Kt,i),p(e,W,i),t(W,S),t(S,ut),y(we,ut,null),t(W,xl),t(W,mt),t(mt,Vl),p(e,eo,i),p(e,We,i),t(We,Cl),p(e,to,i),p(e,v,i),t(v,j),t(j,ye),t(ye,Ll),t(j,zl),t(j,be),t(be,Nl),t(j,Ql),t(j,Me),t(Me,Yl),t(j,Sl),t(v,Hl),t(v,Ie),t(Ie,ge),t(ge,ql),t(Ie,Pl),t(v,Dl),t(v,Re),t(Re,Te),t(Te,Ol),t(Re,Kl),t(v,ea),t(v,Be),t(Be,ta),t(Be,I),t(I,wt),t(wt,ve),t(ve,oa),t(I,la),t(I,yt),t(yt,_e),t(_e,aa),t(I,sa),t(I,bt),t(bt,Je),t(Je,na),oo=!0},p:Ts,i(e){oo||(b(q.$$.fragment,e),b(P.$$.fragment,e),b(le.$$.fragment,e),b(ae.$$.fragment,e),b(se.$$.fragment,e),b(ne.$$.fragment,e),b(re.$$.fragment,e),b(ie.$$.fragment,e),b(pe.$$.fragment,e),b(ce.$$.fragment,e),b(he.$$.fragment,e),b(de.$$.fragment,e),b(ue.$$.fragment,e),b(me.$$.fragment,e),b(we.$$.fragment,e),oo=!0)},o(e){M(q.$$.fragment,e),M(P.$$.fragment,e),M(le.$$.fragment,e),M(ae.$$.fragment,e),M(se.$$.fragment,e),M(ne.$$.fragment,e),M(re.$$.fragment,e),M(ie.$$.fragment,e),M(pe.$$.fragment,e),M(ce.$$.fragment,e),M(he.$$.fragment,e),M(de.$$.fragment,e),M(ue.$$.fragment,e),M(me.$$.fragment,e),M(we.$$.fragment,e),oo=!1},d(e){o(E),e&&o(gt),e&&o(X),g(q),e&&o(Tt),g(P,e),e&&o(vt),e&&o($),e&&o(_t),e&&o(je),e&&o(Jt),e&&o(d),e&&o(Ut),e&&o(T),e&&o(jt),e&&o(ke),e&&o(kt),e&&o(Z),g(le),e&&o(Et),e&&o(Ee),e&&o(Xt),g(ae,e),e&&o(Zt),e&&o(x),e&&o(Gt),g(se,e),e&&o(At),e&&o(Xe),e&&o(Wt),g(ne,e),e&&o(It),e&&o(_),e&&o(Rt),g(re,e),e&&o(Bt),e&&o(G),g(ie),e&&o($t),e&&o(C),e&&o(Ft),g(pe,e),e&&o(xt),e&&o(Ze),e&&o(Vt),g(ce,e),e&&o(Ct),e&&o(L),e&&o(Lt),e&&o(A),g(he),e&&o(zt),e&&o(J),e&&o(Nt),e&&o(N),e&&o(Qt),e&&o(U),e&&o(Yt),g(de,e),e&&o(St),e&&o(Q),e&&o(Ht),g(ue,e),e&&o(qt),e&&o(Ge),e&&o(Pt),g(me,e),e&&o(Dt),e&&o(Y),e&&o(Ot),e&&o(Ae),e&&o(Kt),e&&o(W),g(we),e&&o(eo),e&&o(We),e&&o(to),e&&o(v)}}}const Us={local:"xla-integration-for-tensorflow-models",sections:[{local:"running-tf-functions-with-xla",title:"Running TF functions with XLA"},{local:"running-a-tf-text-generation-model-with-xla-from-transformers",title:"Running a TF text generation model with XLA from \u{1F917} Transformers"},{local:"gotchas-to-be-aware-of",title:"Gotchas to be aware of"},{local:"additional-resources",title:"Additional Resources"}],title:"XLA Integration for TensorFlow Models"};function js(ca){return vs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gs extends ys{constructor(E){super();bs(this,E,js,Js,Ms,{})}}export{Gs as default,Us as metadata};
