https://github.com/halide/Halide
Raw File
Tip revision: bf3b66f9d5ce84bd85f0390c9e198b2e8f7bd554 authored by Z Stern on 24 September 2020, 18:00:10 UTC
Add atomic update support to thread_pool_common parallel for implementations.
Tip revision: bf3b66f
Qualify.cpp
#include "Qualify.h"
#include "IRMutator.h"

namespace Halide {
namespace Internal {

using std::string;

// Prefix all names in an expression with some string.
class QualifyExpr : public IRMutator {
    using IRMutator::visit;

    const string &prefix;

    Expr visit(const Variable *v) override {
        if (v->param.defined()) {
            return v;
        } else {
            return Variable::make(v->type, prefix + v->name, v->reduction_domain);
        }
    }
    Expr visit(const Let *op) override {
        Expr value = mutate(op->value);
        Expr body = mutate(op->body);
        return Let::make(prefix + op->name, value, body);
    }

public:
    QualifyExpr(const string &p)
        : prefix(p) {
    }
};

Expr qualify(const string &prefix, const Expr &value) {
    QualifyExpr q(prefix);
    return q.mutate(value);
}

}  // namespace Internal
}  // namespace Halide
back to top