Skip to content

Commit d2ffa40

Browse files
committed
Expose the necessary functions
Signed-off-by: Ryan Nett <[email protected]>
1 parent 59750dc commit d2ffa40

File tree

5 files changed

+5902
-4823
lines changed

5 files changed

+5902
-4823
lines changed

tensorflow-core/tensorflow-core-api/WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ http_archive(
1212
":tensorflow-macosx.patch",
1313
# ":tensorflow-windows.patch", # https://github.com/tensorflow/tensorflow/issues/25213
1414
":tensorflow-proto.patch",
15+
"expose-internal-functions.patch",
1516
],
1617
patch_tool = "patch",
1718
patch_args = ["-p1"],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
2+
index f3bf7b98a1e..4d4cd1b1fe1 100644
3+
--- a/tensorflow/c/c_api.cc
4+
+++ b/tensorflow/c/c_api.cc
5+
@@ -645,12 +645,12 @@ TF_DEVICELIST_METHOD(uint64_t, TF_DeviceListIncarnation, incarnation(), 0);
6+
7+
// Helper functions -----------------------------------------------------------
8+
9+
-namespace {
10+
-
11+
TF_Operation* ToOperation(Node* node) {
12+
return static_cast<TF_Operation*>(static_cast<void*>(node));
13+
}
14+
15+
+namespace {
16+
+
17+
string OutputName(const TF_Output& output) {
18+
return StrCat(output.oper->node.name(), ":", output.index);
19+
}
20+
@@ -782,7 +782,7 @@ void TF_GraphGetTensorShape(TF_Graph* graph, TF_Output output, int64_t* dims,
21+
22+
extern "C" {
23+
24+
-static TF_OperationDescription* TF_NewOperationLocked(TF_Graph* graph,
25+
+TF_OperationDescription* TF_NewOperationLocked(TF_Graph* graph,
26+
const char* op_type,
27+
const char* oper_name)
28+
TF_EXCLUSIVE_LOCKS_REQUIRED(graph->mu) {
29+
@@ -1041,7 +1041,7 @@ void TF_SetAttrValueProto(TF_OperationDescription* desc, const char* attr_name,
30+
status->status = Status::OK();
31+
}
32+
33+
-static TF_Operation* TF_FinishOperationLocked(TF_OperationDescription* desc,
34+
+TF_Operation* TF_FinishOperationLocked(TF_OperationDescription* desc,
35+
TF_Status* status)
36+
TF_EXCLUSIVE_LOCKS_REQUIRED(desc->graph->mu) {
37+
Node* ret = nullptr;
38+
diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
39+
index 705cf85e051..d38ae62e86a 100644
40+
--- a/tensorflow/c/c_api.h
41+
+++ b/tensorflow/c/c_api.h
42+
@@ -255,6 +255,10 @@ TF_CAPI_EXPORT extern void TF_GraphGetTensorShape(TF_Graph* graph,
43+
int64_t* dims, int num_dims,
44+
TF_Status* status);
45+
46+
+TF_OperationDescription* TF_NewOperationLocked(TF_Graph* graph,
47+
+ const char* op_type,
48+
+ const char* oper_name);
49+
+
50+
// Operation will only be added to *graph when TF_FinishOperation() is
51+
// called (assuming TF_FinishOperation() does not return an error).
52+
// *graph must not be deleted until after TF_FinishOperation() is
53+
@@ -406,6 +410,9 @@ TF_CAPI_EXPORT extern void TF_SetAttrValueProto(TF_OperationDescription* desc,
54+
size_t proto_len,
55+
TF_Status* status);
56+
57+
+TF_Operation* TF_FinishOperationLocked(TF_OperationDescription* desc,
58+
+ TF_Status* status);
59+
+
60+
// If this function succeeds:
61+
// * *status is set to an OK value,
62+
// * a TF_Operation is added to the graph,
63+
diff --git a/tensorflow/c/c_api_internal.h b/tensorflow/c/c_api_internal.h
64+
index 76345cf068c..904f083a2d9 100644
65+
--- a/tensorflow/c/c_api_internal.h
66+
+++ b/tensorflow/c/c_api_internal.h
67+
@@ -185,6 +185,12 @@ struct TF_Server {
68+
};
69+
#endif // !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD)
70+
71+
+// Exposed helper functions
72+
+
73+
+TF_Operation* ToOperation(tensorflow::Node* node);
74+
+
75+
+// End Exposed helper functions
76+
+
77+
namespace tensorflow {
78+
79+
Status MessageToBuffer(const tensorflow::protobuf::MessageLite& in,
80+
--
81+
2.17.1
82+

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ public final class Ops {
364364

365365
public final SignalOps signal;
366366

367-
public final QuantizationOps quantization;
368-
369367
public final TrainOps train;
370368

369+
public final QuantizationOps quantization;
370+
371371
private final Scope scope;
372372

373373
Ops(Scope scope) {
@@ -390,8 +390,8 @@ public final class Ops {
390390
math = new MathOps(this);
391391
audio = new AudioOps(this);
392392
signal = new SignalOps(this);
393-
quantization = new QuantizationOps(this);
394393
train = new TrainOps(this);
394+
quantization = new QuantizationOps(this);
395395
}
396396

397397
/**

0 commit comments

Comments
 (0)