/
vuron
/
adept
Обзор
Документация
Войти
/
vuron
/
adept
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
with_cpu
python/torch_refs/test_bindings.py
50 строк
842 B
kolkir
Refactor python folder structure
01 мар 2025, 22:16
01 мар 2025, 22:16
ef25f05
Код
Авторство
О чём код?
import sys import numpy as np sys.path.insert(0, "build") from adept import Variable, Tensor, Shape, TensorProperties, device_t, dtype_t, relu s = Shape([32, 1]) print(s.numel()) print(s.empty()) print(s.rang()) print(s.dims) b = np.array(s) print(b) print(device_t.CPU) print(dtype_t.Float32) p = TensorProperties(s) print(p.shape.dims) print(p.device) print(p.dtype) t = Tensor([1, 2, 3], TensorProperties(Shape([1, 3]), device_t.CPU, dtype_t.Int32)) print(t) t2 = Tensor.empty(TensorProperties(Shape([3, 3]), device_t.CPU, dtype_t.Float32)) print(t2) t3 = Tensor.uniform( 0, 5, TensorProperties(Shape([3, 3]), device_t.CPU, dtype_t.Float32) ) print(t3) t4 = t3.clone() + 4 print(t4) t4 += t3 print(t4) t5 = t4.dot(-t3) print(t5) v1 = Variable(t4) v2 = Variable(t3) v3 = v1.dot(v2).mean() print(v3) v3.backward() print(v3)