// Predicate to verify that a named argument or result's element type matches a
// given type.
class ArgOrResultElementTypeIs<string name, Type type> : And<[
- SubstLeaves<"$_self", "$" # name # "->getType()", IsShapedTypePred>,
+ SubstLeaves<"$_self", "$" # name # ".getType()", IsShapedTypePred>,
SubstLeaves<"$_self", "$" # name #
- "->getType().cast<ShapedType>().getElementType()",
+ ".getType().cast<ShapedType>().getElementType()",
type.predicate>]>;
// Predicate to verify that the i'th operand and the j'th operand have the same
Or<[And<[ArgOrResultElementTypeIs<"x", I32>,
ArgOrResultElementTypeIs<"y", F32>,
ArgOrResultElementTypeIs<"res", I16>]>,
- // TODO(jpienaar): change back to attr.
- ArgOrResultElementTypeIs<"x", I8>]>>]> {
+ ArgOrResultElementTypeIs<"attr", I8>]>>]> {
let arguments = (ins AnyVectorOrTensor:$x, AnyVectorOrTensor:$y, AnyAttr:$attr);
let results = (outs AnyVectorOrTensor:$res);
}
// -----
-// TODO(jpienaar): re-enable post supporting attributes again.
-// DISABLED_CHECK-LABEL: @fixed_element_types
-//func @fixed_element_types(%arg0: tensor<* x i32>, %arg1: tensor<* x f32>) {
-// %0 = "test.arg_and_res_have_fixed_element_types"(%arg0, %arg1) {attr: splat<tensor<2xi8>, 1>}: (tensor<* x i32>, tensor<* x f32>) -> tensor<* x i32>
-// return
-//}
+// CHECK-LABEL: @fixed_element_types
+func @fixed_element_types(%arg0: tensor<* x i32>, %arg1: tensor<* x f32>) {
+ %0 = "test.arg_and_res_have_fixed_element_types"(%arg0, %arg1) {attr: splat<tensor<2xi8>, 1>}: (tensor<* x i32>, tensor<* x f32>) -> tensor<* x i32>
+ return
+}
// -----
auto &body = method.body();
// Populate substitutions for attributes and named operands and results.
- // TODO(jpienaar): Add attributes back.
+ for (const auto &namedAttr : op.getAttributes())
+ verifyCtx.addSubst(namedAttr.name,
+ formatv("this->getAttr(\"{0}\")", namedAttr.name));
for (int i = 0, e = op.getNumOperands(); i < e; ++i) {
auto &value = op.getOperand(i);
// Skip from from first variadic operands for now. Else getOperand index
if (value.isVariadic())
break;
if (!value.name.empty())
- verifyCtx.addSubst(value.name,
- formatv("this->getOperation()->getOperand({0})", i));
+ verifyCtx.addSubst(
+ value.name, formatv("(*this->getOperation()->getOperand({0}))", i));
}
for (int i = 0, e = op.getNumResults(); i < e; ++i) {
auto &value = op.getResult(i);
break;
if (!value.name.empty())
verifyCtx.addSubst(value.name,
- formatv("this->getOperation()->getResult({0})", i));
+ formatv("(*this->getOperation()->getResult({0}))", i));
}
// Verify the attributes have the correct type.