| 121 | |
| 122 | } |
| 123 | bool TFeatureTensorTracker::AddFeatureTensor(const TFeatureTensor& featureTensor) { |
| 124 | const TFeatureTensor prevTensor = CurrentTensor; |
| 125 | CurrentTensor.AddTensor(featureTensor); |
| 126 | if (prevTensor == CurrentTensor) { |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | TCtrBinBuilder<NCudaLib::TMirrorMapping> binBuilder(Stream); |
| 131 | |
| 132 | if (LearnSlice.Size() == 0) { |
| 133 | binBuilder.SetIndices(LearnDataSet->GetIndices(), |
| 134 | LinkedTest ? &(LinkedTest->GetIndices()) : nullptr); |
| 135 | LearnSlice = binBuilder.GetLearnSlice(); |
| 136 | } else { |
| 137 | binBuilder.SetIndices(std::move(Indices), |
| 138 | LearnSlice); //some ping-pong with buffer |
| 139 | } |
| 140 | |
| 141 | auto catFeatures = NCB::RemoveExisting(CurrentTensor.GetCatFeatures(), prevTensor.GetCatFeatures()); |
| 142 | auto binarySplits = NCB::RemoveExisting(CurrentTensor.GetSplits(), prevTensor.GetSplits()); |
| 143 | |
| 144 | TMirrorCatFeatureProvider broadcastedCatFeatures(LearnDataSet->GetCatFeatures(), |
| 145 | *CacheHolder); |
| 146 | |
| 147 | for (ui32 catFeature : catFeatures) { |
| 148 | const auto& compressedFeatures = broadcastedCatFeatures.BroadcastFeature(catFeature, Stream) |
| 149 | .GetInStream(Stream); |
| 150 | |
| 151 | if (LinkedTest) { |
| 152 | TMirrorCatFeatureProvider broadcastedTestCatFeatures( |
| 153 | LinkedTest->GetCatFeatures(), |
| 154 | *CacheHolder); |
| 155 | const auto& compressedTest = broadcastedTestCatFeatures.BroadcastFeature(catFeature, Stream) |
| 156 | .GetInStream(Stream); |
| 157 | binBuilder.AddCompressedBins(compressedFeatures, |
| 158 | compressedTest, |
| 159 | FeaturesManager->GetBinCount(catFeature)); |
| 160 | } else { |
| 161 | binBuilder.AddCompressedBins(compressedFeatures, |
| 162 | FeaturesManager->GetBinCount(catFeature)); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | //TODO(noxoomo): builder should merge several task in one |
| 167 | for (const auto& binarySplit : binarySplits) { |
| 168 | const auto& learnBits = LearnBinarySplitsProvider->GetCompressedBits(binarySplit); |
| 169 | |
| 170 | if (LinkedTest) { |
| 171 | const auto& testBits = TestBinarySplitsProvider->GetCompressedBits(binarySplit); |
| 172 | |
| 173 | binBuilder.AddCompressedBins(learnBits, |
| 174 | testBits, |
| 175 | 2); |
| 176 | } else { |
| 177 | binBuilder.AddCompressedBins(learnBits, |
| 178 | 2); |
| 179 | } |
| 180 | } |
no test coverage detected