mirror of
https://github.com/zebrajr/tensorflow.git
synced 2026-01-15 12:15:41 +00:00
Adding a feed for boolean tensors to TensorFlowInferenceInterface (#14059)
* Sublime Text index-ignore file (a copy of .gitignore) * Adding the requested implementation to TensorFlowInferenceInterface * Removing Sublime Text .ignore file from remote repository * indeed there was
This commit is contained in:
@@ -282,6 +282,22 @@ public class TensorFlowInferenceInterface {
|
||||
|
||||
// Methods for taking a native Tensor and filling it with values from Java arrays.
|
||||
|
||||
/**
|
||||
* Given a source array with shape {@link dims} and content {@link src}, copy the contents into
|
||||
* the input Tensor with name {@link inputName}. The source array {@link src} must have at least
|
||||
* as many elements as that of the destination Tensor. If {@link src} has more elements than the
|
||||
* destination has capacity, the copy is truncated.
|
||||
*/
|
||||
public void feed(String inputName, boolean[] src, long... dims) {
|
||||
byte[] b = new byte[src.length];
|
||||
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
b[i] = src[i] ? (byte) 1 : (byte) 0;
|
||||
}
|
||||
|
||||
addFeed(inputName, Tensor.create(Boolean.class, dims, ByteBuffer.wrap(b)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a source array with shape {@link dims} and content {@link src}, copy the contents into
|
||||
* the input Tensor with name {@link inputName}. The source array {@link src} must have at least
|
||||
|
||||
Reference in New Issue
Block a user