| 32 | namespace transform { |
| 33 | |
| 34 | void scale::apply(utils::type_erased_matrix& data, std::vector<size_t>&) |
| 35 | { |
| 36 | // Currently only works on DataTypes. |
| 37 | // Need to decide how to handle uint8_t matrices. |
| 38 | auto& mat = data.template get<DataType>(); |
| 39 | if (mat.Height() != mat.LDim()) { |
| 40 | LBANN_ERROR("Scaling non-contiguous matrix not supported."); |
| 41 | } |
| 42 | // Don't use El::Scale because it spawns OpenMP threads. |
| 43 | DataType* __restrict__ buf = mat.Buffer(); |
| 44 | const El::Int size = mat.Height() * mat.Width(); |
| 45 | for (El::Int i = 0; i < size; ++i) { |
| 46 | buf[i] *= m_scale; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | std::unique_ptr<transform> |
| 51 | build_scale_transform_from_pbuf(google::protobuf::Message const& msg) |
no test coverage detected