MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ForEach

Method ForEach

tensorflow/compiler/jit/device_util.h:69–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 // performance neutral.
68 template <typename FnTy>
69 void ForEach(FnTy func) const {
70 // This is really a poor man's iterator, we should consider writing a proper
71 // iterator if this ends up being used widely.
72 for (int word_index = 0; word_index < storage_.size(); word_index++) {
73 uint64 word = storage_[word_index];
74 while (word != 0) {
75 uint64 only_lowest_bit_set = word & -word;
76 // The number of trailing zeros in a non-zero word is the index of the
77 // least significant 1.
78 int bit_index = ctz_uint64(word);
79 if (!func(DeviceId(word_index * kWordSize + bit_index))) {
80 return;
81 }
82 word ^= only_lowest_bit_set;
83 }
84 }
85 }
86
87 private:
88 static int ctz_uint64(uint64 x) {

Callers 3

DebugStringMethod · 0.45
PickDeviceForXlaImplFunction · 0.45

Calls 3

DeviceIdClass · 0.85
funcFunction · 0.50
sizeMethod · 0.45

Tested by 1