MCPcopy Create free account
hub / github.com/alibaba/MNN / transformBatch

Function transformBatch

tools/train/source/data/StackTransform.hpp:19–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18class MNN_PUBLIC StackTransform : public BatchTransform {
19 std::vector<Example> transformBatch(std::vector<Example> batch) override {
20 std::vector<std::vector<VARP>> batchData(batch[0].first.size());
21 std::vector<std::vector<VARP>> batchTarget(batch[0].second.size());
22 for (int i = 0; i < batch.size(); i++) {
23 for (int j = 0; j < batchData.size(); j++) {
24 batchData[j].emplace_back(batch[i].first[j]);
25 }
26 }
27
28 for (int i = 0; i < batch.size(); i++) {
29 for (int j = 0; j < batchTarget.size(); j++) {
30 batchTarget[j].emplace_back(batch[i].second[j]);
31 }
32 }
33
34 Example example;
35 for (int i = 0; i < batchData.size(); i++) {
36 example.first.emplace_back(_Stack(batchData[i], 0));
37 }
38 for (int i = 0; i < batchTarget.size(); i++) {
39 example.second.emplace_back(_Stack(batchTarget[i], 0));
40 }
41
42 return {example};
43 }
44};
45
46} // namespace Train

Callers

nothing calls this directly

Calls 2

_StackFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected