tensorflow/compiler/mlir/tensorflow/ir/tf_ops.cc
void ConstOp::build(OpBuilder &builder, OperationState &result,
                    Attribute value) {
  ShapedType type;
  if (auto elem_attr = value.dyn_cast<ElementsAttr>()) {
    return ConstOp::build(builder, result, elem_attr);
  } else if (value.isa<BoolAttr>() || value.isa<FloatAttr>() ||
             value.isa<IntegerAttr>()) {
    // All TensorFlow types must be tensor types. In the build() method,
    // we want to provide more flexibility by allowing attributes of scalar
    // types. But we need to wrap it up with ElementsAttr to construct
    // valid TensorFlow constants.
    type = RankedTensorType::get(/*shape=*/{}, value.getType());
    return ConstOp::build(builder, result, DenseElementsAttr::get(type, value));
  }
  // TODO(jpienaar): support other TensorFlow specific types.
  llvm_unreachable("unsupported attribute type for building tf.Const");
}
// Builds a constant op with the specified attribute `value`. The result
// op's type is deduced from `value`; if `value` is of scalar type,
// wraps it up with a tensor type of empty shape.
// TODO(jpienaar): This one differs from the autogenerated one as it takes an
// attribute but always creates an ElementsAttr internally.
Builds a constant op with the specified attribute `value`. The result
op's type is deduced from `value`; if `value` is of scalar type,
wraps it up with a tensor type of empty shape.
TODO(jpienaar): This one differs from the autogenerated one as it takes an
attribute but always creates an ElementsAttr internally.
Builds a constant op with the specified attribute ` value ` . The result op ' s type is deduced from ` value ` ; if ` value ` is of scalar type wraps it up with a tensor type of empty shape . TODO ( jpienaar ) : This one differs from the autogenerated one as it takes an attribute but always creates an ElementsAttr internally .
void ConstOp::build(OpBuilder &builder, OperationState &result,
                    Attribute value) {
  ShapedType type;
  if (auto elem_attr = value.dyn_cast<ElementsAttr>()) {
    return ConstOp::build(builder, result, elem_attr);
  } else if (value.isa<BoolAttr>() || value.isa<FloatAttr>() ||
             value.isa<IntegerAttr>()) {
    type = RankedTensorType::get({}, value.getType());
    return ConstOp::build(builder, result, DenseElementsAttr::get(type, value));
  }
  llvm_unreachable("unsupported attribute type for building tf.Const");
}
void ConstOp :: build ( OpBuilder & builder , OperationState & result , Attribute value ) { ShapedType type ; if ( auto elem_attr = value . dyn_cast < ElementsAttr > ( ) ) { return ConstOp :: build ( builder , result , elem_attr ) ; } else if ( value . isa < BoolAttr > ( ) || value . isa < FloatAttr > ( ) || value . isa < IntegerAttr > ( ) ) { type = RankedTensorType :: get ( { } , value . getType ( ) ) ; return ConstOp :: build ( builder , result , DenseElementsAttr :: get ( type , value ) ) ; } llvm_unreachable ( " " ) ; }
Builds a constant op with the specified attribute `value`.
Builds a constant op with the specified attribute ` value ` .
// All TensorFlow types must be tensor types. In the build() method, // we want to provide more flexibility by allowing attributes of scalar // types. But we need to wrap it up with ElementsAttr to construct // valid TensorFlow constants. /*shape=*/ // TODO(jpienaar): support other TensorFlow specific types.