| 109 | } |
| 110 | |
| 111 | const xla::XlaComputation* XlaContext::GetOrCreateAdd(const DataType type) { |
| 112 | return LookupOrCreate(type, &add_func_, [type] { |
| 113 | const string type_string = DataTypeString(type); |
| 114 | VLOG(1) << "Building Add() for " << type_string; |
| 115 | xla::XlaBuilder b("add<" + type_string + ">"); |
| 116 | xla::PrimitiveType xla_type; |
| 117 | TF_CHECK_OK(DataTypeToPrimitiveType(type, &xla_type)); |
| 118 | auto x = |
| 119 | xla::Parameter(&b, 0, xla::ShapeUtil::MakeShape(xla_type, {}), "x"); |
| 120 | auto y = |
| 121 | xla::Parameter(&b, 1, xla::ShapeUtil::MakeShape(xla_type, {}), "y"); |
| 122 | xla::Add(x, y); |
| 123 | return b.Build().ConsumeValueOrDie(); |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | const xla::XlaComputation* XlaContext::GetOrCreateMul(const DataType type) { |
| 128 | return LookupOrCreate(type, &mul_func_, [type] { |
no test coverage detected