def get_data():
test_data_shape = [3,2,2]
out = np.random.randint(100, 255, size=test_data_shape)
print(out)
print("***----***")
return out
def test_cpu():
#prefetch_queue_depth 表示缓存多少个batch_size的数据在内存,默认是2
pipe = Pipeline(batch_size=3, num_threads=4, device_id=None,prefetch_queue_depth=1)
data = fn.external_source(source=get_data)
pipe.set_outputs(data)
pipe.build()
out = pipe.run()#out[0]:2,224,224,out.as_cpu().as_numpy()
print("dali***output")
print(out[0].as_array())
直接引用外部数据,可以是torch,numpy以及tf等