MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / generate_point_op

Method generate_point_op

src/cpp_generator.cpp:155–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155std::string cpp_generator::generate_point_op(const operation& op,
156 const std::vector<std::string>& args)
157{
158 auto v = op.to_value();
159 std::string code;
160 if(contains(impl->point_op_map, op.name()))
161 {
162 code = impl->point_op_map.at(op.name());
163 }
164 else
165 {
166 auto attributes = op.attributes();
167 if(not attributes.contains("point_op"))
168 MIGRAPHX_THROW("op is missing point_op attribute: " + op.name());
169 code = attributes["point_op"].to<std::string>();
170 }
171 return interpolate_string(code, [&](auto start, auto last) -> std::string {
172 auto key = trim({start, last});
173 if(key.empty())
174 MIGRAPHX_THROW("Empty parameter");
175 std::string fselector = "function:";
176 if(starts_with(key, fselector))
177 {
178 auto fname = key.substr(fselector.size());
179 if(impl->fmap == nullptr)
180 return fname;
181 else
182 return impl->fmap(fname);
183 }
184 else if(with_char(::isdigit)(key[0]))
185 {
186 auto i = std::stoul(key);
187 if(i >= args.size())
188 MIGRAPHX_THROW("Invalid argument index: " + key);
189 return args.at(i);
190 }
191 else if(v.contains(key))
192 {
193 return v[key].template to<std::string>();
194 }
195 else
196 {
197 return key;
198 }
199 });
200}
201
202std::string cpp_generator::str() const { return impl->fs.str(); }
203

Callers 1

generate_moduleMethod · 0.95

Calls 13

containsFunction · 0.85
interpolate_stringFunction · 0.85
trimFunction · 0.85
starts_withFunction · 0.85
with_charFunction · 0.85
atMethod · 0.80
fmapMethod · 0.80
to_valueMethod · 0.45
nameMethod · 0.45
attributesMethod · 0.45
containsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected