Skip to content

Commit

Permalink
Start of log sink mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Nett <[email protected]>
  • Loading branch information
rnett committed Jun 27, 2021
1 parent 97298ca commit fbe696a
Show file tree
Hide file tree
Showing 6 changed files with 626 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tensorflow-core/tensorflow-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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
@@ -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,43 @@
// 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 TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer message) { super((Pointer)null); allocate(severity, message); }
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer message);
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) String message) { super((Pointer)null); allocate(severity, message); }
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) String message);

public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer fname, int line,
@StdString @Cast({"char*", "std::string&&"}) BytePointer message) { super((Pointer)null); allocate(severity, fname, line, message); }
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer fname, int line,
@StdString @Cast({"char*", "std::string&&"}) BytePointer message);
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) String fname, int line,
@StdString @Cast({"char*", "std::string&&"}) String message) { super((Pointer)null); allocate(severity, fname, line, message); }
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) String fname, int line,
@StdString @Cast({"char*", "std::string&&"}) String message);

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();
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer text_message();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public TFLogSink(Pointer p) { super(p); }


// `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`.
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.
public native void WaitTillSent();
}
Loading

0 comments on commit fbe696a

Please sign in to comment.