def test_pernode_sched_cache_key(self): ''' Per-node scheduling cache key must be hash-able. ''' layer = self.layers['BASE'] ifmap_layout = self.ifmap_layouts['BASE'] schd = Scheduling(layer, self.batch_size, self.cost, MapStrategyEyeriss) condition = SchedulingCondition(resource=self.resource, ifmap_layout=ifmap_layout) _ = schd.schedule_search(condition, self.options) h, m = schd.cache_stats() self.assertEqual(h, 0) # Make another instance. rsrc = Resource(**self.resource._asdict()) opts = Option(**self.options._asdict()) self.assertNotEqual(id(rsrc), id(self.resource)) self.assertNotEqual(id(opts), id(self.options)) part = PartitionScheme(order=(pe.BATP, pe.INPP, pe.OUTP, pe.OFMP), pdims=((2, 2), (2, 2), (1, 1), (1, 1))) _ = schd.schedule_search_per_node(part, rsrc, opts) h2, m2 = schd.cache_stats() self.assertEqual(h2, h + 1) self.assertEqual(m2, m)
def test_pernode_sched_cache(self): ''' Per-node scheduling cache. ''' # pylint: disable=no-member Scheduling.schedule_search_per_node.cache_clear() layer = self.layers['BASE'] ifmap_layout = self.ifmap_layouts['BASE'] schd = Scheduling(layer, self.batch_size, self.cost, MapStrategyEyeriss) self.assertEqual(schd.schedule_search_per_node.cache_info().currsize, 0) self.assertTupleEqual(schd.cache_stats(), (0, 0)) condition = SchedulingCondition(resource=self.resource, constraint=self.cstr, ifmap_layout=ifmap_layout, sched_seq=self.sched_seq) Scheduling.schedule_search.cache_clear() _ = schd.schedule_search(condition, self.options) h, m = schd.cache_stats() self.assertEqual(schd.schedule_search_per_node.cache_info().currsize, m) self.assertEqual(h, 0) n = m Scheduling.schedule_search.cache_clear() _ = schd.schedule_search(condition, self.options) self.assertEqual(schd.schedule_search_per_node.cache_info().currsize, n) self.assertTupleEqual(schd.cache_stats(), (n, n))
def test_pernode_sched_cache(self): ''' Per-node scheduling cache. ''' layer = self.layers['BASE'] ifmap_layout = self.ifmap_layouts['BASE'] schd = Scheduling(layer, self.batch_size, self.cost, MapStrategyEyeriss) self.assertEqual(len(schd.pernode_sched_cache), 0) self.assertTupleEqual(schd.cache_stats(), (0, 0)) condition = SchedulingCondition(resource=self.resource, ifmap_layout=ifmap_layout) _ = schd.schedule_search(condition, self.options) h, m = schd.cache_stats() self.assertEqual(len(schd.pernode_sched_cache), m) self.assertEqual(h, 0) n = m _ = schd.schedule_search(condition, self.options) self.assertEqual(len(schd.pernode_sched_cache), n) self.assertTupleEqual(schd.cache_stats(), (n, n))