Skip to content

Commit d66e77f

Browse files
ispirmustafatensorflower-gardener
authored andcommitted
Added get variable utils to tf.estimator.Estimator.
PiperOrigin-RevId: 171052121
1 parent 083bd5d commit d66e77f

13 files changed

Lines changed: 24 additions & 333 deletions

File tree

tensorflow/contrib/boosted_trees/examples/boston.py

Lines changed: 0 additions & 155 deletions
This file was deleted.

tensorflow/contrib/boosted_trees/examples/mnist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ def _multiclass_metrics(predictions, labels, weights):
129129
def _make_experiment_fn(output_dir):
130130
"""Creates experiment for gradient boosted decision trees."""
131131
data = tf.contrib.learn.datasets.mnist.load_mnist()
132-
train_input_fn = get_input_fn(data.train, FLAGS.batch_size)
133-
eval_input_fn = get_input_fn(data.validation, FLAGS.eval_batch_size)
132+
train_input_fn = get_input_fn(data.train, batch_size=256)
133+
eval_input_fn = get_input_fn(data.validation, batch_size=5000)
134134

135135
return tf.contrib.learn.Experiment(
136136
estimator=_get_tfbt(output_dir),

tensorflow/java/BUILD

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ load(":src/gen/gen_ops.bzl", "tf_java_op_gen_srcjar")
1010
load(
1111
"//tensorflow:tensorflow.bzl",
1212
"tf_binary_additional_srcs",
13-
"tf_cc_binary",
1413
"tf_copts",
15-
"tf_custom_op_library",
14+
"tf_cc_binary",
1615
"tf_java_test",
1716
)
1817

@@ -181,16 +180,10 @@ tf_java_test(
181180
],
182181
)
183182

