Skip to content

Commit

Permalink
Fix warnings when using record-backward-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
laggui committed Jul 5, 2024
1 parent 1ad2a63 commit 95d060b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/burn-core/src/record/tensor.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use core::marker::PhantomData;

use super::{PrecisionSettings, Record};
use alloc::format;
use burn_tensor::{backend::Backend, Bool, Element, Int, Tensor, TensorData};
use serde::{Deserialize, Serialize};

#[cfg(not(feature = "record-backward-compat"))]
use alloc::format;
#[cfg(feature = "record-backward-compat")]
use burn_tensor::DataSerialize;

/// Versioned serde data deserialization to maintain backward compatibility between formats.
#[cfg(feature = "record-backward-compat")]
#[allow(deprecated)]
#[derive(Serialize, Deserialize)]
#[serde(untagged)]
enum TensorDataSerde<E> {
Expand All @@ -25,7 +27,7 @@ where
{
#[cfg(feature = "record-backward-compat")]
{
let data = match TensorDataSerde::<D, E>::deserialize(deserializer)? {
let data = match TensorDataSerde::<E>::deserialize(deserializer)? {
TensorDataSerde::V1(data) => data.into_tensor_data(),
// NOTE: loading f32 weights with f16 precision will deserialize the f32 weights (bytes) first and then convert to f16
TensorDataSerde::V2(data) => data.convert::<E>(),
Expand Down

0 comments on commit 95d060b

Please sign in to comment.