#burn #contracts #tensor #contract

burn-contracts

Fluent Contracts for the Burn library

3 unstable releases

new 0.2.1 Mar 25, 2025
0.2.0 Mar 24, 2025
0.1.0 Mar 5, 2025

#391 in Testing

Download history 143/week @ 2025-03-04 6/week @ 2025-03-11

149 downloads per month

MIT license

37KB
204 lines

Fluent Api for Burn Contract and Test Assertions

This crate provides a fluent api for contract and test assertions for the Burn framework.

use burn_contracts::assert_tensor;

let tensor: Tensor<B, 4> = Tensor::new(&[10, 3, 32, 17]);
assert_tensor(&tensor)
    .has_named_dims([('N', 10), ('C', 3), ('H', 32), ('W', 32)]);
// Panics:
// "Expected tensor to have dimensions [('N', 10), ('C', 3), ('H', 32), ('W', 32)] but got [(10, 3, 32, 17)]"

Testing API

The "testing" feature enables the testing api; which provides expensive methods for testing tensor contents.

To ensure that the testing api is not used in production, the testing api is only available when the "testing" feature is enabled.

To enable the "testing" feature only for testing, add the following to your Cargo.toml:

[dependencies]
burn-contracts = $VERSION

[dev-dependencies]
burn-contracts = { version = $VERSION, features = ["testing"] }

Dependencies

~70–105MB
~2M SLoC