Class: Torch::Utils::Data::DataPipes::IterDataPipe
- Inherits:
-
IterableDataset
- Object
- Torch::Utils::Data::Dataset
- IterableDataset
- Torch::Utils::Data::DataPipes::IterDataPipe
- Defined in:
- lib/torch/utils/data/data_pipes/iter_data_pipe.rb
Direct Known Subclasses
FilterIterDataPipe, Torch::Utils::Data::DataPipes::Iter::FileLister, Torch::Utils::Data::DataPipes::Iter::FileOpener, Torch::Utils::Data::DataPipes::Iter::IterableWrapper
Class Method Summary collapse
- .functional_datapipe(name) ⇒ Object
- .functions ⇒ Object
- .register_datapipe_as_function(function_name, cls_to_register) ⇒ Object
Instance Method Summary collapse
Class Method Details
.functional_datapipe(name) ⇒ Object
6 7 8 |
# File 'lib/torch/utils/data/data_pipes/iter_data_pipe.rb', line 6 def self.functional_datapipe(name) IterDataPipe.register_datapipe_as_function(name, self) end |
.functions ⇒ Object
10 11 12 |
# File 'lib/torch/utils/data/data_pipes/iter_data_pipe.rb', line 10 def self.functions @functions ||= {} end |
.register_datapipe_as_function(function_name, cls_to_register) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/torch/utils/data/data_pipes/iter_data_pipe.rb', line 14 def self.register_datapipe_as_function(function_name, cls_to_register) if functions.include?(function_name) raise Error, "Unable to add DataPipe function name #{function_name} as it is already taken" end function = lambda do |source_dp, *args, **, &block| cls_to_register.new(source_dp, *args, **, &block) end functions[function_name] = function define_method function_name do |*args, **, &block| IterDataPipe.functions[function_name].call(self, *args, **, &block) end end |
Instance Method Details
#each(&block) ⇒ Object
33 34 35 36 |
# File 'lib/torch/utils/data/data_pipes/iter_data_pipe.rb', line 33 def each(&block) reset @source_datapipe.each(&block) end |
#reset ⇒ Object
29 30 31 |
# File 'lib/torch/utils/data/data_pipes/iter_data_pipe.rb', line 29 def reset # no-op, but subclasses can override end |