MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / build

Method build

tensorflow/compiler/mlir/tensorflow/ir/tf_ops.cc:849–866  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

847// op's type is deduced from `value`; if `value` is of scalar type,
848// wraps it up with a tensor type of empty shape.
849void ConstOp::build(Builder *builder, OperationState &result, Attribute value) {
850 ShapedType type;
851 if (auto elemAttr = value.dyn_cast<ElementsAttr>()) {
852 type = elemAttr.getType();
853 } else if (value.isa<BoolAttr>() || value.isa<FloatAttr>() ||
854 value.isa<IntegerAttr>()) {
855 // All TensorFlow types must be tensor types. In the build() method,
856 // we want to provide more flexibility by allowing attributes of scalar
857 // types. But we need to wrap it up with ElementsAttr to construct
858 // valid TensorFlow constants.
859 type = RankedTensorType::get(/*shape=*/{}, value.getType());
860 value = DenseElementsAttr::get(type, value);
861 }
862 // TODO: support other TensorFlow specific types.
863 assert(type && "unsupported attribute type for building tf.Const");
864 result.types.push_back(type);
865 result.addAttribute("value", value);
866}
867
868void ConstOp::build(Builder *builder, OperationState &result, Type type,
869 Attribute value) {

Callers

nothing calls this directly

Calls 15

buildFunction · 0.85
DeduceEqualCmpOpTypeFunction · 0.85
InferExpandDimsOpTypeFunction · 0.85
InferReductionOpTypeFunction · 0.85
InferOneHotOpTypeFunction · 0.85
IsUnknownDimOrRankFunction · 0.85
InferSelectV2OpTypeFunction · 0.85
getFunction · 0.50
getTypeMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected