MCPcopy Create free account
hub / github.com/LBANN/lbann / apply

Method apply

src/transforms/scale.cpp:34–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32namespace transform {
33
34void 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
50std::unique_ptr<transform>
51build_scale_transform_from_pbuf(google::protobuf::Message const& msg)

Callers 7

__init__Method · 0.45
fetch_datumMethod · 0.45
fetch_datumMethod · 0.45
fetch_datumMethod · 0.45
fetchMethod · 0.45
transform_data_fieldFunction · 0.45
trainMethod · 0.45

Calls 4

HeightMethod · 0.80
LDimMethod · 0.80
BufferMethod · 0.80
WidthMethod · 0.80

Tested by

no test coverage detected