Both functions create a new Func with the given id which is afterwards accessible via .current_func().
Functions receiving a Func as an argument (such as hlo_input, hlo_add, ...) usually use
.current_func() by default.
You can also directly create a function using Func(), which will not be accessible this way.
Differences between the two functions:
local_funcremoves the function when exiting the current scope, whereashlo_funcdoes not.hlo_funcdiscards the previously built function(s), whereaslocal_funcdoes not: after a function created bylocal_funcis either cleaned up automatically (by exiting the scope) or the function is finalized viahlo_return, the previously built function is restored, i.e., accessible via.current_func(). To build nested functions (e.g. to create a closure that is passed to another op), uselocal_funcinstead ofhlo_func.
Usage
hlo_func(id = "main")
local_func(id = "main", envir = parent.frame())Arguments
- id
(
character(1)
The id of the function.- envir
(
environment)
Environment where exit handler will be registered for cleaning up theFuncif it was not returned yet.
Value
A Func object.