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

Function GetBlockByIndex

tensorflow/lite/experimental/ruy/block_map.cc:28–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace ruy {
27
28void GetBlockByIndex(const BlockMap& block_map, int index,
29 SidePair<int>* block) {
30 gemmlowp::ScopedProfilingLabel label("GetBlockByIndex");
31 const std::uint32_t index_u32 = index;
32 const std::uint32_t rectr =
33 index_u32 & ((1u << block_map.rectangularness_log2[Side::kLhs]) - 1);
34 const std::uint32_t rectc =
35 index_u32 & ((1u << block_map.rectangularness_log2[Side::kRhs]) - 1);
36
37 const std::uint32_t n1 =
38 index_u32 >> (block_map.rectangularness_log2[Side::kLhs] +
39 block_map.rectangularness_log2[Side::kRhs]);
40 RUY_DCHECK_EQ(index_u32,
41 (n1 << (block_map.rectangularness_log2[Side::kLhs] +
42 block_map.rectangularness_log2[Side::kRhs])) +
43 rectr + rectc);
44
45 std::uint32_t br, bc;
46 if (block_map.traversal_order == BlockMapTraversalOrder::kLinear) {
47 br = n1 & ((1u << block_map.num_blocks_base_log2) - 1);
48 bc = n1 >> block_map.num_blocks_base_log2;
49 } else {
50 // Decode fractal z-order
51 const std::uint32_t n2 = (n1 & 0x99999999u) | ((n1 & 0x44444444u) >> 1) |
52 ((n1 & 0x22222222u) << 1);
53 const std::uint32_t n4 = (n2 & 0xc3c3c3c3u) | ((n2 & 0x30303030u) >> 2) |
54 ((n2 & 0x0c0c0c0cu) << 2);
55 const std::uint32_t n8 = (n4 & 0xf00ff00fu) | ((n4 & 0x0f000f00u) >> 4) |
56 ((n4 & 0x00f000f0u) << 4);
57 const std::uint32_t n16 = (n8 & 0xff0000ffu) | ((n8 & 0x00ff0000u) >> 8) |
58 ((n8 & 0x0000ff00u) << 8);
59
60 br = n16 & 0xffff;
61 bc = n16 >> 16;
62 if (block_map.traversal_order == BlockMapTraversalOrder::kFractalU) {
63 // Change fractal z-order to u-order
64 br ^= bc;
65 }
66 }
67
68 br = (br << block_map.rectangularness_log2[Side::kLhs]) + rectr;
69 bc = (bc << block_map.rectangularness_log2[Side::kRhs]) + rectc;
70
71 // Store
72 (*block)[Side::kLhs] = br;
73 (*block)[Side::kRhs] = bc;
74}
75
76namespace {
77

Callers 2

DumpFunction · 0.85
RunMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected