add autotune api in config.py

This commit is contained in:
liu-yongqi-63 2021-12-02 17:39:38 +08:00
parent 22f4909784
commit f9eb4fba8b
5 changed files with 10 additions and 9 deletions

View File

@ -340,7 +340,7 @@ Status Dct(std::shared_ptr<Tensor> *output, int n_mfcc, int n_mels, NormMode nor
TensorShape dct_shape({n_mels, n_mfcc});
Tensor::CreateEmpty(dct_shape, DataType(DataType::DE_FLOAT32), output);
auto iter = (*output)->begin<float>();
float sqrt_2 = 1 / sqrt(2);
const float sqrt_2 = 1 / sqrt(2);
float sqrt_2_n_mels = sqrt(2.0 / n_mels);
for (int i = 0; i < n_mels; i++) {
for (int j = 0; j < n_mfcc; j++) {
@ -886,7 +886,7 @@ Status ComputeCmnStartAndEnd(int32_t cmn_window, int32_t min_cmn_window, bool ce
RETURN_IF_NOT_OK(ValidateNonNegative("SlidingWindowCmn", "cmn_window", cmn_window));
RETURN_IF_NOT_OK(ValidateNonNegative("SlidingWindowCmn", "min_cmn_window", min_cmn_window));
int32_t cmn_window_start = 0, cmn_window_end = 0;
constexpr int window_center = 2;
const constexpr int window_center = 2;
if (center) {
cmn_window_start = idx - cmn_window / window_center;
cmn_window_end = cmn_window_start + cmn_window;
@ -1023,8 +1023,8 @@ Status SlidingWindowCmnHelper(const std::shared_ptr<Tensor> &input, std::shared_
*r_it = num_frames;
RETURN_IF_NOT_OK(cmn_waveform->Reshape(TensorShape(re_shape)));
constexpr int specify_input_shape = 2;
constexpr int specify_first_shape = 1;
const constexpr int specify_input_shape = 2;
const constexpr int specify_first_shape = 1;
if (input_shape.size() == specify_input_shape && cmn_waveform->shape()[0] == specify_first_shape) {
cmn_waveform->Squeeze();
}

View File

@ -63,7 +63,7 @@ Status RiaaBiquadOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_p
float b_im = b1 * sin(-w0) + b2 * sin(-2 * w0);
float a_im = a1 * sin(-w0) + a2 * sin(-2 * w0);
// temp is the intermediate variable used to solve for b0, b1, b2.
float temp = 1 / sqrt((b_re * b_re + b_im * b_im) / (a_re * a_re + a_im * a_im));
const float temp = 1 / sqrt((b_re * b_re + b_im * b_im) / (a_re * a_re + a_im * a_im));
b0 *= temp;
b1 *= temp;
b2 *= temp;

View File

@ -37,7 +37,7 @@ Status TrebleBiquadOp::Compute(const std::shared_ptr<Tensor> &input, std::shared
float attenuation = exp(gain_ / 40 * log(10));
// temp1, temp2, temp3 are the intermediate variable used to solve for a and b.
float temp1 = 2 * sqrt(attenuation) * alpha;
const float temp1 = 2 * sqrt(attenuation) * alpha;
float temp2 = (attenuation - 1) * cos(w0);
float temp3 = (attenuation + 1) * cos(w0);

View File

@ -111,7 +111,7 @@ void Tracing::Record(const int32_t type, const int32_t extra_info, const int32_t
(void)records_.emplace_back(record);
(void)value_.emplace_back(record.ToString());
// save timestamp per batch
constexpr int32_t RECORDS_PER_STEP = 4;
const constexpr int32_t RECORDS_PER_STEP = 4;
if (records_.size() % RECORDS_PER_STEP == 0) {
(void)ts_.emplace_back(time_stamp);
}
@ -158,7 +158,7 @@ Status Tracing::StepIntervalForTimeRange(uint64_t start_ts, uint64_t end_ts, int
Status Tracing::GetRecordEntryFieldValue(int32_t start_step, int32_t end_step, int32_t record_offset,
const std::string &field, std::vector<int32_t> *result) {
std::lock_guard<std::mutex> guard(lock_);
constexpr int32_t RECORDS_PER_STEP = 4;
const constexpr int32_t RECORDS_PER_STEP = 4;
auto total_steps = records_.size() / RECORDS_PER_STEP;
MS_LOG(DEBUG) << "start_step: " << start_step << " end_step: " << end_step;
CHECK_FAIL_RETURN_UNEXPECTED(start_step <= total_steps,

View File

@ -33,7 +33,8 @@ __all__ = ['set_seed', 'get_seed', 'set_prefetch_size', 'get_prefetch_size', 'se
'get_num_parallel_workers', 'set_numa_enable', 'get_numa_enable', 'set_monitor_sampling_interval',
'get_monitor_sampling_interval', 'set_callback_timeout', 'get_callback_timeout',
'set_auto_num_workers', 'get_auto_num_workers', 'set_enable_shared_mem', 'get_enable_shared_mem',
'set_sending_batches', 'load', '_init_device_info']
'set_sending_batches', 'load', '_init_device_info', 'set_enable_autotune', 'get_enable_autotune',
'set_autotune_interval', 'get_autotune_interval']
INT32_MAX = 2147483647
UINT32_MAX = 4294967295