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

Fixed Clippy warnings #309

Merged
merged 3 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fixed Clippy warnings (3)
  • Loading branch information
guillaume-be committed Dec 21, 2022
commit af91b72c8fb68b6d785263c007bad02579daf484
2 changes: 1 addition & 1 deletion examples/natural_language_inference_deberta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() -> anyhow::Result<()> {
false,
)?;
let config = DebertaConfig::from_file(config_path);
let model = DebertaForSequenceClassification::new(&vs.root(), &config);
let model = DebertaForSequenceClassification::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down
10 changes: 5 additions & 5 deletions tests/albert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn albert_masked_lm() -> anyhow::Result<()> {
let tokenizer: AlbertTokenizer =
AlbertTokenizer::from_file(vocab_path.to_str().unwrap(), true, false)?;
let config = AlbertConfig::from_file(config_path);
let albert_model = AlbertForMaskedLM::new(&vs.root(), &config);
let albert_model = AlbertForMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -109,7 +109,7 @@ fn albert_for_sequence_classification() -> anyhow::Result<()> {
config.id2label = Some(dummy_label_mapping);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let albert_model = AlbertForSequenceClassification::new(&vs.root(), &config);
let albert_model = AlbertForSequenceClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -170,7 +170,7 @@ fn albert_for_multiple_choice() -> anyhow::Result<()> {
let mut config = AlbertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let albert_model = AlbertForMultipleChoice::new(&vs.root(), &config);
let albert_model = AlbertForMultipleChoice::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -242,7 +242,7 @@ fn albert_for_token_classification() -> anyhow::Result<()> {
config.id2label = Some(dummy_label_mapping);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let albert_model = AlbertForTokenClassification::new(&vs.root(), &config);
let albert_model = AlbertForTokenClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -303,7 +303,7 @@ fn albert_for_question_answering() -> anyhow::Result<()> {
let mut config = AlbertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let albert_model = AlbertForQuestionAnswering::new(&vs.root(), &config);
let albert_model = AlbertForQuestionAnswering::new(vs.root(), &config);

// Define input
let input = [
Expand Down
10 changes: 5 additions & 5 deletions tests/bert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn bert_masked_lm() -> anyhow::Result<()> {
let tokenizer: BertTokenizer =
BertTokenizer::from_file(vocab_path.to_str().unwrap(), true, true)?;
let config = BertConfig::from_file(config_path);
let bert_model = BertForMaskedLM::new(&vs.root(), &config);
let bert_model = BertForMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -162,7 +162,7 @@ fn bert_for_sequence_classification() -> anyhow::Result<()> {
config.id2label = Some(dummy_label_mapping);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let bert_model = BertForSequenceClassification::new(&vs.root(), &config);
let bert_model = BertForSequenceClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -219,7 +219,7 @@ fn bert_for_multiple_choice() -> anyhow::Result<()> {
let mut config = BertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let bert_model = BertForMultipleChoice::new(&vs.root(), &config);
let bert_model = BertForMultipleChoice::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -283,7 +283,7 @@ fn bert_for_token_classification() -> anyhow::Result<()> {
config.id2label = Some(dummy_label_mapping);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let bert_model = BertForTokenClassification::new(&vs.root(), &config);
let bert_model = BertForTokenClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -340,7 +340,7 @@ fn bert_for_question_answering() -> anyhow::Result<()> {
let mut config = BertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let bert_model = BertForQuestionAnswering::new(&vs.root(), &config);
let bert_model = BertForQuestionAnswering::new(vs.root(), &config);

// Define input
let input = [
Expand Down
8 changes: 4 additions & 4 deletions tests/deberta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn deberta_natural_language_inference() -> anyhow::Result<()> {
false,
)?;
let config = DebertaConfig::from_file(config_path);
let model = DebertaForSequenceClassification::new(&vs.root(), &config);
let model = DebertaForSequenceClassification::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -96,7 +96,7 @@ fn deberta_masked_lm() -> anyhow::Result<()> {
let mut config = DebertaConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let deberta_model = DebertaForMaskedLM::new(&vs.root(), &config);
let deberta_model = DebertaForMaskedLM::new(vs.root(), &config);

// Generate random input
let input_tensor = Tensor::randint(42, &[32, 128], (Kind::Int64, device));
Expand Down Expand Up @@ -170,7 +170,7 @@ fn deberta_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(2, String::from("PER"));
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
let model = DebertaForTokenClassification::new(&vs.root(), &config);
let model = DebertaForTokenClassification::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "In Kentucky, United States"];
Expand Down Expand Up @@ -225,7 +225,7 @@ fn deberta_for_question_answering() -> anyhow::Result<()> {
false,
)?;
let config = DebertaConfig::from_file(config_path);
let model = DebertaForQuestionAnswering::new(&vs.root(), &config);
let model = DebertaForQuestionAnswering::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "Paris is in In Kentucky, United States"];
Expand Down
8 changes: 4 additions & 4 deletions tests/deberta_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn deberta_v2_masked_lm() -> anyhow::Result<()> {
let mut config = DebertaV2Config::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let deberta_model = DebertaV2ForMaskedLM::new(&vs.root(), &config);
let deberta_model = DebertaV2ForMaskedLM::new(vs.root(), &config);

// Generate random input
let input_tensor = Tensor::randint(42, &[32, 128], (Kind::Int64, device));
Expand Down Expand Up @@ -88,7 +88,7 @@ fn deberta_v2_for_sequence_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(1, String::from("Neutral"));
dummy_label_mapping.insert(2, String::from("Negative"));
config.id2label = Some(dummy_label_mapping);
let model = DebertaV2ForSequenceClassification::new(&vs.root(), &config);
let model = DebertaV2ForSequenceClassification::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "In Kentucky, United States"];
Expand Down Expand Up @@ -142,7 +142,7 @@ fn deberta_v2_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(2, String::from("PER"));
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
let model = DebertaV2ForTokenClassification::new(&vs.root(), &config);
let model = DebertaV2ForTokenClassification::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "In Kentucky, United States"];
Expand Down Expand Up @@ -190,7 +190,7 @@ fn deberta_v2_for_question_answering() -> anyhow::Result<()> {
let tokenizer =
DeBERTaV2Tokenizer::from_file(vocab_path.to_str().unwrap(), false, false, false)?;
let config = DebertaV2Config::from_file(config_path);
let model = DebertaV2ForQuestionAnswering::new(&vs.root(), &config);
let model = DebertaV2ForQuestionAnswering::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "Paris is in In Kentucky, United States"];
Expand Down
6 changes: 3 additions & 3 deletions tests/distilbert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn distilbert_masked_lm() -> anyhow::Result<()> {
let tokenizer: BertTokenizer =
BertTokenizer::from_file(vocab_path.to_str().unwrap(), true, true)?;
let config = DistilBertConfig::from_file(config_path);
let distil_bert_model = DistilBertModelMaskedLM::new(&vs.root(), &config);
let distil_bert_model = DistilBertModelMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -140,7 +140,7 @@ fn distilbert_for_question_answering() -> anyhow::Result<()> {
let mut config = DistilBertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let distil_bert_model = DistilBertForQuestionAnswering::new(&vs.root(), &config);
let distil_bert_model = DistilBertForQuestionAnswering::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -211,7 +211,7 @@ fn distilbert_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(2, String::from("PER"));
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
let distil_bert_model = DistilBertForTokenClassification::new(&vs.root(), &config);
let distil_bert_model = DistilBertForTokenClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down
2 changes: 1 addition & 1 deletion tests/distilgpt2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn distilgpt2_lm_model() -> anyhow::Result<()> {
false,
)?;
let config = Gpt2Config::from_file(config_path);
let gpt2_model = GPT2LMHeadModel::new(&vs.root(), &config);
let gpt2_model = GPT2LMHeadModel::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down
4 changes: 2 additions & 2 deletions tests/electra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn electra_masked_lm() -> anyhow::Result<()> {
let mut config = ElectraConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let electra_model = ElectraForMaskedLM::new(&vs.root(), &config);
let electra_model = ElectraForMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -114,7 +114,7 @@ fn electra_discriminator() -> anyhow::Result<()> {
let tokenizer: BertTokenizer =
BertTokenizer::from_file(vocab_path.to_str().unwrap(), true, true)?;
let config = ElectraConfig::from_file(config_path);
let electra_model = ElectraDiscriminator::new(&vs.root(), &config);
let electra_model = ElectraDiscriminator::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down
8 changes: 4 additions & 4 deletions tests/fnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn fnet_masked_lm() -> anyhow::Result<()> {
let tokenizer: FNetTokenizer =
FNetTokenizer::from_file(vocab_path.to_str().unwrap(), false, false)?;
let config = FNetConfig::from_file(config_path);
let fnet_model = FNetForMaskedLM::new(&vs.root(), &config);
let fnet_model = FNetForMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -138,7 +138,7 @@ fn fnet_for_multiple_choice() -> anyhow::Result<()> {
let mut config = FNetConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let fnet_model = FNetForMultipleChoice::new(&vs.root(), &config);
let fnet_model = FNetForMultipleChoice::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -201,7 +201,7 @@ fn fnet_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
config.output_hidden_states = Some(true);
let fnet_model = FNetForTokenClassification::new(&vs.root(), &config);
let fnet_model = FNetForTokenClassification::new(vs.root(), &config);

// Define input
let input = [
Expand Down Expand Up @@ -256,7 +256,7 @@ fn fnet_for_question_answering() -> anyhow::Result<()> {
FNetTokenizer::from_file(vocab_path.to_str().unwrap(), false, false)?;
let mut config = FNetConfig::from_file(config_path);
config.output_hidden_states = Some(true);
let fnet_model = FNetForQuestionAnswering::new(&vs.root(), &config);
let fnet_model = FNetForQuestionAnswering::new(vs.root(), &config);

// Define input
let input = [
Expand Down
2 changes: 1 addition & 1 deletion tests/gpt2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn gpt2_lm_model() -> anyhow::Result<()> {
false,
)?;
let config = Gpt2Config::from_file(config_path);
let gpt2_model = GPT2LMHeadModel::new(&vs.root(), &config);
let gpt2_model = GPT2LMHeadModel::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down
2 changes: 1 addition & 1 deletion tests/gpt_neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn gpt_neo_lm() -> anyhow::Result<()> {
let mut config = GptNeoConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let gpt_neo_model = GptNeoForCausalLM::new(&vs.root(), &config)?;
let gpt_neo_model = GptNeoForCausalLM::new(vs.root(), &config)?;
vs.load(weights_path)?;

// Define input
Expand Down
6 changes: 3 additions & 3 deletions tests/longformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn longformer_for_sequence_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(1, String::from("Negative"));
dummy_label_mapping.insert(3, String::from("Neutral"));
config.id2label = Some(dummy_label_mapping);
let model = LongformerForSequenceClassification::new(&vs.root(), &config);
let model = LongformerForSequenceClassification::new(vs.root(), &config);

// Define input
let input = ["Very positive sentence", "Second sentence input"];
Expand Down Expand Up @@ -258,7 +258,7 @@ fn longformer_for_multiple_choice() -> anyhow::Result<()> {
false,
)?;
let config = LongformerConfig::from_file(config_path);
let model = LongformerForMultipleChoice::new(&vs.root(), &config);
let model = LongformerForMultipleChoice::new(vs.root(), &config);

// Define input
let prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.";
Expand Down Expand Up @@ -337,7 +337,7 @@ fn longformer_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(2, String::from("PER"));
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
let model = LongformerForTokenClassification::new(&vs.root(), &config);
let model = LongformerForTokenClassification::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "In Kentucky, United States"];
Expand Down
10 changes: 5 additions & 5 deletions tests/mobilebert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn mobilebert_masked_model() -> anyhow::Result<()> {
let mut config = MobileBertConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let mobilebert_model = MobileBertForMaskedLM::new(&vs.root(), &config);
let mobilebert_model = MobileBertForMaskedLM::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down Expand Up @@ -130,7 +130,7 @@ fn mobilebert_for_sequence_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(1, String::from("Negative"));
dummy_label_mapping.insert(3, String::from("Neutral"));
config.id2label = Some(dummy_label_mapping);
let model = MobileBertForSequenceClassification::new(&vs.root(), &config);
let model = MobileBertForSequenceClassification::new(vs.root(), &config);

// Define input
let input = ["Very positive sentence", "Second sentence input"];
Expand Down Expand Up @@ -176,7 +176,7 @@ fn mobilebert_for_multiple_choice() -> anyhow::Result<()> {
let vs = nn::VarStore::new(device);
let tokenizer = BertTokenizer::from_file(vocab_path.to_str().unwrap(), true, true)?;
let config = MobileBertConfig::from_file(config_path);
let model = MobileBertForMultipleChoice::new(&vs.root(), &config);
let model = MobileBertForMultipleChoice::new(vs.root(), &config);

// Define input
let prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced.";
Expand Down Expand Up @@ -240,7 +240,7 @@ fn mobilebert_for_token_classification() -> anyhow::Result<()> {
dummy_label_mapping.insert(2, String::from("PER"));
dummy_label_mapping.insert(3, String::from("ORG"));
config.id2label = Some(dummy_label_mapping);
let model = MobileBertForTokenClassification::new(&vs.root(), &config);
let model = MobileBertForTokenClassification::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "In Kentucky, United States"];
Expand Down Expand Up @@ -287,7 +287,7 @@ fn mobilebert_for_question_answering() -> anyhow::Result<()> {
let vs = nn::VarStore::new(device);
let tokenizer = BertTokenizer::from_file(vocab_path.to_str().unwrap(), true, true)?;
let config = MobileBertConfig::from_file(config_path);
let model = MobileBertForQuestionAnswering::new(&vs.root(), &config);
let model = MobileBertForQuestionAnswering::new(vs.root(), &config);

// Define input
let inputs = ["Where's Paris?", "Paris is in In Kentucky, United States"];
Expand Down
2 changes: 1 addition & 1 deletion tests/openai_gpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn openai_gpt_lm_model() -> anyhow::Result<()> {
true,
)?;
let config = OpenAiGptConfig::from_file(config_path);
let openai_gpt = OpenAIGPTLMHeadModel::new(&vs.root(), &config);
let openai_gpt = OpenAIGPTLMHeadModel::new(vs.root(), &config);
vs.load(weights_path)?;

// Define input
Expand Down
4 changes: 2 additions & 2 deletions tests/reformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn reformer_for_sequence_classification() -> anyhow::Result<()> {
config.id2label = Some(dummy_label_mapping);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let reformer_model = ReformerForSequenceClassification::new(&vs.root(), &config)?;
let reformer_model = ReformerForSequenceClassification::new(vs.root(), &config)?;

// Define input
let input = [
Expand Down Expand Up @@ -159,7 +159,7 @@ fn reformer_for_question_answering() -> anyhow::Result<()> {
let mut config = ReformerConfig::from_file(config_path);
config.output_attentions = Some(true);
config.output_hidden_states = Some(true);
let reformer_model = ReformerForQuestionAnswering::new(&vs.root(), &config)?;
let reformer_model = ReformerForQuestionAnswering::new(vs.root(), &config)?;

// Define input
let input = [
Expand Down
Loading