Skip to content

Commit

Permalink
Don't cross-ref deprecated funcs in Treelite
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed May 4, 2023
1 parent 05be9c2 commit 7f23bce
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
41 changes: 32 additions & 9 deletions docs/treelite-migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ for model loading.
Generating C code
=================

For generating C code from tree models, replace :py:meth:`treelite.Model.compile`
with :py:meth:`tl2cgen.generate_c_code`
For generating C code from tree models, replace ``treelite.Model.compile()``
with :py:func:`tl2cgen.generate_c_code`

.. code-block:: python
Expand All @@ -75,7 +75,7 @@ with :py:meth:`tl2cgen.generate_c_code`
Exporting libraries
===================
Replace :py:meth:`treelite.Model.export_lib` with :py:meth:`tl2cgen.export_lib`:
Replace ``treelite.Model.export_lib()`` with :py:func:`tl2cgen.export_lib`:

.. code-block:: python
Expand All @@ -85,8 +85,8 @@ Replace :py:meth:`treelite.Model.export_lib` with :py:meth:`tl2cgen.export_lib`:
# After: TL2cgen. The model object is passed as the first argument
tl2cgen.export_lib(model, toolchain="msvc", libpath="./mymodel.dll", params={})
:py:meth:`treelite.Model.export_srcpkg` is replaced with :py:meth:`tl2cgen.export_srcpkg`.
Note that the parameter ``platform`` was removed in :py:meth:`tl2cgen.export_srcpkg`.
``treelite.Model.export_srcpkg()`` is replaced with :py:func:`tl2cgen.export_srcpkg`.
Note that the parameter ``platform`` was removed in :py:func:`tl2cgen.export_srcpkg`.

.. code-block:: python
Expand All @@ -99,19 +99,42 @@ Note that the parameter ``platform`` was removed in :py:meth:`tl2cgen.export_src
tl2cgen.export_srcpkg(model, toolchain="gcc", pkgpath="./mymodel_pkg.zip",
libname="mymodel.so", params={})
Predicting with exported libraries
==================================
Replace ``treelite_runtime.Predictor`` class with :py:class:`tl2cgen.Predictor`.
In TL2cgen, the Predictor class is part of the same Python module as other
classes and methods; there is no separate "runtime" module.

In addition, ``treelite_runtime.DMatrix`` is replaced with
:py:class:`tl2cgen.DMatrix`.

.. code-block:: python
# Before: Treelite 3.x
predictor = treelite_runtime.Predictor("./mymodel.so")
dmat = treelite_runtime.DMatrix(X)
out_pred = predictor.predict(dmat)
# After: TL2cgen
predictor = tl2cgen.Predictor("./mymodel.so")
dmat = tl2cgen.DMatrix(X)
out_pred = predictor.predict(dmat)
Annotating branches
===================
Replace :py:class:`treelite.Annotator` with :py:meth:`tl2cgen.annotate_branch`.
Instead of calling two methods :py:meth:`treelite.Annotator.annotate_branch` and
:py:meth:`treelite.Annotator.save`, you only need to call one,
:py:meth:`tl2cgen.annotate_branch`:
Replace ``treelite.Annotator`` with :py:func:`tl2cgen.annotate_branch`.
Instead of calling two methods ``treelite.Annotator.annotate_branch`` and
``treelite.Annotator.save``, you only need to call one,
:py:func:`tl2cgen.annotate_branch`:

.. code-block:: python
# Before: Treelite 3.x
dmat = treelite_runtime.DMatrix(X_train)
annotator = treelite.Annotator()
annotator.annotate_branch(model, dmat)
annotator.save(path="mymodel-annotation.json")
# After: TL2cgen. Only one method call is needed.
dmat = tl2cgen.DMatrix(X_train)
tl2cgen.annotate_branch(model, dmat, path="mymodel-annotation.json")
2 changes: 1 addition & 1 deletion include/tl2cgen/compiler_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct CompilerParam {
/*!
* \brief Name of model annotation file.
* \verbatim embed:rst:leading-asterisk
* Use :py:meth:`~tl2cgen.annotate_branch` to generate this file.
* Use :py:func:`tl2cgen.annotate_branch` to generate this file.
* \endverbatim
*/
std::string annotate_in;
Expand Down

0 comments on commit 7f23bce

Please sign in to comment.