# mlx.core.simplify — MLX 0.0.7 documentation

Skip to main content
`Ctrl`+`K`

# mlx.core.simplify

mlx.core.simplify(*args) → None

  Simplify the graph that computes the arrays.

  Run a few fast graph simplification operations to reuse computation and reduce memory consumption. This function is meant to be run every time so its overhead should be small, approximately 1ms for a graph with a few thousand nodes.

      import mlx.core as mx

      def foo(x):
        y = x @ x
        z = x @ x
        return y + z

      x = mx.ones((10, 10))
      y = foo(x)
      z = foo(x)

      # Computes the matmul twice
      mx.eval(y)

      # Computes the matmul once
      mx.simplify(z)
      mx.eval(z)

  Parameters:

    args – Any number of arrays and/or trees of arrays to be simplified.