diff options
Diffstat (limited to 'tensorflow/g3doc/how_tos/adding_an_op/attr_examples.cc')
-rw-r--r-- | tensorflow/g3doc/how_tos/adding_an_op/attr_examples.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tensorflow/g3doc/how_tos/adding_an_op/attr_examples.cc b/tensorflow/g3doc/how_tos/adding_an_op/attr_examples.cc new file mode 100644 index 0000000000..84e54c7219 --- /dev/null +++ b/tensorflow/g3doc/how_tos/adding_an_op/attr_examples.cc @@ -0,0 +1,31 @@ +#include <stdio.h> +#include "tensorflow/core/framework/op.h" + +REGISTER_OP("RestrictedTypeExample").Attr("t: {int32, float, bool}"); + +REGISTER_OP("NumberType").Attr("t: numbertype"); + +REGISTER_OP("EnumExample").Attr("e: {'apple', 'orange'}"); + +REGISTER_OP("MinIntExample").Attr("a: int >= 2"); + +REGISTER_OP("TypeListExample").Attr("a: list({int32, float}) >= 3"); + +REGISTER_OP("AttrDefaultExample").Attr("i: int = 0"); + +REGISTER_OP("AttrDefaultExampleForAllTypes") + .Attr("s: string = 'foo'") + .Attr("i: int = 0") + .Attr("f: float = 1.0") + .Attr("b: bool = true") + .Attr("ty: type = DT_INT32") + .Attr("sh: shape = { dim { size: 1 } dim { size: 2 } }") + .Attr("te: tensor = { dtype: DT_INT32 int_val: 5 }") + .Attr("l_empty: list(int) = []") + .Attr("l_int: list(int) = [2, 3, 5, 7]"); + +int main(int argc, char* argv[]) { + printf("All registered ops:\n%s\n", + tensorflow::OpRegistry::Global()->DebugString(false).c_str()); + return 0; +} |