Skip to content

Tensorlist refactor to remove shape input and support empty reserve behavior - #3941

Merged
rsuderman merged 2 commits into
iree-org:mainfrom
rsuderman:test_343373511
Nov 30, 2020
Merged

rsuderman merged 2 commits into
iree-org:mainfrom
rsuderman:test_343373511

Conversation

@rsuderman

Copy link
Copy Markdown
Collaborator

Tensorlist needed a refactor on inputs. To handle support incomplete / unfilled entries for reserve
we need to track tensor information on the tensorlist (shape, element type) and support allocation
when not provided a hal buffer. This was solved by adding type information to the reserve op,
adding allocator attributes to concat and stack.

This included removing unneeded operators from the stack/concat operators.

@google-cla google-cla Bot added the cla: yes label Nov 20, 2020
@rsuderman
rsuderman force-pushed the test_343373511 branch 2 times, most recently from 614ea47 to e59df90 Compare November 20, 2020 20:37
@rsuderman
rsuderman requested a review from silvasean November 20, 2020 20:37
@rsuderman
rsuderman force-pushed the test_343373511 branch 2 times, most recently from 84cf03c to 26607fa Compare November 20, 2020 21:48
TEST_F(TensorListModulesTest, ConcatAppendsEmpty) {
// Allocate the buffer we'll be passing through.
std::vector<float> input = {42.0f};
absl::InlinedVector<int32_t, 4> input_shape = {1};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this cleanup!

// CHECK-LABEL: func @concat
func @concat(%arg0: tensor<?xf32>, %element_shape: tensor<0xi32>, %lead: tensor<i64>) -> (tensor<?xf32>, tensor<0xi64>) {
// CHECK-DAG: [[LIST0:%.+]] = "tf_tensorlist.FromTensor"(%arg0, %arg1)
func @concat(%arg0: tensor<5xf32>, %element_shape: tensor<0xi32>, %lead: tensor<i64>) -> (tensor<5xf32>, tensor<0xi64>) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change ?xf32 to 5xf32?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It let me run both passes in sequence for testing. I will revert back to dynamic.

patterns.insert<
HALOpConversion<tf_tensorlist::Reserve, IREE::TensorList::Reserve>>(
context, typeConverter);
// patterns.insert<

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

.getResult();

Value operand1;
getBufferView(stackOp, stackOp.getOperand(1), newOperands[1], rewriter,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value operand1 = getBufferView(...)? You don't seem to be checking the LogicalResult. You can just return nullptr in case of failure (and actually check it)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@benvanik benvanik added the integrations/tensorflow TensorFlow model import and conversion label Nov 22, 2020
rsuderman and others added 2 commits November 30, 2020 14:11
Shape is a redundant parameter and can be tracked within the tensorlist
structure. Storing on the structure avoids handing the data around needlessly.

PiperOrigin-RevId: 343373511
@rsuderman
rsuderman merged commit 37f0ae8 into iree-org:main Nov 30, 2020
@rsuderman
rsuderman deleted the test_343373511 branch June 2, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrations/tensorflow TensorFlow model import and conversion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants