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

Function GetAddTableCode

tensorflow/lite/delegates/gpu/metal/kernels/add.cc:37–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35namespace {
36
37std::string GetAddTableCode(int src_count) {
38 std::string code = R"(
39 #include <metal_stdlib>
40 using namespace metal;
41
42 struct uniforms {
43 int4 src_size;
44 };
45
46 $0
47 kernel void ComputeFunction(
48 $1
49 uint3 gid[[thread_position_in_grid]]) {
50 if (static_cast<int>(gid.x) >= params.src_size.x ||
51 static_cast<int>(gid.y) >= params.src_size.y) {
52 return;
53 }
54
55 FLT4 value = FLT4(0.0f);
56 int linear_index = (int(gid.z) * params.src_size.y + int(gid.y)) *
57 params.src_size.x + int(gid.x);
58 )";
59 for (int i = 0; i < src_count; ++i) {
60 code += " value += src_buffer" + std::to_string(i) + "[linear_index];\n";
61 }
62 code += " $2\n";
63 code += " dst_buffer[linear_index] = value;\n";
64 code += "}\n";
65 return code;
66}
67} // namespace
68
69std::vector<ComputeTaskDescriptorPtr> Add(int id,

Callers 1

AddFunction · 0.85

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected