Skip to content

Commit 53436a1

Browse files
Songhao Jiafacebook-github-bot
authored andcommitted
h to l
Differential Revision: D59877605
1 parent 51c6eb9 commit 53436a1

11 files changed

+45
-0
lines changed

kernels/portable/cpu/op_hardtanh.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Tensor& hardtanh_out(
3636
out,
3737
"Failed to resize output tensor.");
3838

39+
ET_KERNEL_CHECK(
40+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
41+
3942
ScalarType in_type = in.scalar_type();
4043
ScalarType min_type = utils::get_scalar_dtype(min);
4144
ScalarType max_type = utils::get_scalar_dtype(max);

kernels/portable/cpu/op_index.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Tensor& index_Tensor_out(
3232
ET_KERNEL_CHECK(
3333
ctx, check_index_args(in, indices, out), InvalidArgument, out);
3434

35+
ET_KERNEL_CHECK(
36+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
37+
38+
ET_KERNEL_CHECK(ctx, tensor_is_default_dim_order(in), InvalidArgument, out);
39+
3540
ScalarType in_type = in.scalar_type();
3641
size_t block_count = count_index_blocks(indices);
3742

kernels/portable/cpu/op_index_put.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Tensor& index_put_out(
3333
ET_KERNEL_CHECK(
3434
ctx, tensors_have_same_dtype(in, values), InvalidArgument, out);
3535

36+
ET_KERNEL_CHECK(
37+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
38+
39+
ET_KERNEL_CHECK(ctx, tensor_is_default_dim_order(in), InvalidArgument, out);
40+
3641
ScalarType in_type = in.scalar_type();
3742
size_t block_count = count_index_blocks(indices);
3843

kernels/portable/cpu/op_index_select.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Tensor& index_select_out(
2828
ET_KERNEL_CHECK(
2929
ctx, check_index_select_args(in, dim, index, out), InvalidArgument, out);
3030

31+
ET_KERNEL_CHECK(
32+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
33+
34+
ET_KERNEL_CHECK(ctx, tensor_is_default_dim_order(in), InvalidArgument, out);
35+
3136
if (dim < 0) {
3237
dim += nonzero_dim(in);
3338
}

kernels/portable/cpu/op_le.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Tensor& le_tensor_out(
3535
ScalarType b_type = b.scalar_type();
3636
ScalarType out_type = out.scalar_type();
3737

38+
ET_KERNEL_CHECK(
39+
ctx, tensors_have_same_dim_order(a, b, out), InvalidArgument, out);
40+
3841
ET_SWITCH_REAL_TYPES_AND(Bool, a_type, ctx, "le.Tensor_out", CTYPE_A, [&]() {
3942
ET_SWITCH_REAL_TYPES_AND(
4043
Bool, b_type, ctx, "le.Tensor_out", CTYPE_B, [&]() {
@@ -77,6 +80,9 @@ Tensor& le_scalar_out(
7780
out,
7881
"Failed to resize output tensor.");
7982

83+
ET_KERNEL_CHECK(
84+
ctx, tensors_have_same_dim_order(a, out), InvalidArgument, out);
85+
8086
ScalarType a_type = a.scalar_type();
8187
ScalarType b_type = utils::get_scalar_dtype(b);
8288
ScalarType common_type = utils::promote_type_with_scalar(a_type, b);

kernels/portable/cpu/op_leaky_relu.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Tensor& leaky_relu_out(
3535
out,
3636
"Failed to resize output tensor.");
3737

38+
ET_KERNEL_CHECK(
39+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
40+
3841
ScalarType in_type = in.scalar_type();
3942
ScalarType sc_type = utils::get_scalar_dtype(negative_slope);
4043
ScalarType out_type = out.scalar_type();

kernels/portable/cpu/op_lift_fresh_copy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ lift_fresh_copy_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) {
2525
ET_KERNEL_CHECK(
2626
ctx, resize_tensor(out, in.sizes()) == Error::Ok, InvalidArgument, out);
2727

28+
ET_KERNEL_CHECK(
29+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
30+
2831
if (in.nbytes() > 0) {
2932
// Note that this check is important. It's valid for a tensor with numel 0
3033
// to have a null data pointer, but in some environments it's invalid to

kernels/portable/cpu/op_log_softmax.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Tensor& log_softmax_out(
3636
ET_KERNEL_CHECK(
3737
ctx, resize_tensor(out, in.sizes()) == Error::Ok, InvalidArgument, out);
3838

39+
ET_KERNEL_CHECK(
40+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
41+
3942
// Adjust for negative dim
4043
dim = dim < 0 ? dim + nonzero_dim(in) : dim;
4144

kernels/portable/cpu/op_logical_not.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Tensor& logical_not_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) {
2727
out,
2828
"Failed to resize output tensor.");
2929

30+
ET_KERNEL_CHECK(
31+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
32+
3033
ET_KERNEL_CHECK(ctx, tensors_have_same_shape(in, out), InvalidArgument, out);
3134

3235
ET_SWITCH_REAL_TYPES_AND(

kernels/portable/cpu/op_logit.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Tensor& logit_out(
2828
ET_KERNEL_CHECK(
2929
ctx, resize_tensor(out, in.sizes()) == Error::Ok, InvalidArgument, out);
3030

31+
ET_KERNEL_CHECK(
32+
ctx, tensors_have_same_dim_order(in, out), InvalidArgument, out);
33+
3134
ET_KERNEL_CHECK(ctx, tensor_is_floating_type(out), InvalidArgument, out);
3235

3336
ScalarType in_type = in.scalar_type();

kernels/portable/cpu/op_lt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Tensor& lt_tensor_out(
3131
InvalidArgument,
3232
out);
3333

34+
ET_KERNEL_CHECK(
35+
ctx, tensors_have_same_dim_order(a, out), InvalidArgument, out);
36+
3437
ScalarType a_type = a.scalar_type();
3538
ScalarType b_type = b.scalar_type();
3639
ScalarType out_type = out.scalar_type();
@@ -77,6 +80,9 @@ Tensor& lt_scalar_out(
7780
out,
7881
"Failed to resize output tensor.");
7982

83+
ET_KERNEL_CHECK(
84+
ctx, tensors_have_same_dim_order(a, out), InvalidArgument, out);
85+
8086
ScalarType a_type = a.scalar_type();
8187
ScalarType b_type = utils::get_scalar_dtype(b);
8288
ScalarType common_type = utils::promote_type_with_scalar(a_type, b);

0 commit comments

Comments
 (0)