Skip to content

fix et-view #2843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions kernels/prim_ops/et_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,7 @@ void et_view(RuntimeContext& context, EValue** stack) {
// Do some checks
ET_CHECK(self.numel() == out.numel());

// If out has a data_ptr, it must match self
// We hit this path for memory-planned tensors
if (out.const_data_ptr() != nullptr) {
ET_CHECK_MSG(
self.const_data_ptr() == out.const_data_ptr(),
"out has a non-null data_ptr, but it does not equal self's data_ptr.");

// nothing else to do
return;
}

// out.const_data_ptr() == nullptr now
// Update data ptr
ET_CHECK_MSG(
internal::set_tensor_data(
out,
Expand Down
8 changes: 3 additions & 5 deletions kernels/prim_ops/test/prim_ops_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,13 @@ TEST_F(RegisterPrimOpsTest, TestETView) {
EValue(good_outs[0]), EValue(good_outs[1])};

// bad outs expect death
constexpr int N_BAD_OUTS = 3;
constexpr int N_BAD_OUTS = 2;
Tensor bad_outs[N_BAD_OUTS] = {
tf.ones({1, 3, 2, 1}), // wrong rank
tf.ones({1, 3, 3}), // wrong size
tf.ones({1, 3, 2}) // occupied data_ptr
tf.ones({1, 3, 3}) // wrong size
};
EValue bad_out_evalues[N_BAD_OUTS] = {
EValue(bad_outs[0]), EValue(bad_outs[1]), EValue(bad_outs[2])};
EValue(bad_outs[0]), EValue(bad_outs[1])};

// ***************************************************************************
// Run tests
Expand All @@ -349,7 +348,6 @@ TEST_F(RegisterPrimOpsTest, TestETView) {
// Bad out stacks
{&self_evalue, &size_int_list_evalue, &bad_out_evalues[0]},
{&self_evalue, &size_int_list_evalue, &bad_out_evalues[1]},
{&self_evalue, &size_int_list_evalue, &bad_out_evalues[2]},
// Bad size stacks
{&self_evalue, &bad_size_int_list_evalue1, &good_out_evalues[0]},
{&self_evalue, &bad_size_int_list_evalue2, &good_out_evalues[0]}};
Expand Down