def setUp(self): self.device = Naive() self.graph = Graph() Device.set_default(self.device) Graph.set_default(self.graph) self.a = np.array([[1, 2], [3, 4]], np.float32) self.b = np.array([[1, 1], [4, 8]], np.float32)
def test_device_instance(self): dev = Device.get_default() self.assertIs(dev, self.device) tensor = tF.raw_input([], [0]) dev = tensor.device() self.assertIs(dev, self.device) node = F.raw_input([], [0]) dev = node.device() self.assertIs(dev, self.device) my_device = Naive() self.assertIsNot(my_device, self.device) node = F.raw_input([], [0], device=my_device) dev = node.device() self.assertIs(dev, my_device) dev = self.graph.get_device(node) self.assertIs(dev, my_device) param = Parameter([], I.Constant(1)) dev = param.device() self.assertIs(dev, self.device)
def setUp(self): self.device = Naive() self.graph = Graph() Device.set_default(self.device) Graph.set_default(self.graph) self.ndarray_data = [ np.array([ [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], ], np.float32), np.array([ [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], ], np.float32), ] self.list_data = [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0, 13.0, 16.0, 19.0, 22.0, 14.0, 17.0, 20.0, 23.0, 15.0, 18.0, 21.0, 24.0, ]
def setUp(self): self.device = Naive() self.graph = Graph() Device.set_default(self.device) Graph.set_default(self.graph) self.input_data = [ np.array([ [ 1, 2, 3], [ 4, 5, 6], [ 7, 8, 9], ], np.float32), np.array([ [11,12,13], [14,15,16], [17,18,19], ], np.float32), ] self.list_expected = [ 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0, 11.0, 14.0, 17.0, 12.0, 15.0, 18.0, 13.0, 16.0, 19.0, ]
def available_naive_devices(): from primitiv.devices import Naive return [ Naive(), Naive(), ]
def setUp(self): self.device = Naive() Device.set_default(self.device) self.graph = Graph() Graph.set_default(self.graph)
def setUpClass(cls): cls.device = Naive()