<commit_before>#include <set>

#include "Inline.h"
#include "CSE.h"
#include "IRPrinter.h"
#include "IRMutator.h"
#include "Qualify.h"
#include "Debug.h"

namespace Halide {
namespace Internal {

using std::set;
using std::string;
using std::vector;

class Inliner : public IRMutator {
    using IRMutator::visit;

    Function func;

    // Sanity check that this is a reasonable function to inline
    void check(Function f) {

        internal_assert(f.can_be_inlined()) << "Illegal to inline " << f.name() << "\n";

        const Schedule &s = f.schedule();

        if (!s.store_level().is_inline()) {
            user_error << "Function " << f.name() << " is scheduled to be computed inline, "
                       << "but is not scheduled to be stored inline. A storage schedule "
                       << "is meaningless for functions computed inline.\n";
        }

        if (s.memoized()) {
            user_error << "Cannot memoize function "
                       << f.name() << " because the function is scheduled inline.\n";
        }

        for (size_t i = 0; i < s.dims().size(); i++) {
            Dim d = s.dims()[i];
            if (d.for_type == ForType::Parallel) {
                user_error << "Cannot parallelize dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            } else if (d.for_type == ForType::Unrolled) {
                user_error << "Cannot unroll dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            } else if (d.for_type == ForType::Vectorized) {
                user_error << "Cannot vectorize dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            }
        }

        for (size_t i = 0; i < s.splits().size(); i++) {
            if (s.splits()[i].is_rename()) {
                user_warning << "It is meaningless to rename variable "
                             << s.splits()[i].old_var << " of function "
                             << f.name() << " to " << s.splits()[i].outer
                             << " because " << f.name() << " is scheduled inline.\n";
            } else if (s.splits()[i].is_fuse()) {
                user_warning << "It is meaningless to fuse variables "
                             << s.splits()[i].inner << " and " << s.splits()[i].outer
                             << " because " << f.name() << " is scheduled inline.\n";
            } else {
                user_warning << "It is meaningless to split variable "
                             << s.splits()[i].old_var << " of function "
                             << f.name() << " into "
                             << s.splits()[i].outer << " * "
                             << s.splits()[i].factor << " + "
                             << s.splits()[i].inner << " because "
                             << f.name() << " is scheduled inline.\n";
            }
        }

        for (size_t i = 0; i < s.bounds().size(); i++) {
            user_warning << "It is meaningless to bound dimension "
                         << s.bounds()[i].var << " of function "
                         << f.name() << " to be within ["
                         << s.bounds()[i].min << ", "
                         << s.bounds()[i].extent << "] because the function is scheduled inline.\n";
        }

    }

    void visit(const Call *op) {
        if (op->name == func.name()) {

            // Mutate the args
            vector<Expr> args(op->args.size());
            for (size_t i = 0; i < args.size(); i++) {
                args[i] = mutate(op->args[i]);
            }
            // Grab the body
            Expr body = qualify(func.name() + ".", func.values()[op->value_index]);

            const vector<string> func_args = func.args();

            // Bind the args using Let nodes
            internal_assert(args.size() == func_args.size());
<commit_msg>Fix warning<commit_after>#include <set>

#include "Inline.h"
#include "CSE.h"
#include "IRPrinter.h"
#include "IRMutator.h"
#include "Qualify.h"
#include "Debug.h"

namespace Halide {
namespace Internal {

using std::set;
using std::string;
using std::vector;

class Inliner : public IRMutator {
    using IRMutator::visit;

    Function func;

    // Sanity check that this is a reasonable function to inline
    void check(Function f) {

        internal_assert(f.can_be_inlined()) << "Illegal to inline " << f.name() << "\n";

        const Schedule &s = f.schedule();

        if (!s.store_level().is_inline()) {
            user_error << "Function " << f.name() << " is scheduled to be computed inline, "
                       << "but is not scheduled to be stored inline. A storage schedule "
                       << "is meaningless for functions computed inline.\n";
        }

        if (s.memoized()) {
            user_error << "Cannot memoize function "
                       << f.name() << " because the function is scheduled inline.\n";
        }

        for (size_t i = 0; i < s.dims().size(); i++) {
            Dim d = s.dims()[i];
            if (d.for_type == ForType::Parallel) {
                user_error << "Cannot parallelize dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            } else if (d.for_type == ForType::Unrolled) {
                user_error << "Cannot unroll dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            } else if (d.for_type == ForType::Vectorized) {
                user_error << "Cannot vectorize dimension "
                           << d.var << " of function "
                           << f.name() << " because the function is scheduled inline.\n";
            }
        }

        for (size_t i = 0; i < s.splits().size(); i++) {
            if (s.splits()[i].is_rename()) {
                user_warning << "It is meaningless to rename variable "
                             << s.splits()[i].old_var << " of function "
                             << f.name() << " to " << s.splits()[i].outer
                             << " because " << f.name() << " is scheduled inline.\n";
            } else if (s.splits()[i].is_fuse()) {
                user_warning << "It is meaningless to fuse variables "
                             << s.splits()[i].inner << " and " << s.splits()[i].outer
                             << " because " << f.name() << " is scheduled inline.\n";
            } else {
                user_warning << "It is meaningless to split variable "
                             << s.splits()[i].old_var << " of function "
                             << f.name() << " into "
                             << s.splits()[i].outer << " * "
                             << s.splits()[i].factor << " + "
                             << s.splits()[i].inner << " because "
                             << f.name() << " is scheduled inline.\n";
            }
        }

        for (size_t i = 0; i < s.bounds().size(); i++) {
            if (s.bounds()[i].min.defined()) {
                user_warning << "It is meaningless to bound dimension "
                             << s.bounds()[i].var << " of function "
                             << f.name() << " to be within ["
                             << s.bounds()[i].min << ", "
                             << s.bounds()[i].extent << "] because the function is scheduled inline.\n";
            } else if (s.bounds()[i].modulus.defined()) {
                user_warning << "It is meaningless to align the bounds of dimension "
                             << s.bounds()[i].var << " of function "
                             << f.name() << " to have modulus/remainder ["
                             << s.bounds()[i].modulus << ", "
                             << s.bounds()[i].remainder << "] because the function is scheduled inline.\n";
            }
        }
    }

    void visit(const Call *op) {
        if (op->name == func.name()) {

            // Mutate the args
            vector<Expr> args(op->args.size());
            for (size_t i = 0; i < args.size(); i++) {
                args[i] = mutate(op->args[i]);
            }
            // Grab the body
            Expr body = qualify(func.name() + ".", func.values()[op->value_index]);

            const vector<string> func_args = func.args();

            // Bind the args using Let nodes
            internal_assert(args.size() == func_args.size());

{'fraction_non_alphanumeric': 0.15119182746878548, 'fraction_numerical': 0.0009080590238365494, 'mean_word_length': 1.3685483870967743, 'pattern_counts': {'":': 0, '<': 291, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6460566', 'n_tokens_mistral': 2412, 'n_tokens_neox': 2340, 'n_words': 627}