profile
viewpoint

tensorflow/java 68

Java bindings for TensorFlow

tensorflow/java-models 11

Models in Java

karllessard/tensorflow-models 5

Models and examples built with TensorFlow

karllessard/tensorflow-java-sandbox 2

Experimenting on TensorFlow Java client modularization

karllessard/community 0

Stores documents used by the TensorFlow developer community

karllessard/mind-model-services 0

Java utils for loading and inferring various pre-trained TensorFlow models

karllessard/Pillow 0

The friendly PIL fork (Python Imaging Library)

karllessard/tensorflow 0

Computation using data flow graphs for scalable machine learning

karllessard/tensorflow-java 0

Java bindings for TensorFlow

Pull request review commenttensorflow/java

Recycle objects when iterating an element sequence

+/*+ *  Copyright 2019 The TensorFlow Authors. All Rights Reserved.+ *+ *  Licensed under the Apache License, Version 2.0 (the "License");+ *  you may not use this file except in compliance with the License.+ *  You may obtain a copy of the License at+ *+ *      http://www.apache.org/licenses/LICENSE-2.0+ *+ *  Unless required by applicable law or agreed to in writing, software+ *  distributed under the License is distributed on an "AS IS" BASIS,+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ *  See the License for the specific language governing permissions and+ *  limitations under the License.+ *  =======================================================================+ */++package org.tensorflow.tools.ndarray.impl.sequence;++import java.util.NoSuchElementException;++import org.tensorflow.tools.ndarray.impl.dimension.DimensionalSpace;

Yup, thanks!

karllessard

comment created time in 3 hours

Pull request review commenttensorflow/java

