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

Class PythonFunctionPipeline

dali/test/python/test_gpu_python_function_operator.py:40–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40class PythonFunctionPipeline(Pipeline):
41 def __init__(self, function, device, num_outputs=1):
42 super(PythonFunctionPipeline, self).__init__(BATCH_SIZE, NUM_WORKERS, DEVICE_ID, seed=SEED)
43 self.device = device
44 self.reader = ops.readers.File(file_root=images_dir)
45 self.decode = ops.decoders.Image(device="cpu", output_type=types.RGB)
46 self.norm = ops.CropMirrorNormalize(std=255.0, mean=0.0, device=device, output_layout="HWC")
47 self.func = ops.PythonFunction(device=device, function=function, num_outputs=num_outputs)
48
49 def define_graph(self):
50 jpegs, labels = self.reader()
51 decoded = self.decode(jpegs)
52 images = decoded if self.device == "cpu" else decoded.gpu()
53 normalized = self.norm(images)
54 return self.func(normalized, normalized)
55
56
57def validate_cpu_vs_gpu(gpu_fun, cpu_fun, num_outputs=1):

Callers 1

validate_cpu_vs_gpuFunction · 0.85

Calls

no outgoing calls

Tested by 1

validate_cpu_vs_gpuFunction · 0.68