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

Class SliceSynthDataPipeline

dali/test/python/operator_1/test_slice.py:69–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69class SliceSynthDataPipeline(Pipeline):
70 def __init__(
71 self,
72 device,
73 batch_size,
74 layout,
75 iterator,
76 pos_size_iter,
77 num_threads=1,
78 device_id=0,
79 num_gpus=1,
80 axes=None,
81 axis_names=None,
82 normalized_anchor=True,
83 normalized_shape=True,
84 extra_outputs=False,
85 out_of_bounds_policy=None,
86 fill_values=None,
87 input_type=types.FLOAT,
88 output_type=None,
89 ):
90 super().__init__(batch_size, num_threads, device_id, seed=1234)
91 self.device = device
92 self.layout = layout
93 self.iterator = iterator
94 self.pos_size_iter = pos_size_iter
95 self.inputs = ops.ExternalSource()
96 self.input_crop_pos = ops.ExternalSource()
97 self.input_crop_size = ops.ExternalSource()
98 self.extra_outputs = extra_outputs
99 self.cast_in = ops.Cast(dtype=input_type)
100 self.slice = ops.Slice(
101 device=self.device,
102 dtype=output_type,
103 normalized_anchor=normalized_anchor,
104 normalized_shape=normalized_shape,
105 axes=axes,
106 axis_names=axis_names,
107 out_of_bounds_policy=out_of_bounds_policy,
108 fill_values=fill_values,
109 )
110
111 def define_graph(self):
112 self.data = self.inputs()
113 self.crop_pos = self.input_crop_pos()
114 self.crop_size = self.input_crop_size()
115 data = self.cast_in(self.data)
116 data = data.gpu() if self.device == "gpu" else data
117 out = self.slice(data, self.crop_pos, self.crop_size)
118 if self.extra_outputs:
119 return out, self.data, self.crop_pos, self.crop_size
120 else:
121 return out
122
123 def iter_setup(self):
124 data = self.iterator.next()
125 self.feed_input(self.data, data, layout=self.layout)
126

Calls

no outgoing calls