99#include < pybind11/stl.h>
1010#include < pybind11/stl_bind.h>
1111
12+ #include < dtlmod/CompressionReductionMethod.hpp>
1213#include < dtlmod/DTL.hpp>
1314#include < dtlmod/DTLException.hpp>
1415#include < dtlmod/Engine.hpp>
1516#include < dtlmod/FileEngine.hpp>
1617#include < dtlmod/FileTransport.hpp>
1718#include < dtlmod/Metadata.hpp>
19+ #include < dtlmod/ReductionMethod.hpp>
1820#include < dtlmod/StagingEngine.hpp>
1921#include < dtlmod/StagingMboxTransport.hpp>
2022#include < dtlmod/StagingMqTransport.hpp>
2931namespace py = pybind11;
3032using dtlmod::DTL;
3133using dtlmod::Engine;
34+ using dtlmod::ReductionMethod;
3235using dtlmod::Stream;
3336using dtlmod::Transport;
3437using dtlmod::Variable;
@@ -73,6 +76,18 @@ PYBIND11_MODULE(dtlmod, m)
7376
7477 py::register_exception<dtlmod::GetWhenNoTransactionException>(m, " GetWhenNoTransactionException" );
7578
79+ py::register_exception<dtlmod::UnknownReductionMethodException>(m, " UnknownReductionMethodException" );
80+ py::register_exception<dtlmod::InconsistentDecimationStrideException>(m, " InconsistentDecimationStrideException" );
81+ py::register_exception<dtlmod::InconsistentDecimationInterpolationException>(
82+ m, " InconsistentDecimationInterpolationException" );
83+ py::register_exception<dtlmod::UnknownDecimationOptionException>(m, " UnknownDecimationOptionException" );
84+ py::register_exception<dtlmod::UnknownDecimationInterpolationException>(m, " UnknownDecimationInterpolationException" );
85+ py::register_exception<dtlmod::DoubleReductionException>(m, " DoubleReductionException" );
86+
87+ py::register_exception<dtlmod::UnknownCompressionOptionException>(m, " UnknownCompressionOptionException" );
88+ py::register_exception<dtlmod::InconsistentCompressionRatioException>(m, " InconsistentCompressionRatioException" );
89+ py::register_exception<dtlmod::SubscriberSideCompressionException>(m, " SubscriberSideCompressionException" );
90+
7691 /* Class DTL */
7792 py::class_<DTL, std::shared_ptr<DTL>>(m, " DTL" , " Data Transport Layer" )
7893 .def_static (" create" , py::overload_cast<std::string_view>(&DTL::create), py::call_guard<py::gil_scoped_release>(),
@@ -147,7 +162,9 @@ PYBIND11_MODULE(dtlmod, m)
147162 .def_property_readonly (" metadata_file_name" , &Stream::get_metadata_file_name,
148163 " The name of the file in which the stream stores metadata (read-only)" )
149164 .def (" inquire_variable" , &Stream::inquire_variable, py::arg (" name" ), " Retrieve a Variable information by name" )
150- .def (" remove_variable" , &Stream::remove_variable, py::arg (" name" ), " Remove a Variable from this Stream" );
165+ .def (" remove_variable" , &Stream::remove_variable, py::arg (" name" ), " Remove a Variable from this Stream" )
166+ .def (" define_reduction_method" , &Stream::define_reduction_method, py::arg (" name" ),
167+ " Define a reduction method for this Stream (e.g. 'decimation' or 'compression')" );
151168
152169 py::enum_<Stream::Mode>(stream, " Mode" , " The access mode for a Stream" )
153170 .value (" Publish" , Stream::Mode::Publish)
@@ -172,7 +189,32 @@ PYBIND11_MODULE(dtlmod, m)
172189 [](Variable& self, unsigned int begin, unsigned int count) { self.set_transaction_selection (begin, count); },
173190 py::arg (" begin" ), py::arg (" count" ), " Set the selection of transactions to consider for this Variable" )
174191 .def (" set_selection" , &Variable::set_selection, py::arg (" start" ), py::arg (" count" ),
175- " Set the selection of elements to consider for this Variable" );
192+ " Set the selection of elements to consider for this Variable" )
193+ .def (" set_reduction_operation" , &Variable::set_reduction_operation, py::arg (" method" ), py::arg (" parameters" ),
194+ " Set a reduction operation on this Variable with the given method and parameters" )
195+ .def_property_readonly (" is_reduced" , &Variable::is_reduced,
196+ " Whether this Variable has a reduction method applied (read-only)" )
197+ .def_property_readonly (" is_reduced_by_publisher" , &Variable::is_reduced_by_publisher,
198+ " Whether this Variable was reduced on the publisher side (read-only)" )
199+ .def_property_readonly (" is_reduced_by_subscriber" , &Variable::is_reduced_by_subscriber,
200+ " Whether this Variable was reduced on the subscriber side (read-only)" )
201+ .def_property_readonly (" reduction_method" , &Variable::get_reduction_method,
202+ " The reduction method applied to this Variable, or None (read-only)" );
203+
204+ /* Class ReductionMethod */
205+ py::class_<ReductionMethod, std::shared_ptr<ReductionMethod>>(m, " ReductionMethod" ,
206+ " A reduction method applied to Variables in a Stream" )
207+ .def_property_readonly (" name" , &ReductionMethod::get_name, " The name of the ReductionMethod (read-only)" )
208+ .def (" get_reduced_variable_global_size" , &ReductionMethod::get_reduced_variable_global_size, py::arg (" var" ),
209+ " Get the reduced global size of a Variable" )
210+ .def (" get_reduced_variable_local_size" , &ReductionMethod::get_reduced_variable_local_size, py::arg (" var" ),
211+ " Get the reduced local size of a Variable" )
212+ .def (" get_reduced_variable_shape" , &ReductionMethod::get_reduced_variable_shape, py::arg (" var" ),
213+ " Get the reduced shape of a Variable" )
214+ .def (" get_flop_amount_to_reduce_variable" , &ReductionMethod::get_flop_amount_to_reduce_variable, py::arg (" var" ),
215+ " Get the flop cost to reduce a Variable" )
216+ .def (" get_flop_amount_to_decompress_variable" , &ReductionMethod::get_flop_amount_to_decompress_variable,
217+ py::arg (" var" ), " Get the flop cost to decompress a Variable" );
176218
177219 /* Class Engine */
178220 py::class_<Engine, std::shared_ptr<Engine>> engine (
0 commit comments