Skip to content

Commit

Permalink
test: zero out first input for custom-ops tests
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Dec 21, 2024
1 parent cf447cf commit 4d16d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion examples/custom-ops/examples/custom-ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ fn main() -> ort::Result<()> {
.commit_from_file("tests/data/custom_op_test.onnx")?;

let allocator = session.allocator();
let value1 = Tensor::<f32>::new(allocator, [3, 5])?;
let mut value1 = Tensor::<f32>::new(allocator, [3, 5])?;
{
let (_, data) = value1.extract_raw_tensor_mut();
for datum in data {
*datum = 0.;
}
}
let mut value2 = Tensor::<f32>::new(allocator, [3, 5])?;
{
let (_, data) = value2.extract_raw_tensor_mut();
Expand Down
8 changes: 7 additions & 1 deletion src/operator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ fn test_custom_ops() -> crate::Result<()> {
.commit_from_file("tests/data/custom_op_test.onnx")?;

let allocator = session.allocator();
let value1 = Tensor::<f32>::new(allocator, [3, 5])?;
let mut value1 = Tensor::<f32>::new(allocator, [3, 5])?;
{
let (_, data) = value1.extract_raw_tensor_mut();
for datum in data {
*datum = 0.;
}
}
let mut value2 = Tensor::<f32>::new(allocator, [3, 5])?;
{
let (_, data) = value2.extract_raw_tensor_mut();
Expand Down

0 comments on commit 4d16d60

Please sign in to comment.