Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging #345

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tensorflow-core/tensorflow-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<artifactId>ndarray</artifactId>
<version>${ndarray.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.31</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -73,6 +78,12 @@
<artifactId>jmh-generator-annprocess</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.31</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -212,6 +223,8 @@
<includePaths>
<includePath>${project.basedir}/</includePath>
<includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>
<includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_absl/</includePath>
<includePath>${project.basedir}/bazel-${project.artifactId}/external/eigen_archive/</includePath>
</includePaths>
<linkPaths>
<linkPath>${project.basedir}/bazel-bin/external/llvm_openmp/</linkPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ public final class Ops {

public final SignalOps signal;

public final QuantizationOps quantization;

public final TrainOps train;

public final QuantizationOps quantization;

private final Scope scope;

private Ops(Scope scope) {
Expand All @@ -402,8 +402,8 @@ private Ops(Scope scope) {
math = new MathOps(this);
audio = new AudioOps(this);
signal = new SignalOps(this);
quantization = new QuantizationOps(this);
train = new TrainOps(this);
quantization = new QuantizationOps(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE

package org.tensorflow.internal.c_api;

import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.tensorflow.internal.c_api.global.tensorflow.*;


// This is the default log sink. This log sink is used if there are no other
// log sinks registered. To disable the default log sink, set the
// "no_default_logger" Bazel config setting to true or define a
// NO_DEFAULT_LOGGER preprocessor symbol. This log sink will always log to
// stderr.
@Namespace("tensorflow") @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
public class TFDefaultLogSink extends TFLogSink {
static { Loader.load(); }
/** Default native constructor. */
public TFDefaultLogSink() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public TFDefaultLogSink(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TFDefaultLogSink(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public TFDefaultLogSink position(long position) {
return (TFDefaultLogSink)super.position(position);
}
@Override public TFDefaultLogSink getPointer(long i) {
return new TFDefaultLogSink(this).position(position + i);
}

public native void Send(@Const @ByRef TFLogEntry entry);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE

package org.tensorflow.internal.c_api;

import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.tensorflow.internal.c_api.global.tensorflow.*;
// namespace internal

// LogSink support adapted from //base/logging.h
//
// `LogSink` is an interface which can be extended to intercept and process
// all log messages. LogSink implementations must be thread-safe. A single
// instance will be called from whichever thread is performing a logging
// operation.
@Namespace("tensorflow") @NoOffset @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
public class TFLogEntry extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TFLogEntry(Pointer p) { super(p); }


public native @Cast("absl::LogSeverity") int log_severity();
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer FName();
public native int Line();
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer ToString();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE

package org.tensorflow.internal.c_api;

import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.tensorflow.internal.c_api.global.tensorflow.*;


@Namespace("tensorflow") @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
public class TFLogSink extends Pointer {
static { Loader.load(); }
/** Default native constructor. */
public TFLogSink() { super((Pointer)null); allocate(); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public TFLogSink(long size) { super((Pointer)null); allocateArray(size); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TFLogSink(Pointer p) { super(p); }
private native void allocate();
private native void allocateArray(long size);
@Override public TFLogSink position(long position) {
return (TFLogSink)super.position(position);
}
@Override public TFLogSink getPointer(long i) {
return new TFLogSink(this).position(position + i);
}


// `Send` is called synchronously during the log statement. The logging
// module guarantees not to call `Send` concurrently on the same log sink.
// Implementations should be careful not to call`LOG` or `CHECK` or take
// any locks that might be held by the `LOG` caller, to avoid deadlock.
//
// `e` is guaranteed to remain valid until the subsequent call to
// `WaitTillSent` completes, so implementations may store a pointer to or
// copy of `e` (e.g. in a thread local variable) for use in `WaitTillSent`.
@Virtual(true) public native void Send(@Const @ByRef TFLogEntry entry);

// `WaitTillSent` blocks the calling thread (the thread that generated a log
// message) until the sink has finished processing the log message.
// `WaitTillSent` is called once per log message, following the call to
// `Send`. This may be useful when log messages are buffered or processed
// asynchronously by an expensive log sink.
// The default implementation returns immediately. Like `Send`,
// implementations should be careful not to call `LOG` or `CHECK or take any
// locks that might be held by the `LOG` caller, to avoid deadlock.
@Virtual public native void WaitTillSent();
}
Loading