TensorFlow Decision Forests 0.1.3 open sourced

Yeah, sorry, after looking more closely through the ops I think we’ll probably be able to use that from Java with the usual amount of tricks. I’m not so sure how well it’ll work in eager mode, but the C API doesn’t really do that very well at the moment anyway. I know we’ve hit issues with resource variables in the past, and I’m not sure what kind of resource the tree model is, so that might be another issue.

I’ll have a look at it in some more detail in the future.

2 Likes

Please keep us posted how it goes: the same is probably valid for support in other languages, and we would add any information to the docs.

1 Like

Thanks for making this available. I’m new to tensorflow and ML, I’m somewhat overwhelmed and I’m curious as to why this is separate from the main project and if the plan is to merge it at some point? As I understand - if I want to perform inference using a model saved from tfdf in C++ I need to use yddrasil-df’s C++ api, is that correct? The model would not load via the normal tensorflow C api (wrapped via the 3rd party cppflow). I am a bit confused since I saw the c++ code in the tfdf repo. Ideally I would like to be able to use tfdf and nn models in the same c++ binary. Wondering if I can do that with cppflow and without getting bazel involved.

Hi Oliver,

Thanks for the interest.

The code is separated to isolate tensorflow and non-tensorflow code. From the point of view of TF-DF, YggdrasilDF is one of the third party libraries. A TF-DF SavedModel is a Yggdrasil DF model and some extra data.

If your language is C / C++, a TF-DF model can be served as:

  1. A classical SavedModel using the TensorFlow C++ or C APIs.
  2. A Yggdrasil DF model using the Yggdrasil DF C++ API.

Both options are not fully equivalent: Solution 1. supports any complex SavedModel, including ones containing TensorFlow preprocessing or multiple sub models. However, this solution can be slow as TensorFlow adds a non-negligible complexity overhead. Solution 2. is designed for fast inference and ease of use. Compiling Yggdrasil is also significantly simpler and faster than compiling TensorFlow. However, this solution only supports “pure” Yggdrasil models (i.e. no TensorFlow preprocessing).

If your SavedModel model contains both TF-DF and NN components, you should use solution 1.

1 Like

Thanks. For option 1, how would I get support for the necessary ops?

When trying to load the SavedModel with TF 2.5.0 dll I have the following error:

2021-06-30 13:36:47.070533: I tensorflow/cc/saved_model/loader.cc:277] SavedModel load for tags { serve }; Status: fail: Not found: Op type not registered 'SimpleMLCreateModelResource’

This indicates that the implementation of these Ops (short for “tensor flow operations”) are not available to the TF session. You need to link either the static or dynamic version of these ops in your binary. If you are working with Bazel, it means adding a dependency to TF-DF.

Thanks again. Having trouble building those on macOS:

bazel build -c opt //tensorflow_decision_forests/tensorflow/ops/inference:kernel_and_op

and

bazel build -c opt //tensorflow_decision_forests/tensorflow/ops/inference:inference.so

fail. I won’t pollute this thread more with the details. I’ll wait for tfdf macOS/win support which I guess might fix the above commands. It would be brilliant if you are able to publish prebuilt dylib binaries BTW, to make the process of using a tfdf model in C++ a bit easier.

update: managed to build the .so and object files for op and kernel on macOS (needed cpp17). Not having much luck linking to either. Will keep trying

Hi Olivier,

Thanks for the updates :).

Releasing the Windows and MacOS versions of TF-DF are high priority features for us. Unfortunately we don’t have a good ETA (hopefully soon :slight_smile:). I’ll keep you posted.

I forgot to mention it earlier. Yggdrasil DF works on Windows and should work seemingly on MacOs.

Cheers,
M.