Exemplo n.º 1
0
void Environment::addTensorIndex(const StencilLayout& stencil, const Var& var) {
  iassert(var.defined())
      << "attempting to add a tensor index to an undefined var";

  string name = var.getName();

  // Lazily create a new index if no index with the given pexpr exist.
  // TODO: Maybe rename indices as they get used by multiple tensors
  if (!hasTensorIndex(stencil)) {
    TensorIndex ti(name+"_index", stencil);
    content->tensorIndices.push_back(ti);
    size_t loc = content->tensorIndices.size() - 1;
    content->locationOfTensorIndexStencil.insert({stencil, loc});
  }
  content->tensorIndexOfVar.insert({var, getTensorIndex(stencil)});
}
Exemplo n.º 2
0
// class PathExpressionPrinter
void PathExpressionPrinter::print(const Var &v) {
  simit_iassert(v.defined()) << "attempting to print undefined var";
  std::string name;
  if (util::contains(names, v)) {
    name = names.at(v);
  }
  else {
    if (v.getName() != "") {
      name = nameGenerator.getName(v.getName());
    }
    else {
      name = nameGenerator.getName("e");
    }
    names[v] = name;
  }
  os << name;
}
Exemplo n.º 3
0
void Environment::addTensorIndex(const pe::PathExpression& pexpr,
                                 const Var& var) {
  iassert(pexpr.defined())
      << "Attempting to add tensor " << util::quote(var)
      << " index with an undefined path expression";
  iassert(var.defined())
      << "attempting to add a tensor index to an undefined var";

  string name = var.getName();

  // Lazily create a new index if no index with the given pexpr exist.
  // TODO: Maybe rename indices as they get used by multiple tensors
  if (!hasTensorIndex(pexpr)) {
    TensorIndex ti(name+"_index", pexpr);
    content->tensorIndices.push_back(ti);
    size_t loc = content->tensorIndices.size() - 1;
    content->locationOfTensorIndex.insert({pexpr, loc});
  }
  content->tensorIndexOfVar.insert({var, getTensorIndex(pexpr)});
}