#1447·ggml

Try to return a local variable in `mnist_model_init_from_file`

Author: vtpxCreated Mar 28, 2026Updated Sep 24, 2026

A local variable model is decleared in mnist-common.cpp: 132:

cpp
mnist_model mnist_model_init_from_file(const std::string & fname, const std::string & backend, const int nbatch_logical, const int nbatch_physical) {
    mnist_model model(backend, nbatch_logical, nbatch_physical);

and finally the variable is returned directly (mnist-common.cpp: 238).

cpp
    return model;
}

After mnist_model_init_from_file, the return value model in main is no longer available.

Image

As is shown in the figure, the variable such as model.images.op is not a legal ggml_op value.