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

Function BuildConstRangeTensor

tensorflow/compiler/mlir/lite/ir/tfl_ops.cc:1531–1549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1529// mlir::FloatAttr.
1530template <typename FloatOrIntAtrr>
1531DenseElementsAttr BuildConstRangeTensor(Type result_elem_type, int num_elements,
1532 FloatOrIntAtrr start_attr,
1533 FloatOrIntAtrr delta_attr) {
1534 using ValueType = typename FloatOrIntAtrr::ValueType; // APInt or APFloat
1535 ValueType start = start_attr.getValue();
1536 ValueType delta = delta_attr.getValue();
1537
1538 SmallVector<ValueType, 16> new_values;
1539 new_values.reserve(num_elements);
1540 ValueType new_value = start;
1541 for (int i = 0; i < num_elements; ++i) {
1542 new_values.push_back(new_value);
1543 new_value = new_value + delta;
1544 }
1545 // Result is always a 1-D tensor.
1546 auto new_result_type =
1547 RankedTensorType::get({num_elements}, result_elem_type);
1548 return DenseElementsAttr::get(new_result_type, new_values);
1549}
1550} // namespace
1551
1552OpFoldResult RangeOp::fold(ArrayRef<Attribute> operands) {

Callers 1

foldMethod · 0.85

Calls 3

getFunction · 0.50
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected