LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
transform_pipeline.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
26 
27 #ifndef LBANN_TRANSFORMS_TRANSFORM_PIPELINE_HPP_INCLUDED
28 #define LBANN_TRANSFORMS_TRANSFORM_PIPELINE_HPP_INCLUDED
29 
30 #include "lbann/base.hpp"
33 
34 namespace lbann {
35 namespace transform {
36 
41 {
42 public:
49 
50  transform_pipeline* copy() const { return new transform_pipeline(*this); }
51 
55  void add_transform(std::unique_ptr<transform>&& trans)
56  {
57  m_transforms.push_back(std::move(trans));
58  }
59 
64  void set_expected_out_dims(std::vector<size_t> expected_out_dims)
65  {
66  m_expected_out_dims = expected_out_dims;
67  }
68 
74  void apply(utils::type_erased_matrix& data, std::vector<size_t>& dims);
76  void apply(CPUMat& data, std::vector<size_t>& dims);
83  void
84  apply(El::Matrix<uint8_t>& data, CPUMat& out_data, std::vector<size_t>& dims);
85 
86 private:
88  std::vector<std::unique_ptr<transform>> m_transforms;
90  std::vector<size_t> m_expected_out_dims;
91 
93  void assert_expected_out_dims(const std::vector<size_t>& dims);
94 };
95 
96 } // namespace transform
97 } // namespace lbann
98 
99 #endif // LBANN_TRANSFORMS_TRANSFORM_PIPELINE_HPP_INCLUDED
void add_transform(std::unique_ptr< transform > &&trans)
T & data(const cnpy::NpyArray &na, const std::vector< size_t > indices)
Definition: cnpy_utils.hpp:75
El::Matrix< DataType, El::Device::CPU > CPUMat
Definition: base.hpp:116
transform_pipeline & operator=(const transform_pipeline &)
void set_expected_out_dims(std::vector< size_t > expected_out_dims)
A type-erased wrapper around an El::Matrix<T,Device::CPU>
transform_pipeline * copy() const
void assert_expected_out_dims(const std::vector< size_t > &dims)
std::vector< std::unique_ptr< transform > > m_transforms
void apply(utils::type_erased_matrix &data, std::vector< size_t > &dims)