Commit Graph

9 Commits

Author SHA1 Message Date
Lei Zhang ff3b9149b3 Clean up base TableGen definitions
* Removed unused builder field for type definitions
* Refined comments and reordered classes

PiperOrigin-RevId: 224223038
2019-03-29 14:18:07 -07:00
Jacques Pienaar c143132a56 Enable using bare attributes.
Useful for defining ops such as <dialect>.Const where multiple kinds of attributes are legal.

PiperOrigin-RevId: 224210511
2019-03-29 14:17:53 -07:00
Lei Zhang 5858102ab1 Remove tfl.reshape op when possible
Remove tfl.reshape for the following two cases:

1. A tfl.reshape's input is from another tfl.reshape.
   Then these two tfl.reshape ops can be merged.

2. A tfl.reshape's result type is the same as its input type.
   This tfl.reshape op does nothing, which can be removed.

These transformations are put in a new source file, Canonicalizer.cpp,
because they are TFLite op to TFLite op transformations, and aiming
to making TFLite ops more canonicalized.

Also added a hasCanonicalizationPatterns marker in TableGen Op class
to indicate whether an op has custom getCanonicalizationPatterns().

PiperOrigin-RevId: 223806921
2019-03-29 14:14:13 -07:00
Jacques Pienaar 16f525bc27 Add derived attribute support.
Derived attributes are attributes that are derived from other properties of the operation (e.g., the shape returned from the type). DerivedAttr is parameterized on the return type and function body.

PiperOrigin-RevId: 223180315
2019-03-29 14:11:40 -07:00
Jacques Pienaar 75376b8e33 Change Attr to have a storage and return type.
Separate the storage and return type more explicitly. This is in preparation for, among others, allowing supporting enum attributes where the return type is a enum class. NFC.

PiperOrigin-RevId: 219368487
2019-03-29 13:45:38 -07:00
River Riddle 792d1c25e4 Implement value type abstraction for attributes.
This is done by changing Attribute to be a POD interface around an underlying pointer storage and adding in-class support for isa/dyn_cast/cast.

PiperOrigin-RevId: 218764173
2019-03-29 13:39:19 -07:00
Jacques Pienaar 58168e476e [opgen] Change Attr to be more intuitive to insert
Change how attributes can be added to an Op to make the syntax in the td file a bit cleaner. Also avoid unnecessarily emitting verify method (trivial return false one that's already in base) and use custom syntax in test.

PiperOrigin-RevId: 217330036
2019-03-29 13:31:31 -07:00
Jacques Pienaar d4b095b164 Make the op specification more declarative wrt properties.
Also remove the builder generator as it isn't useful until there are output constraints.

PiperOrigin-RevId: 217322623
2019-03-29 13:31:17 -07:00
Jacques Pienaar f37a9909a1 Add op gen tool to generate C++ classes for Operations.
Create tblgen based tool to generate the C++ Op definitions. The modelling is
currently simple (ops, attributes, properties) with the printer/parser/verifier
the bodies of those functions and builders being very explicit.

PiperOrigin-RevId: 217150213
2019-03-29 13:30:35 -07:00