MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_inflate

Function test_inflate

dali/test/python/test_dali_variable_batch_size.py:1446–1480  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1444@has_operator("decoders.inflate")
1445@restrict_platform(min_compute_cap=6.0)
1446def test_inflate():
1447 import lz4.block
1448
1449 def sample_to_lz4(sample):
1450 deflated_buf = lz4.block.compress(sample, store_size=False)
1451 return np.frombuffer(deflated_buf, dtype=np.uint8)
1452
1453 def inflate_pipline(max_batch_size, inputs, device):
1454 input_data = [[sample_to_lz4(sample) for sample in batch] for batch in inputs]
1455 input_shape = [
1456 [np.array(sample.shape, dtype=np.int32) for sample in batch] for batch in inputs
1457 ]
1458
1459 @pipeline_def
1460 def piepline():
1461 defalted = fn.external_source(source=input_data)
1462 shape = fn.external_source(source=input_shape)
1463 return fn.decoders.inflate(defalted.gpu(), shape=shape)
1464
1465 return piepline(batch_size=max_batch_size, num_threads=4, device_id=0)
1466
1467 def sample_gen():
1468 j = 42
1469 while True:
1470 yield np.full((13, 7), j)
1471 j += 1
1472
1473 sample = sample_gen()
1474 batches = [
1475 [next(sample) for _ in range(5)],
1476 [next(sample) for _ in range(13)],
1477 [next(sample) for _ in range(2)],
1478 ]
1479
1480 check_pipeline(batches, inflate_pipline, devices=["gpu"])
1481
1482
1483@params(fn.experimental.debayer, fn.debayer)

Callers

nothing calls this directly

Calls 3

nextFunction · 0.85
check_pipelineFunction · 0.85
sample_genFunction · 0.70

Tested by

no test coverage detected