Enzyme main
Loading...
Searching...
No Matches
DataFlowLattice.cpp
Go to the documentation of this file.
1//===- DataFlowLattice.h - Implementation of common dataflow lattices -----===//
2//
3// Enzyme Project
4//
5// Part of the Enzyme Project, under the Apache License v2.0 with LLVM
6// Exceptions. See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9// If using this code in an academic setting, please cite the following:
10// @inproceedings{NEURIPS2020_9332c513,
11// author = {Moses, William and Churavy, Valentin},
12// booktitle = {Advances in Neural Information Processing Systems},
13// editor = {H. Larochelle and M. Ranzato and R. Hadsell and M. F. Balcan and H.
14// Lin}, pages = {12472--12485}, publisher = {Curran Associates, Inc.}, title =
15// {Instead of Rewriting Foreign Code for Machine Learning, Automatically
16// Synthesize Fast Gradients}, url =
17// {https://proceedings.neurips.cc/paper/2020/file/9332c513ef44b682e9347822c2e457ac-Paper.pdf},
18// volume = {33},
19// year = {2020}
20// }
21//
22//===----------------------------------------------------------------------===//
23//
24// This file contains the implementation of reusable lattices in dataflow
25// analyses.
26//
27//===----------------------------------------------------------------------===//
28
30
31#include <algorithm>
32
33using namespace mlir;
34
35bool enzyme::sortAttributes(Attribute a, Attribute b) {
36 std::string strA, strB;
37 llvm::raw_string_ostream sstreamA(strA), sstreamB(strB);
38 sstreamA << a;
39 sstreamB << b;
40 return strA < strB;
41}
42
43bool enzyme::sortArraysLexicographic(ArrayAttr a, ArrayAttr b) {
44 return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(),
46}
bool sortArraysLexicographic(ArrayAttr a, ArrayAttr b)
bool sortAttributes(Attribute a, Attribute b)
Used when serializing to ensure a consistent order.