def test_python_stencil_batch_kernel(cl): input = NamedVideoStream(cl, 'test1') frame = cl.io.Input([input]) range_frame = cl.streams.Range(frame, ranges=[{'start': 0, 'end': 30}]) test_out = cl.ops.TestPyStencilBatch(frame=range_frame, batch=50) output = NamedStream(cl, 'test_hist') output_op = cl.io.Output(test_out, [output]) cl.run(output_op, PerfParams.estimate(), cache_mode=CacheMode.Overwrite, show_progress=False) next(output.load())
def run(self, cl, device): input = NamedVideoStream(cl, 'test1_inplace') frame = cl.io.Input([input]) hist = cl.ops.Histogram(frame=frame, device=device) output = NamedStream(cl, 'test_hist') output_op = cl.io.Output(hist, [output]) cl.run(output_op, PerfParams.estimate(), cache_mode=CacheMode.Overwrite, show_progress=False) next(output.load())
def test_slice_args(cl): frame = cl.io.Input([NamedVideoStream(cl, 'test1')]) slice_frame = cl.streams.Slice( frame, [cl.partitioner.ranges([[0, 1], [1, 2], [2, 3]])]) test = cl.ops.TestSliceArgs(frame=slice_frame, arg=[SliceList([i for i in range(3)])]) unsliced_frame = cl.streams.Unslice(test) output = NamedStream(cl, 'test_slicing') output_op = cl.io.Output(unsliced_frame, [output]) cl.run(output_op, PerfParams.estimate(), cache_mode=CacheMode.Overwrite, show_progress=False) num_rows = 0 list(output.load())
def test_bounded_state(cl): warmup = 3 frame = cl.io.Input([NamedVideoStream(cl, 'test1')]) increment = cl.ops.TestIncrementBounded(ignore=frame, bounded_state=warmup) sampled_increment = cl.streams.Gather(increment, indices=[[0, 10, 25, 26, 27]]) output = NamedStream(cl, 'test_bounded_state') output_op = cl.io.Output(sampled_increment, [output]) cl.run(output_op, PerfParams.estimate(), cache_mode=CacheMode.Overwrite, show_progress=False) num_rows = 0 expected_output = [0, warmup, warmup, warmup + 1, warmup + 2] for buf in output.load(): (val, ) = struct.unpack('=q', buf) assert val == expected_output[num_rows] num_rows += 1 assert num_rows == 5