Skip to content

Commit e1865bf

Browse files
committed
Clarify dim_order format and remove unrelated comments
1 parent de049ef commit e1865bf

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

kernels/test/op__clone_dim_order_test.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,10 @@ class OpDimOrderCloneTest : public OperatorTest {
8787
}
8888
}
8989

90-
/* %python
91-
import torch
92-
torch.manual_seed(0)
93-
x = torch.rand(2, 3)
94-
res = x.clone(memory_format = torch.preserve_format)
95-
op = "op__clone_dim_order_out"
96-
opt_setup_params = """
97-
bool non_blocking = false;
98-
optional<MemoryFormat> memory_format;
99-
"""
100-
opt_extra_params = "non_blocking, memory_format,"
101-
out_args = "out_shape, dynamism"
102-
dtype = "ScalarType::Float"
103-
check = "EXPECT_TENSOR_EQ" */
104-
10590
// Helper for testing dynamic shape outputs.
10691
void test_dynamic_shape(
10792
const std::vector<int32_t>& out_shape,
10893
enum torch::executor::TensorShapeDynamism dynamism) {
109-
/* %python
110-
%rewrite(unary_op) */
111-
11294
TensorFactory<ScalarType::Float> tf;
11395

11496
Tensor x = tf.make(
@@ -197,7 +179,7 @@ TEST_F(OpDimOrderCloneTest, MismatchedSizesDie) {
197179
out));
198180
}
199181

200-
// Cloning with a non-contiguous memory format should fail.
182+
// Cloning with an unsupported memory format should fail.
201183
TEST_F(OpDimOrderCloneTest, MismatchedMemoryFormatDies) {
202184
if (torch::executor::testing::SupportedFeatures::get()->is_aten) {
203185
GTEST_SKIP()
@@ -266,7 +248,7 @@ TEST_F(OpDimOrderCloneTest, DynamicShapeUpperBoundLargerThanExpected) {
266248

267249
TEST_F(OpDimOrderCloneTest, DynamicShapeUnbound) {
268250
if (!torch::executor::testing::SupportedFeatures::get()->output_resize) {
269-
GTEST_SKIP() << "Dynamic shape unbound not supported.";
251+
GTEST_SKIP() << "Skipping: Dynamic shape unbound not supported.";
270252
}
271253
test_dynamic_shape(
272254
{1, 1}, torch::executor::TensorShapeDynamism::DYNAMIC_UNBOUND);
@@ -275,6 +257,8 @@ TEST_F(OpDimOrderCloneTest, DynamicShapeUnbound) {
275257
TEST_F(OpDimOrderCloneTest, ContiguousToChannelsLast) {
276258
TensorFactory<ScalarType::Float> tf;
277259

260+
// x is in contiguous dim order {0, 1, 2, 3}.
261+
// make_with_dimorder() defaults to contiguous when dim_order isn't specified.
278262
Tensor x = tf.make_with_dimorder(
279263
{3, 5, 2, 2},
280264
{0.2432, 0.5248, 0.5361, 0.8513, 0.8184, 0.8206, 0.7357, 0.9655, 0.6138,
@@ -311,6 +295,8 @@ TEST_F(OpDimOrderCloneTest, ChannelsLastToContiguous) {
311295
TensorFactory<ScalarType::Float> tf;
312296

313297
Tensor out = tf.full({3, 5, 2, 2}, 0.0);
298+
299+
// x is in channels_last dim order {0, 2, 3, 1}.
314300
Tensor x = tf.make_with_dimorder(
315301
{3, 5, 2, 2},
316302
{0.2432, 0.8184, 0.6138, 0.9680, 0.2257, 0.5248, 0.8206, 0.1112, 0.2548,

0 commit comments

Comments
 (0)