@@ -40,10 +40,8 @@ FlowMatchEulerDiscreteScheduler::FlowMatchEulerDiscreteScheduler(const Config& s
40
40
int32_t num_train_timesteps = m_config.num_train_timesteps ;
41
41
float shift = m_config.shift ;
42
42
43
- auto linspaced = linspace<float >(1 .0f , static_cast <float >(num_train_timesteps), num_train_timesteps, true );
44
- for (auto it = linspaced.rbegin (); it != linspaced.rend (); ++it) {
45
- m_timesteps.push_back (*it);
46
- }
43
+ m_timesteps = linspace<float >(1 .0f , static_cast <float >(num_train_timesteps), num_train_timesteps, true );
44
+ std::reverse (m_timesteps.begin (), m_timesteps.end ());
47
45
48
46
std::transform (m_timesteps.begin (),
49
47
m_timesteps.end (),
@@ -66,7 +64,7 @@ FlowMatchEulerDiscreteScheduler::FlowMatchEulerDiscreteScheduler(const Config& s
66
64
m_sigma_max = m_sigmas[0 ], m_sigma_min = m_sigmas.back ();
67
65
}
68
66
69
- float FlowMatchEulerDiscreteScheduler::sigma_to_t (float sigma) {
67
+ double FlowMatchEulerDiscreteScheduler::sigma_to_t (double sigma) {
70
68
return sigma * m_config.num_train_timesteps ;
71
69
}
72
70
@@ -79,20 +77,24 @@ void FlowMatchEulerDiscreteScheduler::set_timesteps(size_t num_inference_steps,
79
77
float shift = m_config.shift ;
80
78
81
79
using numpy_utils::linspace;
82
- m_timesteps = linspace<float >(sigma_to_t (m_sigma_max), sigma_to_t (m_sigma_min), m_num_inference_steps, true );
80
+ std::vector< double > timesteps = linspace<double >(sigma_to_t (m_sigma_max), sigma_to_t (m_sigma_min), m_num_inference_steps, true );
83
81
84
- for (const float & i : m_timesteps) {
85
- m_sigmas.push_back (i / num_train_timesteps);
82
+ std::vector<double > sigmas (timesteps.size ());
83
+ for (size_t i = 0 ; i < sigmas.size (); ++i) {
84
+ sigmas[i] = timesteps[i] / num_train_timesteps;
86
85
}
87
86
88
87
OPENVINO_ASSERT (!m_config.use_dynamic_shifting ,
89
88
" Parameter 'use_dynamic_shifting' is not supported. Please, add support." );
90
89
91
- for (size_t i = 0 ; i < m_sigmas.size (); ++i) {
92
- m_sigmas[i] = shift * m_sigmas[i] / (1 + (shift - 1 ) * m_sigmas[i]);
90
+ m_sigmas.resize (sigmas.size ());
91
+ m_timesteps.resize (sigmas.size ());
92
+
93
+ for (size_t i = 0 ; i < sigmas.size (); ++i) {
94
+ m_sigmas[i] = shift * sigmas[i] / (1.0 + (shift - 1.0 ) * sigmas[i]);
93
95
m_timesteps[i] = m_sigmas[i] * num_train_timesteps;
94
96
}
95
- m_sigmas.push_back (0 );
97
+ m_sigmas.push_back (0 . 0f );
96
98
97
99
m_step_index = -1 , m_begin_index = -1 ;
98
100
}
@@ -102,8 +104,8 @@ std::map<std::string, ov::Tensor> FlowMatchEulerDiscreteScheduler::step(ov::Tens
102
104
// latents - sample
103
105
// inference_step
104
106
105
- float * model_output_data = noise_pred.data <float >();
106
- float * sample_data = latents.data <float >();
107
+ const float * model_output_data = noise_pred.data <const float >();
108
+ const float * sample_data = latents.data <const float >();
107
109
108
110
if (m_step_index == -1 )
109
111
init_step_index ();
0 commit comments