| 37 | using UnalignedInt64Vector = TTypes<const int64>::UnalignedConstVec; |
| 38 | |
| 39 | void FeatureWeightsDenseStorage::UpdateDenseDeltaWeights( |
| 40 | const Eigen::ThreadPoolDevice& device, |
| 41 | const Example::DenseVector& dense_vector, |
| 42 | const std::vector<double>& normalized_bounded_dual_delta) { |
| 43 | const size_t num_weight_vectors = normalized_bounded_dual_delta.size(); |
| 44 | if (num_weight_vectors == 1) { |
| 45 | deltas_.device(device) = |
| 46 | deltas_ + dense_vector.RowAsMatrix() * |
| 47 | deltas_.constant(normalized_bounded_dual_delta[0]); |
| 48 | } else { |
| 49 | // Transform the dual vector into a column matrix. |
| 50 | const Eigen::TensorMap<Eigen::Tensor<const double, 2, Eigen::RowMajor>> |
| 51 | dual_matrix(normalized_bounded_dual_delta.data(), num_weight_vectors, |
| 52 | 1); |
| 53 | const Eigen::array<Eigen::IndexPair<int>, 1> product_dims = { |
| 54 | Eigen::IndexPair<int>(1, 0)}; |
| 55 | // This computes delta_w += delta_vector / \lamdba * N. |
| 56 | deltas_.device(device) = |
| 57 | (deltas_.cast<double>() + |
| 58 | dual_matrix.contract(dense_vector.RowAsMatrix().cast<double>(), |
| 59 | product_dims)) |
| 60 | .cast<float>(); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void FeatureWeightsSparseStorage::UpdateSparseDeltaWeights( |
| 65 | const Eigen::ThreadPoolDevice& device, |
no test coverage detected