| 29 | namespace { |
| 30 | |
| 31 | Status 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 | |
| 53 | Status ReadVariableShapeFn(InferenceContext* c) { |
| 54 | ShapeAndType shape_and_type; |
no test coverage detected