Recycle objects when iterating an element sequence

 default DoubleDataBuffer narrow(long size) {    @Override   DoubleDataBuffer slice(long index, long size);++  @Override+  default DataBufferWindow<DoubleDataBuffer> window(long size) {+    return null;

here

I just implemented windows for raw buffers at the moment. At some point, they should have a window implementation but it is not mandatory.

Unfortunately in Java, when you override the signature of a method in a super interface, you don’t inherit anymore of its default implementation, so I had to return null explicitly in all subinterfaces.

karllessard

comment created time in 3 hours

push eventtensorflow/java

Christoph Henkelmann

commit sha 3062c14be0713be554015e257e30e7547abf711c

Suggestions for minor improvements to Shape.java (#64) * Suggestions for improvements to Shape.java: - some utility methods - negative indexing for size() - more javadoc * Fixed javadoc formatting to conform to the Google styleguide, fixed other inconsistencies in the javadoc, changed `toArray` method: - Fixed plural of axis (axes not axis) - Changed writing of 'Shape' to be consistently upper case - Fixed block formatting - Removed redundant @return-blocks - Changed semantics of toArray: now a defensive copy is returned * Fixed typo in "equal".

view details

push time in 3 days

PR merged tensorflow/java

Suggestions for minor improvements to Shape.java
  • Added some utility methods to query the shape for its properties.
  • Allowed negative indexing for Shape.size(), that way it is easier and better readable to get the size of the last dimension or second-to-last dimension etc.
  • Add missing javadoc and new javadoc for the new methods.
  • Added unit tests for the new methods.

I hope this doesn't make the API too bloated, I just wished Shape classes had these methods in other frameworks I have used, maybe they are useful for other users as well.

+249 -19

3 comments

2 changed files

chenkelmann

pr closed time in 3 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

 public Shape prepend(long firstDimension) {     return Shape.of(newDimensions);   } +  /** Returns a new shape, with a new last dimension added. In order for this call to succeed,+   * {@link Shape#isUnknown()} must be {@code false}.+   * @param lastDimension the dimension to append+   * @return a new shape with this shape's dimensions followed by the given dimension+   */+  public Shape append(long lastDimension) {+    long[] newDimensions = new long[dimensionSizes.length + 1];+    newDimensions[newDimensions.length - 1] = lastDimension;+    System.arraycopy(dimensionSizes, 0, newDimensions, 0, dimensionSizes.length);++    return Shape.of(newDimensions);+  }++  /** Returns a new shape, with another shapes' dimensions prepended.

shape's? same thing for append(Shape)

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

 public int hashCode() {     return dimensionSizes != null ? Arrays.hashCode(dimensionSizes) : super.hashCode();   } +  /**+   * Equals implementation for shapes. Two shapes are considered equal iff:+   * <p><ul>+   * <li>the number of dimensions is defined and equal for both+   * <li>the size of each dimension is defined and eqaul for both

typo in eqaul

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

 public int hashCode() {     return dimensionSizes != null ? Arrays.hashCode(dimensionSizes) : super.hashCode();   } +  /**+   * Equals implementation for shapes. Two shapes are considered equal iff:+   * <p><ul>+   * <li>the number of dimensions is defined and equal for both+   * <li>the size of each dimension is defined and eqaul for both+   * </ul><p>+   * If either shape has an unknown dimension (even if it is the same in both) or if either+   * shape has an unknown number of dimensions (even if both return {@code true} for+   * {@link Shape#isUnknown()}), they are not considered equal. However, a shape will always+   * equal itself, event it is unknown or contains unknown dimensions.

event it is... you meant even if it is?

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

 public boolean hasUnknownDimension() {     return false;   } +  /**+   * Returns whether this shape represents a scalar.+   * @return whether this shape represents a scalar.+   */+  public boolean isScalar() {+    return dimensionSizes != null && dimensionSizes.length == 0;+  }++  /**+   * Returns whether this shape is the shape of a vector.+   * @return whether this shape is the shape of a vector.+   */+  public boolean isVector() {+    return dimensionSizes != null && dimensionSizes.length == 1;+  }++  /**+   * Returns whether this shape is the shape of a matrix+   * @return whether this shape is the shape of a matrix+   */+  public boolean isMatrix() {+    return dimensionSizes != null && dimensionSizes.length == 2;+  }++  /**+   * Returns whether the number of dimensions of this shape is unknown.+   * @return whether the number of dimensions of this shape is unknown.+   */+  public boolean isUnknown() {+    return dimensionSizes == null;+  }+   public long[] asArray() {

maybe add doc to this one as well? :)

Might be worth mentioning that changing the values in the returned array will affect the actual shape (or even better, change the code to return a copy of the array, it might be less performant but it is safer).

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

  import java.util.Arrays; +/**+ * The shape of a Tensor or {@link org.tensorflow.tools.ndarray.NdArray}. Defines the size along+ * its axis. May contain an unknown size for one of the axis or may be totally unknown, in which+ * case not even the number of axis is known.+ */

Funny, I never realized that Shape was missing that much documentation... thanks!

Can you please reformat it to follow Google Java Style guide? "Defines the.." should start on a separate line, preceded by a blank line plus a <p> tag, like here. This should be applied to all other javadoc blocks as well.

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

 public static Shape of(long... dimensionSizes) {     return new Shape(dimensionSizes);   } +  /**+   * Returns the total number of elements a Tensor with this shape would have. If this+   * {@link Shape#isUnknown()} is true or {@link Shape#hasUnknownDimension()}  is true,+   * {@link Shape#UNKNOWN_SIZE} is returned.+   *+   * @return the total number of elements a Tensor with this shape would have if it can be+   * calculated, else {@link Shape#UNKNOWN_SIZE}.+   */   public long size() {     if (size == null) {       size = computeSize(dimensionSizes);     }     return size;   } +  /**+   * The size of the dimension with the given index. If {@link Shape#isUnknown()} is true or+   * the size of the dimension with the given index has an unknown size, {@link Shape#UNKNOWN_SIZE}+   * is returned.+   * @param i the index of the dimension to get the size for. If this Shape has a known number of+   *          dimensions, it must be < {@link Shape#numDimensions()}. The index may be negative,+   *          in which case the position is counted from the end of the shape. E.g.+   *          {@code size(-1) returns the size of the last dimension, size(-2) the size of the+   *          second to last dimension etc.}+   * @return The size of the dimension with the given index if known, {@link Shape#UNKNOWN_SIZE}+   *         otherwise.+   */   public long size(int i) {-    return dimensionSizes != null ? dimensionSizes[i] : UNKNOWN_SIZE;+    if (dimensionSizes == null) {+      return UNKNOWN_SIZE;+    } else if (i >= 0) {+      return dimensionSizes[i];+    } else {+      return dimensionSizes[dimensionSizes.length + i];+    }   } +  /**+   * Returns the number of dimensions of this shape. -1 if unknown, 0 for a scalar, 1 for a vector,+   * 2 for a matrix etc.+   * @return the number of dimensions of this shape. -1 if unknown, 0 for a scalar, 1 for a vector,

again according to the guide, you should omit the @return tag. Same for other block below.

chenkelmann

comment created time in 4 days

Pull request review commenttensorflow/java

Suggestions for minor improvements to Shape.java

  import java.util.Arrays; +/**+ * The shape of a Tensor or {@link org.tensorflow.tools.ndarray.NdArray}. Defines the size along+ * its axis. May contain an unknown size for one of the axis or may be totally unknown, in which+ * case not even the number of axis is known.+ */ public final class Shape { +  /**+   * Size reported for shapes for which the total size cannot be computed, either because their+   * number of dimensions is unknown or one or more of their dimensions have an unknown size.+   */   public static long UNKNOWN_SIZE = -1L; -  /** Create a Shape representing an unknown number of dimensions. */+  /** Create a Shape representing an unknown number of dimensions.+   * @return a Shape for which {@link Shape#isUnknown()} is true.+   */

Here, the guide suggest to enter a newline after /** (same thing, should be applied to all javadoc blocks added)

chenkelmann

comment created time in 4 days

issue commenttensorflow/java

Current default build is MKL

Hi @zhangruiskyline , please take a look at the README page of this repository, it explains how to fetch these artifacts (only available as snapshots for now): https://github.com/tensorflow/java

Craigacp

comment created time in 5 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 442d65d546db4704422e6f98c7b9c4172fecabef

Recycle objects when iterating an element sequence

view details

push time in 5 days

PR opened tensorflow/java

Recycle objects when iterating an element sequence

The main addition of this PR is the creation on a DataBufferWindow interface, that allows a user to view partially the content of a given buffer and to move (or "slide") it across the memory segment so that the same window instance can reused to present different chunk of data.

This is particularly useful when visiting all values (or elements of a given dimension) of a NdArray in a given sequence (e.g. ndArray.elements(0) or ndArray.scalars()) and performance gains are substantial for large tensors (in the order of 80% faster).

+650 -76

0 comment

33 changed files

pr created time in 5 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 97b96c0cacadff86e5bf65fcf2357cd11a66480e

Recycle objects when iterating an element sequence

view details

push time in 5 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 3f016598de3f5ee94c81a45f29ed6fe0b9cd9932

Recycle objects when iterating an element sequence

view details

push time in 5 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha f0d26485cc859133c0aa8fea23ec1e6de0504328

Recycle objects when iterating an element sequence

view details

push time in 5 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 26f4fe46ec41cf7303a6c4063d213d8933abc0c8

Recycle objects when iterating an element sequence

view details

push time in 6 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 379bd6b31aa880b545f30fa3103f16d7b19a383d

Recycle objects when iterating an element sequence

view details

push time in 6 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha ef0b4f26254cbbfd29b39e184962706c2d348e59

Do not visit underlying buffer when layout is applied

view details

Karl Lessard

commit sha 5e75e68478886ec5c7da648f3b184c287266a565

Recycle objects when iterating an element sequence

view details

push time in 6 days

delete branch karllessard/tensorflow-java

delete branch : fix-float16

delete time in 6 days

push eventtensorflow/java

Karl Lessard

commit sha ef0b4f26254cbbfd29b39e184962706c2d348e59

Do not visit underlying buffer when layout is applied

view details

push time in 6 days

PR merged tensorflow/java

Do not visit underlying buffer when layout is applied

This is a fix for #61

The problem was that we should not visit directly a buffer that has a specific layout. Visiting buffers is used to apply bulk operations between two buffers, like copies or equality checks, but when there is a layout, those are not possible (unless both buffers uses the same layout, which could eventually be supported...)

In the specific case of #61 , we ended up trying to copy all bytes of the source array (32-bits values) to the target (16-bits values), hence why the first value (0) was overflowing on the second one.

+0 -6

0 comment

1 changed file

karllessard

pr closed time in 6 days

issue closedtensorflow/java

Tensors created using TFloat16.tensorOf does not have correct output

<em>Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em>

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 2.2.0
  • Python version:3.6
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

You can collect some of this information using our environment capture script You can also obtain the TensorFlow version with python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the current behavior Tensor created using TFloat16.tensorOf does not have correct value. In example below float has value [0, 1] but TFloat16 generate values [0,0] whereas TFloat32 gives correct value [0, 1] Describe the expected behavior

Code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem. public class Test {

public static void main(String[] args) {
	float[][] f1 = {{0}, {1}};
	

    System.out.println(StdArrays.ndCopyOf(f1).getFloat(0,0));
    System.out.println(StdArrays.ndCopyOf(f1).getFloat(1,0));
    
	System.out.println("FLOAT16");
    Tensor<TFloat16> tf_float1 = TFloat16.tensorOf(StdArrays.ndCopyOf(f1));
    System.out.println(tf_float1.data().getFloat(0,0));
    System.out.println(tf_float1.data().getFloat(1,0));
    
    System.out.println("FLOAT32");
    Tensor<TFloat32> tf_float2 = TFloat32.tensorOf(StdArrays.ndCopyOf(f1));
    System.out.println(tf_float2.data().getFloat(0,0));
    System.out.println(tf_float2.data().getFloat(1,0));
}

}

OUTPUT 0.0 1.0 FLOAT16 Warning: Could not load Loader: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path Warning: Could not load Pointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path Warning: Could not load BytePointer: java.lang.UnsatisfiedLinkError: no jnijavacpp in java.library.path 0.0 0.0 FLOAT32 0.0 1.0 Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

closed time in 6 days

vissood

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

@17patelumang are you running your code snippet in IntelliJ? There is a known issue where it cannot resolve properly the transitive dependencies of tensorflow-core-platform, it seems that you have hit that bug.

If so, can you please retry to run your test outside of it (maybe my using the java -jar command line) or try this simple configuration tweak I’ve been using as a workaround?

17patelumang

comment created time in 7 days

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

@17patelumang can you please provide the full trace of that last issue?

17patelumang

comment created time in 7 days

issue commenttensorflow/java-models

Add missed dependency "org.tensorflow.tools"

you should need to add these, that's the point, and yes it worked using Maven exclusively in my case, please remove these two dependencies and give a try to mvn clean install to see if that works for you as well.

zaleslaw

comment created time in 7 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 4be0b4768f727c4361a60cf408fedc5497604cc5

Recycle objects when iterating an element sequence

view details

push time in 8 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 7f6d79e01540c54de3e5a4f98d8141fb2f549775

Increase to TF v2.2.0

view details

Karl Lessard

commit sha c86293e2a7b53e3afe3d96d571a998e2bc6ea9d1

TF 2.2.0 with non-monolithic build

view details

Karl Lessard

commit sha 596921f0b2bc8ee01eb47e51e02d3c3dce513b53

Import XLA ops and annotate data ops

view details

Karl Lessard

commit sha 921488efa00b6ce99da388986679e4f22d0637ee

Reenable custom op test

view details

Karl Lessard

commit sha f6a3c90fe911460ce1eda2f04aa45d3df0e0062a

Update .bazelrc with TF2.2.0 version

view details

Karl Lessard

commit sha ee45632acb5895802e787f1ed7a326d2e1465cf2

Fix MKL builds

view details

Karl Lessard

commit sha 4300f2335b09433193fd52c557d0a92e9be0be1f

Use TF env for loading libs dynamically

view details

Karl Lessard

commit sha eccf54b8236f6e2c02a770fc9dd0d94ff071ae42

Fix windows build

view details

Karl Lessard

commit sha eeb67786b2d142bedc6975a0ad092218cac2ded4

Remove unnecessary timeout value

view details

Dhruv Rajan

commit sha 9c86cbbd81987364e9b924aa26efbe60aa18449b

Add functionality to map over dataset elements in both graph and eager mode.

view details

Dhruv Rajan

commit sha c92e0b96bdb7bc73776dda3db3aacd791017943a

fix copyright comments

view details

Dhruv Rajan

commit sha 30d830087227803e2cdf5b9edf235cc1eade180d

use captured Ops object for dataset map

view details

Dhruv Rajan

commit sha 70d9fdb0922c5aeff354e20a34a842ea85bcaa49

refactor method and constructor access

view details

Dhruv Rajan

commit sha b6049c5005f8ef3d2632da1bb29449c8ead5e9f8

move map methods to Dataset class

view details

Karl Lessard

commit sha b41f4fa0cccb14889f2ac5613636210ecc4779d8

Add buffer sliding windows

view details

push time in 8 days

create barnchkarllessard/tensorflow-java

branch : tools-performance-tuning

created branch time in 8 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 49b7bac612adce3773bdc1dff27f36542a91e21d

Remove obsolete comments about missing protos

view details

Samuel Audet

commit sha d947c9aeb469a32ea7b585a666f06d05721aba92

Replace EagerSession.NativeReference with JavaCPP Pointer Also upgrade JavaCPP to 1.5.3 and TensorFlow to 2.2.0-rc3

view details

Samuel Audet

commit sha f38b1b680d8bd96409bea3dd4873a254a7875966

Fix nits

view details

Samuel Audet

commit sha 9c7833db381e3b2e54988e94d63fe0be5227dd11

Remove incorrectly generated op file

view details

Samuel Audet

commit sha a3f5b7a9431196790e608c1fc78bce3965a2ac87

Remove no longer useful ResourceCleanupStrategy

view details

Samuel Audet

commit sha 695c3e8f394f5259a4807664291df4b4faa79cb0

Use PointerScope everywhere

view details

Karl Lessard

commit sha 467fb7a20e74dbf5e57c34ec673138dce7c97bfe

Skip MKL-specific op and update protos (#1)

view details

Samuel Audet

commit sha 78f84c08bff9126f90cf6e123283f80450513d75

Get rid of temporary output PointerScope objects

view details

Lai Wei

commit sha 18cf9f9eddfdd34db0e5f0777ddfb47ab5f967a4

increase max num of outputs

view details

Dhruv Rajan

commit sha 0f0ff7d10fafe2c42ea4768ec13ab5a169da1ce5

TF Data API for Java (#30)

view details

Karl Lessard

commit sha a9d3b1783b847ca8138dda0880f3a447347ef95c

Add version mapping

view details

Karl Lessard

commit sha 69da4826d554b7072b1ea182cd4c914992d463c0

Add buffer sliding windows

view details

push time in 8 days

issue closedtensorflow/java

TFlite support for tensorflow java

Does Tensorflow Java API support .tflite file format? I am not able to find any documentation, so any leads in this direction will be helpful

closed time in 11 days

vissood

issue commenttensorflow/java

Tensors created using TFloat16.tensorOf does not have correct output

Thanks @vissood ,

It was effectively a bug, I created a PR for this (#62), you can try to make the same small change on your side and see if it works. If it does, then I'll merge it.

vissood

comment created time in 11 days

PR opened tensorflow/java

Do not visit underlying buffer when layout is applied

This is a fix for #61

The problem was that we should not visit directly a buffer that has a specific layout. Visiting buffers is used to apply bulk operations between two buffers, like copies or equality checks, but when there is a layout, those are not possible (unless both buffers uses the same layout, which could eventually be supported...)

In the specific case of #61 , we ended up trying to copy all bytes of the source array (32-bits values) to the target (16-bits values), hence why the first value (0) was overflowing on the second one.

+0 -6

0 comment

1 changed file

pr created time in 11 days

create barnchkarllessard/tensorflow-java

branch : fix-float16

created branch time in 11 days

PR closed tensorflow/java-models

Added the missed dependency cla: yes

I suggest the simple fixe for the issue

+5 -0

9 comments

1 changed file

zaleslaw

pr closed time in 12 days

pull request commenttensorflow/java-models

Added the missed dependency

See #4 , it seems to be a bug related to IDEA. Closing this PR for now.

zaleslaw

comment created time in 12 days

issue commenttensorflow/java-models

Add missed dependency "org.tensorflow.tools"

@zaleslaw , I was able to reproduce that error on my IntelliJ as well (it seems to be a IDEA bug). I have a module A that depends on another module B depending on tensorflow-core-platform. Module A then inherit from the following dependencies:

ModuleA -> ModuleB -> (tensorflow-core-platform) -> (tensorflow-core-api)

It should have retrieve transitive dependencies from tensorflow-core-api though. I found that old and long thread on IntelliJ forum where someone suggested to enable the following parameter in my workspace:

image

I did not went through the whole thread nor tried to understand much what I was doing but it worked out in my case, with this parameter set, I now retrieve dependencies from tensorflow-core-api transitively, which includes tensorflow-tools, protobuf, etc.

Let me know if that fixes your issue as well. We might want to try to understand better what is going on with IDEA too...

zaleslaw

comment created time in 12 days

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

@karllessard sure please let me know when to try.

You can do it now

17patelumang

comment created time in 13 days

push eventtensorflow/java-models

Alexey Zinoviev

commit sha c30c55062014f89d6248c09ee0c4b2c8fb731f75

Added the TensorCreation.java example (#7)

view details

push time in 13 days

push eventtensorflow/java

Dhruv Rajan

commit sha 9c86cbbd81987364e9b924aa26efbe60aa18449b

Add functionality to map over dataset elements in both graph and eager mode.

view details

Dhruv Rajan

commit sha c92e0b96bdb7bc73776dda3db3aacd791017943a

fix copyright comments

view details

Dhruv Rajan

commit sha 30d830087227803e2cdf5b9edf235cc1eade180d

use captured Ops object for dataset map

view details

Dhruv Rajan

commit sha 70d9fdb0922c5aeff354e20a34a842ea85bcaa49

refactor method and constructor access

view details

Dhruv Rajan

commit sha b6049c5005f8ef3d2632da1bb29449c8ead5e9f8

move map methods to Dataset class

view details

push time in 14 days

PR merged tensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

While we can't use the MapDataset op very easily in Java, using the DatasetIterator abstraction, we can map over dataset elements using a lambda.

In Graph mode, we apply the lambda once to add new operands to the graph as the targets for each session.run(). In Eager mode, the function is applied to each returned dataset element during iteration.

Each Dataset element is represented as a list of components: List<Operand<?>>.

In this PR, I added 3 utility functions to map over such elements:

  • DatasetIterator.map(Bifunction<Ops, List<Operand<?>>, List<Operand<?>> mapper) to map an element-level transform to each returned element.

  • DatasetIterator.mapOneComponent(int index, BiFunction<Ops, Operand<?>, Operand<?>> mapper) to map a component-level transform to a single component of each returned element.

  • DatasetIterator.mapAllComponents(BiFunction<Ops, Operand<?>, Operand<?>>) to map a single component-level transform to all components of each returned element.

This PR also adds wrappers and static creation methods for using the TFRecordDataset and TextLineDataset ops.

+670 -90

4 comments

19 changed files

dhruvrajan

pr closed time in 14 days

issue commenttensorflow/java

Graph importGraphDef doesn't match documentation

We don't support (yet) loading hdf5 models directly to TF Java. I've already used this script in the past to convert the .h5 model to .pb and it worked pretty well.

Also, you can forget my previous comment about the GraphDef format being legacy, it looks like this format is still being used when exporting a saved model.

Ben-Epstein

comment created time in 14 days

issue commenttensorflow/java

Graph importGraphDef doesn't match documentation

Mmh, if you are receiving a stream of bytes, then I guess your model was saved as a GraphDef. What do you mean exactly by ByteStream, a simple Java InputStream?

If so, then you can probably do something like:

try (Graph g = new Graph()) {
    g.importGraphDef(GraphDef.parseFrom(inputStream));
    ...
}
Ben-Epstein

comment created time in 14 days

issue commenttensorflow/java

Graph importGraphDef doesn't match documentation

@Ben-Epstein , I can probably find an example for this, yes, but before doing it, is there any reason why you can't use a SavedModelBundle instead?

While still being supported, GraphDef protobuf is the "legacy" format for saving TF models and have been replaced by the saved model format. You can load a saved model just by providing the path of the saved model directory:

try (SavedModelBundle bundle : SavedModelBundle.load("path/to/saved/model", "serve")) {
    Graph graph = bundle.graph();
    ... 
}
Ben-Epstein

comment created time in 14 days

Pull request review commenttensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

+package org.tensorflow.framework.data.impl;

missing copyrights

dhruvrajan

comment created time in 14 days

Pull request review commenttensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

 public final Dataset take(long count) {         tf, this.getVariant(), tf.constant(count), this.getOutputTypes(), this.getOutputShapes());
   }
 
+  /**
+   * Returns a new Dataset which maps a function across all elements from this iterator, on a single
+   * component of each element.
+   *
+   * <p>For example, suppose each element is a `List<Operand<?>>` with 2 components: (features,
+   * labels).
+   *
+   * <p>Calling `iterator.mapOneComponent(0, features -> tf.math.mul(features, tf.constant(2)))`
+   * will map the function over the `features` component of each element, multiplying each by 2.
+   *
+   * @param index The index of the component to transform.
+   * @param mapper The function to apply to the target component.
+   * @return A new DatasetIterator applying `mapper` to the component at the chosen index.
+   */
+  public Dataset mapOneComponent(int index, Function<Operand<?>, Operand<?>> mapper) {
+    return map(
+        outputs -> {
+          List<Operand<?>> newComponents = new ArrayList<>(outputs);
+          newComponents.set(index, mapper.apply(outputs.get(index)));
+          return newComponents;
+        });
+  }
+
+  /**
+   * Returns a new Dataset which maps a function across all elements from this iterator, on all
+   * components of each element.
+   *
+   * <p>For example, suppose each element is a `List<Operand<?>>` with 2 components: (features,
+   * labels).
+   *
+   * <p>Calling `iterator.mapAllComponents(component -> tf.math.mul(component, tf.constant(2)))`
+   * will map the function over the both the `features` and `labels` components of each element,
+   * multiplying them all by 2
+   *
+   * @param mapper The function to apply to each component
+   * @return A new DatasetIterator applying `mapper` to all components of each element.
+   */
+  public Dataset mapAllComponents(Function<Operand<?>, Operand<?>> mapper) {
+    return map(
+        outputs -> {
+          List<Operand<?>> mappedOutputs = new ArrayList<>();
+          outputs.forEach(o -> mappedOutputs.add(mapper.apply(o)));
+          return mappedOutputs;
+        });
+  }
+
+  /**
+   * Returns a new Dataset which maps a function over all elements returned by this iterator.
+   *
+   * <p>For example, suppose each element is a `List<Operand<?>>` with 2 components: (features,
+   * labels).
+   *
+   * <p>Calling ``` iterator.map(components -> { Operand<?> features = components.get(0); Operand<?>
+   * labels = components.get(1);
+   *
+   * <p>return Arrays.asList( tf.math.mul(features, tf.constant(2)), tf.math.mul(labels,
+   * tf.constant(5)) ); }) ``` will map the function over the `features` and `labels` components,

again instead of triple backquotes ``` (which should help with Javadoc, did it?, you should go with a block like this:

<pre>{@code
your 
multiline 
code
here
}</pre>
dhruvrajan

comment created time in 14 days

Pull request review commenttensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

 public final Dataset take(long count) {         tf, this.getVariant(), tf.constant(count), this.getOutputTypes(), this.getOutputShapes());
   }
 
+  /**
+   * Returns a new Dataset which maps a function across all elements from this iterator, on a single
+   * component of each element.
+   *
+   * <p>For example, suppose each element is a `List<Operand<?>>` with 2 components: (features,
+   * labels).
+   *
+   * <p>Calling `iterator.mapOneComponent(0, features -> tf.math.mul(features, tf.constant(2)))`

update to dataset.mapOneComponent (idem for other methods below).

By the way in Java, you want to use {@code ...} for code snippets in your Javadoc instead of backquotes.

dhruvrajan

comment created time in 14 days

Pull request review commenttensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

 public final Dataset take(long count) {         tf, this.getVariant(), tf.constant(count), this.getOutputTypes(), this.getOutputShapes());
   }
 
+  /**
+   * Returns a new Dataset which maps a function across all elements from this iterator, on a single
+   * component of each element.
+   *
+   * <p>For example, suppose each element is a `List<Operand<?>>` with 2 components: (features,
+   * labels).
+   *
+   * <p>Calling `iterator.mapOneComponent(0, features -> tf.math.mul(features, tf.constant(2)))`
+   * will map the function over the `features` component of each element, multiplying each by 2.
+   *
+   * @param index The index of the component to transform.
+   * @param mapper The function to apply to the target component.
+   * @return A new DatasetIterator applying `mapper` to the component at the chosen index.

Update the return type to Dataset instead of DatasetIterator (same for other methods below)

dhruvrajan

comment created time in 14 days

issue commenttensorflow/java

Graph importGraphDef doesn't match documentation

The legacy version of TF Java (as pointed by your documentation) does not include the protobuf classes automatically and you need to depend on org.tensorflow:proto to access and serialize them.

The new version is more convenient as the proto classes (like GraphDef) are already provided, thus you should use it directly and not go through this unnecessary serialization.

In other words, the new method accepting GraphDef as a parameter is safer than the old one accepting the serialized version of this proto class as a raw byte array.

Ben-Epstein

comment created time in 14 days

issue commenttensorflow/java

TFlite support for tensorflow java

Does Tensorflow Java API support .tflite file format?

AFAIK, it does not and I don't know what would be the amount of work to support it.

Ideally, you would still have access to the original .pb model that was used to generate the TF Lite version and use that one instead, as there are no real gain running a .tflite model if your application has access to the complete set of TF ops, as provided by TF Java. But if you are planning to use TF Lite models distributed on the public hub, it is possible that the original .pb file is "lost", unless you reach and ask the author directly.

vissood

comment created time in 14 days

issue commenttensorflow/java

Maven coordinates not found

The section I've pointed you to is already under Using Maven Artifacts, as you suggested. Note that this extra-configuration is only required for the time being that the new generation of TF Java artifacts are only available as snapshots. After their first official release, it shouldn't be required anymore.

Ben-Epstein

comment created time in 14 days

PR closed tensorflow/java

Upgrade to TensorFlow 2.2.0

Also try to increase timeout to 8 hours for Windows builds on GitHub Actions

+5 -4

3 comments

3 changed files

saudet

pr closed time in 15 days

pull request commenttensorflow/java

Upgrade to TensorFlow 2.2.0

PR #44 has been merged, with TF2.2 upgrade.

saudet

comment created time in 15 days

issue commenttensorflow/java

Add abstractions for parsing TFRecord Files using `tf.Example` and `tf.io` ops

Thanks @dhruvrajan ,

Before we begin, can you please take a look at this old example of mine based on TF1.x where I use tf.io.parseExample? Here I was using raw ops so yes, having a higher-level API to wrap them up would be interesting for sure. But I just wanted to show you how I used to do it and to check if you ended up doing similar too at this stage.

dhruvrajan

comment created time in 15 days

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

Ok, so PR #44 was merged, which came with an upgrade to TF2.2 but also with changes that support back loading of custom ops libraries, like in TF1.x. @17patelumang , once the new artifacts are done being deployed, can you please give it another try?

BTW, I've tried loading the tensorflow-text custom op library like in your example and ended up with this error: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs, which seems to be a common issue with this library on TF > 2.0, check this thread for more details. But at least the initial issue (looking for libtensorflow_framework.so.2) is now resolved.

Also, note that custom ops libraries probably don't work on Windows since TF is still built as a monolithic binary on this platform, as configured by TensorFlow. There is also an interesting thread on this topic and it looks like they came up with a pythonic solution to fix it... We need to do more research to understand what should done to enable it in Java.

17patelumang

comment created time in 15 days

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

actually, the main-tensorflow-repo has changed to load version from resources/tensorflow-version-info, see NativeLibrary.class.getClassLoader().getResourceAsStream("tensorflow-version-info"

Thanks @ericxsun , can you please give it a try and/or make a PR for this?

17patelumang

comment created time in 15 days

IssuesEvent

issue commenttensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

(closed by mistake)

17patelumang

comment created time in 15 days

delete branch karllessard/tensorflow-java

delete branch : add-framework-lib

delete time in 15 days

push eventtensorflow/java

Karl Lessard

commit sha 7f6d79e01540c54de3e5a4f98d8141fb2f549775

Increase to TF v2.2.0

view details

Karl Lessard

commit sha c86293e2a7b53e3afe3d96d571a998e2bc6ea9d1

TF 2.2.0 with non-monolithic build

view details

Karl Lessard

commit sha 596921f0b2bc8ee01eb47e51e02d3c3dce513b53

Import XLA ops and annotate data ops

view details

Karl Lessard

commit sha 921488efa00b6ce99da388986679e4f22d0637ee

Reenable custom op test

view details

Karl Lessard

commit sha f6a3c90fe911460ce1eda2f04aa45d3df0e0062a

Update .bazelrc with TF2.2.0 version

view details

Karl Lessard

commit sha ee45632acb5895802e787f1ed7a326d2e1465cf2

Fix MKL builds

view details

Karl Lessard

commit sha 4300f2335b09433193fd52c557d0a92e9be0be1f

Use TF env for loading libs dynamically

view details

Karl Lessard

commit sha eccf54b8236f6e2c02a770fc9dd0d94ff071ae42

Fix windows build

view details

Karl Lessard

commit sha eeb67786b2d142bedc6975a0ad092218cac2ded4

Remove unnecessary timeout value

view details

push time in 15 days

PR merged tensorflow/java

Build/distribute framework library and upgrade to TF 2.2.0

This is to fix this issue when loading custom ops built on top of libtensorflow_framework

It builds the TF framework library and attach it to do the native artifacts we distribute. For example:

jar tvf target/tensorflow-core-api-0.1.0-SNAPSHOT-macosx-x86_64.jar 
    99 Tue Apr 28 00:32:46 EDT 2020 META-INF/MANIFEST.MF
     0 Tue Apr 28 00:32:46 EDT 2020 META-INF/
     0 Tue Apr 28 00:32:46 EDT 2020 org/
     0 Tue Apr 28 00:32:46 EDT 2020 org/tensorflow/
     0 Tue Apr 28 00:32:46 EDT 2020 org/tensorflow/internal/
     0 Tue Apr 28 00:32:46 EDT 2020 org/tensorflow/internal/c_api/
     0 Tue Apr 28 00:32:40 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/
     0 Tue Apr 28 00:32:46 EDT 2020 META-INF/maven/
     0 Tue Apr 28 00:32:46 EDT 2020 META-INF/maven/org.tensorflow/
     0 Tue Apr 28 00:32:46 EDT 2020 META-INF/maven/org.tensorflow/tensorflow-core-api/
 11419 Tue Apr 28 00:32:40 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/LICENSE
494616 Tue Apr 28 00:32:38 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/libjnitensorflow.dylib
27689440 Tue Apr 28 00:32:38 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/libtensorflow_framework.2.dylib
255688376 Tue Apr 28 00:32:40 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/libtensorflow.2.dylib
469957 Tue Apr 28 00:32:40 EDT 2020 org/tensorflow/internal/c_api/macosx-x86_64/THIRD_PARTY_TF_JNI_LICENSES
 14489 Wed Apr 22 23:50:18 EDT 2020 META-INF/maven/org.tensorflow/tensorflow-core-api/pom.xml
   108 Thu Apr 23 01:50:26 EDT 2020 META-INF/maven/org.tensorflow/tensorflow-core-api/pom.properties

Unfortunately, that increases each native artifact by 28M but I don't think there is any way to avoid that. Also, I've only build on OSx for now, @saudet can you please validate if the build.sh script is doing the right thing for other platforms as well, especially for Windows?

I'll try to load tensorflow-text extracted from TF2.x packages in the JVM after that.

+2721 -163

5 comments

74 changed files

karllessard

pr closed time in 15 days

issue closedtensorflow/java

TF 2.x Java Binding @rpath/libtensorflow_framework.1.dylib

OS Platform and Distribution : macOS Catalina 10.15.3

TensorFlow installed from : binary

TensorFlow version : 2.1.0

Python version: 3.7.3

Java - 1.8

So basically I am using TF 1.15.0 Java binding to do the inferencing from savedmodel where features are ported as part of savedmodel , the code below is working

import org.tensorflow.SavedModelBundle;
import org.tensorflow.Session;
import org.tensorflow.Tensor;
import org.tensorflow.TensorFlow;

public class TF1_b {

	public static void main(String[] args) {

		String testSen = "1";

		byte[] inputBytes = new byte[1];
		try {
			inputBytes = testSen.getBytes("UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println(TensorFlow.version());


		String basePath = "<path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/";
		System.load(basePath + "_wordpiece_tokenizer.dylib");


		try (SavedModelBundle b = SavedModelBundle.load("<saved_model_path>", "serve")) {


			Session sess = b.session();


			Tensor x = Tensor.create(inputBytes, String.class);

			float[][] y = sess.runner().feed("text:0", x)
							.fetch("linear/linear_model/linear_model/linear_model/weighted_sum:0").run().get(0)
							.copyTo(new float[1][1]);

			System.out.println(y[0][0]);



		} catch (Exception e) {
			System.out.println(e);

		}
	}

}

In pom.xml the dependency I am using for above is

<dependencies>
		<dependency>
			<groupId>org.tensorflow</groupId>
			<artifactId>tensorflow</artifactId>
			<version>1.15.0</version>
		</dependency>
	</dependencies>

The above code works perfect and i am able to load System.load(basePath + "_wordpiece_tokenizer.dylib"); with no problems .

Now when I try to run the same model with


<repositories>
    <repository>
        <id>tensorflow-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<dependencies>
    <!-- Example of dependency, see README.md for more options -->
    <dependency>
        <groupId>org.tensorflow</groupId>
        <artifactId>tensorflow-core-platform</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

as described https://stackoverflow.com/questions/61373396/tensorflow-2-x-java-bindings

with changes only for for two lines

Tensor x = TString.scalarOf(new String("1"));
Tensor<TFloat32> y = sess.runner().feed("text:0", x) .fetch("linear/linear_model/linear_model/linear_model/weighted_sum:0").run().get(0).expect(TFloat32.DTYPE);

I get error

Exception in thread "main" java.lang.UnsatisfiedLinkError: <path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/_wordpiece_tokenizer.dylib: dlopen(<path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/_wordpiece_tokenizer.dylib, 1): Library not loaded: @rpath/libtensorflow_framework.1.dylib
  Referenced from: <path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/_wordpiece_tokenizer.dylib
  Reason: image not found
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
	at java.lang.Runtime.load0(Runtime.java:809)
	at java.lang.System.load(System.java:1086)

The path <path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/_wordpiece_tokenizer.dylib: exists and so TF 1.15.x java inferencing is working fine for inferencing .

The java code for TF 2.x i am using is below


import org.tensorflow.SavedModelBundle;
import org.tensorflow.Session;
import org.tensorflow.Tensor;
import org.tensorflow.TensorFlow;
import org.tensorflow.tools.ndarray.NdArrays;
import org.tensorflow.types.TFloat32;
import org.tensorflow.types.TString;

public class TF_2 {



	public static void main(String[] args) {



		String testSen = "1";

		byte[] inputBytes = new byte[1];
		try {
			inputBytes = testSen.getBytes("UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println(TensorFlow.version());

		String basePath = "<path>/anaconda3/lib/python3.7/site-packages/tensorflow_text/python/ops/";

		System.load(basePath + "_wordpiece_tokenizer.dylib");



		try (SavedModelBundle b = SavedModelBundle.load("<saved_model_path>", "serve")) {


			Session sess = b.session();


			Tensor x = TString.scalarOf(new String("1"));

			Tensor<TFloat32> y = sess.runner().feed("text:0", x)
							.fetch("linear/linear_model/linear_model/linear_model/weighted_sum:0").run().get(0)
							.expect(TFloat32.DTYPE);


			System.out.println(y.data().toString());



		} catch (Exception e) {
			System.out.println(e);
		}
	}


}

closed time in 15 days

17patelumang

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

Ok, it's unfortunate but it looks like we cannot increase the timeout of a job on GitHub action on their hosted-runners beyond 6 hours, as dictated here. Setting the timeout-minutes parameter to a higher value didn't helped.

So this build (based on TF2.2) is the best we had got so far on this CI solution. So I'll go ahead with merging PR #44 and we will probably need to continue the discussion to find an alternative or a complement to it.

roywei

comment created time in 15 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 496ea5115329e518f58c2801051af38b0f229e5a

Remove unnecessary timeout value

view details

push time in 15 days

pull request commenttensorflow/java-models

Added the missed dependency

I just commented on this here, effectively the snapshot repository was missing in the pom, keep me posted if that fixes all your problems with missing dependencies.

zaleslaw

comment created time in 15 days

Pull request review commenttensorflow/java-models

Added the TensorCreation.java example

+package org.tensorflow.model.examples.tensors;++import org.tensorflow.Tensor;+import org.tensorflow.tools.Shape;+import org.tensorflow.tools.ndarray.IntNdArray;+import org.tensorflow.tools.ndarray.NdArrays;+import org.tensorflow.types.TInt32;++/**+ * Creates a few tensors of ranks: 0, 1, 2, 3.+ */+public class TensorCreation {+    public static void main(String[] args) {+        // Rank 0 Tensor+        Tensor<TInt32> rank0Tensor = TInt32.scalarOf(42);+        System.out.println("---- Scalar tensor ---------");+        System.out.println("DataType: " + rank0Tensor.dataType().name());+        System.out.println("Rank: " + rank0Tensor.data().rank());+        System.out.println("NumElements: " + rank0Tensor.data().size());++        // Rank 1 Tensor+        Tensor<TInt32> rank1Tensor = TInt32.vectorOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);+        System.out.println("---- Vector tensor ---------");+        System.out.println("DataType: " + rank1Tensor.dataType().name());+        System.out.println("Rank: " + rank1Tensor.data().rank());+        System.out.println("NumElements: " + rank1Tensor.data().size());++        // Rank 2 Tensor+        // 3x2 matrix of ints.+        IntNdArray matrix2d = NdArrays.ofInts(Shape.of(3, 2));++        matrix2d.set(NdArrays.vectorOf(1, 2), 0)+                .set(NdArrays.vectorOf(3, 4), 1)+                .set(NdArrays.vectorOf(5, 6), 2);++        Tensor<TInt32> rank2Tensor = TInt32.tensorOf(matrix2d);+

Nit: I suggest some consistency with the usage of the blank lines in your example, sometimes the System.out prints are preceded by one and sometimes they are not (sorry for being that picky :-/...)

zaleslaw

comment created time in 15 days

Pull request review commenttensorflow/java-models

Added the TensorCreation.java example

+package org.tensorflow.model.examples.tensors;++import org.tensorflow.Tensor;+import org.tensorflow.tools.Shape;+import org.tensorflow.tools.ndarray.IntNdArray;+import org.tensorflow.tools.ndarray.NdArrays;+import org.tensorflow.types.TInt32;++/**+ * Creates a few tensors of ranks: 0, 1, 2, 3.+ */+public class TensorCreation {+    public static void main(String[] args) {+        // Rank 0 Tensor+        Tensor<TInt32> rank0Tensor = TInt32.scalarOf(42);+        System.out.println("---- Scalar tensor ---------");+        System.out.println("DataType: " + rank0Tensor.dataType().name());+        System.out.println("Rank: " + rank0Tensor.data().rank());+        System.out.println("NumElements: " + rank0Tensor.data().size());

I think a user should access data() only when he's interested in doing some read/write operations to the tensor memory, as it might move the tensor from some remote location or from GPU memory to the local CPU for this purpose.

Therefore, if the user intent is only to display some metadata about the shape of the tensor, the tensor.shape() method is probably better. (rank0Tensor.shape().numDimensions() and rank0Tensor.shape().size() respectively in this case).

zaleslaw

comment created time in 15 days

Pull request review commenttensorflow/java-models

Added the TensorCreation.java example

+package org.tensorflow.model.examples.tensors;

Missing license/copyright... and that make me realize that it was also missing in most of the files in this repo, which I just updated now. You can take the same one as in this file.

zaleslaw

comment created time in 15 days

delete branch karllessard/tensorflow-java-models

delete branch : add-copyrights

delete time in 15 days

push eventtensorflow/java-models

klessard

commit sha a9990dfa1d55b947feffbdd4772609caf0d6e7ce

Add missing copyrights

view details

push time in 15 days

push eventkarllessard/tensorflow-java-models

klessard

commit sha d91770c726734942d8585511df170be31e423e6c

Add snapshot repo and adjust framework dependency

view details

klessard

commit sha 94747ffdd43ad2a2b23969e94a16618dc7442188

Add missing copyrights

view details

push time in 15 days

create barnchkarllessard/tensorflow-java-models

branch : add-copyrights

created branch time in 15 days

issue commenttensorflow/java-models

Add missed dependency "org.tensorflow.tools"

Please tell me if that commit also fixed this issue

zaleslaw

comment created time in 15 days

issue commenttensorflow/java-models

The runtime error with protobuf

Yeah @zaleslaw , I just realized that as well, the snapshot repo was missing in our example pom.xml, I've just updated it and update the framework dependency while being at it. Can you now give it a try?

zaleslaw

comment created time in 15 days

delete branch karllessard/tensorflow-java-models

delete branch : add-snapshot-repo

delete time in 15 days

push eventtensorflow/java-models

klessard

commit sha d91770c726734942d8585511df170be31e423e6c

Add snapshot repo and adjust framework dependency

view details

push time in 15 days

create barnchkarllessard/tensorflow-java-models

branch : add-snapshot-repo

created branch time in 15 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha a1fd340ca36f0a298790e79db2d650dcfe0c1475

Fix windows build

view details

push time in 15 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 4b52381a3875433e75ec4303f91daea1647a17dd

Fix windows build

view details

push time in 16 days

issue closedtensorflow/java

Tensors.create factory method is not supported

Java API does not support factory method for creating Tensor Tensors.create() - https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/Tensors

closed time in 16 days

vissood

issue commenttensorflow/java

Maven coordinates not found

Are you looking for this information?

Ben-Epstein

comment created time in 16 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha ddba0d39a073f555522ee67e0811bd39791cfec8

Fix windows build

view details

push time in 16 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha dd156e3c09c889246b7605a6b45d2958e35f9afd

Fix windows build

view details

push time in 16 days

Pull request review commenttensorflow/java

Add functionality to map over dataset elements in both graph and eager mode.

 
 import org.tensorflow.DataType;
 import org.tensorflow.Operand;
-import org.tensorflow.framework.data.impl.BatchDataset;
-import org.tensorflow.framework.data.impl.SkipDataset;
-import org.tensorflow.framework.data.impl.TakeDataset;
-import org.tensorflow.framework.data.impl.TensorSliceDataset;
+import org.tensorflow.Output;
+import org.tensorflow.framework.data.impl.*;

Star import came back, check your IDE settings!

dhruvrajan

comment created time in 17 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 9d0a6c87f7b0454f174511ea55ca00a451f82e4f

Use TF env for loading libs dynamically

view details

push time in 17 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 49b9696ce338b50a0d2749bd02f2be1bcc0a0098

Use TF env for loading libs dynamically

view details

push time in 17 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha aed619d11a870119b46b084cc671f03f8a60cc73

Use TF env for loading libs dynamically

view details

push time in 17 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 43aac34964b6abf8aa6ecca08f95c75bf62d9a5f

Use TF env for loading libs dynamically

view details

push time in 17 days

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

An update on this: I've added the --define build_with_mkl_dnn_v1_only=false flag to the bazel command line and now MacOS + MKL passes, looks like MKL-DNN v1 only works out with Linux.

I was planning to leave it that way if everything goes fine and then we can check how to enable MKL-DNN 1.x on all platforms or only on Linux.

roywei

comment created time in 17 days

push eventkarllessard/tensorflow-java

Karl Lessard

commit sha 7cb7a3f76e66b4f68683b43f8908059c5933e7da

Fix MKL builds

view details

push time in 18 days

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

Yeah, sorry, my previous message was not very explicit (it's still the morning and I did not went through my first coffee yet...). So if you have any tip for that second problem, please let me know!

roywei

comment created time in 18 days

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

But what concerns me here is that the error I'm having is not with missing omp.h header anymore (that, just brew install it did the trick). The error is not that the code does not compile on Mac and Windows because of what seems an incompatibility on those platforms between the MKL library released with TF and the some kernels making use of it:

ERROR: /private/var/tmp/_bazel_runner/17ed05ace81230cf3c69807725c012c8/external/org_tensorflow/tensorflow/core/kernels/BUILD:7897:1: C++ compilation of rule '@org_tensorflow//tensorflow/core/kernels:mkl_conv_op' failed (Exit 1)
In file included from external/org_tensorflow/tensorflow/core/kernels/mkl_conv_ops.cc:19:
external/org_tensorflow/tensorflow/core/kernels/mkl_conv_ops.h:157:19: error: no viable overloaded '='
      *input_dims = mkldnn_sizes;
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~

Both platforms have the same error. So just to confirm @Craigacp , you are telling me that playing with include paths may fix this error as well or you were referring to the previous problem with omp.h?

roywei

comment created time in 18 days

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

Thanks @Craigacp , any tip on how to install it easily from the command line?

roywei

comment created time in 18 days

issue commenttensorflow/java

Failed to fetch latest snapshot for tensorflow-core-api linux gpu mkl

So the missing file in MacOSX seems to be fixed now, I brew install libomp before building on the Mac machine. Still, the MKL build fail for Mac and Windows.

But I'm a bit concerned about this comment I found in TensorFlow configuration file:

# Please note that MKL on MacOS or windows is still not supported.
# If you would like to use a local MKL instead of downloading, please set the
# environment variable "TF_MKL_ROOT" every time before build.

So it sounds like we cannot assume that the MKL version coming with TF will work on those platforms for all TF releases and we need to install our own? Here is another related thread.

/cc @saudet

roywei

comment created time in 18 days

more