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

Function ValidateVariableResourceHandle

tensorflow/core/ops/kv_variable_ops.cc:31–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace {
30
31Status ValidateVariableResourceHandle(InferenceContext* c,
32 int input_indice,
33 ShapeAndType* shape_and_type) {
34 auto* handle_data = c->input_handle_shapes_and_types(input_indice);
35 if (handle_data == nullptr || handle_data->empty()) {
36 shape_and_type->shape = c->UnknownShape();
37 shape_and_type->dtype = DT_INVALID;
38 } else {
39 *shape_and_type = (*handle_data)[0];
40 DataType value_dtype;
41 TF_RETURN_IF_ERROR(c->GetAttr("dtype", &value_dtype));
42 if (shape_and_type->dtype != value_dtype) {
43 return errors::InvalidArgument(
44 "Trying to read variable with wrong dtype. "
45 "Expected ",
46 DataTypeString(shape_and_type->dtype), " got ",
47 DataTypeString(value_dtype));
48 }
49 }
50 return Status::OK();
51}
52
53Status ReadVariableShapeFn(InferenceContext* c) {
54 ShapeAndType shape_and_type;

Callers 3

ReadVariableShapeFnFunction · 0.70
CreateAssignShapeFnFunction · 0.70
kv_variable_ops.ccFile · 0.70

Calls 6

InvalidArgumentFunction · 0.85
UnknownShapeMethod · 0.80
DataTypeStringFunction · 0.50
emptyMethod · 0.45
GetAttrMethod · 0.45

Tested by

no test coverage detected