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:
loki der quaeler
2017-10-31 23:40:37 -07:00
committed by gunan
parent fa9d8aab41
commit 16b0bb0952

View File

@@ -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