184-
tf_custom_op_library(
185-
name = "my_test_op.so",
186-
srcs = ["src/test/native/my_test_op.cc"],
187-
)
188-
189183
tf_java_test(
190184
name = "TensorFlowTest",
191185
size = "small",
192186
srcs = ["src/test/java/org/tensorflow/TensorFlowTest.java"],
193-
data = [":my_test_op.so"],
194187
javacopts = JAVACOPTS,
195188
test_class = "org.tensorflow.TensorFlowTest",
196189
deps = [

tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,6 @@ public final class TensorFlow {
2929
*/
3030
public static native byte[] registeredOpList();
3131

32-
/**
33-
* Load the dynamic library in filename and register the operations and kernels present in that
34-
* library.
35-
*
36-
* @param filename Path of the dynamic library containing operations and kernels to load.
37-
* @return Serialized bytes of the <a
38-
* href="https://www.tensorflow.org/code/tensorflow/core/framework/op_def.proto">OpList</a>
39-
* protocol buffer message defining the operations defined in the library.
40-
* @throws UnsatisfiedLinkError if filename cannot be loaded.
41-
*/
42-
public static byte[] loadLibrary(String filename) {
43-
long h = 0;
44-
try {
45-
h = libraryLoad(filename);
46-
} catch (RuntimeException e) {
47-
throw new UnsatisfiedLinkError(e.getMessage());
48-
}
49-
try {
50-
return libraryOpList(h);
51-
} finally {
52-
libraryDelete(h);
53-
}
54-
}
55-
56-
private static native long libraryLoad(String filename);
57-
58-
private static native void libraryDelete(long handle);
59-
60-
private static native byte[] libraryOpList(long handle);
61-
6232
private TensorFlow() {}
6333

6434
/** Load the TensorFlow runtime C library. */

tensorflow/java/src/main/native/tensorflow_jni.cc

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ limitations under the License.
1414
==============================================================================*/
1515

1616
#include "tensorflow/java/src/main/native/tensorflow_jni.h"
17-
18-
#include <limits>
1917
#include "tensorflow/c/c_api.h"
20-
#include "tensorflow/java/src/main/native/exception_jni.h"
2118

2219
JNIEXPORT jstring JNICALL Java_org_tensorflow_TensorFlow_version(JNIEnv* env,
2320
jclass clazz) {
@@ -33,35 +30,3 @@ Java_org_tensorflow_TensorFlow_registeredOpList(JNIEnv* env, jclass clazz) {
3330
TF_DeleteBuffer(buf);
3431
return ret;
3532
}
36-
37-
JNIEXPORT jlong JNICALL Java_org_tensorflow_TensorFlow_libraryLoad(
38-
JNIEnv* env, jclass clazz, jstring filename) {
39-
TF_Status* status = TF_NewStatus();
40-
const char* cname = env->GetStringUTFChars(filename, nullptr);
41-
TF_Library* h = TF_LoadLibrary(cname, status);
42-
throwExceptionIfNotOK(env, status);
43-
env->ReleaseStringUTFChars(filename, cname);
44-
TF_DeleteStatus(status);
45-
return reinterpret_cast<jlong>(h);
46-
}
47-
48-
JNIEXPORT void JNICALL Java_org_tensorflow_TensorFlow_libraryDelete(
49-
JNIEnv* env, jclass clazz, jlong handle) {
50-
if (handle != 0) {
51-
TF_DeleteLibraryHandle(reinterpret_cast<TF_Library*>(handle));
52-
}
53-
}
54-
55-
JNIEXPORT jbyteArray JNICALL Java_org_tensorflow_TensorFlow_libraryOpList(
56-
JNIEnv* env, jclass clazz, jlong handle) {
57-
TF_Buffer buf = TF_GetOpList(reinterpret_cast<TF_Library*>(handle));
58-
if (buf.length > std::numeric_limits<jint>::max()) {
59-
throwException(env, kIndexOutOfBoundsException,
60-
"Serialized OpList is too large for a byte[] array");
61-
return nullptr;
62-
}
63-
auto ret_len = static_cast<jint>(buf.length);
64-
jbyteArray ret = env->NewByteArray(ret_len);
65-
env->SetByteArrayRegion(ret, 0, ret_len, static_cast<const jbyte*>(buf.data));
66-
return ret;
67-
}

tensorflow/java/src/main/native/tensorflow_jni.h

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
* Method: version
2828
* Signature: ()Ljava/lang/String;
2929
*/
30-
JNIEXPORT jstring JNICALL Java_org_tensorflow_TensorFlow_version(JNIEnv *,
30+
JNIEXPORT jstring JNICALL Java_org_tensorflow_TensorFlow_version(JNIEnv*,
3131
jclass);
3232

3333
/*
@@ -36,33 +36,7 @@ JNIEXPORT jstring JNICALL Java_org_tensorflow_TensorFlow_version(JNIEnv *,
3636
* Signature: ()[B
3737
*/
3838
JNIEXPORT jbyteArray JNICALL
39-
Java_org_tensorflow_TensorFlow_registeredOpList(JNIEnv *, jclass);
40-
41-
/*
42-
* Class: org_tensorflow_TensorFlow
43-
* Method: libraryLoad
44-
* Signature: (Ljava/lang/String;)J
45-
*/
46-
JNIEXPORT jlong JNICALL Java_org_tensorflow_TensorFlow_libraryLoad(JNIEnv *,
47-
jclass,
48-
jstring);
49-
50-
/*
51-
* Class: org_tensorflow_TensorFlow
52-
* Method: libraryDelete
53-
* Signature: (J)V
54-
*/
55-
JNIEXPORT void JNICALL Java_org_tensorflow_TensorFlow_libraryDelete(JNIEnv *,
56-
jclass,
57-
jlong);
58-
59-
/*
60-
* Class: org_tensorflow_TensorFlow
61-
* Method: libraryOpList
62-
* Signature: (J)[B
63-
*/
64-
JNIEXPORT jbyteArray JNICALL
65-
Java_org_tensorflow_TensorFlow_libraryOpList(JNIEnv *, jclass, jlong);
39+
Java_org_tensorflow_TensorFlow_registeredOpList(JNIEnv*, jclass);
6640

6741
#ifdef __cplusplus
6842
} // extern "C"

tensorflow/java/src/test/java/org/tensorflow/TensorFlowTest.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.tensorflow;
1717

1818
import static org.junit.Assert.assertTrue;
19-
import static org.junit.Assert.fail;
2019

2120
import org.junit.Test;
2221
import org.junit.runner.RunWith;
@@ -37,26 +36,4 @@ public void registeredOpList() {
3736
// was not sorted out. Revisit? Till then, at least exercise the code.
3837
assertTrue(TensorFlow.registeredOpList().length > 0);
3938
}
40-
41-
@Test
42-
public void loadLibrary() {
43-
// TODO(ashankar): This tell will fail when built with --config=monolithic.
44-
// Figure out how we can ignore the test in that case.
45-
try (Graph g = new Graph()) {
46-
// Build a graph with an unrecognized operation.
47-
try {
48-
g.opBuilder("MyTest", "MyTest").build();
49-
fail("should not be able to construct graphs with unregistered ops");
50-
} catch (IllegalArgumentException e) {
51-
// expected exception
52-
}
53-
54-
// Load the library containing the operation.
55-
byte[] opList = TensorFlow.loadLibrary("tensorflow/java/my_test_op.so");
56-
assertTrue(opList.length > 0);
57-
58-
// Now graph building should succeed.
59-
g.opBuilder("MyTest", "MyTest").build();
60-
}
61-
}
6239
}

tensorflow/java/src/test/native/my_test_op.cc

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)