chris-rannou HF Staff commited on
Commit
cd8812a
·
verified ·
1 Parent(s): 5058fbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -5,6 +5,8 @@ import gradio as gr
5
  import time
6
  import os
7
  import elasticsearch
 
 
8
 
9
  MB = 1024*1024
10
  def eat_memory():
@@ -14,7 +16,11 @@ def eat_memory():
14
  time.sleep(0.1)
15
 
16
  def greet(name):
17
- return "Hello " + name + "!! secret: " + os.environ.get("TEST_ENV_SECRET")
 
 
 
 
18
 
19
  # bidule
20
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
5
  import time
6
  import os
7
  import elasticsearch
8
+ import torch
9
+ import torch_xla.core.xla_model as xm
10
 
11
  MB = 1024*1024
12
  def eat_memory():
 
16
  time.sleep(0.1)
17
 
18
  def greet(name):
19
+ device = xm.xla_device()
20
+ t1 = torch.randn(3,3,device=device)
21
+ t2 = torch.randn(3,3,device=device)
22
+ t3 = str(t1 + t2)
23
+ return "Hello " + name + "!! Tensor: " + t3 + ", secret: " + os.environ.get("TEST_ENV_SECRET")
24
 
25
  # bidule
26
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")