| 201 | tensorflow::EagerOperation* op() { return op_.get(); } |
| 202 | |
| 203 | tensorflow::Status InitializeNodeDef(const void* custom_initial_data, |
| 204 | int custom_initial_data_size) { |
| 205 | if (!custom_initial_data) { |
| 206 | return tensorflow::errors::Internal( |
| 207 | "Cannot convert empty data into a valid NodeDef"); |
| 208 | } |
| 209 | // The flexbuffer contains a vector where the first elements is the |
| 210 | // op name and the second is a serialized NodeDef. |
| 211 | const flexbuffers::Vector& v = |
| 212 | flexbuffers::GetRoot( |
| 213 | reinterpret_cast<const uint8_t*>(custom_initial_data), |
| 214 | custom_initial_data_size) |
| 215 | .AsVector(); |
| 216 | |
| 217 | name_ = v[0].AsString().str(); |
| 218 | if (!nodedef_.ParseFromString(v[1].AsString().str())) { |
| 219 | nodedef_.Clear(); |
| 220 | return tensorflow::errors::Internal( |
| 221 | "Failed to parse data into a valid NodeDef"); |
| 222 | } |
| 223 | |
| 224 | // Fill NodeDef with defaults if it's a valid op. |
| 225 | const tensorflow::OpRegistrationData* op_reg_data; |
| 226 | TF_RETURN_IF_ERROR( |
| 227 | tensorflow::OpRegistry::Global()->LookUp(nodedef_.op(), &op_reg_data)); |
| 228 | AddDefaultsToNodeDef(op_reg_data->op_def, &nodedef_); |
| 229 | |
| 230 | return tensorflow::Status::OK(); |
| 231 | } |
| 232 | |
| 233 | // Build thew new EagerOperation. In case of error, the returned 'op' is |
| 234 | // guaranteed to be 'nullptr'. |
no test coverage detected