Skip to content
Merged
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
8 changes: 8 additions & 0 deletions R/op-pad.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ infer_types_pad <- function(
) {
assert_vts_are_tensors(operand, padding_value)

# (I2): padding_value must be a 0-dimensional tensor.
if (length(shape(padding_value)) != 0L) {
cli_abort(c(
"{.arg padding_value} must be a 0-dimensional tensor.",
x = "Got shape {shapevec_repr(shape(padding_value))}."
))
}

# (C1)
assert_vts_have_same_dtype(operand, padding_value)

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/_snaps/op-pad.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@
! edge_padding_low must have length equal to operand rank
x length(edge_padding_low): 1, operand_rank: 2

---

Code
infer_types_pad(operand, padding_value, edge_padding_low = cnst(low, "i64",
length(low)), edge_padding_high = cnst(high, "i64", length(high)),
interior_padding = cnst(interior, "i64", length(interior)))
Condition
Error in `infer_types_pad()`:
! `padding_value` must be a 0-dimensional tensor.
x Got shape (2).

8 changes: 8 additions & 0 deletions tests/testthat/test-op-pad.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ test_that("errors", {
)
# (C2) wrong length
check(vt("f32", c(2L, 3L)), vt("f32", integer()), c(0L), c(0L, 0L), c(0L, 0L))
# (I2) padding_value must be a 0-dimensional tensor
check(
vt("f32", c(2L, 3L)),
vt("f32", 2L),
c(0L, 0L),
c(0L, 0L),
c(0L, 0L)
)
})
Loading