| 85 | } |
| 86 | |
| 87 | void TF_OpDefinitionBuilderSetShapeInferenceFunction( |
| 88 | TF_OpDefinitionBuilder* builder, |
| 89 | void (*shape_inference_func)(TF_ShapeInferenceContext* ctx, |
| 90 | TF_Status* status)) { |
| 91 | auto* cc_builder = reinterpret_cast<OpDefBuilder*>(builder); |
| 92 | cc_builder->SetShapeFn( |
| 93 | [shape_inference_func](InferenceContext* ctx) -> tensorflow::Status { |
| 94 | TF_Status* c_status = TF_NewStatus(); |
| 95 | auto c_ctx = reinterpret_cast<TF_ShapeInferenceContext*>(ctx); |
| 96 | shape_inference_func(c_ctx, c_status); |
| 97 | tensorflow::Status result = ::tensorflow::StatusFromTF_Status(c_status); |
| 98 | TF_DeleteStatus(c_status); |
| 99 | return result; |
| 100 | }); |
| 101 | } |
| 102 | |
| 103 | TF_ShapeHandle* TF_NewShapeHandle() { |
| 104 | return reinterpret_cast<TF_ShapeHandle*>(new ShapeHandle); |