Skip to content

Commit

Permalink
separate tests for convert pytorch tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
macroexpansion committed Oct 25, 2023
1 parent 1da21cd commit cd56f6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 0 additions & 13 deletions candle-pyo3/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import candle
import torch

print(f"mkl: {candle.utils.has_mkl()}")
print(f"accelerate: {candle.utils.has_accelerate()}")
Expand Down Expand Up @@ -30,15 +29,3 @@
dequant_t = quant_t.dequantize()
diff2 = (t - dequant_t).sqr()
print(diff2.mean_all())

# convert from candle tensor to torch tensor
t = candle.randn((3, 512, 512))
torch_tensor = t.to_torch()
print(torch_tensor)
print(type(torch_tensor))

# convert from torch tensor to candle tensor
t = torch.randn((3, 512, 512))
candle_tensor = candle.Tensor(t)
print(candle_tensor)
print(type(candle_tensor))
14 changes: 14 additions & 0 deletions candle-pyo3/test_pytorch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import candle
import torch

# convert from candle tensor to torch tensor
t = candle.randn((3, 512, 512))
torch_tensor = t.to_torch()
print(torch_tensor)
print(type(torch_tensor))

# convert from torch tensor to candle tensor
t = torch.randn((3, 512, 512))
candle_tensor = candle.Tensor(t)
print(candle_tensor)
print(type(candle_tensor))

0 comments on commit cd56f6c

Please sign in to comment.