Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features enabled by examples unexpectedly which impact features in crates directory. #2289

Open
kingwingfly opened this issue Sep 19, 2024 · 0 comments

Comments

@kingwingfly
Copy link
Contributor

kingwingfly commented Sep 19, 2024

Describe the bug
This picture is about code from burn-core/backend.rs

Screenshot from 2024-09-20 00-56-49

As we can see from the editor (Rust Analyzer), the features like tch autodiff and so on are enabled (they are lighter than cuda-jit candle which is not) with [feature] like this in Cargo.toml

[features]
default = [
    "std",
    "burn-candle?/default",
    "burn-common/default",
    "burn-dataset?/default",
    "burn-ndarray?/default",
    "burn-tch?/default",
    "burn-tensor/default",
    "burn-wgpu?/default",
    "burn-cuda?/default",
    "burn-autodiff?/default",
]

We can find features tch autodiff are not enable by default, but they are actually enabled. So do features train std ndarray and fusion...

Actually, they are enabled by examples/text-classification, examples/text-generation and so on.

# examples/text-classification/Cargo.toml
burn = { path = "../../crates/burn", features = [
    "train",
    "ndarray",
    "std",
    "metrics",
    "autotune",
    "fusion",
    "default",
], default-features = false }

Although it likely has no influence on the end users, it may have impact on contributors. For example, with tch feature actually on, contributors who do not care about burn-tch without libtorch configured will be blocked when running cargo clippy.

To Reproduce

(section not need)

Expected behavior

The features enabled in examples do not influence code in crate.

Screenshots
(put before)

Desktop (please complete the following information):
(unrelated)

Smartphone (please complete the following information):
(unrelated)

Additional context

This problem can be solve with required-features, but it's tedious to fix.
Here's an example to fix:
step 1. set required features
step 2. set --features for each example )

I'd like to deal with this flaw, however, I'm not so familar with cargo-xtask. If this is considered worth fixing, I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant