dlfeval — Evaluate a function handle in Deep Learning compatibility context.

dlfeval(fun,args...) invokes a function handle through RunMat's function-handle dispatch and forwards requested outputs.

Syntax

varargout = dlfeval(fun, args...)

How dlfeval works

  • fun must be a function handle value, including named handles, method handles, bound handles, and closures.
  • Requested output count is preserved, so bracketed multi-output calls forward to the invoked function.
  • A bounded automatic-differentiation tape is installed for the call. Host dlarray inputs, supported dlnetwork learnables, dlarray arithmetic, scalar sums, and supported forward layer chains can be differentiated with dlgradient inside fun.
  • Text function names and callable objects are rejected by dlfeval; use feval for those RunMat extension forms.

GPU memory and residency

dlfeval preserves callable dispatch behavior. GPU-backed dlarray values are rejected for automatic differentiation with an explicit provider-gap error because provider-resident tape kernels are not implemented yet.

Example

Evaluate Function

[loss,gradients] = dlfeval(@modelLoss, net, X, T)

Expected output:

Outputs returned by `modelLoss`, including traced losses and gradients from `dlgradient`.

Using dlfeval with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how dlfeval changes the result.

Run a small dlfeval example, explain the result, then change one input and compare the output.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.