import{s as ce,n as he,o as fe}from"../chunks/scheduler.9bc65507.js";import{S as ue,i as Me,g as s,s as i,u as Z,A as Te,h as a,f as l,c as n,j as $,v as _,y as d,k as g,o as L,a as o,w as I,d as V,t as C,x as k}from"../chunks/index.78c82d43.js";import{I as we}from"../chunks/IconCopyLink.bedaa44d.js";import{C as K}from"../chunks/CodeBlock.48618ec2.js";function be(te){let r,F,G,H,m,p,j,c,ee,J,le="Export to TFLite",S,h,oe=`<a href="https://www.tensorflow.org/lite/guide" rel="nofollow">TensorFlow Lite</a> is a lightweight framework for deploying machine learning models
on resource-constrained devices, such as mobile phones, embedded systems, and Internet of Things (IoT) devices.
TFLite is designed to optimize and run models efficiently on these devices with limited computational power, memory, and
power consumption.
A TensorFlow Lite model is represented in a special efficient portable format identified by the <code>.tflite</code> file extension.`,A,f,ie=`🤗 Optimum offers functionality to export 🤗 Transformers models to TFLite through the <code>exporters.tflite</code> module.
For the list of supported model architectures, please refer to <a href="https://huggingface.co/docs/optimum/exporters/tflite/overview" rel="nofollow">🤗 Optimum documentation</a>.`,R,u,ne="To export a model to TFLite, install the required dependencies:",W,M,X,T,se=`To check out all available arguments, refer to the <a href="https://huggingface.co/docs/optimum/main/en/exporters/tflite/usage_guides/export_a_model" rel="nofollow">🤗 Optimum docs</a>,
or view help in command line:`,Q,w,z,b,ae="To export a model’s checkpoint from the 🤗 Hub, for example, <code>bert-base-uncased</code>, run the following command:",N,y,Y,x,re="You should see the logs indicating progress and showing where the resulting <code>model.tflite</code> is saved, like this:",E,U,P,v,me=`The example above illustrates exporting a checkpoint from 🤗 Hub. When exporting a local model, first make sure that you
saved both the model’s weights and tokenizer files in the same directory (<code>local_path</code>). When using CLI, pass the
<code>local_path</code> to the <code>model</code> argument instead of the checkpoint name on 🤗 Hub.`,D,B,O;return c=new we({}),M=new K({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMtdGYlNUQ=",highlighted:"pip install optimum[exporters-tf]"}}),w=new K({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLWhlbHA=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --<span class="hljs-built_in">help</span>'}}),y=new K({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLW1vZGVsJTIwYmVydC1iYXNlLXVuY2FzZWQlMjAtLXNlcXVlbmNlX2xlbmd0aCUyMDEyOCUyMGJlcnRfdGZsaXRlJTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --model bert-base-uncased --sequence_length 128 bert_tflite/'}}),U=new K({props:{code:"VmFsaWRhdGluZyUyMFRGTGl0ZSUyMG1vZGVsLi4uJTBBJTA5LSU1QiVFMiU5QyU5MyU1RCUyMFRGTGl0ZSUyMG1vZGVsJTIwb3V0cHV0JTIwbmFtZXMlMjBtYXRjaCUyMHJlZmVyZW5jZSUyMG1vZGVsJTIwKGxvZ2l0cyklMEElMDktJTIwVmFsaWRhdGluZyUyMFRGTGl0ZSUyME1vZGVsJTIwb3V0cHV0JTIwJTIybG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTIwbWF0Y2hlcyUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTBBJTA5JTA5LSU1QnglNUQlMjB2YWx1ZXMlMjBub3QlMjBjbG9zZSUyMGVub3VnaCUyQyUyMG1heCUyMGRpZmYlM0ElMjA1LjgxNzQxMzMzMDA3ODEyNWUtMDUlMjAoYXRvbCUzQSUyMDFlLTA1KSUwQVRoZSUyMFRlbnNvckZsb3clMjBMaXRlJTIwZXhwb3J0JTIwc3VjY2VlZGVkJTIwd2l0aCUyMHRoZSUyMHdhcm5pbmclM0ElMjBUaGUlMjBtYXhpbXVtJTIwYWJzb2x1dGUlMjBkaWZmZXJlbmNlJTIwYmV0d2VlbiUyMHRoZSUyMG91dHB1dCUyMG9mJTIwdGhlJTIwcmVmZXJlbmNlJTIwbW9kZWwlMjBhbmQlMjB0aGUlMjBURkxpdGUlMjBleHBvcnRlZCUyMG1vZGVsJTIwaXMlMjBub3QlMjB3aXRoaW4lMjB0aGUlMjBzZXQlMjB0b2xlcmFuY2UlMjAxZS0wNSUzQSUwQS0lMjBsb2dpdHMlM0ElMjBtYXglMjBkaWZmJTIwJTNEJTIwNS44MTc0MTMzMzAwNzgxMjVlLTA1LiUwQSUyMFRoZSUyMGV4cG9ydGVkJTIwbW9kZWwlMjB3YXMlMjBzYXZlZCUyMGF0JTNBJTIwYmVydF90ZmxpdGU=",highlighted:`Validating TFLite model...
	-[✓] TFLite model output names match reference model (logits)
	- Validating TFLite Model output <span class="hljs-string">&quot;logits&quot;</span>:
		-[✓] (1, 128, 30522) matches (1, 128, 30522)
		-[x] values not close enough, max diff: 5.817413330078125e-05 (atol: 1e-05)
The TensorFlow Lite <span class="hljs-built_in">export</span> succeeded with the warning: The maximum absolute difference between the output of the reference model and the TFLite exported model is not within the <span class="hljs-built_in">set</span> tolerance 1e-05:
- logits: max diff = 5.817413330078125e-05.
 The exported model was saved at: bert_tflite`}}),{c(){r=s("meta"),F=i(),G=s("p"),H=i(),m=s("h1"),p=s("a"),j=s("span"),Z(c.$$.fragment),ee=i(),J=s("span"),J.textContent=le,S=i(),h=s("p"),h.innerHTML=oe,A=i(),f=s("p"),f.innerHTML=ie,R=i(),u=s("p"),u.textContent=ne,W=i(),Z(M.$$.fragment),X=i(),T=s("p"),T.innerHTML=se,Q=i(),Z(w.$$.fragment),z=i(),b=s("p"),b.innerHTML=ae,N=i(),Z(y.$$.fragment),Y=i(),x=s("p"),x.innerHTML=re,E=i(),Z(U.$$.fragment),P=i(),v=s("p"),v.innerHTML=me,D=i(),B=s("p"),this.h()},l(e){const t=Te("svelte-1phssyn",document.head);r=a(t,"META",{name:!0,content:!0}),t.forEach(l),F=n(e),G=a(e,"P",{}),$(G).forEach(l),H=n(e),m=a(e,"H1",{class:!0});var q=$(m);p=a(q,"A",{id:!0,class:!0,href:!0});var pe=$(p);j=a(pe,"SPAN",{});var de=$(j);_(c.$$.fragment,de),de.forEach(l),pe.forEach(l),ee=n(q),J=a(q,"SPAN",{"data-svelte-h":!0}),d(J)!=="svelte-28dh8c"&&(J.textContent=le),q.forEach(l),S=n(e),h=a(e,"P",{"data-svelte-h":!0}),d(h)!=="svelte-1btfcc4"&&(h.innerHTML=oe),A=n(e),f=a(e,"P",{"data-svelte-h":!0}),d(f)!=="svelte-m0va7t"&&(f.innerHTML=ie),R=n(e),u=a(e,"P",{"data-svelte-h":!0}),d(u)!=="svelte-fibc5e"&&(u.textContent=ne),W=n(e),_(M.$$.fragment,e),X=n(e),T=a(e,"P",{"data-svelte-h":!0}),d(T)!=="svelte-1ebb3ag"&&(T.innerHTML=se),Q=n(e),_(w.$$.fragment,e),z=n(e),b=a(e,"P",{"data-svelte-h":!0}),d(b)!=="svelte-8zfn5r"&&(b.innerHTML=ae),N=n(e),_(y.$$.fragment,e),Y=n(e),x=a(e,"P",{"data-svelte-h":!0}),d(x)!=="svelte-ptkmnx"&&(x.innerHTML=re),E=n(e),_(U.$$.fragment,e),P=n(e),v=a(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-1a6s6im"&&(v.innerHTML=me),D=n(e),B=a(e,"P",{}),$(B).forEach(l),this.h()},h(){g(r,"name","hf:doc:metadata"),g(r,"content",JSON.stringify(ye)),g(p,"id","export-to-tflite"),g(p,"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"),g(p,"href","#export-to-tflite"),g(m,"class","relative group")},m(e,t){L(document.head,r),o(e,F,t),o(e,G,t),o(e,H,t),o(e,m,t),L(m,p),L(p,j),I(c,j,null),L(m,ee),L(m,J),o(e,S,t),o(e,h,t),o(e,A,t),o(e,f,t),o(e,R,t),o(e,u,t),o(e,W,t),I(M,e,t),o(e,X,t),o(e,T,t),o(e,Q,t),I(w,e,t),o(e,z,t),o(e,b,t),o(e,N,t),I(y,e,t),o(e,Y,t),o(e,x,t),o(e,E,t),I(U,e,t),o(e,P,t),o(e,v,t),o(e,D,t),o(e,B,t),O=!0},p:he,i(e){O||(V(c.$$.fragment,e),V(M.$$.fragment,e),V(w.$$.fragment,e),V(y.$$.fragment,e),V(U.$$.fragment,e),O=!0)},o(e){C(c.$$.fragment,e),C(M.$$.fragment,e),C(w.$$.fragment,e),C(y.$$.fragment,e),C(U.$$.fragment,e),O=!1},d(e){e&&(l(F),l(G),l(H),l(m),l(S),l(h),l(A),l(f),l(R),l(u),l(W),l(X),l(T),l(Q),l(z),l(b),l(N),l(Y),l(x),l(E),l(P),l(v),l(D),l(B)),l(r),k(c),k(M,e),k(w,e),k(y,e),k(U,e)}}}const ye={local:"export-to-tflite",title:"Export to TFLite"};function xe(te){return fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends ue{constructor(r){super(),Me(this,r,xe,be,ce,{})}}export{Ge as component};
