There are many ops out there without shape functions, and it's very
onerous to add UnknownShape to all of them.
PiperOrigin-RevId:
186524294
}
}
+void SetRequireShapeInferenceFns(TF_Graph* graph, bool require) {
+ mutex_lock l(graph->mu);
+ graph->refiner.set_require_shape_inference_fns(require);
+}
+
} // namespace tensorflow
void RemoveAllControlInputs(TF_Graph* graph, TF_Operation* op);
+// Sets whether ops missing a shape inference function should trigger an
+// error. The default is true.
+void SetRequireShapeInferenceFns(TF_Graph* graph, bool require);
+
} // namespace tensorflow
#endif // TENSORFLOW_C_PYTHON_API_H_
$1 = &types_local;
}
+%unignore SetRequireShapeInferenceFns;
+
%include "tensorflow/python/client/tf_session_helper.h"
%unignoreall
# implementation
if self._use_c_api_hack():
self._scoped_c_graph = c_api_util.ScopedTFGraph()
+ # The C API requires all ops to have shape functions. Disable this
+ # requirement (many custom ops do not have shape functions, and we don't
+ # want to break these existing cases).
+ c_api.SetRequireShapeInferenceFns(self._c_graph, False)
else:
self._scoped_c_graph = None
self._variable_creator_stack = []