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

Method GetCoreCode

tensorflow/lite/delegates/gpu/cl/kernels/add.cc:120–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120std::string Add::GetCoreCode(const std::string& src, const std::string& z_coord,
121 const std::string& address) const {
122 std::string result;
123 for (int i = 1; i < src_depthes_.size(); ++i) {
124 const std::string tensor_name =
125 absl::StrCat("src_data_", link_index_, "_", i);
126 TensorCodeGenerator src_tensor(tensor_name, "", definition_.src_tensors[i]);
127 if (src_depthes_[i] != dst_depth_) {
128 absl::StrAppend(&result, " if (", z_coord, " < ", src_depthes_[i],
129 ") {\n");
130 if (definition_.src_tensors[i].storage_type ==
131 TensorStorageType::TEXTURE_2D) {
132 absl::StrAppend(&result, " float t_y = ", address, ".y - ", z_coord,
133 ";\n");
134 absl::StrAppend(&result, " int ti_y = (t_y + 0.5) * ",
135 inv_divisor_name_, ";\n");
136 absl::StrAppend(&result, " int2 tmp_add = (int2)(", address,
137 ".x, ti_y * ", src_depthes_[i], " + ", z_coord, ");\n");
138 absl::StrAppend(
139 &result, " ", src,
140 " += ", src_tensor.Read3D("tmp_add", TextureAddressMode::DONT_CARE),
141 ";\n");
142 } else {
143 absl::StrAppend(
144 &result, " ", src,
145 " += ", src_tensor.Read3D(address, TextureAddressMode::DONT_CARE),
146 ";\n");
147 }
148 absl::StrAppend(&result, " }\n");
149 } else {
150 absl::StrAppend(
151 &result, " ", src, " += ",
152 src_tensor.Read3D(address, TextureAddressMode::DONT_CARE) + ";\n");
153 }
154 }
155 return result;
156}
157
158std::string Add::GetArgsDeclaration() const {
159 std::string args;

Callers 2

GetElementWiseCodeFunction · 0.45
PostProcessFunction · 0.45

Calls 4

Read3DMethod · 0.80
StrCatFunction · 0.50
StrAppendFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected