# Runtime Generated Functions

**URL:** <https://discourse.julialang.org/t/runtime-generated-functions/53507>\
**Category:** Machine Learning\
**Tags:** question\
**Created:** [January 17, 2021, 10:54pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507 "2021-01-17T22:54:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 17, 2021, 10:54pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/1 "2021-01-17T22:54:56Z")

</div>

> Blockquote nlsys\_func = generate\_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2]

Generates :  
(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol(“##MTIIPVar#873”), Symbol(“##MTKArg#870”), Symbol(“##MTKArg#871”)),ModelingToolkit.var"#\_RGF\_ModTag",(0xe85d4d5a, 0xc9aaedcf, 0x24c24ac9, 0xb7dd2fb4, 0xc6ba2717)}) (generic function with 1 method)

Can someone please guide how to overcome this issue

Thaks in advance

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 17, 2021, 11:11pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/2 "2021-01-17T23:11:57Z")

</div>

What’s the issue?

---

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 17, 2021, 11:22pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/4 "2021-01-17T23:22:15Z")

</div>

(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol(“##MTIIPVar#873”), Symbol(“##MTKArg#870”), Symbol(“##MTKArg#871”)),ModelingToolkit.var"#\_RGF\_ModTag",(0xe85d4d5a, 0xc9aaedcf, 0x24c24ac9, 0xb7dd2fb4, 0xc6ba2717)}) (generic function with 1 method)

Unable to understand this generated output

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 17, 2021, 11:31pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/5 "2021-01-17T23:31:46Z")

</div>

That’s just the name of the function. It could print something else, but in general functions don’t print something too interesting to most people.

---

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 17, 2021, 11:38pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/7 "2021-01-17T23:38:06Z")

</div>

So is there any other way to generate Runtime Generated Functions?

Following is my code sample which I followed from [Tutorial](https://mtk.sciml.ai/dev/tutorials/nonlinear/)

using ModelingToolkit, GeneralizedGenerated

@variables x y z  
@parameters a b c

##Define a nonlinear system  
eqs = [0 ~ - y - (z+20),  
0 ~ x + a \* y,  
0 ~ b + (z+20) \* (x - c)]  
ns = NonlinearSystem(eqs, [x,y,z], [a,b,c])  
nlsys\_func = generate\_function(ns)[2] # second is the inplace version

rossler = ModelingToolkit.eval(nlsys\_func)  
du = zeros(3); u = ones(3)  
params = (0.2,0.2,5.7)

j\_func2 = generate\_jacobian(ns)[2] # second is in-place  
j2! = ModelingToolkit.eval(j\_func2)

using NLsolve  
nlsolve((out, x) → rossler(out, x, params), (out, x) → j2!(out, x, params), ones(3))

nlsys\_func = generate\_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2] # runtime generated function

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 17, 2021, 11:42pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/8 "2021-01-17T23:42:23Z")

</div>

> [@Ruchitha\_Kumar](#):
>
> So is there any other way to generate Runtime Generated Functions?

You can directly use [GitHub - SciML/RuntimeGeneratedFunctions.jl: Functions generated at runtime without world-age issues or overhead](https://github.com/SciML/RuntimeGeneratedFunctions.jl)

---

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 17, 2021, 11:50pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/9 "2021-01-17T23:50:21Z")

</div>

Even using RuntimeGeneratedFunctions.jl the output remains the same but I would really like to know if its just a function name which is generated as output then, whats the use of line:

> nlsys\_func = generate\_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2] # runtime generated function

What can be concluded with the output of this line of code generated?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 17, 2021, 11:55pm UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/10 "2021-01-17T23:55:08Z")

</div>

> [@Ruchitha\_Kumar](#):
>
> can be concluded with the output of this line of code genera

It’s just the hash of the function body.

---

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 18, 2021, 12:01am UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/11 "2021-01-18T00:01:41Z")

</div>

So is **Runtime generated functions is made to generate hash value of the function body**? Can i conclude the use of RuntimeGeneratedFunctions.jl like that?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 18, 2021, 12:04am UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/12 "2021-01-18T00:04:52Z")

</div>

It’s just a function.

---

<div class="post-metadata">

**Author:** ![Ruchitha\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@Ruchitha\_Kumar](https://discourse.julialang.org/u/Ruchitha_Kumar)\
**Post date:** [January 18, 2021, 12:08am UTC](https://discourse.julialang.org/t/runtime-generated-functions/53507/13 "2021-01-18T00:08:46Z")

</div>

Okay, thank you
