Skip to content
Snippets Groups Projects

Refactoring Tensor

Closed laurent soulier requested to merge fix/TensorPIMPL into master
Compare and
72 files
+ 4091
3174
Compare changes
  • Side-by-side
  • Inline
Files
72
@@ -2,7 +2,7 @@ import unittest
import aidge_core
import aidge_backend_cpu
import numpy as np
from functools import reduce
class test_tensor(unittest.TestCase):
"""Test tensor binding
@@ -24,6 +24,7 @@ class test_tensor(unittest.TestCase):
self.assertTrue(i_t == i_n)
for i,j in zip(t.dims(), np_array.shape):
self.assertEqual(i,j)
def test_tensor_int_to_numpy(self):
np_array = np.arange(9).reshape(1,1,3,3)
# Numpy -> Tensor
@@ -46,6 +47,18 @@ class test_tensor(unittest.TestCase):
for i,j in zip(t.dims(), np_array.shape):
self.assertEqual(i,j)
def test_getcoord_getidx(self):
dims = [2,2,2]
size = reduce((lambda x, y: x*y), dims)
np_array = np.arange(size).reshape(dims)
t = aidge_core.Tensor(np_array)
for i in range(size):
coord = t.get_coord(i)
idx = t.get_idx(coord)
self.assertEqual(idx, i)
def test_get_set(self):
dims = [2,2,2]
Loading