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

Function OpInferSingleInputAttrs

tensorflow/c/eager/c_api.cc:286–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284#endif // !IS_MOBILE_PLATFORM
285
286tensorflow::Status OpInferSingleInputAttrs(TFE_Op* op,
287 TFE_TensorHandle* input) {
288 TFE_OpInferenceContext* ictx = op->inference_ctx.get();
289 const auto& input_def = ictx->op_def->input_arg(ictx->input_arg_idx++);
290 if (!input_def.number_attr().empty() || !input_def.type_list_attr().empty()) {
291 // Some clients that are still setting their input attributes manually are
292 // adding input list to their op by calling `TFE_OpAddInput` for each of
293 // its elements instead of calling `TFE_OpAddInputList`. When this happens,
294 // we cannot detect the end of such list, thus lose track of the input
295 // arguments in the op definition. To guarantee backward compatibility with
296 // those clients, disable automatic inference in this case.
297 op->inference_ctx.reset(nullptr);
298 return tensorflow::Status::OK();
299 }
300 const std::string& type_attr = input_def.type_attr();
301 if (!type_attr.empty() && ictx->attrs.find(type_attr) == ictx->attrs.end()) {
302 op->operation.MutableAttrs()->Set(type_attr, input->handle->dtype);
303 ictx->attrs.insert(type_attr);
304 }
305 return tensorflow::Status::OK();
306}
307
308void OpInferSingleTypeInputListAttrs(TFE_Op* op,
309 const tensorflow::OpDef::ArgDef& input_def,

Callers 1

TFE_OpAddInputFunction · 0.85

Calls 8

MutableAttrsMethod · 0.80
getMethod · 0.45
emptyMethod · 0.45
resetMethod · 0.45
findMethod · 0.45
endMethod · 0.45
SetMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected