diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75651b690..26a47c478 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,10 +29,10 @@ jobs: cp -r docs/_build/html/* public/en/ mkdir public/m2met2 touch public/m2met2/.nojekyll - cp -r docs_m2met2/_build/html/* public/m2met2/ + cp -r docs/m2met2/_build/html/* public/m2met2/ mkdir public/m2met2_cn touch public/m2met2_cn/.nojekyll - cp -r docs_m2met2_cn/_build/html/* public/m2met2_cn/ + cp -r docs/m2met2_cn/_build/html/* public/m2met2_cn/ - name: deploy github.io pages if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev_wjm' || github.ref == 'refs/heads/dev_lyh' diff --git a/README.md b/README.md index 48b5ccdf8..665f42592 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,12 @@ | [**Runtime**](https://github.com/alibaba-damo-academy/FunASR/tree/main/funasr/runtime) | [**Model Zoo**](https://github.com/alibaba-damo-academy/FunASR/blob/main/docs/modelscope_models.md) | [**Contact**](#contact) -| -[**M2MET2.0 Guidence_CN**](https://alibaba-damo-academy.github.io/FunASR/m2met2_cn/index.html) -| [**M2MET2.0 Guidence_EN**](https://alibaba-damo-academy.github.io/FunASR/m2met2/index.html) +| [**M2MET2.0 Challenge**](https://github.com/alibaba-damo-academy/FunASR#multi-channel-multi-party-meeting-transcription-20-m2met20-challenge) -## Multi-Channel Multi-Party Meeting Transcription 2.0 (M2MET2.0) Challenge -We are pleased to announce that the M2MeT2.0 challenge will be held in the near future. The baseline system is conducted on FunASR and is provided as a receipe of AliMeeting corpus. For more details you can see the guidence of M2MET2.0 ([CN](https://alibaba-damo-academy.github.io/FunASR/m2met2_cn/index.html)/[EN](https://alibaba-damo-academy.github.io/FunASR/m2met2/index.html)). ## What's new: - +### Multi-Channel Multi-Party Meeting Transcription 2.0 (M2MET2.0) Challenge +We are pleased to announce that the M2MeT2.0 challenge will be held in the near future. The baseline system is conducted on FunASR and is provided as a receipe of AliMeeting corpus. For more details you can see the guidence of M2MET2.0 ([CN](https://alibaba-damo-academy.github.io/FunASR/m2met2_cn/index.html)/[EN](https://alibaba-damo-academy.github.io/FunASR/m2met2/index.html)). +### Release notes For the release notes, please ref to [news](https://github.com/alibaba-damo-academy/FunASR/releases) ## Highlights diff --git a/docs_m2met2/Baseline.md b/docs/m2met2/Baseline.md similarity index 100% rename from docs_m2met2/Baseline.md rename to docs/m2met2/Baseline.md diff --git a/docs_m2met2/Contact.md b/docs/m2met2/Contact.md similarity index 100% rename from docs_m2met2/Contact.md rename to docs/m2met2/Contact.md diff --git a/docs_m2met2/Dataset.md b/docs/m2met2/Dataset.md similarity index 92% rename from docs_m2met2/Dataset.md rename to docs/m2met2/Dataset.md index c987acac9..a897d673b 100644 --- a/docs_m2met2/Dataset.md +++ b/docs/m2met2/Dataset.md @@ -2,7 +2,7 @@ ## Overview of training data In the fixed training condition, the training dataset is restricted to three publicly available corpora, namely, AliMeeting, AISHELL-4, and CN-Celeb. To evaluate the performance of the models trained on these datasets, we will release a new Test set called Test-2023 for scoring and ranking. We will describe the AliMeeting dataset and the Test-2023 set in detail. ## Detail of AliMeeting corpus -AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train and Eval sets contain 212 and 8 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train and Eval sets is 456 and 25, respectively, with balanced gender coverage. +AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train, Eval and Test sets contain 212, 8 and 20 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train, Eval and Test sets is 456, 25 and 60, respectively, with balanced gender coverage. The dataset is collected in 13 meeting venues, which are categorized into three types: small, medium, and large rooms with sizes ranging from 8 m$^{2}$ to 55 m$^{2}$. Different rooms give us a variety of acoustic properties and layouts. The detailed parameters of each meeting venue will be released together with the Train data. The type of wall material of the meeting venues covers cement, glass, etc. Other furnishings in meeting venues include sofa, TV, blackboard, fan, air conditioner, plants, etc. During recording, the participants of the meeting sit around the microphone array which is placed on the table and conduct a natural conversation. The microphone-speaker distance ranges from 0.3 m to 5.0 m. All participants are native Chinese speakers speaking Mandarin without strong accents. During the meeting, various kinds of indoor noise including but not limited to clicking, keyboard, door opening/closing, fan, bubble noise, etc., are made naturally. For both Train and Eval sets, the participants are required to remain in the same position during recording. There is no speaker overlap between the Train and Eval set. An example of the recording venue from the Train set is shown in Fig 1. diff --git a/docs_m2met2/Introduction.md b/docs/m2met2/Introduction.md similarity index 82% rename from docs_m2met2/Introduction.md rename to docs/m2met2/Introduction.md index e1f9fc792..eac9eb6b5 100644 --- a/docs_m2met2/Introduction.md +++ b/docs/m2met2/Introduction.md @@ -9,17 +9,20 @@ The ICASSP2022 M2MeT challenge focuses on meeting scenarios, and it comprises tw Building on the success of the previous M2MeT challenge, we are excited to propose the M2MeT2.0 challenge as an ASRU2023 challenge special session. In the original M2MeT challenge, the evaluation metric was speaker-independent, which meant that the transcription could be determined, but not the corresponding speaker. To address this limitation and further advance the current multi-talker ASR system towards practicality, the M2MeT2.0 challenge proposes the speaker-attributed ASR task with two sub-tracks: fixed and open training conditions. The speaker-attribute automatic speech recognition (ASR) task aims to tackle the practical and challenging problem of identifying "who spoke what at when". To facilitate reproducible research in this field, we offer a comprehensive overview of the dataset, rules, evaluation metrics, and baseline systems. Furthermore, we will release a carefully curated test set, comprising approximately 10 hours of audio, according to the timeline. The new test set is designed to enable researchers to validate and compare their models' performance and advance the state of the art in this area. ## Timeline(AOE Time) - -- $ May~5^{th}, 2023: $ Registration deadline, the due date for participants to join the Challenge. -- $ June~9^{th}, 2023: $ Test data release. -- $ June~13^{rd}, 2023: $ Final submission deadline. -- $ June~19^{th}, 2023: $ Evaluation result and ranking release. -- $ July~3^{rd}, 2023: $ Deadline for paper submission. -- $ July~10^{th}, 2023: $ Deadline for final paper submission. -- $ December~12^{nd}\ to\ 16^{th}, 2023: $ ASRU Workshop +- $ April~29, 2023: $ Challenge and registration open. +- $ May~8, 2023: $ Baseline release. +- $ May~15, 2023: $ Registration deadline, the due date for participants to join the Challenge. +- $ June~9, 2023: $ Test data release and leaderboard open. +- $ June~13, 2023: $ Final submission deadline. +- $ June~19, 2023: $ Evaluation result and ranking release. +- $ July~3, 2023: $ Deadline for paper submission. +- $ July~10, 2023: $ Deadline for final paper submission. +- $ December~12\ to\ 16, 2023: $ ASRU Workshop and challenge session ## Guidelines -Interested participants, whether from academia or industry, must register for the challenge by completing a Google form, which will be available here. The deadline for registration is May 5, 2023. +Interested participants, whether from academia or industry, must register for the challenge by completing the Google form below. The deadline for registration is May 15, 2023. + +[M2MET2.0 Registration](https://docs.google.com/forms/d/e/1FAIpQLSf77T9vAl7Ym-u5g8gXu18SBofoWRaFShBo26Ym0-HDxHW9PQ/viewform?usp=sf_link) Within three working days, the challenge organizer will send email invitations to eligible teams to participate in the challenge. All qualified teams are required to adhere to the challenge rules, which will be published on the challenge page. Prior to the ranking release time, each participant must submit a system description document detailing their approach and methods. The organizer will select the top three submissions to be included in the ASRU2023 Proceedings. diff --git a/docs_m2met2/Makefile b/docs/m2met2/Makefile similarity index 100% rename from docs_m2met2/Makefile rename to docs/m2met2/Makefile diff --git a/docs_m2met2/Organizers.md b/docs/m2met2/Organizers.md similarity index 100% rename from docs_m2met2/Organizers.md rename to docs/m2met2/Organizers.md diff --git a/docs_m2met2/Rules.md b/docs/m2met2/Rules.md similarity index 92% rename from docs_m2met2/Rules.md rename to docs/m2met2/Rules.md index 8bc1a1900..340c2f50d 100644 --- a/docs_m2met2/Rules.md +++ b/docs/m2met2/Rules.md @@ -4,8 +4,6 @@ All participants should adhere to the following rules to be eligible for the cha - Data augmentation is allowed on the original training dataset, including, but not limited to, adding noise or reverberation, speed perturbation and tone change. - Participants are permitted to use the Eval set for model training, but it is not allowed to use the Test set for this purpose. Instead, the Test set should only be utilized for parameter tuning and model selection. Any use of the Test-2023 dataset that violates these rules is strictly prohibited, including but not limited to the use of the Test set for fine-tuning or training the model. - -- Multi-system fusion is allowed, but the systems with same structure and different parameters is not encouraged. - If the cpCER of the two systems on the Test dataset are the same, the system with lower computation complexity will be judged as the superior one. diff --git a/docs_m2met2/Track_setting_and_evaluation.md b/docs/m2met2/Track_setting_and_evaluation.md similarity index 95% rename from docs_m2met2/Track_setting_and_evaluation.md rename to docs/m2met2/Track_setting_and_evaluation.md index b90c17af1..2b75fcac5 100644 --- a/docs_m2met2/Track_setting_and_evaluation.md +++ b/docs/m2met2/Track_setting_and_evaluation.md @@ -1,6 +1,6 @@ # Track & Evaluation -## Speaker-Attributed ASR (Main Track) -The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It's worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps. Instead, segments containing multiple speakers will be provided on the Test-2023 set, which can be obtained using a simple voice activity detection (VAD) model. +## Speaker-Attributed ASR +The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It's worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps of the Test-2023 set. Instead, segments containing multiple speakers will be provided, which can be obtained using a simple voice activity detection (VAD) model. ![task difference](images/task_diff.png) diff --git a/docs_m2met2/_build/doctrees/Baseline.doctree b/docs/m2met2/_build/doctrees/Baseline.doctree similarity index 50% rename from docs_m2met2/_build/doctrees/Baseline.doctree rename to docs/m2met2/_build/doctrees/Baseline.doctree index c30687bab..9fc7c50bc 100644 Binary files a/docs_m2met2/_build/doctrees/Baseline.doctree and b/docs/m2met2/_build/doctrees/Baseline.doctree differ diff --git a/docs_m2met2/_build/doctrees/Contact.doctree b/docs/m2met2/_build/doctrees/Contact.doctree similarity index 62% rename from docs_m2met2/_build/doctrees/Contact.doctree rename to docs/m2met2/_build/doctrees/Contact.doctree index bed2f74c5..e3f579ff5 100644 Binary files a/docs_m2met2/_build/doctrees/Contact.doctree and b/docs/m2met2/_build/doctrees/Contact.doctree differ diff --git a/docs_m2met2/_build/doctrees/Dataset.doctree b/docs/m2met2/_build/doctrees/Dataset.doctree similarity index 63% rename from docs_m2met2/_build/doctrees/Dataset.doctree rename to docs/m2met2/_build/doctrees/Dataset.doctree index 841452cfb..47c8bb491 100644 Binary files a/docs_m2met2/_build/doctrees/Dataset.doctree and b/docs/m2met2/_build/doctrees/Dataset.doctree differ diff --git a/docs/m2met2/_build/doctrees/Introduction.doctree b/docs/m2met2/_build/doctrees/Introduction.doctree new file mode 100644 index 000000000..84f1baaa6 Binary files /dev/null and b/docs/m2met2/_build/doctrees/Introduction.doctree differ diff --git a/docs/m2met2/_build/doctrees/Organizers.doctree b/docs/m2met2/_build/doctrees/Organizers.doctree new file mode 100644 index 000000000..0f571a3b7 Binary files /dev/null and b/docs/m2met2/_build/doctrees/Organizers.doctree differ diff --git a/docs/m2met2/_build/doctrees/Rules.doctree b/docs/m2met2/_build/doctrees/Rules.doctree new file mode 100644 index 000000000..5b7655f68 Binary files /dev/null and b/docs/m2met2/_build/doctrees/Rules.doctree differ diff --git a/docs_m2met2/_build/doctrees/Track_setting_and_evaluation.doctree b/docs/m2met2/_build/doctrees/Track_setting_and_evaluation.doctree similarity index 76% rename from docs_m2met2/_build/doctrees/Track_setting_and_evaluation.doctree rename to docs/m2met2/_build/doctrees/Track_setting_and_evaluation.doctree index 12d3c2bc1..8770fba7c 100644 Binary files a/docs_m2met2/_build/doctrees/Track_setting_and_evaluation.doctree and b/docs/m2met2/_build/doctrees/Track_setting_and_evaluation.doctree differ diff --git a/docs_m2met2/_build/doctrees/environment.pickle b/docs/m2met2/_build/doctrees/environment.pickle similarity index 71% rename from docs_m2met2/_build/doctrees/environment.pickle rename to docs/m2met2/_build/doctrees/environment.pickle index 57b88c870..ea9c740c1 100644 Binary files a/docs_m2met2/_build/doctrees/environment.pickle and b/docs/m2met2/_build/doctrees/environment.pickle differ diff --git a/docs/m2met2/_build/doctrees/index.doctree b/docs/m2met2/_build/doctrees/index.doctree new file mode 100644 index 000000000..f40d4fe78 Binary files /dev/null and b/docs/m2met2/_build/doctrees/index.doctree differ diff --git a/docs_m2met2/_build/html/.buildinfo b/docs/m2met2/_build/html/.buildinfo similarity index 100% rename from docs_m2met2/_build/html/.buildinfo rename to docs/m2met2/_build/html/.buildinfo diff --git a/docs_m2met2/_build/html/Baseline.html b/docs/m2met2/_build/html/Baseline.html similarity index 97% rename from docs_m2met2/_build/html/Baseline.html rename to docs/m2met2/_build/html/Baseline.html index 282f23529..e52d32275 100644 --- a/docs_m2met2/_build/html/Baseline.html +++ b/docs/m2met2/_build/html/Baseline.html @@ -88,7 +88,7 @@
  • Track & Evaluation @@ -135,8 +135,8 @@

    Baseline results

    -

    The results of the baseline system are shown in Table 3. The speaker profile adopts the oracle speaker embedding during training. However, due to the lack of oracle speaker label during evaluation, the speaker profile provided by an additional spectral clustering is used. Meanwhile, the results of using the oracle speaker profile on Eval and Test Set are also provided to show the impact of speaker profile accuracy. -baseline result

    +

    The results of the baseline system are shown in Table 3. The speaker profile adopts the oracle speaker embedding during training. However, due to the lack of oracle speaker label during evaluation, the speaker profile provided by an additional spectral clustering is used. Meanwhile, the results of using the oracle speaker profile on Eval and Test Set are also provided to show the impact of speaker profile accuracy.

    +

    baseline result

    diff --git a/docs_m2met2/_build/html/Contact.html b/docs/m2met2/_build/html/Contact.html similarity index 98% rename from docs_m2met2/_build/html/Contact.html rename to docs/m2met2/_build/html/Contact.html index 44546d590..eafd2d5b8 100644 --- a/docs_m2met2/_build/html/Contact.html +++ b/docs/m2met2/_build/html/Contact.html @@ -84,7 +84,7 @@
  • Track & Evaluation diff --git a/docs_m2met2/_build/html/Dataset.html b/docs/m2met2/_build/html/Dataset.html similarity index 96% rename from docs_m2met2/_build/html/Dataset.html rename to docs/m2met2/_build/html/Dataset.html index 88531f6d0..43bf8a121 100644 --- a/docs_m2met2/_build/html/Dataset.html +++ b/docs/m2met2/_build/html/Dataset.html @@ -89,7 +89,7 @@
  • Track & Evaluation @@ -131,7 +131,7 @@

    Detail of AliMeeting corpus

    -

    AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train and Eval sets contain 212 and 8 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train and Eval sets is 456 and 25, respectively, with balanced gender coverage.

    +

    AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train, Eval and Test sets contain 212, 8 and 20 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train, Eval and Test sets is 456, 25 and 60, respectively, with balanced gender coverage.

    The dataset is collected in 13 meeting venues, which are categorized into three types: small, medium, and large rooms with sizes ranging from 8 m\(^{2}\) to 55 m\(^{2}\). Different rooms give us a variety of acoustic properties and layouts. The detailed parameters of each meeting venue will be released together with the Train data. The type of wall material of the meeting venues covers cement, glass, etc. Other furnishings in meeting venues include sofa, TV, blackboard, fan, air conditioner, plants, etc. During recording, the participants of the meeting sit around the microphone array which is placed on the table and conduct a natural conversation. The microphone-speaker distance ranges from 0.3 m to 5.0 m. All participants are native Chinese speakers speaking Mandarin without strong accents. During the meeting, various kinds of indoor noise including but not limited to clicking, keyboard, door opening/closing, fan, bubble noise, etc., are made naturally. For both Train and Eval sets, the participants are required to remain in the same position during recording. There is no speaker overlap between the Train and Eval set. An example of the recording venue from the Train set is shown in Fig 1.

    meeting room

    The number of participants within one meeting session ranges from 2 to 4. To ensure the coverage of different overlap ratios, we select various meeting topics during recording, including medical treatment, education, business, organization management, industrial production and other daily routine meetings. The average speech overlap ratio of Train, Eval and Test sets are 42.27%, 34.76% and 42.8%, respectively. More details of AliMeeting are shown in Table 1. A detailed overlap ratio distribution of meeting sessions with different numbers of speakers in the Train, Eval and Test set is shown in Table 2.

    diff --git a/docs_m2met2/_build/html/Introduction.html b/docs/m2met2/_build/html/Introduction.html similarity index 76% rename from docs_m2met2/_build/html/Introduction.html rename to docs/m2met2/_build/html/Introduction.html index 54de72d3e..2ddafe22c 100644 --- a/docs_m2met2/_build/html/Introduction.html +++ b/docs/m2met2/_build/html/Introduction.html @@ -89,7 +89,7 @@
  • Track & Evaluation @@ -128,26 +128,28 @@

    Call for participation

    Automatic speech recognition (ASR) and speaker diarization have made significant strides in recent years, resulting in a surge of speech technology applications across various domains. However, meetings present unique challenges to speech technologies due to their complex acoustic conditions and diverse speaking styles, including overlapping speech, variable numbers of speakers, far-field signals in large conference rooms, and environmental noise and reverberation.

    -

    Over the years, several challenges have been organized to advance the development of meeting transcription, including the Rich Transcription evaluation and Computational Hearing in Multisource Environments (CHIME) challenges. The latest iteration of the CHIME challenge has a particular focus on distant automatic speech recognition (ASR) and developing systems that can generalize across various array topologies and application scenarios. However, while progress has been made in English meeting transcription, language differences remain a significant barrier to achieving comparable results in non-English languages, such as Mandarin.

    -

    The Multimodal Information Based Speech Processing (MISP) and Multi-Channel Multi-Party Meeting Transcription (M2MeT) challenges have been instrumental in advancing Mandarin meeting transcription. The MISP challenge seeks to address the problem of audio-visual distant multi-microphone signal processing in everyday home environments, while the M2MeT challenge focuses on tackling the speech overlap issue in offline meeting rooms.

    -

    The ICASSP2022 M2MeT challenge focuses on meeting scenarios, and it comprises two main tasks: speaker diarization and multi-speaker automatic speech recognition (ASR). The former involves identifying who spoke when in the meeting, while the latter aims to transcribe speech from multiple speakers simultaneously, which poses significant technical difficulties due to overlapping speech and acoustic interferences.

    -

    Building on the success of the previous M2MeT challenge, we are excited to propose the M2MeT2.0 challenge as an ASRU2023 challenge special session. In the original M2MeT challenge, the evaluation metric was speaker-independent, which meant that the transcription could be determined, but not the corresponding speaker. To address this limitation and further advance the current multi-talker ASR system towards practicality, the M2MeT2.0 challenge proposes the speaker-attributed ASR task with two sub-tracks: fixed and open training conditions. By attributing speech to specific speakers, this task aims to improve the accuracy and applicability of multi-talker ASR systems in real-world settings. The challenge provides detailed datasets, rules, evaluation methods, and baseline systems to facilitate reproducible research in this field. The speaker-attribute automatic speech recognition (ASR) task aims to tackle the practical and challenging problem of identifying “who spoke what at when”. To facilitate reproducible research in this field, we offer a comprehensive overview of the dataset, rules, evaluation metrics, and baseline systems. Furthermore, we will release a carefully curated test set, comprising approximately 10 hours of audio, according to the timeline. The new test set is designed to enable researchers to validate and compare their models’ performance and advance the state of the art in this area.

    +

    Over the years, several challenges have been organized to advance the development of meeting transcription, including the Rich Transcription evaluation and Computational Hearing in Multisource Environments (CHIME) challenges. The latest iteration of the CHIME challenge has a particular focus on distant automatic speech recognition and developing systems that can generalize across various array topologies and application scenarios. However, while progress has been made in English meeting transcription, language differences remain a significant barrier to achieving comparable results in non-English languages, such as Mandarin. The Multimodal Information Based Speech Processing (MISP) and Multi-Channel Multi-Party Meeting Transcription (M2MeT) challenges have been instrumental in advancing Mandarin meeting transcription. The MISP challenge seeks to address the problem of audio-visual distant multi-microphone signal processing in everyday home environments, while the M2MeT challenge focuses on tackling the speech overlap issue in offline meeting rooms.

    +

    The ICASSP2022 M2MeT challenge focuses on meeting scenarios, and it comprises two main tasks: speaker diarization and multi-speaker automatic speech recognition. The former involves identifying who spoke when in the meeting, while the latter aims to transcribe speech from multiple speakers simultaneously, which poses significant technical difficulties due to overlapping speech and acoustic interferences.

    +

    Building on the success of the previous M2MeT challenge, we are excited to propose the M2MeT2.0 challenge as an ASRU2023 challenge special session. In the original M2MeT challenge, the evaluation metric was speaker-independent, which meant that the transcription could be determined, but not the corresponding speaker. To address this limitation and further advance the current multi-talker ASR system towards practicality, the M2MeT2.0 challenge proposes the speaker-attributed ASR task with two sub-tracks: fixed and open training conditions. The speaker-attribute automatic speech recognition (ASR) task aims to tackle the practical and challenging problem of identifying “who spoke what at when”. To facilitate reproducible research in this field, we offer a comprehensive overview of the dataset, rules, evaluation metrics, and baseline systems. Furthermore, we will release a carefully curated test set, comprising approximately 10 hours of audio, according to the timeline. The new test set is designed to enable researchers to validate and compare their models’ performance and advance the state of the art in this area.

    Timeline(AOE Time)

    Guidelines

    -

    Possible improved version: Interested participants, whether from academia or industry, must register for the challenge by completing a Google form, which will be available here. The deadline for registration is May 5, 2023.

    +

    Interested participants, whether from academia or industry, must register for the challenge by completing the Google form below. The deadline for registration is May 15, 2023.

    +

    M2MET2.0 Registration

    Within three working days, the challenge organizer will send email invitations to eligible teams to participate in the challenge. All qualified teams are required to adhere to the challenge rules, which will be published on the challenge page. Prior to the ranking release time, each participant must submit a system description document detailing their approach and methods. The organizer will select the top three submissions to be included in the ASRU2023 Proceedings.

    diff --git a/docs_m2met2/_build/html/Organizers.html b/docs/m2met2/_build/html/Organizers.html similarity index 61% rename from docs_m2met2/_build/html/Organizers.html rename to docs/m2met2/_build/html/Organizers.html index e5bb748aa..0a8811e78 100644 --- a/docs_m2met2/_build/html/Organizers.html +++ b/docs/m2met2/_build/html/Organizers.html @@ -88,7 +88,7 @@
  • Track & Evaluation @@ -127,36 +127,27 @@

    Lei Xie, Professor, Northwestern Polytechnical University, China

    Email: lxie@nwpu.edu.cn

    lxie -

    Lei Xie received the Ph.D. degree in computer science from Northwestern Polytechnical University, Xi’an, China, in 2004. From 2001 to 2002, he was with the Department of Electronics and Information Processing, Vrije Universiteit Brussel (VUB), Brussels, Belgium, as a Visiting Scientist. From 2004 to 2006, he was a Senior Research Associate with the Center for Media Technology, School of Creative Media, City University of Hong Kong, Hong Kong, China. From 2006 to 2007, he was a Postdoctoral Fellow with the Human-Computer Communications Laboratory (HCCL), The Chinese University of Hong Kong, Hong Kong, China. He is currently a Professor with School of Computer Science, Northwestern Polytechnical University, Xian, China and leads the Audio, Speech and Language Processing Group (ASLP@NPU). He has published over 200 papers in referred journals and conferences, such as IEEE/ACM Transactions on Audio, Speech and Language Processing, IEEE Transactions on Multimedia, Interspeech, ICASSP, ASRU, ACL and ACM Multimedia. He has achieved several best paper awards in flagship conferences. His current research interests include general topics in speech and language processing, multimedia, and human-computer interaction. Dr. Xie is currently an associate editor (AE) of IEEE/ACM Trans. on Audio, Speech and language Processing. He has actively served as Chairs in many conferences and technical committees. He serves as an IEEE Speech and Language Processing -Technical Committee Member.

    Kong Aik Lee, Senior Scientist at Institute for Infocomm Research, A*Star, Singapore

    Email: kongaik.lee@ieee.org

    kong -

    Kong Aik Lee started off him career as a researcher, then a team leader and a strategic planning manager, at the Institute Infocomm Research, A*STAR, Singapore, working on speaker and language recognition research. From 2018 to 2020, he spent two and a half years in NEC Corporation, Japan, focusing very much on voice biometrics and multi-modal biometrics products. He is proud to work with a great team on voice biometrics featured on NEC Bio-Idiom platform. He returned to Singapore in July 2020, and now leading the speech and audio analytics research at the Institute for Infocomm Research, as a Senior Scientist and PI. He also serve as an Editor for Elsevier Computer Speech and Language (since 2016), and was an Associate Editor for IEEE/ACM Transactions on Audio, Speech and Language Processing (2017 - 2021), and am an elected member of IEEE Speech and Language Technical Committee (2019 - 2021).

    Zhijie Yan, Principal Engineer at Alibaba, China Email: zhijie.yzj@alibaba-inc.com

    zhijie -

    Zhijie Yan holds a PhD from the University of Science and Technology of China, and is a senior member of the Institute of Electrical and Electronics Engineers (IEEE). He is also an expert reviewer of top academic conferences and journals in the speech field. His research fields include speech recognition, speech synthesis, voiceprints, and speech interaction. His research results are applied in speech services provided by Alibaba Group and Ant Financial. He was awarded the title of “One of the Top 100 Grassroots Scientists” by the China Association for Science and Technology.

    Shiliang Zhang, Senior Engineer at Alibaba, China Email: sly.zsl@alibaba-inc.com

    zsl -

    Shiliang Zhang graduated with a Ph.D. from the University of Science and Technology of China in 2017. His research areas mainly include speech recognition, natural language understanding, and machine learning. Currently, he has published over 40 papers in mainstream academic journals and conferences in the fields of speech and machine learning, and has applied for dozens of patents. After obtaining his doctorate degree, he joined the Alibaba Intelligent Speech team. He is currently leading the direction of speech recognition and fundamental technology at DAMO Academy’s speech laboratory.

    Yanmin Qian, Professor, Shanghai Jiao Tong University, China

    Email: yanminqian@sjtu.edu.cn

    qian -

    Yanmin Qian received the B.S. degree from the Department of Electronic and Information Engineering,Huazhong University of Science and Technology, Wuhan, China, in 2007, and the Ph.D. degree from the Department of Electronic Engineering, Tsinghua University, Beijing, China, in 2012. Since 2013, he has been with the Department of Computer Science and Engineering, Shanghai Jiao Tong University (SJTU), Shanghai, China, where he is currently an Associate Professor. From 2015 to 2016, he also worked as an Associate Research in the Speech Group, Cambridge University Engineering Department, Cambridge, U.K. He is a senior member of IEEE and a member of ISCA, and one of the founding members of Kaldi Speech Recognition Toolkit. He has published more than 110 papers on speech and language processing with 4000+ citations, including the top conference: ICASSP, INTERSPEECH and ASRU. His current research interests include the acoustic and language modeling in speech recognition, speaker and language recognition, key word spotting, and multimedia signal processing.

    Zhuo Chen, Applied Scientist in Microsoft, USA

    Email: zhuc@microsoft.com

    chenzhuo -

    Zhuo Chen received the Ph.D. degree from Columbia University, New York, NY, USA, in 2017. He is currently a Principal Applied Data Scientist with Microsoft. He has authored or coauthored more than 80 papers in peer-reviewed journals and conferences with around 6000 citations. He is a reviewer or technical committee member for more than ten journals and conferences. His research interests include automatic conversation recognition, speech separation, diarisation, and speaker information extraction. He actively participated in the academic events and challenges, and won several awards. Meanwhile, he contributed to open-sourced datasets, such as WSJ0-2mix, LibriCSS, and AISHELL-4, that have been main benchmark datasets for multi-speaker processing research. In 2020, he was the Team Leader in 2020 Jelinek workshop, leading more than 30 researchers and students to push the state of the art in conversation transcription.

    Jian Wu, Applied Scientist in Microsoft, USA

    Email: wujian@microsoft.com

    wujian -

    Jian Wu received a master degree from Northwestern Polytechnical University, Xi’an, China, in 2020 and currently he is a Applied Scientist in Microsoft, USA. His research interests cover multi-channel signal processing, robust and multi-talker speech recognition, speech enhancement, dereverberation and separation. He has around 30 conference publications with a total citation over 1200. He participated in several challenges such as CHiME5, DNS 2020 and FFSVC 2020 and contributed to the open-sourced datasets including LibriCSS and AISHELL-4. He is also a reviewer for several journals and conferences such as ICASSP, SLT, TASLP and SPL.

    Hui Bu, CEO, AISHELL foundation, China

    Email: buhui@aishelldata.com

    buhui -

    Hui Bu received his master degree in the Artificial Intelligence Laboratory of Korea University in 2014. He is the founder and the CEO of AISHELL and AISHELL foundation. He participated in the release of AISHELL 1 & 2 & 3 & 4, DMASH and HI-MIA open source database project and is the co-founder of China Kaldi offline Technology Forum.

    diff --git a/docs_m2met2/_build/html/Rules.html b/docs/m2met2/_build/html/Rules.html similarity index 97% rename from docs_m2met2/_build/html/Rules.html rename to docs/m2met2/_build/html/Rules.html index 3d2bddebe..59651158a 100644 --- a/docs_m2met2/_build/html/Rules.html +++ b/docs/m2met2/_build/html/Rules.html @@ -88,7 +88,7 @@
  • Track & Evaluation @@ -128,7 +128,6 @@
  • Track & Evaluation @@ -125,9 +125,9 @@

    Track & Evaluation

    -
    -

    Speaker-Attributed ASR (Main Track)

    -

    The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It’s worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps. Instead, segments containing multiple speakers will be provided on the Test-2023 set, which can be obtained using a simple voice activity detection (VAD) model.

    +
    +

    Speaker-Attributed ASR

    +

    The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It’s worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps of the Test-2023 set. Instead, segments containing multiple speakers will be provided, which can be obtained using a simple voice activity detection (VAD) model.

    task difference

    diff --git a/docs_m2met2/_build/html/_images/baseline_result.png b/docs/m2met2/_build/html/_images/baseline_result.png similarity index 100% rename from docs_m2met2/_build/html/_images/baseline_result.png rename to docs/m2met2/_build/html/_images/baseline_result.png diff --git a/docs_m2met2/_build/html/_images/buhui.jpeg b/docs/m2met2/_build/html/_images/buhui.jpeg similarity index 100% rename from docs_m2met2/_build/html/_images/buhui.jpeg rename to docs/m2met2/_build/html/_images/buhui.jpeg diff --git a/docs_m2met2/_build/html/_images/chenzhuo.jpg b/docs/m2met2/_build/html/_images/chenzhuo.jpg similarity index 100% rename from docs_m2met2/_build/html/_images/chenzhuo.jpg rename to docs/m2met2/_build/html/_images/chenzhuo.jpg diff --git a/docs_m2met2/_build/html/_images/dataset_details.png b/docs/m2met2/_build/html/_images/dataset_details.png similarity index 100% rename from docs_m2met2/_build/html/_images/dataset_details.png rename to docs/m2met2/_build/html/_images/dataset_details.png diff --git a/docs_m2met2/_build/html/_images/kong.png b/docs/m2met2/_build/html/_images/kong.png similarity index 100% rename from docs_m2met2/_build/html/_images/kong.png rename to docs/m2met2/_build/html/_images/kong.png diff --git a/docs_m2met2/_build/html/_images/lxie.jpeg b/docs/m2met2/_build/html/_images/lxie.jpeg similarity index 100% rename from docs_m2met2/_build/html/_images/lxie.jpeg rename to docs/m2met2/_build/html/_images/lxie.jpeg diff --git a/docs_m2met2/_build/html/_images/meeting_room.png b/docs/m2met2/_build/html/_images/meeting_room.png similarity index 100% rename from docs_m2met2/_build/html/_images/meeting_room.png rename to docs/m2met2/_build/html/_images/meeting_room.png diff --git a/docs_m2met2/_build/html/_images/qian.jpeg b/docs/m2met2/_build/html/_images/qian.jpeg similarity index 100% rename from docs_m2met2/_build/html/_images/qian.jpeg rename to docs/m2met2/_build/html/_images/qian.jpeg diff --git a/docs_m2met2/images/sa_asr_arch.png b/docs/m2met2/_build/html/_images/sa_asr_arch.png similarity index 100% rename from docs_m2met2/images/sa_asr_arch.png rename to docs/m2met2/_build/html/_images/sa_asr_arch.png diff --git a/docs_m2met2/_build/html/_images/task_diff.png b/docs/m2met2/_build/html/_images/task_diff.png similarity index 100% rename from docs_m2met2/_build/html/_images/task_diff.png rename to docs/m2met2/_build/html/_images/task_diff.png diff --git a/docs_m2met2/_build/html/_images/wujian.jpg b/docs/m2met2/_build/html/_images/wujian.jpg similarity index 100% rename from docs_m2met2/_build/html/_images/wujian.jpg rename to docs/m2met2/_build/html/_images/wujian.jpg diff --git a/docs_m2met2/_build/html/_images/zhijie.jpg b/docs/m2met2/_build/html/_images/zhijie.jpg similarity index 100% rename from docs_m2met2/_build/html/_images/zhijie.jpg rename to docs/m2met2/_build/html/_images/zhijie.jpg diff --git a/docs_m2met2/_build/html/_images/zsl.JPG b/docs/m2met2/_build/html/_images/zsl.JPG similarity index 100% rename from docs_m2met2/_build/html/_images/zsl.JPG rename to docs/m2met2/_build/html/_images/zsl.JPG diff --git a/docs_m2met2/_build/html/_sources/Baseline.md.txt b/docs/m2met2/_build/html/_sources/Baseline.md.txt similarity index 99% rename from docs_m2met2/_build/html/_sources/Baseline.md.txt rename to docs/m2met2/_build/html/_sources/Baseline.md.txt index c34679fd6..6f9609bde 100644 --- a/docs_m2met2/_build/html/_sources/Baseline.md.txt +++ b/docs/m2met2/_build/html/_sources/Baseline.md.txt @@ -9,4 +9,5 @@ We will release an E2E SA-ASR~\cite{kanda21b_interspeech} baseline conducted on ## Baseline results The results of the baseline system are shown in Table 3. The speaker profile adopts the oracle speaker embedding during training. However, due to the lack of oracle speaker label during evaluation, the speaker profile provided by an additional spectral clustering is used. Meanwhile, the results of using the oracle speaker profile on Eval and Test Set are also provided to show the impact of speaker profile accuracy. + ![baseline result](images/baseline_result.png) \ No newline at end of file diff --git a/docs_m2met2/_build/html/_sources/Contact.md.txt b/docs/m2met2/_build/html/_sources/Contact.md.txt similarity index 100% rename from docs_m2met2/_build/html/_sources/Contact.md.txt rename to docs/m2met2/_build/html/_sources/Contact.md.txt diff --git a/docs_m2met2/_build/html/_sources/Dataset.md.txt b/docs/m2met2/_build/html/_sources/Dataset.md.txt similarity index 92% rename from docs_m2met2/_build/html/_sources/Dataset.md.txt rename to docs/m2met2/_build/html/_sources/Dataset.md.txt index c987acac9..a897d673b 100644 --- a/docs_m2met2/_build/html/_sources/Dataset.md.txt +++ b/docs/m2met2/_build/html/_sources/Dataset.md.txt @@ -2,7 +2,7 @@ ## Overview of training data In the fixed training condition, the training dataset is restricted to three publicly available corpora, namely, AliMeeting, AISHELL-4, and CN-Celeb. To evaluate the performance of the models trained on these datasets, we will release a new Test set called Test-2023 for scoring and ranking. We will describe the AliMeeting dataset and the Test-2023 set in detail. ## Detail of AliMeeting corpus -AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train and Eval sets contain 212 and 8 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train and Eval sets is 456 and 25, respectively, with balanced gender coverage. +AliMeeting contains 118.75 hours of speech data in total. The dataset is divided into 104.75 hours for training (Train), 4 hours for evaluation (Eval) and 10 hours as test set (Test) for scoring and ranking. Specifically, the Train, Eval and Test sets contain 212, 8 and 20 sessions, respectively. Each session consists of a 15 to 30-minute discussion by a group of participants. The total number of participants in Train, Eval and Test sets is 456, 25 and 60, respectively, with balanced gender coverage. The dataset is collected in 13 meeting venues, which are categorized into three types: small, medium, and large rooms with sizes ranging from 8 m$^{2}$ to 55 m$^{2}$. Different rooms give us a variety of acoustic properties and layouts. The detailed parameters of each meeting venue will be released together with the Train data. The type of wall material of the meeting venues covers cement, glass, etc. Other furnishings in meeting venues include sofa, TV, blackboard, fan, air conditioner, plants, etc. During recording, the participants of the meeting sit around the microphone array which is placed on the table and conduct a natural conversation. The microphone-speaker distance ranges from 0.3 m to 5.0 m. All participants are native Chinese speakers speaking Mandarin without strong accents. During the meeting, various kinds of indoor noise including but not limited to clicking, keyboard, door opening/closing, fan, bubble noise, etc., are made naturally. For both Train and Eval sets, the participants are required to remain in the same position during recording. There is no speaker overlap between the Train and Eval set. An example of the recording venue from the Train set is shown in Fig 1. diff --git a/docs/m2met2/_build/html/_sources/Introduction.md.txt b/docs/m2met2/_build/html/_sources/Introduction.md.txt new file mode 100644 index 000000000..eac9eb6b5 --- /dev/null +++ b/docs/m2met2/_build/html/_sources/Introduction.md.txt @@ -0,0 +1,28 @@ +# Introduction +## Call for participation +Automatic speech recognition (ASR) and speaker diarization have made significant strides in recent years, resulting in a surge of speech technology applications across various domains. However, meetings present unique challenges to speech technologies due to their complex acoustic conditions and diverse speaking styles, including overlapping speech, variable numbers of speakers, far-field signals in large conference rooms, and environmental noise and reverberation. + +Over the years, several challenges have been organized to advance the development of meeting transcription, including the Rich Transcription evaluation and Computational Hearing in Multisource Environments (CHIME) challenges. The latest iteration of the CHIME challenge has a particular focus on distant automatic speech recognition and developing systems that can generalize across various array topologies and application scenarios. However, while progress has been made in English meeting transcription, language differences remain a significant barrier to achieving comparable results in non-English languages, such as Mandarin. The Multimodal Information Based Speech Processing (MISP) and Multi-Channel Multi-Party Meeting Transcription (M2MeT) challenges have been instrumental in advancing Mandarin meeting transcription. The MISP challenge seeks to address the problem of audio-visual distant multi-microphone signal processing in everyday home environments, while the M2MeT challenge focuses on tackling the speech overlap issue in offline meeting rooms. + +The ICASSP2022 M2MeT challenge focuses on meeting scenarios, and it comprises two main tasks: speaker diarization and multi-speaker automatic speech recognition. The former involves identifying who spoke when in the meeting, while the latter aims to transcribe speech from multiple speakers simultaneously, which poses significant technical difficulties due to overlapping speech and acoustic interferences. + +Building on the success of the previous M2MeT challenge, we are excited to propose the M2MeT2.0 challenge as an ASRU2023 challenge special session. In the original M2MeT challenge, the evaluation metric was speaker-independent, which meant that the transcription could be determined, but not the corresponding speaker. To address this limitation and further advance the current multi-talker ASR system towards practicality, the M2MeT2.0 challenge proposes the speaker-attributed ASR task with two sub-tracks: fixed and open training conditions. The speaker-attribute automatic speech recognition (ASR) task aims to tackle the practical and challenging problem of identifying "who spoke what at when". To facilitate reproducible research in this field, we offer a comprehensive overview of the dataset, rules, evaluation metrics, and baseline systems. Furthermore, we will release a carefully curated test set, comprising approximately 10 hours of audio, according to the timeline. The new test set is designed to enable researchers to validate and compare their models' performance and advance the state of the art in this area. + +## Timeline(AOE Time) +- $ April~29, 2023: $ Challenge and registration open. +- $ May~8, 2023: $ Baseline release. +- $ May~15, 2023: $ Registration deadline, the due date for participants to join the Challenge. +- $ June~9, 2023: $ Test data release and leaderboard open. +- $ June~13, 2023: $ Final submission deadline. +- $ June~19, 2023: $ Evaluation result and ranking release. +- $ July~3, 2023: $ Deadline for paper submission. +- $ July~10, 2023: $ Deadline for final paper submission. +- $ December~12\ to\ 16, 2023: $ ASRU Workshop and challenge session + +## Guidelines + +Interested participants, whether from academia or industry, must register for the challenge by completing the Google form below. The deadline for registration is May 15, 2023. + +[M2MET2.0 Registration](https://docs.google.com/forms/d/e/1FAIpQLSf77T9vAl7Ym-u5g8gXu18SBofoWRaFShBo26Ym0-HDxHW9PQ/viewform?usp=sf_link) + +Within three working days, the challenge organizer will send email invitations to eligible teams to participate in the challenge. All qualified teams are required to adhere to the challenge rules, which will be published on the challenge page. Prior to the ranking release time, each participant must submit a system description document detailing their approach and methods. The organizer will select the top three submissions to be included in the ASRU2023 Proceedings. diff --git a/docs/m2met2/_build/html/_sources/Organizers.md.txt b/docs/m2met2/_build/html/_sources/Organizers.md.txt new file mode 100644 index 000000000..e16c803af --- /dev/null +++ b/docs/m2met2/_build/html/_sources/Organizers.md.txt @@ -0,0 +1,48 @@ +# Organizers +***Lei Xie, Professor, Northwestern Polytechnical University, China*** + +Email: [lxie@nwpu.edu.cn](mailto:lxie@nwpu.edu.cn) + +lxie + + +***Kong Aik Lee, Senior Scientist at Institute for Infocomm Research, A\*Star, Singapore*** + +Email: [kongaik.lee@ieee.org](mailto:kongaik.lee@ieee.org) + +kong + + +***Zhijie Yan, Principal Engineer at Alibaba, China*** +Email: [zhijie.yzj@alibaba-inc.com](mailto:zhijie.yzj@alibaba-inc.com) + +zhijie + +***Shiliang Zhang, Senior Engineer at Alibaba, China*** +Email: [sly.zsl@alibaba-inc.com](mailto:sly.zsl@alibaba-inc.com) + +zsl + +***Yanmin Qian, Professor, Shanghai Jiao Tong University, China*** + +Email: [yanminqian@sjtu.edu.cn](mailto:yanminqian@sjtu.edu.cn) + +qian + +***Zhuo Chen, Applied Scientist in Microsoft, USA*** + +Email: [zhuc@microsoft.com](mailto:zhuc@microsoft.com) + +chenzhuo + +***Jian Wu, Applied Scientist in Microsoft, USA*** + +Email: [wujian@microsoft.com](mailto:wujian@microsoft.com) + +wujian + +***Hui Bu, CEO, AISHELL foundation, China*** + +Email: [buhui@aishelldata.com](mailto:buhui@aishelldata.com) + +buhui diff --git a/docs_m2met2/_build/html/_sources/Rules.md.txt b/docs/m2met2/_build/html/_sources/Rules.md.txt similarity index 92% rename from docs_m2met2/_build/html/_sources/Rules.md.txt rename to docs/m2met2/_build/html/_sources/Rules.md.txt index 8bc1a1900..340c2f50d 100644 --- a/docs_m2met2/_build/html/_sources/Rules.md.txt +++ b/docs/m2met2/_build/html/_sources/Rules.md.txt @@ -4,8 +4,6 @@ All participants should adhere to the following rules to be eligible for the cha - Data augmentation is allowed on the original training dataset, including, but not limited to, adding noise or reverberation, speed perturbation and tone change. - Participants are permitted to use the Eval set for model training, but it is not allowed to use the Test set for this purpose. Instead, the Test set should only be utilized for parameter tuning and model selection. Any use of the Test-2023 dataset that violates these rules is strictly prohibited, including but not limited to the use of the Test set for fine-tuning or training the model. - -- Multi-system fusion is allowed, but the systems with same structure and different parameters is not encouraged. - If the cpCER of the two systems on the Test dataset are the same, the system with lower computation complexity will be judged as the superior one. diff --git a/docs_m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt b/docs/m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt similarity index 95% rename from docs_m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt rename to docs/m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt index b90c17af1..2b75fcac5 100644 --- a/docs_m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt +++ b/docs/m2met2/_build/html/_sources/Track_setting_and_evaluation.md.txt @@ -1,6 +1,6 @@ # Track & Evaluation -## Speaker-Attributed ASR (Main Track) -The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It's worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps. Instead, segments containing multiple speakers will be provided on the Test-2023 set, which can be obtained using a simple voice activity detection (VAD) model. +## Speaker-Attributed ASR +The speaker-attributed ASR task poses a unique challenge of transcribing speech from multiple speakers and assigning a speaker label to the transcription. Figure 2 illustrates the difference between the speaker-attributed ASR task and the multi-speaker ASR task. This track allows for the use of the AliMeeting, Aishell4, and Cn-Celeb datasets as constrained data sources during both training and evaluation. The AliMeeting dataset, which was used in the M2MeT challenge, includes Train, Eval, and Test sets. Additionally, a new Test-2023 set, consisting of approximately 10 hours of meeting data recorded in an identical acoustic setting as the AliMeeting corpus, will be released soon for challenge scoring and ranking. It's worth noting that the organizers will not provide the near-field audio, transcriptions, or oracle timestamps of the Test-2023 set. Instead, segments containing multiple speakers will be provided, which can be obtained using a simple voice activity detection (VAD) model. ![task difference](images/task_diff.png) diff --git a/docs_m2met2/_build/html/_sources/index.rst.txt b/docs/m2met2/_build/html/_sources/index.rst.txt similarity index 92% rename from docs_m2met2/_build/html/_sources/index.rst.txt rename to docs/m2met2/_build/html/_sources/index.rst.txt index 04cb9345d..e0e7562c7 100644 --- a/docs_m2met2/_build/html/_sources/index.rst.txt +++ b/docs/m2met2/_build/html/_sources/index.rst.txt @@ -20,10 +20,3 @@ To facilitate reproducible research, we provide a comprehensive overview of the ./Rules ./Organizers ./Contact - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` \ No newline at end of file diff --git a/docs_m2met2/_build/html/_static/_sphinx_javascript_frameworks_compat.js b/docs/m2met2/_build/html/_static/_sphinx_javascript_frameworks_compat.js similarity index 100% rename from docs_m2met2/_build/html/_static/_sphinx_javascript_frameworks_compat.js rename to docs/m2met2/_build/html/_static/_sphinx_javascript_frameworks_compat.js diff --git a/docs_m2met2/_build/html/_static/basic.css b/docs/m2met2/_build/html/_static/basic.css similarity index 100% rename from docs_m2met2/_build/html/_static/basic.css rename to docs/m2met2/_build/html/_static/basic.css diff --git a/docs_m2met2/_build/html/_static/css/bootstrap-theme.min.css b/docs/m2met2/_build/html/_static/css/bootstrap-theme.min.css similarity index 100% rename from docs_m2met2/_build/html/_static/css/bootstrap-theme.min.css rename to docs/m2met2/_build/html/_static/css/bootstrap-theme.min.css diff --git a/docs_m2met2/_build/html/_static/css/bootstrap.min.css b/docs/m2met2/_build/html/_static/css/bootstrap.min.css similarity index 100% rename from docs_m2met2/_build/html/_static/css/bootstrap.min.css rename to docs/m2met2/_build/html/_static/css/bootstrap.min.css diff --git a/docs_m2met2/_build/html/_static/doctools.js b/docs/m2met2/_build/html/_static/doctools.js similarity index 100% rename from docs_m2met2/_build/html/_static/doctools.js rename to docs/m2met2/_build/html/_static/doctools.js diff --git a/docs_m2met2/_build/html/_static/documentation_options.js b/docs/m2met2/_build/html/_static/documentation_options.js similarity index 100% rename from docs_m2met2/_build/html/_static/documentation_options.js rename to docs/m2met2/_build/html/_static/documentation_options.js diff --git a/docs_m2met2/_build/html/_static/file.png b/docs/m2met2/_build/html/_static/file.png similarity index 100% rename from docs_m2met2/_build/html/_static/file.png rename to docs/m2met2/_build/html/_static/file.png diff --git a/docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.eot b/docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.eot rename to docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.eot diff --git a/docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.svg b/docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.svg rename to docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.svg diff --git a/docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.ttf b/docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.ttf rename to docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.woff b/docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.woff rename to docs/m2met2/_build/html/_static/fonts/glyphicons-halflings-regular.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff b/docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff rename to docs/m2met2/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff diff --git a/docs_m2met2/_build/html/_static/fonts/open-sans/stylesheet.css b/docs/m2met2/_build/html/_static/fonts/open-sans/stylesheet.css similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/open-sans/stylesheet.css rename to docs/m2met2/_build/html/_static/fonts/open-sans/stylesheet.css diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/LICENSE.txt b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/LICENSE.txt similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/LICENSE.txt rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/LICENSE.txt diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/README.md b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/README.md similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/README.md rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/README.md diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/ReadMe.html b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/ReadMe.html similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/ReadMe.html rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/ReadMe.html diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/bower.json b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/bower.json similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/bower.json rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/bower.json diff --git a/docs_m2met2/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css b/docs/m2met2/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css similarity index 100% rename from docs_m2met2/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css rename to docs/m2met2/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css diff --git a/docs_m2met2/_build/html/_static/guzzle.css b/docs/m2met2/_build/html/_static/guzzle.css similarity index 100% rename from docs_m2met2/_build/html/_static/guzzle.css rename to docs/m2met2/_build/html/_static/guzzle.css diff --git a/docs_m2met2/_build/html/_static/jquery-3.6.0.js b/docs/m2met2/_build/html/_static/jquery-3.6.0.js similarity index 100% rename from docs_m2met2/_build/html/_static/jquery-3.6.0.js rename to docs/m2met2/_build/html/_static/jquery-3.6.0.js diff --git a/docs_m2met2/_build/html/_static/jquery.js b/docs/m2met2/_build/html/_static/jquery.js similarity index 100% rename from docs_m2met2/_build/html/_static/jquery.js rename to docs/m2met2/_build/html/_static/jquery.js diff --git a/docs_m2met2/_build/html/_static/jquery.min.map b/docs/m2met2/_build/html/_static/jquery.min.map similarity index 100% rename from docs_m2met2/_build/html/_static/jquery.min.map rename to docs/m2met2/_build/html/_static/jquery.min.map diff --git a/docs_m2met2/_build/html/_static/js/bootstrap.js b/docs/m2met2/_build/html/_static/js/bootstrap.js similarity index 100% rename from docs_m2met2/_build/html/_static/js/bootstrap.js rename to docs/m2met2/_build/html/_static/js/bootstrap.js diff --git a/docs_m2met2/_build/html/_static/js/bootstrap.min.js b/docs/m2met2/_build/html/_static/js/bootstrap.min.js similarity index 100% rename from docs_m2met2/_build/html/_static/js/bootstrap.min.js rename to docs/m2met2/_build/html/_static/js/bootstrap.min.js diff --git a/docs_m2met2/_build/html/_static/language_data.js b/docs/m2met2/_build/html/_static/language_data.js similarity index 100% rename from docs_m2met2/_build/html/_static/language_data.js rename to docs/m2met2/_build/html/_static/language_data.js diff --git a/docs_m2met2/_build/html/_static/minus.png b/docs/m2met2/_build/html/_static/minus.png similarity index 100% rename from docs_m2met2/_build/html/_static/minus.png rename to docs/m2met2/_build/html/_static/minus.png diff --git a/docs_m2met2/_build/html/_static/plus.png b/docs/m2met2/_build/html/_static/plus.png similarity index 100% rename from docs_m2met2/_build/html/_static/plus.png rename to docs/m2met2/_build/html/_static/plus.png diff --git a/docs_m2met2/_build/html/_static/pygments.css b/docs/m2met2/_build/html/_static/pygments.css similarity index 100% rename from docs_m2met2/_build/html/_static/pygments.css rename to docs/m2met2/_build/html/_static/pygments.css diff --git a/docs_m2met2/_build/html/_static/searchtools.js b/docs/m2met2/_build/html/_static/searchtools.js similarity index 100% rename from docs_m2met2/_build/html/_static/searchtools.js rename to docs/m2met2/_build/html/_static/searchtools.js diff --git a/docs_m2met2/_build/html/_static/sphinx_highlight.js b/docs/m2met2/_build/html/_static/sphinx_highlight.js similarity index 100% rename from docs_m2met2/_build/html/_static/sphinx_highlight.js rename to docs/m2met2/_build/html/_static/sphinx_highlight.js diff --git a/docs_m2met2/_build/html/_static/underscore-1.13.1.js b/docs/m2met2/_build/html/_static/underscore-1.13.1.js similarity index 100% rename from docs_m2met2/_build/html/_static/underscore-1.13.1.js rename to docs/m2met2/_build/html/_static/underscore-1.13.1.js diff --git a/docs_m2met2/_build/html/_static/underscore.js b/docs/m2met2/_build/html/_static/underscore.js similarity index 100% rename from docs_m2met2/_build/html/_static/underscore.js rename to docs/m2met2/_build/html/_static/underscore.js diff --git a/docs_m2met2/_build/html/genindex.html b/docs/m2met2/_build/html/genindex.html similarity index 98% rename from docs_m2met2/_build/html/genindex.html rename to docs/m2met2/_build/html/genindex.html index 0071a1845..e7e17b6ed 100644 --- a/docs_m2met2/_build/html/genindex.html +++ b/docs/m2met2/_build/html/genindex.html @@ -79,7 +79,7 @@
  • Track & Evaluation diff --git a/docs_m2met2/_build/html/index.html b/docs/m2met2/_build/html/index.html similarity index 93% rename from docs_m2met2/_build/html/index.html rename to docs/m2met2/_build/html/index.html index a65dfa0cb..dcbb8cb03 100644 --- a/docs_m2met2/_build/html/index.html +++ b/docs/m2met2/_build/html/index.html @@ -84,7 +84,7 @@
  • Track & Evaluation @@ -135,14 +135,6 @@ To facilitate reproducible research, we provide a comprehensive overview of the
  • Contact
  • - -
    -

    Indices and tables

    -
    diff --git a/docs_m2met2/_build/html/objects.inv b/docs/m2met2/_build/html/objects.inv similarity index 100% rename from docs_m2met2/_build/html/objects.inv rename to docs/m2met2/_build/html/objects.inv diff --git a/docs_m2met2/_build/html/search.html b/docs/m2met2/_build/html/search.html similarity index 98% rename from docs_m2met2/_build/html/search.html rename to docs/m2met2/_build/html/search.html index 344ad958a..71adf366d 100644 --- a/docs_m2met2/_build/html/search.html +++ b/docs/m2met2/_build/html/search.html @@ -72,7 +72,7 @@
  • Track & Evaluation diff --git a/docs/m2met2/_build/html/searchindex.js b/docs/m2met2/_build/html/searchindex.js new file mode 100644 index 000000000..54443a001 --- /dev/null +++ b/docs/m2met2/_build/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({"docnames": ["Baseline", "Contact", "Dataset", "Introduction", "Organizers", "Rules", "Track_setting_and_evaluation", "index"], "filenames": ["Baseline.md", "Contact.md", "Dataset.md", "Introduction.md", "Organizers.md", "Rules.md", "Track_setting_and_evaluation.md", "index.rst"], "titles": ["Baseline", "Contact", "Datasets", "Introduction", "Organizers", "Rules", "Track & Evaluation", "ASRU 2023 MULTI-CHANNEL MULTI-PARTY MEETING TRANSCRIPTION CHALLENGE 2.0 (M2MeT2.0)"], "terms": {"we": [0, 2, 3, 7], "releas": [0, 2, 3, 6], "an": [0, 2, 3, 6], "e2": 0, "sa": 0, "asr": [0, 3, 7], "cite": 0, "kanda21b_interspeech": 0, "conduct": [0, 2], "funasr": 0, "time": [0, 6], "accord": [0, 3], "timelin": [0, 2], "The": [0, 2, 3, 5, 6], "model": [0, 2, 3, 5, 6], "architectur": 0, "i": [0, 2, 3, 5], "shown": [0, 2], "figur": [0, 6], "3": [0, 2, 3], "speakerencod": 0, "initi": 0, "pre": [0, 6], "train": [0, 3, 5, 7], "speaker": [0, 2, 3, 7], "verif": 0, "from": [0, 2, 3, 5, 6], "modelscop": [0, 6], "thi": [0, 3, 5, 6], "also": [0, 2, 6], "us": [0, 2, 5, 6], "extract": 0, "embed": 0, "profil": 0, "todo": 0, "fill": 0, "readm": 0, "md": 0, "system": [0, 3, 5, 6, 7], "ar": [0, 2, 3, 5, 6, 7], "tabl": [0, 2], "adopt": 0, "oracl": [0, 6], "dure": [0, 2, 6], "howev": [0, 3, 6], "due": [0, 3], "lack": 0, "label": [0, 5, 6], "evalu": [0, 2, 3, 7], "provid": [0, 2, 6, 7], "addit": [0, 6], "spectral": 0, "cluster": 0, "meanwhil": 0, "eval": [0, 2, 5, 6], "test": [0, 2, 3, 5, 6], "set": [0, 2, 3, 5, 6], "show": 0, "impact": 0, "accuraci": [0, 6], "If": [1, 5, 6], "you": 1, "have": [1, 3], "ani": [1, 5, 6], "question": 1, "about": 1, "m2met2": [1, 3], "0": [1, 2, 3], "challeng": [1, 3, 5, 6], "pleas": 1, "u": [1, 2], "email": [1, 3, 4], "m2met": [1, 3, 6, 7], "alimeet": [1, 6], "gmail": 1, "com": [1, 4], "wechat": 1, "group": [1, 2], "In": [2, 3, 5], "fix": [2, 3, 7], "condit": [2, 3, 7], "restrict": 2, "three": [2, 3, 6], "publicli": [2, 6], "avail": [2, 6], "corpora": 2, "name": 2, "aishel": [2, 4, 6], "4": [2, 6], "cn": [2, 4, 6], "celeb": [2, 6], "To": [2, 3, 7], "perform": [2, 3], "new": [2, 3, 6], "call": 2, "2023": [2, 3, 5, 6], "score": [2, 6], "rank": [2, 3, 6], "describ": 2, "contain": [2, 6], "118": 2, "75": 2, "hour": [2, 3, 6], "speech": [2, 3, 6, 7], "total": [2, 6], "divid": [2, 6], "104": 2, "10": [2, 3, 6], "specif": [2, 6], "212": 2, "8": [2, 3], "20": 2, "session": [2, 3, 6, 7], "respect": 2, "each": [2, 3, 6], "consist": [2, 6], "15": [2, 3], "30": 2, "minut": 2, "discuss": 2, "particip": [2, 5, 6], "number": [2, 3, 6], "456": 2, "25": 2, "60": 2, "balanc": 2, "gender": 2, "coverag": 2, "collect": 2, "13": [2, 3], "meet": [2, 3, 6], "venu": 2, "which": [2, 3, 6], "categor": 2, "type": 2, "small": 2, "medium": 2, "larg": [2, 3], "room": [2, 3], "size": 2, "rang": 2, "m": 2, "2": [2, 6], "55": 2, "differ": [2, 3, 6], "give": 2, "varieti": 2, "acoust": [2, 3, 6], "properti": 2, "layout": 2, "paramet": [2, 5], "togeth": 2, "wall": 2, "materi": 2, "cover": 2, "cement": 2, "glass": 2, "etc": 2, "other": 2, "furnish": 2, "includ": [2, 3, 5, 6], "sofa": 2, "tv": 2, "blackboard": 2, "fan": 2, "air": 2, "condition": 2, "plant": 2, "record": [2, 6], "sit": 2, "around": 2, "microphon": [2, 3], "arrai": [2, 3], "place": 2, "natur": 2, "convers": 2, "distanc": 2, "5": 2, "all": [2, 3, 5, 6], "nativ": 2, "chines": 2, "speak": [2, 3], "mandarin": [2, 3], "without": 2, "strong": 2, "accent": 2, "variou": [2, 3], "kind": 2, "indoor": 2, "nois": [2, 3, 5], "limit": [2, 3, 5], "click": 2, "keyboard": 2, "door": 2, "open": [2, 3, 7], "close": 2, "bubbl": 2, "made": [2, 3], "For": 2, "both": [2, 6], "requir": [2, 3, 6], "remain": [2, 3], "same": [2, 5], "posit": 2, "There": 2, "overlap": [2, 3], "between": [2, 6], "exampl": 2, "fig": 2, "1": 2, "within": [2, 3], "one": [2, 5], "ensur": 2, "ratio": 2, "select": [2, 3, 5, 6], "topic": 2, "medic": 2, "treatment": 2, "educ": 2, "busi": 2, "organ": [2, 3, 5, 6, 7], "manag": 2, "industri": [2, 3], "product": 2, "daili": 2, "routin": 2, "averag": 2, "42": 2, "27": 2, "34": 2, "76": 2, "more": 2, "A": [2, 4], "distribut": 2, "were": 2, "ident": [2, 6], "compris": [2, 3, 7], "therebi": 2, "share": 2, "similar": 2, "configur": 2, "field": [2, 3, 6], "signal": [2, 3], "headset": 2, "onli": [2, 5, 6], "": [2, 6], "own": 2, "transcrib": [2, 3, 6], "It": [2, 6], "worth": [2, 6], "note": [2, 6], "far": [2, 3], "audio": [2, 3, 6], "synchron": 2, "common": 2, "transcript": [2, 3, 5, 6], "prepar": 2, "textgrid": 2, "format": 2, "inform": [2, 3], "durat": 2, "id": 2, "segment": [2, 6], "timestamp": [2, 6], "mention": 2, "abov": 2, "can": [2, 3, 5, 6], "download": 2, "openslr": 2, "via": 2, "follow": [2, 5], "link": 2, "particularli": 2, "baselin": [2, 3, 7], "conveni": 2, "script": 2, "automat": [3, 7], "recognit": [3, 7], "diariz": 3, "signific": 3, "stride": 3, "recent": 3, "year": 3, "result": 3, "surg": 3, "technologi": 3, "applic": 3, "across": 3, "domain": 3, "present": 3, "uniqu": [3, 6], "complex": [3, 5], "divers": 3, "style": 3, "variabl": 3, "confer": 3, "environment": 3, "reverber": [3, 5], "over": 3, "sever": 3, "been": 3, "advanc": [3, 7], "develop": [3, 6], "rich": 3, "comput": [3, 5], "hear": 3, "multisourc": 3, "environ": 3, "chime": 3, "latest": 3, "iter": 3, "ha": 3, "particular": 3, "focu": 3, "distant": 3, "gener": 3, "topologi": 3, "scenario": 3, "while": 3, "progress": 3, "english": 3, "languag": [3, 5], "barrier": 3, "achiev": 3, "compar": 3, "non": 3, "multimod": 3, "base": 3, "process": [3, 6], "misp": 3, "multi": [3, 6], "channel": 3, "parti": [3, 6], "instrument": 3, "seek": 3, "address": 3, "problem": 3, "visual": 3, "everydai": 3, "home": 3, "focus": 3, "tackl": 3, "issu": 3, "offlin": 3, "icassp2022": 3, "two": [3, 5, 7], "main": 3, "task": [3, 6, 7], "former": 3, "involv": [3, 6], "identifi": 3, "who": 3, "spoke": 3, "when": 3, "latter": 3, "aim": 3, "multipl": [3, 6], "simultan": 3, "pose": [3, 6], "technic": 3, "difficulti": 3, "interfer": 3, "build": [3, 6, 7], "success": [3, 7], "previou": 3, "excit": 3, "propos": [3, 7], "asru2023": [3, 7], "special": [3, 5, 7], "origin": [3, 5], "metric": [3, 7], "wa": [3, 6], "independ": 3, "meant": 3, "could": 3, "determin": 3, "correspond": [3, 5], "further": 3, "current": [3, 7], "talker": [3, 7], "toward": 3, "practic": 3, "attribut": [3, 7], "sub": [3, 5, 7], "track": [3, 5, 7], "what": 3, "facilit": [3, 7], "reproduc": [3, 7], "research": [3, 4, 7], "offer": 3, "comprehens": [3, 7], "overview": [3, 7], "dataset": [3, 5, 6, 7], "rule": [3, 7], "furthermor": 3, "carefulli": 3, "curat": 3, "approxim": [3, 6], "design": 3, "enabl": 3, "valid": 3, "state": [3, 6, 7], "art": [3, 7], "area": 3, "april": 3, "29": 3, "registr": 3, "mai": 3, "deadlin": 3, "date": 3, "join": 3, "june": 3, "9": 3, "data": [3, 5, 6], "leaderboard": 3, "final": [3, 5, 6], "submiss": 3, "19": 3, "juli": 3, "paper": [3, 6], "decemb": 3, "12": 3, "16": 3, "asru": 3, "workshop": 3, "interest": 3, "whether": 3, "academia": 3, "must": [3, 5, 6], "regist": 3, "complet": 3, "googl": 3, "form": 3, "below": 3, "work": 3, "dai": 3, "send": 3, "invit": 3, "elig": [3, 5], "team": 3, "qualifi": 3, "adher": [3, 5], "publish": 3, "page": 3, "prior": 3, "submit": 3, "descript": [3, 6], "document": 3, "detail": [3, 6], "approach": [3, 5], "method": 3, "top": 3, "proceed": 3, "lei": 4, "xie": 4, "professor": 4, "northwestern": 4, "polytechn": 4, "univers": 4, "china": 4, "lxie": 4, "nwpu": 4, "edu": 4, "kong": 4, "aik": 4, "lee": 4, "senior": 4, "scientist": 4, "institut": 4, "infocomm": 4, "star": 4, "singapor": 4, "kongaik": 4, "ieee": 4, "org": 4, "zhiji": 4, "yan": 4, "princip": 4, "engin": 4, "alibaba": 4, "yzj": 4, "inc": 4, "shiliang": 4, "zhang": 4, "sly": 4, "zsl": 4, "yanmin": 4, "qian": 4, "shanghai": 4, "jiao": 4, "tong": 4, "yanminqian": 4, "sjtu": 4, "zhuo": 4, "chen": 4, "appli": 4, "microsoft": 4, "usa": 4, "zhuc": 4, "jian": 4, "wu": 4, "wujian": 4, "hui": 4, "bu": 4, "ceo": 4, "foundat": 4, "buhui": 4, "aishelldata": 4, "should": 5, "augment": 5, "allow": [5, 6], "ad": 5, "speed": 5, "perturb": 5, "tone": 5, "chang": 5, "permit": 5, "purpos": 5, "instead": [5, 6], "util": [5, 6], "tune": 5, "violat": 5, "strictli": [5, 6], "prohibit": [5, 6], "fine": 5, "cpcer": [5, 6], "lower": 5, "judg": 5, "superior": 5, "forc": 5, "align": 5, "obtain": [5, 6], "frame": 5, "level": 5, "classif": 5, "basi": 5, "shallow": 5, "fusion": 5, "end": 5, "e": [5, 6], "g": 5, "la": 5, "rnnt": 5, "transform": [5, 6], "come": 5, "right": 5, "interpret": 5, "belong": 5, "case": 5, "circumst": 5, "coordin": 5, "assign": 6, "illustr": 6, "aishell4": 6, "constrain": 6, "sourc": 6, "addition": 6, "corpu": 6, "soon": 6, "simpl": 6, "voic": 6, "activ": 6, "detect": 6, "vad": 6, "concaten": 6, "minimum": 6, "permut": 6, "charact": 6, "error": 6, "rate": 6, "calcul": 6, "step": 6, "firstli": 6, "refer": 6, "hypothesi": 6, "chronolog": 6, "order": 6, "secondli": 6, "cer": 6, "repeat": 6, "possibl": 6, "lowest": 6, "tthe": 6, "insert": 6, "Ins": 6, "substitut": 6, "delet": 6, "del": 6, "output": 6, "text": 6, "frac": 6, "mathcal": 6, "n_": 6, "100": 6, "where": 6, "usag": 6, "third": 6, "hug": 6, "face": 6, "list": 6, "clearli": 6, "privat": 6, "manual": 6, "simul": 6, "thei": 6, "mandatori": 6, "clear": 6, "scheme": 6, "delight": 7, "introduct": 7, "contact": 7}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"baselin": 0, "overview": [0, 2], "quick": 0, "start": 0, "result": 0, "contact": 1, "dataset": 2, "train": [2, 6], "data": 2, "detail": 2, "alimeet": 2, "corpu": 2, "get": 2, "introduct": 3, "call": 3, "particip": 3, "timelin": 3, "aoe": 3, "time": 3, "guidelin": 3, "organ": 4, "rule": 5, "track": 6, "evalu": 6, "speaker": 6, "attribut": 6, "asr": 6, "metric": 6, "sub": 6, "arrang": 6, "i": 6, "fix": 6, "condit": 6, "ii": 6, "open": 6, "asru": 7, "2023": 7, "multi": 7, "channel": 7, "parti": 7, "meet": 7, "transcript": 7, "challeng": 7, "2": 7, "0": 7, "m2met2": 7, "content": 7}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 57}, "alltitles": {"Baseline": [[0, "baseline"]], "Overview": [[0, "overview"]], "Quick start": [[0, "quick-start"]], "Baseline results": [[0, "baseline-results"]], "Contact": [[1, "contact"]], "Datasets": [[2, "datasets"]], "Overview of training data": [[2, "overview-of-training-data"]], "Detail of AliMeeting corpus": [[2, "detail-of-alimeeting-corpus"]], "Get the data": [[2, "get-the-data"]], "Introduction": [[3, "introduction"]], "Call for participation": [[3, "call-for-participation"]], "Timeline(AOE Time)": [[3, "timeline-aoe-time"]], "Guidelines": [[3, "guidelines"]], "Organizers": [[4, "organizers"]], "Rules": [[5, "rules"]], "Track & Evaluation": [[6, "track-evaluation"]], "Speaker-Attributed ASR": [[6, "speaker-attributed-asr"]], "Evaluation metric": [[6, "evaluation-metric"]], "Sub-track arrangement": [[6, "sub-track-arrangement"]], "Sub-track I (Fixed Training Condition):": [[6, "sub-track-i-fixed-training-condition"]], "Sub-track II (Open Training Condition):": [[6, "sub-track-ii-open-training-condition"]], "ASRU 2023 MULTI-CHANNEL MULTI-PARTY MEETING TRANSCRIPTION CHALLENGE 2.0 (M2MeT2.0)": [[7, "asru-2023-multi-channel-multi-party-meeting-transcription-challenge-2-0-m2met2-0"]], "Contents:": [[7, null]]}, "indexentries": {}}) \ No newline at end of file diff --git a/docs_m2met2/conf.py b/docs/m2met2/conf.py similarity index 100% rename from docs_m2met2/conf.py rename to docs/m2met2/conf.py diff --git a/docs_m2met2/images/baseline_result.png b/docs/m2met2/images/baseline_result.png similarity index 100% rename from docs_m2met2/images/baseline_result.png rename to docs/m2met2/images/baseline_result.png diff --git a/docs_m2met2/images/buhui.jpeg b/docs/m2met2/images/buhui.jpeg similarity index 100% rename from docs_m2met2/images/buhui.jpeg rename to docs/m2met2/images/buhui.jpeg diff --git a/docs_m2met2/images/chenzhuo.jpg b/docs/m2met2/images/chenzhuo.jpg similarity index 100% rename from docs_m2met2/images/chenzhuo.jpg rename to docs/m2met2/images/chenzhuo.jpg diff --git a/docs_m2met2/images/dataset_details.png b/docs/m2met2/images/dataset_details.png similarity index 100% rename from docs_m2met2/images/dataset_details.png rename to docs/m2met2/images/dataset_details.png diff --git a/docs_m2met2/images/kong.png b/docs/m2met2/images/kong.png similarity index 100% rename from docs_m2met2/images/kong.png rename to docs/m2met2/images/kong.png diff --git a/docs_m2met2/images/lxie.jpeg b/docs/m2met2/images/lxie.jpeg similarity index 100% rename from docs_m2met2/images/lxie.jpeg rename to docs/m2met2/images/lxie.jpeg diff --git a/docs_m2met2/images/meeting_room.png b/docs/m2met2/images/meeting_room.png similarity index 100% rename from docs_m2met2/images/meeting_room.png rename to docs/m2met2/images/meeting_room.png diff --git a/docs_m2met2/images/qian.jpeg b/docs/m2met2/images/qian.jpeg similarity index 100% rename from docs_m2met2/images/qian.jpeg rename to docs/m2met2/images/qian.jpeg diff --git a/docs_m2met2_cn/_build/html/_images/sa_asr_arch.png b/docs/m2met2/images/sa_asr_arch.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/sa_asr_arch.png rename to docs/m2met2/images/sa_asr_arch.png diff --git a/docs_m2met2/images/task_diff.png b/docs/m2met2/images/task_diff.png similarity index 100% rename from docs_m2met2/images/task_diff.png rename to docs/m2met2/images/task_diff.png diff --git a/docs_m2met2/images/wujian.jpg b/docs/m2met2/images/wujian.jpg similarity index 100% rename from docs_m2met2/images/wujian.jpg rename to docs/m2met2/images/wujian.jpg diff --git a/docs_m2met2/images/zhijie.jpg b/docs/m2met2/images/zhijie.jpg similarity index 100% rename from docs_m2met2/images/zhijie.jpg rename to docs/m2met2/images/zhijie.jpg diff --git a/docs_m2met2/images/zsl.JPG b/docs/m2met2/images/zsl.JPG similarity index 100% rename from docs_m2met2/images/zsl.JPG rename to docs/m2met2/images/zsl.JPG diff --git a/docs_m2met2/index.rst b/docs/m2met2/index.rst similarity index 92% rename from docs_m2met2/index.rst rename to docs/m2met2/index.rst index 04cb9345d..e0e7562c7 100644 --- a/docs_m2met2/index.rst +++ b/docs/m2met2/index.rst @@ -20,10 +20,3 @@ To facilitate reproducible research, we provide a comprehensive overview of the ./Rules ./Organizers ./Contact - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` \ No newline at end of file diff --git a/docs_m2met2/make.bat b/docs/m2met2/make.bat similarity index 100% rename from docs_m2met2/make.bat rename to docs/m2met2/make.bat diff --git a/docs_m2met2_cn/Makefile b/docs/m2met2_cn/Makefile similarity index 100% rename from docs_m2met2_cn/Makefile rename to docs/m2met2_cn/Makefile diff --git a/docs/m2met2_cn/_build/doctrees/environment.pickle b/docs/m2met2_cn/_build/doctrees/environment.pickle new file mode 100644 index 000000000..fb92f83a0 Binary files /dev/null and b/docs/m2met2_cn/_build/doctrees/environment.pickle differ diff --git a/docs/m2met2_cn/_build/doctrees/index.doctree b/docs/m2met2_cn/_build/doctrees/index.doctree new file mode 100644 index 000000000..77742ac2a Binary files /dev/null and b/docs/m2met2_cn/_build/doctrees/index.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/基线.doctree b/docs/m2met2_cn/_build/doctrees/基线.doctree similarity index 99% rename from docs_m2met2_cn/_build/doctrees/基线.doctree rename to docs/m2met2_cn/_build/doctrees/基线.doctree index 27ec7ca19..f88f67d87 100644 Binary files a/docs_m2met2_cn/_build/doctrees/基线.doctree and b/docs/m2met2_cn/_build/doctrees/基线.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/数据集.doctree b/docs/m2met2_cn/_build/doctrees/数据集.doctree similarity index 66% rename from docs_m2met2_cn/_build/doctrees/数据集.doctree rename to docs/m2met2_cn/_build/doctrees/数据集.doctree index 26addbfc8..5950ee3c1 100644 Binary files a/docs_m2met2_cn/_build/doctrees/数据集.doctree and b/docs/m2met2_cn/_build/doctrees/数据集.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/简介.doctree b/docs/m2met2_cn/_build/doctrees/简介.doctree similarity index 55% rename from docs_m2met2_cn/_build/doctrees/简介.doctree rename to docs/m2met2_cn/_build/doctrees/简介.doctree index f2d3b2263..373ee340a 100644 Binary files a/docs_m2met2_cn/_build/doctrees/简介.doctree and b/docs/m2met2_cn/_build/doctrees/简介.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/组委会.doctree b/docs/m2met2_cn/_build/doctrees/组委会.doctree similarity index 99% rename from docs_m2met2_cn/_build/doctrees/组委会.doctree rename to docs/m2met2_cn/_build/doctrees/组委会.doctree index 7b2bf0f4b..551248c38 100644 Binary files a/docs_m2met2_cn/_build/doctrees/组委会.doctree and b/docs/m2met2_cn/_build/doctrees/组委会.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/联系方式.doctree b/docs/m2met2_cn/_build/doctrees/联系方式.doctree similarity index 98% rename from docs_m2met2_cn/_build/doctrees/联系方式.doctree rename to docs/m2met2_cn/_build/doctrees/联系方式.doctree index 988c2b520..df477c8d5 100644 Binary files a/docs_m2met2_cn/_build/doctrees/联系方式.doctree and b/docs/m2met2_cn/_build/doctrees/联系方式.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/规则.doctree b/docs/m2met2_cn/_build/doctrees/规则.doctree similarity index 53% rename from docs_m2met2_cn/_build/doctrees/规则.doctree rename to docs/m2met2_cn/_build/doctrees/规则.doctree index e0b6338e6..1cf759cca 100644 Binary files a/docs_m2met2_cn/_build/doctrees/规则.doctree and b/docs/m2met2_cn/_build/doctrees/规则.doctree differ diff --git a/docs_m2met2_cn/_build/doctrees/赛道设置与评估.doctree b/docs/m2met2_cn/_build/doctrees/赛道设置与评估.doctree similarity index 75% rename from docs_m2met2_cn/_build/doctrees/赛道设置与评估.doctree rename to docs/m2met2_cn/_build/doctrees/赛道设置与评估.doctree index 5231301e5..fa83a0c82 100644 Binary files a/docs_m2met2_cn/_build/doctrees/赛道设置与评估.doctree and b/docs/m2met2_cn/_build/doctrees/赛道设置与评估.doctree differ diff --git a/docs_m2met2_cn/_build/html/.buildinfo b/docs/m2met2_cn/_build/html/.buildinfo similarity index 100% rename from docs_m2met2_cn/_build/html/.buildinfo rename to docs/m2met2_cn/_build/html/.buildinfo diff --git a/docs_m2met2_cn/_build/html/_images/baseline_result.png b/docs/m2met2_cn/_build/html/_images/baseline_result.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/baseline_result.png rename to docs/m2met2_cn/_build/html/_images/baseline_result.png diff --git a/docs_m2met2_cn/_build/html/_images/buhui.jpeg b/docs/m2met2_cn/_build/html/_images/buhui.jpeg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/buhui.jpeg rename to docs/m2met2_cn/_build/html/_images/buhui.jpeg diff --git a/docs_m2met2_cn/_build/html/_images/chenzhuo.jpg b/docs/m2met2_cn/_build/html/_images/chenzhuo.jpg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/chenzhuo.jpg rename to docs/m2met2_cn/_build/html/_images/chenzhuo.jpg diff --git a/docs_m2met2_cn/_build/html/_images/dataset_detail.png b/docs/m2met2_cn/_build/html/_images/dataset_detail.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/dataset_detail.png rename to docs/m2met2_cn/_build/html/_images/dataset_detail.png diff --git a/docs_m2met2_cn/_build/html/_images/kong.png b/docs/m2met2_cn/_build/html/_images/kong.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/kong.png rename to docs/m2met2_cn/_build/html/_images/kong.png diff --git a/docs_m2met2_cn/_build/html/_images/lxie.jpeg b/docs/m2met2_cn/_build/html/_images/lxie.jpeg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/lxie.jpeg rename to docs/m2met2_cn/_build/html/_images/lxie.jpeg diff --git a/docs_m2met2_cn/_build/html/_images/meeting_room.png b/docs/m2met2_cn/_build/html/_images/meeting_room.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/meeting_room.png rename to docs/m2met2_cn/_build/html/_images/meeting_room.png diff --git a/docs_m2met2_cn/_build/html/_images/qian.jpeg b/docs/m2met2_cn/_build/html/_images/qian.jpeg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/qian.jpeg rename to docs/m2met2_cn/_build/html/_images/qian.jpeg diff --git a/docs_m2met2_cn/images/sa_asr_arch.png b/docs/m2met2_cn/_build/html/_images/sa_asr_arch.png similarity index 100% rename from docs_m2met2_cn/images/sa_asr_arch.png rename to docs/m2met2_cn/_build/html/_images/sa_asr_arch.png diff --git a/docs_m2met2_cn/_build/html/_images/task_diff.png b/docs/m2met2_cn/_build/html/_images/task_diff.png similarity index 100% rename from docs_m2met2_cn/_build/html/_images/task_diff.png rename to docs/m2met2_cn/_build/html/_images/task_diff.png diff --git a/docs_m2met2_cn/_build/html/_images/wujian.jpg b/docs/m2met2_cn/_build/html/_images/wujian.jpg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/wujian.jpg rename to docs/m2met2_cn/_build/html/_images/wujian.jpg diff --git a/docs_m2met2_cn/_build/html/_images/zhijie.jpg b/docs/m2met2_cn/_build/html/_images/zhijie.jpg similarity index 100% rename from docs_m2met2_cn/_build/html/_images/zhijie.jpg rename to docs/m2met2_cn/_build/html/_images/zhijie.jpg diff --git a/docs_m2met2_cn/_build/html/_images/zsl.JPG b/docs/m2met2_cn/_build/html/_images/zsl.JPG similarity index 100% rename from docs_m2met2_cn/_build/html/_images/zsl.JPG rename to docs/m2met2_cn/_build/html/_images/zsl.JPG diff --git a/docs_m2met2_cn/_build/html/_sources/index.rst.txt b/docs/m2met2_cn/_build/html/_sources/index.rst.txt similarity index 91% rename from docs_m2met2_cn/_build/html/_sources/index.rst.txt rename to docs/m2met2_cn/_build/html/_sources/index.rst.txt index b35ac96da..c089b36e7 100644 --- a/docs_m2met2_cn/_build/html/_sources/index.rst.txt +++ b/docs/m2met2_cn/_build/html/_sources/index.rst.txt @@ -20,10 +20,3 @@ ASRU 2023 多通道多方会议转录挑战 2.0 ./规则 ./组委会 ./联系方式 - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs_m2met2_cn/_build/html/_sources/基线.md.txt b/docs/m2met2_cn/_build/html/_sources/基线.md.txt similarity index 100% rename from docs_m2met2_cn/_build/html/_sources/基线.md.txt rename to docs/m2met2_cn/_build/html/_sources/基线.md.txt diff --git a/docs_m2met2_cn/_build/html/_sources/数据集.md.txt b/docs/m2met2_cn/_build/html/_sources/数据集.md.txt similarity index 85% rename from docs_m2met2_cn/_build/html/_sources/数据集.md.txt rename to docs/m2met2_cn/_build/html/_sources/数据集.md.txt index 52965a1c5..24bfaf3d9 100644 --- a/docs_m2met2_cn/_build/html/_sources/数据集.md.txt +++ b/docs/m2met2_cn/_build/html/_sources/数据集.md.txt @@ -3,13 +3,13 @@ 在限定数据集条件下,训练数据集仅限于三个公开的语料库,即AliMeeting、AISHELL-4和CN-Celeb。为了评估参赛者提交的模型的性能,我们将发布一个新的测试集(Test-2023)用于打分和排名。下面我们将详细描述AliMeeting数据集和Test-2023测试集。 ## Alimeeting数据集介绍 -AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集和Eval集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train和Eval集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。 +AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集,Eval集和Test集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train,Eval和Test集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。 该数据集收集于13个不同的会议室,按照大小规格分为小型、中型和大型三种,房间面积从8到55平方米不等。不同房间具有不同的布局和声学特性,每个房间的详细参数也将发送给参与者。会议场地的墙体材料类型包括水泥、玻璃等。会议场地的家具包括沙发、电视、黑板、风扇、空调、植物等。在录制过程中,麦克风阵列放置于桌上,多个说话人围坐在桌边进行自然对话。麦克风阵列离说话人距离约0.3到5.0米之间。所有说话人的母语均是汉语,并且说的都是普通话,没有浓重的口音。在会议录制期间可能会产生各种室内的噪音,包括键盘声、开门/关门声、风扇声、气泡声等。所有说话人在会议的录制期间均保持相同位置,不发生走动。训练集和验证集的说话人没有重复。图1展示了一个会议室的布局以及麦克风的拓扑结构。 ![meeting room](images/meeting_room.png) -每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27\%和34.76\%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。 +每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27\%,34.76\%和42.8\%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。 ![dataset detail](images/dataset_detail.png) Test-2023测试集由20场会议组成,这些会议是在与AliMeeting数据集相同的声学环境下录制的。Test-2023测试集中的每个会议环节由2到4个参与者组成并且与AliMeeting测试集的配置相似。 diff --git a/docs_m2met2_cn/_build/html/_sources/简介.md.txt b/docs/m2met2_cn/_build/html/_sources/简介.md.txt similarity index 90% rename from docs_m2met2_cn/_build/html/_sources/简介.md.txt rename to docs/m2met2_cn/_build/html/_sources/简介.md.txt index cf4dfb86a..52df97d6b 100644 --- a/docs_m2met2_cn/_build/html/_sources/简介.md.txt +++ b/docs/m2met2_cn/_build/html/_sources/简介.md.txt @@ -13,16 +13,20 @@ ASSP2022 M2MeT挑战的侧重点是会议场景,它包括两个赛道:说话 ## 时间安排(AOE时间) -- $ 2023.5.5: $ 参赛者注册截止 +- $ 2023.4.29: $ 开放注册 +- $ 2023.5.8: $ 基线发布 +- $ 2023.5.15: $ 注册截止 - $ 2023.6.9: $ 测试集数据发布 - $ 2023.6.13: $ 最终结果提交截止 - $ 2023.6.19: $ 评估结果和排名发布 - $ 2023.7.3: $ 论文提交截止 - $ 2023.7.10: $ 最终版论文提交截止 -- $ 2023.12.12: $ ASRU Workshop +- $ 2023.12.12: $ ASRU Workshop & challenge session ## 竞赛报名 -来自学术界和工业界的有意向参赛者均应在2023年5月5日及之前填写下方的谷歌表单: +来自学术界和工业界的有意向参赛者均应在2023年5月15日及之前填写下方的谷歌表单: + +[M2MET2.0报名](https://docs.google.com/forms/d/e/1FAIpQLSf77T9vAl7Ym-u5g8gXu18SBofoWRaFShBo26Ym0-HDxHW9PQ/viewform?usp=sf_link) 主办方将在3个工作日内通过电子邮件通知符合条件的参赛团队,团队必须遵守将在挑战网站上发布的挑战规则。在排名发布之前,每个参赛者必须提交一份系统描述文件,详细说明使用的方法和模型。主办方将选择前三名纳入ASRU2023论文集。 \ No newline at end of file diff --git a/docs_m2met2_cn/_build/html/_sources/组委会.md.txt b/docs/m2met2_cn/_build/html/_sources/组委会.md.txt similarity index 100% rename from docs_m2met2_cn/_build/html/_sources/组委会.md.txt rename to docs/m2met2_cn/_build/html/_sources/组委会.md.txt diff --git a/docs_m2met2_cn/_build/html/_sources/联系方式.md.txt b/docs/m2met2_cn/_build/html/_sources/联系方式.md.txt similarity index 100% rename from docs_m2met2_cn/_build/html/_sources/联系方式.md.txt rename to docs/m2met2_cn/_build/html/_sources/联系方式.md.txt diff --git a/docs_m2met2_cn/_build/html/_sources/规则.md.txt b/docs/m2met2_cn/_build/html/_sources/规则.md.txt similarity index 90% rename from docs_m2met2_cn/_build/html/_sources/规则.md.txt rename to docs/m2met2_cn/_build/html/_sources/规则.md.txt index b0928ee54..68cb15972 100644 --- a/docs_m2met2_cn/_build/html/_sources/规则.md.txt +++ b/docs/m2met2_cn/_build/html/_sources/规则.md.txt @@ -4,8 +4,6 @@ - 允许在原始训练数据集上进行数据增强,包括但不限于添加噪声或混响、速度扰动和音调变化。 - 允许参赛者使用Eval集进行模型训练,但Test集仅能用于调参和模型选择,严禁以任何形式使用Test-2023数据集,包括但不限于使用测试数据集微调或训练模型。 - -- 允许多系统融合,但不鼓励使用具有相同结构仅参数不同的子系统融合。 - 如果两个系统的测试cpCER相同,则计算复杂度较低的系统将被认定为更优。 diff --git a/docs_m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt b/docs/m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt similarity index 86% rename from docs_m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt rename to docs/m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt index a99c1eddc..94a623690 100644 --- a/docs_m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt +++ b/docs/m2met2_cn/_build/html/_sources/赛道设置与评估.md.txt @@ -1,6 +1,6 @@ # 赛道设置与评估 -## 说话人相关的语音识别 (主赛道) -说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,组织者将不提供耳机的近场音频、转录以及真实时间戳。主办方将不再提供每个说话人的真实时间戳,而是在Test-2023集上提供包含多个说话人的片段。这些片段可以通过一个简单的vad模型获得。 +## 说话人相关的语音识别 +说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,对于Test-2023测试集,主办方将不再提供耳机的近场音频、转录以及真实时间戳。而是提供可以通过一个简单的VAD模型得到的包含多个说话人的片段。 ![task difference](images/task_diff.png) @@ -12,6 +12,6 @@ $$ \text{CER} = \frac {\mathcal N_{\text{Ins}} + \mathcal N_{\text{Sub}} + \math 其中 $\mathcal N_{\text{Ins}}$ , $\mathcal N_{\text{Sub}}$ , $\mathcal N_{\text{Del}}$ 是三种错误的字符数, $\mathcal N_{\text{Total}}$ 是字符总数. ## 子赛道设置 ### 子赛道一 (限定训练数据): -参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如[Hugging Face](https://huggingface.co/models)以及[ModelScope](https://www.modelscope.cn/models)上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。 +参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN-Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如[Hugging Face](https://huggingface.co/models)以及[ModelScope](https://www.modelscope.cn/models)上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。 ### 子赛道二 (开放训练数据): 除了限定数据外,参与者可以使用任何公开可用、私人录制和模拟仿真的数据集。但是,参与者必须清楚地列出使用的数据。同样,参赛者也可以使用任何第三方开源的预训练模型,但必须在最后的系统描述文件中明确的列出所使用的数据和模型链接,如果使用模拟仿真数据,请详细描述数据模拟的方案。 \ No newline at end of file diff --git a/docs_m2met2_cn/_build/html/_static/_sphinx_javascript_frameworks_compat.js b/docs/m2met2_cn/_build/html/_static/_sphinx_javascript_frameworks_compat.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/_sphinx_javascript_frameworks_compat.js rename to docs/m2met2_cn/_build/html/_static/_sphinx_javascript_frameworks_compat.js diff --git a/docs_m2met2_cn/_build/html/_static/basic.css b/docs/m2met2_cn/_build/html/_static/basic.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/basic.css rename to docs/m2met2_cn/_build/html/_static/basic.css diff --git a/docs_m2met2_cn/_build/html/_static/css/bootstrap-theme.min.css b/docs/m2met2_cn/_build/html/_static/css/bootstrap-theme.min.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/css/bootstrap-theme.min.css rename to docs/m2met2_cn/_build/html/_static/css/bootstrap-theme.min.css diff --git a/docs_m2met2_cn/_build/html/_static/css/bootstrap.min.css b/docs/m2met2_cn/_build/html/_static/css/bootstrap.min.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/css/bootstrap.min.css rename to docs/m2met2_cn/_build/html/_static/css/bootstrap.min.css diff --git a/docs_m2met2_cn/_build/html/_static/doctools.js b/docs/m2met2_cn/_build/html/_static/doctools.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/doctools.js rename to docs/m2met2_cn/_build/html/_static/doctools.js diff --git a/docs_m2met2_cn/_build/html/_static/documentation_options.js b/docs/m2met2_cn/_build/html/_static/documentation_options.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/documentation_options.js rename to docs/m2met2_cn/_build/html/_static/documentation_options.js diff --git a/docs_m2met2_cn/_build/html/_static/file.png b/docs/m2met2_cn/_build/html/_static/file.png similarity index 100% rename from docs_m2met2_cn/_build/html/_static/file.png rename to docs/m2met2_cn/_build/html/_static/file.png diff --git a/docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.eot b/docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.eot rename to docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.svg b/docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.svg rename to docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.ttf b/docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.woff b/docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.woff rename to docs/m2met2_cn/_build/html/_static/fonts/glyphicons-halflings-regular.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Bold-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-BoldItalic-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBold-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-ExtraBoldItalic-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Italic-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Light-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-LightItalic-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Regular-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-Semibold-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.svg diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/fonts/OpenSans-SemiboldItalic-webfont.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/open-sans/stylesheet.css b/docs/m2met2_cn/_build/html/_static/fonts/open-sans/stylesheet.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/open-sans/stylesheet.css rename to docs/m2met2_cn/_build/html/_static/fonts/open-sans/stylesheet.css diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Black.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Bold.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-ExtraLight.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Light.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Regular.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/EOT/SourceSerifPro-Semibold.eot diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/LICENSE.txt b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/LICENSE.txt similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/LICENSE.txt rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/LICENSE.txt diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Black.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Bold.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-ExtraLight.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Light.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Regular.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/OTF/SourceSerifPro-Semibold.otf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/README.md b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/README.md similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/README.md rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/README.md diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/ReadMe.html b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/ReadMe.html similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/ReadMe.html rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/ReadMe.html diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/SourceSerifProReadMe.html diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Black.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Bold.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-ExtraLight.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Light.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Regular.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/TTF/SourceSerifPro-Semibold.ttf diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Black.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Bold.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-ExtraLight.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Light.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Regular.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/OTF/SourceSerifPro-Semibold.otf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Black.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Bold.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-ExtraLight.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Light.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Regular.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/WOFF/TTF/SourceSerifPro-Semibold.ttf.woff diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/bower.json b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/bower.json similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/bower.json rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/bower.json diff --git a/docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css b/docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css rename to docs/m2met2_cn/_build/html/_static/fonts/source-serif-pro/source-serif-pro.css diff --git a/docs_m2met2_cn/_build/html/_static/guzzle.css b/docs/m2met2_cn/_build/html/_static/guzzle.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/guzzle.css rename to docs/m2met2_cn/_build/html/_static/guzzle.css diff --git a/docs_m2met2_cn/_build/html/_static/jquery-3.6.0.js b/docs/m2met2_cn/_build/html/_static/jquery-3.6.0.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/jquery-3.6.0.js rename to docs/m2met2_cn/_build/html/_static/jquery-3.6.0.js diff --git a/docs_m2met2_cn/_build/html/_static/jquery.js b/docs/m2met2_cn/_build/html/_static/jquery.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/jquery.js rename to docs/m2met2_cn/_build/html/_static/jquery.js diff --git a/docs_m2met2_cn/_build/html/_static/jquery.min.map b/docs/m2met2_cn/_build/html/_static/jquery.min.map similarity index 100% rename from docs_m2met2_cn/_build/html/_static/jquery.min.map rename to docs/m2met2_cn/_build/html/_static/jquery.min.map diff --git a/docs_m2met2_cn/_build/html/_static/js/bootstrap.js b/docs/m2met2_cn/_build/html/_static/js/bootstrap.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/js/bootstrap.js rename to docs/m2met2_cn/_build/html/_static/js/bootstrap.js diff --git a/docs_m2met2_cn/_build/html/_static/js/bootstrap.min.js b/docs/m2met2_cn/_build/html/_static/js/bootstrap.min.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/js/bootstrap.min.js rename to docs/m2met2_cn/_build/html/_static/js/bootstrap.min.js diff --git a/docs_m2met2_cn/_build/html/_static/language_data.js b/docs/m2met2_cn/_build/html/_static/language_data.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/language_data.js rename to docs/m2met2_cn/_build/html/_static/language_data.js diff --git a/docs_m2met2_cn/_build/html/_static/minus.png b/docs/m2met2_cn/_build/html/_static/minus.png similarity index 100% rename from docs_m2met2_cn/_build/html/_static/minus.png rename to docs/m2met2_cn/_build/html/_static/minus.png diff --git a/docs_m2met2_cn/_build/html/_static/plus.png b/docs/m2met2_cn/_build/html/_static/plus.png similarity index 100% rename from docs_m2met2_cn/_build/html/_static/plus.png rename to docs/m2met2_cn/_build/html/_static/plus.png diff --git a/docs_m2met2_cn/_build/html/_static/pygments.css b/docs/m2met2_cn/_build/html/_static/pygments.css similarity index 100% rename from docs_m2met2_cn/_build/html/_static/pygments.css rename to docs/m2met2_cn/_build/html/_static/pygments.css diff --git a/docs_m2met2_cn/_build/html/_static/searchtools.js b/docs/m2met2_cn/_build/html/_static/searchtools.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/searchtools.js rename to docs/m2met2_cn/_build/html/_static/searchtools.js diff --git a/docs_m2met2_cn/_build/html/_static/sphinx_highlight.js b/docs/m2met2_cn/_build/html/_static/sphinx_highlight.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/sphinx_highlight.js rename to docs/m2met2_cn/_build/html/_static/sphinx_highlight.js diff --git a/docs_m2met2_cn/_build/html/_static/translations.js b/docs/m2met2_cn/_build/html/_static/translations.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/translations.js rename to docs/m2met2_cn/_build/html/_static/translations.js diff --git a/docs_m2met2_cn/_build/html/_static/underscore-1.13.1.js b/docs/m2met2_cn/_build/html/_static/underscore-1.13.1.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/underscore-1.13.1.js rename to docs/m2met2_cn/_build/html/_static/underscore-1.13.1.js diff --git a/docs_m2met2_cn/_build/html/_static/underscore.js b/docs/m2met2_cn/_build/html/_static/underscore.js similarity index 100% rename from docs_m2met2_cn/_build/html/_static/underscore.js rename to docs/m2met2_cn/_build/html/_static/underscore.js diff --git a/docs_m2met2_cn/_build/html/genindex.html b/docs/m2met2_cn/_build/html/genindex.html similarity index 99% rename from docs_m2met2_cn/_build/html/genindex.html rename to docs/m2met2_cn/_build/html/genindex.html index 98b17f018..5558bcf2f 100644 --- a/docs_m2met2_cn/_build/html/genindex.html +++ b/docs/m2met2_cn/_build/html/genindex.html @@ -80,7 +80,7 @@
  • 赛道设置与评估 diff --git a/docs_m2met2_cn/_build/html/index.html b/docs/m2met2_cn/_build/html/index.html similarity index 93% rename from docs_m2met2_cn/_build/html/index.html rename to docs/m2met2_cn/_build/html/index.html index 4bfbdbfd9..fbc2fceac 100644 --- a/docs_m2met2_cn/_build/html/index.html +++ b/docs/m2met2_cn/_build/html/index.html @@ -85,7 +85,7 @@
  • 赛道设置与评估 @@ -136,14 +136,6 @@
  • 联系方式
  • - -
    -

    Indices and tables

    -
    diff --git a/docs_m2met2_cn/_build/html/objects.inv b/docs/m2met2_cn/_build/html/objects.inv similarity index 100% rename from docs_m2met2_cn/_build/html/objects.inv rename to docs/m2met2_cn/_build/html/objects.inv diff --git a/docs_m2met2_cn/_build/html/search.html b/docs/m2met2_cn/_build/html/search.html similarity index 99% rename from docs_m2met2_cn/_build/html/search.html rename to docs/m2met2_cn/_build/html/search.html index 0257e4c2e..4fe0684db 100644 --- a/docs_m2met2_cn/_build/html/search.html +++ b/docs/m2met2_cn/_build/html/search.html @@ -73,7 +73,7 @@
  • 赛道设置与评估 diff --git a/docs/m2met2_cn/_build/html/searchindex.js b/docs/m2met2_cn/_build/html/searchindex.js new file mode 100644 index 000000000..c9fe167cc --- /dev/null +++ b/docs/m2met2_cn/_build/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({"docnames": ["index", "\u57fa\u7ebf", "\u6570\u636e\u96c6", "\u7b80\u4ecb", "\u7ec4\u59d4\u4f1a", "\u8054\u7cfb\u65b9\u5f0f", "\u89c4\u5219", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30"], "filenames": ["index.rst", "\u57fa\u7ebf.md", "\u6570\u636e\u96c6.md", "\u7b80\u4ecb.md", "\u7ec4\u59d4\u4f1a.md", "\u8054\u7cfb\u65b9\u5f0f.md", "\u89c4\u5219.md", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30.md"], "titles": ["ASRU 2023 \u591a\u901a\u9053\u591a\u65b9\u4f1a\u8bae\u8f6c\u5f55\u6311\u6218 2.0", "\u57fa\u7ebf", "\u6570\u636e\u96c6", "\u7b80\u4ecb", "\u7ec4\u59d4\u4f1a", "\u8054\u7cfb\u65b9\u5f0f", "\u7ade\u8d5b\u89c4\u5219", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30"], "terms": {"m2met": [0, 3, 5, 7], "asru2023": [0, 3], "m2met2": [0, 3, 5, 7], "funasr": 1, "sa": 1, "asr": [1, 3, 7], "speakerencod": 1, "modelscop": [1, 7], "todo": 1, "fill": 1, "with": 1, "the": 1, "readm": 1, "md": 1, "of": 1, "baselin": [1, 2], "aishel": [2, 7], "cn": [2, 4, 7], "celeb": [2, 7], "test": [2, 6, 7], "2023": [2, 3, 6, 7], "118": 2, "75": 2, "104": 2, "train": 2, "eval": [2, 6], "10": [2, 3, 7], "212": 2, "15": [2, 3], "30": 2, "456": 2, "25": 2, "13": [2, 3], "55": 2, "42": 2, "27": 2, "34": 2, "76": 2, "20": 2, "textgrid": 2, "id": 2, "openslr": 2, "automat": 3, "speech": 3, "recognit": 3, "speaker": 3, "diariz": 3, "rich": 3, "transcript": 3, "evalu": 3, "chime": 3, "comput": 3, "hear": 3, "in": 3, "multisourc": 3, "environ": 3, "misp": 3, "multimod": 3, "inform": 3, "base": 3, "process": 3, "multi": 3, "channel": 3, "parti": 3, "meet": 3, "assp2022": 3, "29": 3, "19": 3, "12": 3, "asru": 3, "workshop": 3, "challeng": 3, "session": 3, "lxie": 4, "nwpu": 4, "edu": 4, "kong": 4, "aik": 4, "lee": 4, "star": 4, "kongaik": 4, "ieee": 4, "org": 4, "zhiji": 4, "yzj": 4, "alibaba": 4, "inc": 4, "com": [4, 5], "sli": 4, "zsl": 4, "yanminqian": 4, "sjtu": 4, "zhuc": 4, "microsoft": 4, "wujian": 4, "ceo": 4, "buhui": 4, "aishelldata": 4, "alimeet": [5, 7], "gmail": 5, "cpcer": [6, 7], "las": 6, "rnnt": 6, "transform": 6, "aishell4": 7, "vad": 7, "cer": 7, "ins": 7, "sub": 7, "del": 7, "text": 7, "frac": 7, "mathcal": 7, "n_": 7, "total": 7, "time": 7, "100": 7, "hug": 7, "face": 7}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"asru": 0, "2023": 0, "alimeet": 2, "aoe": 3}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 57}, "alltitles": {"ASRU 2023 \u591a\u901a\u9053\u591a\u65b9\u4f1a\u8bae\u8f6c\u5f55\u6311\u6218 2.0": [[0, "asru-2023-2-0"]], "\u76ee\u5f55:": [[0, null]], "\u57fa\u7ebf": [[1, "id1"]], "\u57fa\u7ebf\u6982\u8ff0": [[1, "id2"]], "\u5feb\u901f\u5f00\u59cb": [[1, "id3"]], "\u57fa\u7ebf\u7ed3\u679c": [[1, "id4"]], "\u6570\u636e\u96c6": [[2, "id1"]], "\u6570\u636e\u96c6\u6982\u8ff0": [[2, "id2"]], "Alimeeting\u6570\u636e\u96c6\u4ecb\u7ecd": [[2, "alimeeting"]], "\u83b7\u53d6\u6570\u636e": [[2, "id3"]], "\u7b80\u4ecb": [[3, "id1"]], "\u7ade\u8d5b\u4ecb\u7ecd": [[3, "id2"]], "\u65f6\u95f4\u5b89\u6392(AOE\u65f6\u95f4)": [[3, "aoe"]], "\u7ade\u8d5b\u62a5\u540d": [[3, "id3"]], "\u7ec4\u59d4\u4f1a": [[4, "id1"]], "\u8054\u7cfb\u65b9\u5f0f": [[5, "id1"]], "\u7ade\u8d5b\u89c4\u5219": [[6, "id1"]], "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30": [[7, "id1"]], "\u8bf4\u8bdd\u4eba\u76f8\u5173\u7684\u8bed\u97f3\u8bc6\u522b": [[7, "id2"]], "\u8bc4\u4f30\u65b9\u6cd5": [[7, "id3"]], "\u5b50\u8d5b\u9053\u8bbe\u7f6e": [[7, "id4"]], "\u5b50\u8d5b\u9053\u4e00 (\u9650\u5b9a\u8bad\u7ec3\u6570\u636e):": [[7, "id5"]], "\u5b50\u8d5b\u9053\u4e8c (\u5f00\u653e\u8bad\u7ec3\u6570\u636e):": [[7, "id6"]]}, "indexentries": {}}) \ No newline at end of file diff --git a/docs_m2met2_cn/_build/html/基线.html b/docs/m2met2_cn/_build/html/基线.html similarity index 98% rename from docs_m2met2_cn/_build/html/基线.html rename to docs/m2met2_cn/_build/html/基线.html index 569ba57e7..f28043ea7 100644 --- a/docs_m2met2_cn/_build/html/基线.html +++ b/docs/m2met2_cn/_build/html/基线.html @@ -89,7 +89,7 @@
  • 赛道设置与评估 @@ -102,7 +102,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • diff --git a/docs_m2met2_cn/_build/html/数据集.html b/docs/m2met2_cn/_build/html/数据集.html similarity index 94% rename from docs_m2met2_cn/_build/html/数据集.html rename to docs/m2met2_cn/_build/html/数据集.html index 3ceb89cfa..ddefcc188 100644 --- a/docs_m2met2_cn/_build/html/数据集.html +++ b/docs/m2met2_cn/_build/html/数据集.html @@ -89,7 +89,7 @@
  • 赛道设置与评估 @@ -102,7 +102,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • @@ -131,10 +131,10 @@

    Alimeeting数据集介绍

    -

    AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集和Eval集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train和Eval集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。

    +

    AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集,Eval集和Test集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train,Eval和Test集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。

    该数据集收集于13个不同的会议室,按照大小规格分为小型、中型和大型三种,房间面积从8到55平方米不等。不同房间具有不同的布局和声学特性,每个房间的详细参数也将发送给参与者。会议场地的墙体材料类型包括水泥、玻璃等。会议场地的家具包括沙发、电视、黑板、风扇、空调、植物等。在录制过程中,麦克风阵列放置于桌上,多个说话人围坐在桌边进行自然对话。麦克风阵列离说话人距离约0.3到5.0米之间。所有说话人的母语均是汉语,并且说的都是普通话,没有浓重的口音。在会议录制期间可能会产生各种室内的噪音,包括键盘声、开门/关门声、风扇声、气泡声等。所有说话人在会议的录制期间均保持相同位置,不发生走动。训练集和验证集的说话人没有重复。图1展示了一个会议室的布局以及麦克风的拓扑结构。

    meeting room

    -

    每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27%和34.76%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。

    +

    每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27%,34.76%和42.8%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。

    dataset detail Test-2023测试集由20场会议组成,这些会议是在与AliMeeting数据集相同的声学环境下录制的。Test-2023测试集中的每个会议环节由2到4个参与者组成并且与AliMeeting测试集的配置相似。

    我们还使用耳机麦克风记录了每个说话人的近场音频信号,并确保只转录对应说话人自己的语音。需要注意的是,麦克风阵列记录的远场音频和耳机麦克风记录的近场音频在时间上是同步的。每场会议的所有抄本均以TextGrid格式存储,内容包括会议的时长、说话人信息(说话人数量、说话人ID、性别等)、每个说话人的片段总数、每个片段的时间戳和转录内容。

    diff --git a/docs_m2met2_cn/_build/html/简介.html b/docs/m2met2_cn/_build/html/简介.html similarity index 94% rename from docs_m2met2_cn/_build/html/简介.html rename to docs/m2met2_cn/_build/html/简介.html index 00e916c96..f1da18e63 100644 --- a/docs_m2met2_cn/_build/html/简介.html +++ b/docs/m2met2_cn/_build/html/简介.html @@ -90,7 +90,7 @@
  • 赛道设置与评估 @@ -103,7 +103,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • @@ -138,18 +138,21 @@

    时间安排(AOE时间)

    竞赛报名

    -

    来自学术界和工业界的有意向参赛者均应在2023年5月5日及之前填写下方的谷歌表单:

    +

    来自学术界和工业界的有意向参赛者均应在2023年5月15日及之前填写下方的谷歌表单:

    +

    M2MET2.0报名

    主办方将在3个工作日内通过电子邮件通知符合条件的参赛团队,团队必须遵守将在挑战网站上发布的挑战规则。在排名发布之前,每个参赛者必须提交一份系统描述文件,详细说明使用的方法和模型。主办方将选择前三名纳入ASRU2023论文集。

    diff --git a/docs_m2met2_cn/_build/html/组委会.html b/docs/m2met2_cn/_build/html/组委会.html similarity index 97% rename from docs_m2met2_cn/_build/html/组委会.html rename to docs/m2met2_cn/_build/html/组委会.html index c295c28ec..ddf93bb58 100644 --- a/docs_m2met2_cn/_build/html/组委会.html +++ b/docs/m2met2_cn/_build/html/组委会.html @@ -27,7 +27,7 @@ - + @@ -40,7 +40,7 @@ 索引
  • - 下一页 |
  • 赛道设置与评估 @@ -102,7 +102,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • @@ -168,7 +168,7 @@
    - Contact + 联系方式
    @@ -183,7 +183,7 @@ 索引
  • - 下一页 |
  • 赛道设置与评估 diff --git a/docs_m2met2_cn/_build/html/规则.html b/docs/m2met2_cn/_build/html/规则.html similarity index 97% rename from docs_m2met2_cn/_build/html/规则.html rename to docs/m2met2_cn/_build/html/规则.html index b6fae2901..5186ebdf3 100644 --- a/docs_m2met2_cn/_build/html/规则.html +++ b/docs/m2met2_cn/_build/html/规则.html @@ -89,7 +89,7 @@
  • 赛道设置与评估 @@ -102,7 +102,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • @@ -129,7 +129,6 @@
  • 赛道设置与评估 @@ -103,7 +103,7 @@
  • 竞赛规则
  • 组委会
  • -
  • Contact
  • +
  • 联系方式
  • @@ -127,8 +127,8 @@

    赛道设置与评估

    -

    说话人相关的语音识别 (主赛道)

    -

    说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,组织者将不提供耳机的近场音频、转录以及真实时间戳。主办方将不再提供每个说话人的真实时间戳,而是在Test-2023集上提供包含多个说话人的片段。这些片段可以通过一个简单的vad模型获得。

    +

    说话人相关的语音识别

    +

    说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,对于Test-2023测试集,主办方将不再提供耳机的近场音频、转录以及真实时间戳。而是提供可以通过一个简单的VAD模型得到的包含多个说话人的片段。

    task difference

    @@ -142,7 +142,7 @@

    子赛道设置

    子赛道一 (限定训练数据):

    -

    参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如Hugging Face以及ModelScope上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。

    +

    参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN-Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如Hugging Face以及ModelScope上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。

    子赛道二 (开放训练数据):

    diff --git a/docs_m2met2_cn/conf.py b/docs/m2met2_cn/conf.py similarity index 100% rename from docs_m2met2_cn/conf.py rename to docs/m2met2_cn/conf.py diff --git a/docs_m2met2_cn/images/baseline_result.png b/docs/m2met2_cn/images/baseline_result.png similarity index 100% rename from docs_m2met2_cn/images/baseline_result.png rename to docs/m2met2_cn/images/baseline_result.png diff --git a/docs_m2met2_cn/images/buhui.jpeg b/docs/m2met2_cn/images/buhui.jpeg similarity index 100% rename from docs_m2met2_cn/images/buhui.jpeg rename to docs/m2met2_cn/images/buhui.jpeg diff --git a/docs_m2met2_cn/images/chenzhuo.jpg b/docs/m2met2_cn/images/chenzhuo.jpg similarity index 100% rename from docs_m2met2_cn/images/chenzhuo.jpg rename to docs/m2met2_cn/images/chenzhuo.jpg diff --git a/docs_m2met2_cn/images/dataset_detail.png b/docs/m2met2_cn/images/dataset_detail.png similarity index 100% rename from docs_m2met2_cn/images/dataset_detail.png rename to docs/m2met2_cn/images/dataset_detail.png diff --git a/docs_m2met2_cn/images/dataset_details.png b/docs/m2met2_cn/images/dataset_details.png similarity index 100% rename from docs_m2met2_cn/images/dataset_details.png rename to docs/m2met2_cn/images/dataset_details.png diff --git a/docs_m2met2_cn/images/kong.png b/docs/m2met2_cn/images/kong.png similarity index 100% rename from docs_m2met2_cn/images/kong.png rename to docs/m2met2_cn/images/kong.png diff --git a/docs_m2met2_cn/images/lxie.jpeg b/docs/m2met2_cn/images/lxie.jpeg similarity index 100% rename from docs_m2met2_cn/images/lxie.jpeg rename to docs/m2met2_cn/images/lxie.jpeg diff --git a/docs_m2met2_cn/images/meeting_room.png b/docs/m2met2_cn/images/meeting_room.png similarity index 100% rename from docs_m2met2_cn/images/meeting_room.png rename to docs/m2met2_cn/images/meeting_room.png diff --git a/docs_m2met2_cn/images/qian.jpeg b/docs/m2met2_cn/images/qian.jpeg similarity index 100% rename from docs_m2met2_cn/images/qian.jpeg rename to docs/m2met2_cn/images/qian.jpeg diff --git a/docs/m2met2_cn/images/sa_asr_arch.png b/docs/m2met2_cn/images/sa_asr_arch.png new file mode 100644 index 000000000..fd65dd2c6 Binary files /dev/null and b/docs/m2met2_cn/images/sa_asr_arch.png differ diff --git a/docs_m2met2_cn/images/task_diff.png b/docs/m2met2_cn/images/task_diff.png similarity index 100% rename from docs_m2met2_cn/images/task_diff.png rename to docs/m2met2_cn/images/task_diff.png diff --git a/docs_m2met2_cn/images/wujian.jpg b/docs/m2met2_cn/images/wujian.jpg similarity index 100% rename from docs_m2met2_cn/images/wujian.jpg rename to docs/m2met2_cn/images/wujian.jpg diff --git a/docs_m2met2_cn/images/zhijie.jpg b/docs/m2met2_cn/images/zhijie.jpg similarity index 100% rename from docs_m2met2_cn/images/zhijie.jpg rename to docs/m2met2_cn/images/zhijie.jpg diff --git a/docs_m2met2_cn/images/zsl.JPG b/docs/m2met2_cn/images/zsl.JPG similarity index 100% rename from docs_m2met2_cn/images/zsl.JPG rename to docs/m2met2_cn/images/zsl.JPG diff --git a/docs_m2met2_cn/index.rst b/docs/m2met2_cn/index.rst similarity index 91% rename from docs_m2met2_cn/index.rst rename to docs/m2met2_cn/index.rst index b35ac96da..c089b36e7 100644 --- a/docs_m2met2_cn/index.rst +++ b/docs/m2met2_cn/index.rst @@ -20,10 +20,3 @@ ASRU 2023 多通道多方会议转录挑战 2.0 ./规则 ./组委会 ./联系方式 - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs_m2met2_cn/make.bat b/docs/m2met2_cn/make.bat similarity index 100% rename from docs_m2met2_cn/make.bat rename to docs/m2met2_cn/make.bat diff --git a/docs_m2met2_cn/基线.md b/docs/m2met2_cn/基线.md similarity index 100% rename from docs_m2met2_cn/基线.md rename to docs/m2met2_cn/基线.md diff --git a/docs_m2met2_cn/数据集.md b/docs/m2met2_cn/数据集.md similarity index 85% rename from docs_m2met2_cn/数据集.md rename to docs/m2met2_cn/数据集.md index 52965a1c5..24bfaf3d9 100644 --- a/docs_m2met2_cn/数据集.md +++ b/docs/m2met2_cn/数据集.md @@ -3,13 +3,13 @@ 在限定数据集条件下,训练数据集仅限于三个公开的语料库,即AliMeeting、AISHELL-4和CN-Celeb。为了评估参赛者提交的模型的性能,我们将发布一个新的测试集(Test-2023)用于打分和排名。下面我们将详细描述AliMeeting数据集和Test-2023测试集。 ## Alimeeting数据集介绍 -AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集和Eval集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train和Eval集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。 +AliMeeting总共包含118.75小时的语音数据,包括104.75小时的训练集(Train)、4小时的验证集(Eval)和10小时的测试集(Test)。Train集,Eval集和Test集分别包含212场和8场会议,其中每场会议由多个说话人进行15到30分钟的讨论。Train,Eval和Test集中参与会议的总人数分别为456人和25人,并且参会的男女比例人数均衡。 该数据集收集于13个不同的会议室,按照大小规格分为小型、中型和大型三种,房间面积从8到55平方米不等。不同房间具有不同的布局和声学特性,每个房间的详细参数也将发送给参与者。会议场地的墙体材料类型包括水泥、玻璃等。会议场地的家具包括沙发、电视、黑板、风扇、空调、植物等。在录制过程中,麦克风阵列放置于桌上,多个说话人围坐在桌边进行自然对话。麦克风阵列离说话人距离约0.3到5.0米之间。所有说话人的母语均是汉语,并且说的都是普通话,没有浓重的口音。在会议录制期间可能会产生各种室内的噪音,包括键盘声、开门/关门声、风扇声、气泡声等。所有说话人在会议的录制期间均保持相同位置,不发生走动。训练集和验证集的说话人没有重复。图1展示了一个会议室的布局以及麦克风的拓扑结构。 ![meeting room](images/meeting_room.png) -每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27\%和34.76\%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。 +每场会议的说话人数量从2到4人不等。同时为了覆盖各种内容的会议场景,我们选择了多种会议主题,包括医疗、教育、商业、组织管理、工业生产等不同内容的例会。Train集,Eval集和Test集的平均语音重叠率分别为42.27\%,34.76\%和42.8\%。AliMeeting Train集,Eval集和Test集的详细信息见表1。表2显示了Train集,Eval集和Test集中不同发言者人数会议的语音重叠率和会议数量。 ![dataset detail](images/dataset_detail.png) Test-2023测试集由20场会议组成,这些会议是在与AliMeeting数据集相同的声学环境下录制的。Test-2023测试集中的每个会议环节由2到4个参与者组成并且与AliMeeting测试集的配置相似。 diff --git a/docs_m2met2_cn/简介.md b/docs/m2met2_cn/简介.md similarity index 90% rename from docs_m2met2_cn/简介.md rename to docs/m2met2_cn/简介.md index cf4dfb86a..52df97d6b 100644 --- a/docs_m2met2_cn/简介.md +++ b/docs/m2met2_cn/简介.md @@ -13,16 +13,20 @@ ASSP2022 M2MeT挑战的侧重点是会议场景,它包括两个赛道:说话 ## 时间安排(AOE时间) -- $ 2023.5.5: $ 参赛者注册截止 +- $ 2023.4.29: $ 开放注册 +- $ 2023.5.8: $ 基线发布 +- $ 2023.5.15: $ 注册截止 - $ 2023.6.9: $ 测试集数据发布 - $ 2023.6.13: $ 最终结果提交截止 - $ 2023.6.19: $ 评估结果和排名发布 - $ 2023.7.3: $ 论文提交截止 - $ 2023.7.10: $ 最终版论文提交截止 -- $ 2023.12.12: $ ASRU Workshop +- $ 2023.12.12: $ ASRU Workshop & challenge session ## 竞赛报名 -来自学术界和工业界的有意向参赛者均应在2023年5月5日及之前填写下方的谷歌表单: +来自学术界和工业界的有意向参赛者均应在2023年5月15日及之前填写下方的谷歌表单: + +[M2MET2.0报名](https://docs.google.com/forms/d/e/1FAIpQLSf77T9vAl7Ym-u5g8gXu18SBofoWRaFShBo26Ym0-HDxHW9PQ/viewform?usp=sf_link) 主办方将在3个工作日内通过电子邮件通知符合条件的参赛团队,团队必须遵守将在挑战网站上发布的挑战规则。在排名发布之前,每个参赛者必须提交一份系统描述文件,详细说明使用的方法和模型。主办方将选择前三名纳入ASRU2023论文集。 \ No newline at end of file diff --git a/docs_m2met2_cn/组委会.md b/docs/m2met2_cn/组委会.md similarity index 100% rename from docs_m2met2_cn/组委会.md rename to docs/m2met2_cn/组委会.md diff --git a/docs_m2met2_cn/联系方式.md b/docs/m2met2_cn/联系方式.md similarity index 100% rename from docs_m2met2_cn/联系方式.md rename to docs/m2met2_cn/联系方式.md diff --git a/docs_m2met2_cn/规则.md b/docs/m2met2_cn/规则.md similarity index 90% rename from docs_m2met2_cn/规则.md rename to docs/m2met2_cn/规则.md index b0928ee54..68cb15972 100644 --- a/docs_m2met2_cn/规则.md +++ b/docs/m2met2_cn/规则.md @@ -4,8 +4,6 @@ - 允许在原始训练数据集上进行数据增强,包括但不限于添加噪声或混响、速度扰动和音调变化。 - 允许参赛者使用Eval集进行模型训练,但Test集仅能用于调参和模型选择,严禁以任何形式使用Test-2023数据集,包括但不限于使用测试数据集微调或训练模型。 - -- 允许多系统融合,但不鼓励使用具有相同结构仅参数不同的子系统融合。 - 如果两个系统的测试cpCER相同,则计算复杂度较低的系统将被认定为更优。 diff --git a/docs_m2met2_cn/赛道设置与评估.md b/docs/m2met2_cn/赛道设置与评估.md similarity index 86% rename from docs_m2met2_cn/赛道设置与评估.md rename to docs/m2met2_cn/赛道设置与评估.md index a99c1eddc..94a623690 100644 --- a/docs_m2met2_cn/赛道设置与评估.md +++ b/docs/m2met2_cn/赛道设置与评估.md @@ -1,6 +1,6 @@ # 赛道设置与评估 -## 说话人相关的语音识别 (主赛道) -说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,组织者将不提供耳机的近场音频、转录以及真实时间戳。主办方将不再提供每个说话人的真实时间戳,而是在Test-2023集上提供包含多个说话人的片段。这些片段可以通过一个简单的vad模型获得。 +## 说话人相关的语音识别 +说话人相关的ASR任务需要从重叠的语音中识别每个说话人的语音,并为识别内容分配一个说话人标签。图2展示了说话人相关语音识别任务和多说话人语音识别任务的主要区别。在本次竞赛中AliMeeting、Aishell4和Cn-Celeb数据集可作为受限数据源。在M2MeT挑战赛中使用的AliMeeting数据集包含训练、评估和测试集,在M2MET2.0可以在训练和评估中使用。此外,一个包含约10小时会议数据的新的Test-2023集将根据赛程安排发布并用于挑战赛的评分和排名。值得注意的是,对于Test-2023测试集,主办方将不再提供耳机的近场音频、转录以及真实时间戳。而是提供可以通过一个简单的VAD模型得到的包含多个说话人的片段。 ![task difference](images/task_diff.png) @@ -12,6 +12,6 @@ $$ \text{CER} = \frac {\mathcal N_{\text{Ins}} + \mathcal N_{\text{Sub}} + \math 其中 $\mathcal N_{\text{Ins}}$ , $\mathcal N_{\text{Sub}}$ , $\mathcal N_{\text{Del}}$ 是三种错误的字符数, $\mathcal N_{\text{Total}}$ 是字符总数. ## 子赛道设置 ### 子赛道一 (限定训练数据): -参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如[Hugging Face](https://huggingface.co/models)以及[ModelScope](https://www.modelscope.cn/models)上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。 +参赛者在系统构建过程中仅能使用AliMeeting、AISHELL-4和CN-Celeb,严禁使用额外数据。参赛者可以任何第三方开源的预训练模型,如[Hugging Face](https://huggingface.co/models)以及[ModelScope](https://www.modelscope.cn/models)上提供的模型。参赛者需要在最终的系统描述文档中详细列出使用的预训练模型名称以及链接。 ### 子赛道二 (开放训练数据): 除了限定数据外,参与者可以使用任何公开可用、私人录制和模拟仿真的数据集。但是,参与者必须清楚地列出使用的数据。同样,参赛者也可以使用任何第三方开源的预训练模型,但必须在最后的系统描述文件中明确的列出所使用的数据和模型链接,如果使用模拟仿真数据,请详细描述数据模拟的方案。 \ No newline at end of file diff --git a/docs_m2met2/_build/doctrees/Introduction.doctree b/docs_m2met2/_build/doctrees/Introduction.doctree deleted file mode 100644 index a5119b7d7..000000000 Binary files a/docs_m2met2/_build/doctrees/Introduction.doctree and /dev/null differ diff --git a/docs_m2met2/_build/doctrees/Organizers.doctree b/docs_m2met2/_build/doctrees/Organizers.doctree deleted file mode 100644 index d8d4e5204..000000000 Binary files a/docs_m2met2/_build/doctrees/Organizers.doctree and /dev/null differ diff --git a/docs_m2met2/_build/doctrees/Rules.doctree b/docs_m2met2/_build/doctrees/Rules.doctree deleted file mode 100644 index 4ac75811c..000000000 Binary files a/docs_m2met2/_build/doctrees/Rules.doctree and /dev/null differ diff --git a/docs_m2met2/_build/doctrees/index.doctree b/docs_m2met2/_build/doctrees/index.doctree deleted file mode 100644 index 1cb0d3dd2..000000000 Binary files a/docs_m2met2/_build/doctrees/index.doctree and /dev/null differ diff --git a/docs_m2met2/_build/html/_images/sa_asr_arch.png b/docs_m2met2/_build/html/_images/sa_asr_arch.png deleted file mode 100644 index 6c662ff67..000000000 Binary files a/docs_m2met2/_build/html/_images/sa_asr_arch.png and /dev/null differ diff --git a/docs_m2met2/_build/html/_sources/Introduction.md.txt b/docs_m2met2/_build/html/_sources/Introduction.md.txt deleted file mode 100644 index c98e6ce7a..000000000 --- a/docs_m2met2/_build/html/_sources/Introduction.md.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Introduction -## Call for participation -Automatic speech recognition (ASR) and speaker diarization have made significant strides in recent years, resulting in a surge of speech technology applications across various domains. However, meetings present unique challenges to speech technologies due to their complex acoustic conditions and diverse speaking styles, including overlapping speech, variable numbers of speakers, far-field signals in large conference rooms, and environmental noise and reverberation. - -Over the years, several challenges have been organized to advance the development of meeting transcription, including the Rich Transcription evaluation and Computational Hearing in Multisource Environments (CHIME) challenges. The latest iteration of the CHIME challenge has a particular focus on distant automatic speech recognition (ASR) and developing systems that can generalize across various array topologies and application scenarios. However, while progress has been made in English meeting transcription, language differences remain a significant barrier to achieving comparable results in non-English languages, such as Mandarin. - -The Multimodal Information Based Speech Processing (MISP) and Multi-Channel Multi-Party Meeting Transcription (M2MeT) challenges have been instrumental in advancing Mandarin meeting transcription. The MISP challenge seeks to address the problem of audio-visual distant multi-microphone signal processing in everyday home environments, while the M2MeT challenge focuses on tackling the speech overlap issue in offline meeting rooms. - -The ICASSP2022 M2MeT challenge focuses on meeting scenarios, and it comprises two main tasks: speaker diarization and multi-speaker automatic speech recognition (ASR). The former involves identifying who spoke when in the meeting, while the latter aims to transcribe speech from multiple speakers simultaneously, which poses significant technical difficulties due to overlapping speech and acoustic interferences. - -Building on the success of the previous M2MeT challenge, we are excited to propose the M2MeT2.0 challenge as an ASRU2023 challenge special session. In the original M2MeT challenge, the evaluation metric was speaker-independent, which meant that the transcription could be determined, but not the corresponding speaker. To address this limitation and further advance the current multi-talker ASR system towards practicality, the M2MeT2.0 challenge proposes the speaker-attributed ASR task with two sub-tracks: fixed and open training conditions. By attributing speech to specific speakers, this task aims to improve the accuracy and applicability of multi-talker ASR systems in real-world settings. The challenge provides detailed datasets, rules, evaluation methods, and baseline systems to facilitate reproducible research in this field. The speaker-attribute automatic speech recognition (ASR) task aims to tackle the practical and challenging problem of identifying "who spoke what at when". To facilitate reproducible research in this field, we offer a comprehensive overview of the dataset, rules, evaluation metrics, and baseline systems. Furthermore, we will release a carefully curated test set, comprising approximately 10 hours of audio, according to the timeline. The new test set is designed to enable researchers to validate and compare their models' performance and advance the state of the art in this area. - -## Timeline(AOE Time) - -- $ May~5^{th}, 2023: $ Registration deadline, the due date for participants to join the Challenge. -- $ June~9^{th}, 2023: $ Test data release. -- $ June~13^{rd}, 2023: $ Final submission deadline. -- $ June~19^{th}, 2023: $ Evaluation result and ranking release. -- $ July~3^{rd}, 2023: $ Deadline for paper submission. -- $ July~10^{th}, 2023: $ Deadline for final paper submission. -- $ December~12^{nd}\ to\ 16^{th}, 2023: $ ASRU Workshop - -## Guidelines - -Possible improved version: Interested participants, whether from academia or industry, must register for the challenge by completing a Google form, which will be available here. The deadline for registration is May 5, 2023. - -Within three working days, the challenge organizer will send email invitations to eligible teams to participate in the challenge. All qualified teams are required to adhere to the challenge rules, which will be published on the challenge page. Prior to the ranking release time, each participant must submit a system description document detailing their approach and methods. The organizer will select the top three submissions to be included in the ASRU2023 Proceedings. diff --git a/docs_m2met2/_build/html/_sources/Organizers.md.txt b/docs_m2met2/_build/html/_sources/Organizers.md.txt deleted file mode 100644 index 5aea55846..000000000 --- a/docs_m2met2/_build/html/_sources/Organizers.md.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Organizers -***Lei Xie, Professor, Northwestern Polytechnical University, China*** - -Email: [lxie@nwpu.edu.cn](mailto:lxie@nwpu.edu.cn) - -lxie - -Lei Xie received the Ph.D. degree in computer science from Northwestern Polytechnical University, Xi'an, China, in 2004. From 2001 to 2002, he was with the Department of Electronics and Information Processing, Vrije Universiteit Brussel (VUB), Brussels, Belgium, as a Visiting Scientist. From 2004 to 2006, he was a Senior Research Associate with the Center for Media Technology, School of Creative Media, City University of Hong Kong, Hong Kong, China. From 2006 to 2007, he was a Postdoctoral Fellow with the Human-Computer Communications Laboratory (HCCL), The Chinese University of Hong Kong, Hong Kong, China. He is currently a Professor with School of Computer Science, Northwestern Polytechnical University, Xian, China and leads the Audio, Speech and Language Processing Group (ASLP@NPU). He has published over 200 papers in referred journals and conferences, such as IEEE/ACM Transactions on Audio, Speech and Language Processing, IEEE Transactions on Multimedia, Interspeech, ICASSP, ASRU, ACL and ACM Multimedia. He has achieved several best paper awards in flagship conferences. His current research interests include general topics in speech and language processing, multimedia, and human-computer interaction. Dr. Xie is currently an associate editor (AE) of IEEE/ACM Trans. on Audio, Speech and language Processing. He has actively served as Chairs in many conferences and technical committees. He serves as an IEEE Speech and Language Processing -Technical Committee Member. - -***Kong Aik Lee, Senior Scientist at Institute for Infocomm Research, A\*Star, Singapore*** - -Email: [kongaik.lee@ieee.org](mailto:kongaik.lee@ieee.org) - -kong - -Kong Aik Lee started off him career as a researcher, then a team leader and a strategic planning manager, at the Institute Infocomm Research, A*STAR, Singapore, working on speaker and language recognition research. From 2018 to 2020, he spent two and a half years in NEC Corporation, Japan, focusing very much on voice biometrics and multi-modal biometrics products. He is proud to work with a great team on voice biometrics featured on NEC Bio-Idiom platform. He returned to Singapore in July 2020, and now leading the speech and audio analytics research at the Institute for Infocomm Research, as a Senior Scientist and PI. He also serve as an Editor for Elsevier Computer Speech and Language (since 2016), and was an Associate Editor for IEEE/ACM Transactions on Audio, Speech and Language Processing (2017 - 2021), and am an elected member of IEEE Speech and Language Technical Committee (2019 - 2021). - -***Zhijie Yan, Principal Engineer at Alibaba, China*** -Email: [zhijie.yzj@alibaba-inc.com](mailto:zhijie.yzj@alibaba-inc.com) - -zhijie - -Zhijie Yan holds a PhD from the University of Science and Technology of China, and is a senior member of the Institute of Electrical and Electronics Engineers (IEEE). He is also an expert reviewer of top academic conferences and journals in the speech field. His research fields include speech recognition, speech synthesis, voiceprints, and speech interaction. His research results are applied in speech services provided by Alibaba Group and Ant Financial. He was awarded the title of "One of the Top 100 Grassroots Scientists" by the China Association for Science and Technology. - - -***Shiliang Zhang, Senior Engineer at Alibaba, China*** -Email: [sly.zsl@alibaba-inc.com](mailto:sly.zsl@alibaba-inc.com) - -zsl - -Shiliang Zhang graduated with a Ph.D. from the University of Science and Technology of China in 2017. His research areas mainly include speech recognition, natural language understanding, and machine learning. Currently, he has published over 40 papers in mainstream academic journals and conferences in the fields of speech and machine learning, and has applied for dozens of patents. After obtaining his doctorate degree, he joined the Alibaba Intelligent Speech team. He is currently leading the direction of speech recognition and fundamental technology at DAMO Academy's speech laboratory. - - - -***Yanmin Qian, Professor, Shanghai Jiao Tong University, China*** - -Email: [yanminqian@sjtu.edu.cn](mailto:yanminqian@sjtu.edu.cn) - -qian - -Yanmin Qian received the B.S. degree from the Department of Electronic and Information Engineering,Huazhong University of Science and Technology, Wuhan, China, in 2007, and the Ph.D. degree from the Department of Electronic Engineering, Tsinghua University, Beijing, China, in 2012. Since 2013, he has been with the Department of Computer Science and Engineering, Shanghai Jiao Tong University (SJTU), Shanghai, China, where he is currently an Associate Professor. From 2015 to 2016, he also worked as an Associate Research in the Speech Group, Cambridge University Engineering Department, Cambridge, U.K. He is a senior member of IEEE and a member of ISCA, and one of the founding members of Kaldi Speech Recognition Toolkit. He has published more than 110 papers on speech and language processing with 4000+ citations, including the top conference: ICASSP, INTERSPEECH and ASRU. His current research interests include the acoustic and language modeling in speech recognition, speaker and language recognition, key word spotting, and multimedia signal processing. - - - -***Zhuo Chen, Applied Scientist in Microsoft, USA*** - -Email: [zhuc@microsoft.com](mailto:zhuc@microsoft.com) - -chenzhuo - -Zhuo Chen received the Ph.D. degree from Columbia University, New York, NY, USA, in 2017. He is currently a Principal Applied Data Scientist with Microsoft. He has authored or coauthored more than 80 papers in peer-reviewed journals and conferences with around 6000 citations. He is a reviewer or technical committee member for more than ten journals and conferences. His research interests include automatic conversation recognition, speech separation, diarisation, and speaker information extraction. He actively participated in the academic events and challenges, and won several awards. Meanwhile, he contributed to open-sourced datasets, such as WSJ0-2mix, LibriCSS, and AISHELL-4, that have been main benchmark datasets for multi-speaker processing research. In 2020, he was the Team Leader in 2020 Jelinek workshop, leading more than 30 researchers and students to push the state of the art in conversation transcription. - -***Jian Wu, Applied Scientist in Microsoft, USA*** - -Email: [wujian@microsoft.com](mailto:wujian@microsoft.com) - -wujian - -Jian Wu received a master degree from Northwestern Polytechnical University, Xi'an, China, in 2020 and currently he is a Applied Scientist in Microsoft, USA. His research interests cover multi-channel signal processing, robust and multi-talker speech recognition, speech enhancement, dereverberation and separation. He has around 30 conference publications with a total citation over 1200. He participated in several challenges such as CHiME5, DNS 2020 and FFSVC 2020 and contributed to the open-sourced datasets including LibriCSS and AISHELL-4. He is also a reviewer for several journals and conferences such as ICASSP, SLT, TASLP and SPL. - -***Hui Bu, CEO, AISHELL foundation, China*** - -Email: [buhui@aishelldata.com](mailto:buhui@aishelldata.com) - -buhui - -Hui Bu received his master degree in the Artificial Intelligence Laboratory of Korea University in 2014. He is the founder and the CEO of AISHELL and AISHELL foundation. He participated in the release of AISHELL 1 \& 2 \& 3 \& 4, DMASH and HI-MIA open source database project and is the co-founder of China Kaldi offline Technology Forum. diff --git a/docs_m2met2/_build/html/searchindex.js b/docs_m2met2/_build/html/searchindex.js deleted file mode 100644 index 940cc2856..000000000 --- a/docs_m2met2/_build/html/searchindex.js +++ /dev/null @@ -1 +0,0 @@ -Search.setIndex({"docnames": ["Baseline", "Contact", "Dataset", "Introduction", "Organizers", "Rules", "Track_setting_and_evaluation", "index"], "filenames": ["Baseline.md", "Contact.md", "Dataset.md", "Introduction.md", "Organizers.md", "Rules.md", "Track_setting_and_evaluation.md", "index.rst"], "titles": ["Baseline", "Contact", "Datasets", "Introduction", "Organizers", "Rules", "Track & Evaluation", "ASRU 2023 MULTI-CHANNEL MULTI-PARTY MEETING TRANSCRIPTION CHALLENGE 2.0 (M2MeT2.0)"], "terms": {"we": [0, 2, 3, 7], "releas": [0, 2, 3, 4, 6], "an": [0, 2, 3, 4, 6], "e2": 0, "sa": 0, "asr": [0, 3, 7], "cite": 0, "kanda21b_interspeech": 0, "conduct": [0, 2], "funasr": 0, "time": [0, 6], "accord": [0, 3], "timelin": [0, 2], "The": [0, 2, 3, 4, 5, 6], "model": [0, 2, 3, 4, 5, 6], "architectur": 0, "i": [0, 2, 3, 4, 5], "shown": [0, 2], "figur": [0, 6], "3": [0, 2, 3, 4], "speakerencod": 0, "initi": 0, "pre": [0, 6], "train": [0, 3, 5, 7], "speaker": [0, 2, 3, 4, 7], "verif": 0, "from": [0, 2, 3, 4, 5, 6], "modelscop": [0, 6], "thi": [0, 3, 5, 6], "also": [0, 2, 4, 6], "us": [0, 2, 5, 6], "extract": [0, 4], "embed": 0, "profil": 0, "todo": 0, "fill": 0, "readm": 0, "md": 0, "system": [0, 3, 5, 6, 7], "ar": [0, 2, 3, 4, 5, 6, 7], "tabl": [0, 2], "adopt": 0, "oracl": [0, 6], "dure": [0, 2, 6], "howev": [0, 3, 6], "due": [0, 3], "lack": 0, "label": [0, 5, 6], "evalu": [0, 2, 3, 7], "provid": [0, 2, 3, 4, 6, 7], "addit": [0, 6], "spectral": 0, "cluster": 0, "meanwhil": [0, 4], "eval": [0, 2, 5, 6], "test": [0, 2, 3, 5, 6], "set": [0, 2, 3, 5, 6], "show": 0, "impact": 0, "accuraci": [0, 3, 6], "If": [1, 5, 6], "you": 1, "have": [1, 3, 4], "ani": [1, 5, 6], "question": 1, "about": 1, "m2met2": [1, 3], "0": [1, 2, 3], "challeng": [1, 3, 4, 5, 6], "pleas": 1, "u": [1, 2, 4], "email": [1, 3, 4], "m2met": [1, 3, 6, 7], "alimeet": [1, 6], "gmail": 1, "com": [1, 4], "wechat": 1, "group": [1, 2, 4], "In": [2, 3, 4, 5], "fix": [2, 3, 7], "condit": [2, 3, 7], "restrict": 2, "three": [2, 3, 6], "publicli": [2, 6], "avail": [2, 3, 6], "corpora": 2, "name": 2, "aishel": [2, 4, 6], "4": [2, 4, 6], "cn": [2, 4, 6], "celeb": [2, 6], "To": [2, 3, 7], "perform": [2, 3], "new": [2, 3, 4, 6], "call": 2, "2023": [2, 3, 5, 6], "score": [2, 6], "rank": [2, 3, 6], "describ": 2, "contain": [2, 6], "118": 2, "75": 2, "hour": [2, 3, 6], "speech": [2, 3, 4, 6, 7], "total": [2, 4, 6], "divid": [2, 6], "104": 2, "10": [2, 3, 6], "specif": [2, 3, 6], "212": 2, "8": 2, "session": [2, 3, 6, 7], "respect": 2, "each": [2, 3, 6], "consist": [2, 6], "15": 2, "30": [2, 4], "minut": 2, "discuss": 2, "particip": [2, 4, 5, 6], "number": [2, 3, 6], "456": 2, "25": 2, "balanc": 2, "gender": 2, "coverag": 2, "collect": 2, "13": [2, 3], "meet": [2, 3, 6], "venu": 2, "which": [2, 3, 6], "categor": 2, "type": 2, "small": 2, "medium": 2, "larg": [2, 3], "room": [2, 3], "size": 2, "rang": 2, "m": 2, "2": [2, 4, 6], "55": 2, "differ": [2, 3, 5, 6], "give": 2, "varieti": 2, "acoust": [2, 3, 4, 6], "properti": 2, "layout": 2, "paramet": [2, 5], "togeth": 2, "wall": 2, "materi": 2, "cover": [2, 4], "cement": 2, "glass": 2, "etc": 2, "other": 2, "furnish": 2, "includ": [2, 3, 4, 5, 6], "sofa": 2, "tv": 2, "blackboard": 2, "fan": 2, "air": 2, "condition": 2, "plant": 2, "record": [2, 6], "sit": 2, "around": [2, 4], "microphon": [2, 3], "arrai": [2, 3], "place": 2, "natur": [2, 4], "convers": [2, 4], "distanc": 2, "5": [2, 3], "all": [2, 3, 5, 6], "nativ": 2, "chines": [2, 4], "speak": [2, 3], "mandarin": [2, 3], "without": 2, "strong": 2, "accent": 2, "variou": [2, 3], "kind": 2, "indoor": 2, "nois": [2, 3, 5], "limit": [2, 3, 5], "click": 2, "keyboard": 2, "door": 2, "open": [2, 3, 4, 7], "close": 2, "bubbl": 2, "made": [2, 3], "For": 2, "both": [2, 6], "requir": [2, 3, 6], "remain": [2, 3], "same": [2, 5], "posit": 2, "There": 2, "overlap": [2, 3], "between": [2, 6], "exampl": 2, "fig": 2, "1": [2, 4], "within": [2, 3], "one": [2, 4, 5], "ensur": 2, "ratio": 2, "select": [2, 3, 5, 6], "topic": [2, 4], "medic": 2, "treatment": 2, "educ": 2, "busi": 2, "organ": [2, 3, 5, 6, 7], "manag": [2, 4], "industri": [2, 3], "product": [2, 4], "daili": 2, "routin": 2, "averag": 2, "42": 2, "27": 2, "34": 2, "76": 2, "more": [2, 4], "A": [2, 4], "distribut": 2, "20": 2, "were": 2, "ident": [2, 6], "compris": [2, 3, 7], "therebi": 2, "share": 2, "similar": 2, "configur": 2, "field": [2, 3, 4, 6], "signal": [2, 3, 4], "headset": 2, "onli": [2, 5, 6], "": [2, 4, 6], "own": 2, "transcrib": [2, 3, 6], "It": [2, 6], "worth": [2, 6], "note": [2, 6], "far": [2, 3], "audio": [2, 3, 4, 6], "synchron": 2, "common": 2, "transcript": [2, 3, 4, 5, 6], "prepar": 2, "textgrid": 2, "format": 2, "inform": [2, 3, 4], "durat": 2, "id": 2, "segment": [2, 6], "timestamp": [2, 6], "mention": 2, "abov": 2, "can": [2, 3, 5, 6], "download": 2, "openslr": 2, "via": 2, "follow": [2, 5], "link": 2, "particularli": 2, "baselin": [2, 3, 7], "conveni": 2, "script": 2, "automat": [3, 4, 7], "recognit": [3, 4, 7], "diariz": 3, "signific": 3, "stride": 3, "recent": 3, "year": [3, 4], "result": [3, 4], "surg": 3, "technologi": [3, 4], "applic": 3, "across": 3, "domain": 3, "present": 3, "uniqu": [3, 6], "complex": [3, 5], "divers": 3, "style": 3, "variabl": 3, "confer": [3, 4], "environment": 3, "reverber": [3, 5], "over": [3, 4], "sever": [3, 4], "been": [3, 4], "advanc": [3, 7], "develop": [3, 6], "rich": 3, "comput": [3, 4, 5], "hear": 3, "multisourc": 3, "environ": 3, "chime": 3, "latest": 3, "iter": 3, "ha": [3, 4], "particular": 3, "focu": 3, "distant": 3, "gener": [3, 4], "topologi": 3, "scenario": 3, "while": 3, "progress": 3, "english": 3, "languag": [3, 4, 5], "barrier": 3, "achiev": [3, 4], "compar": 3, "non": 3, "multimod": 3, "base": 3, "process": [3, 4, 6], "misp": 3, "multi": [3, 4, 5, 6], "channel": [3, 4], "parti": [3, 6], "instrument": 3, "seek": 3, "address": 3, "problem": 3, "visual": 3, "everydai": 3, "home": 3, "focus": [3, 4], "tackl": 3, "issu": 3, "offlin": [3, 4], "icassp2022": 3, "two": [3, 4, 5, 7], "main": [3, 4], "task": [3, 6, 7], "former": 3, "involv": [3, 6], "identifi": 3, "who": 3, "spoke": 3, "when": 3, "latter": 3, "aim": 3, "multipl": [3, 6], "simultan": 3, "pose": [3, 6], "technic": [3, 4], "difficulti": 3, "interfer": 3, "build": [3, 6, 7], "success": [3, 7], "previou": 3, "excit": 3, "propos": [3, 7], "asru2023": [3, 7], "special": [3, 5, 7], "origin": [3, 5], "metric": [3, 7], "wa": [3, 4, 6], "independ": 3, "meant": 3, "could": 3, "determin": 3, "correspond": [3, 5], "further": 3, "current": [3, 4, 7], "talker": [3, 4, 7], "toward": 3, "practic": 3, "attribut": [3, 7], "sub": [3, 5, 7], "track": [3, 5, 7], "By": 3, "improv": 3, "real": 3, "world": 3, "detail": [3, 6], "dataset": [3, 4, 5, 6, 7], "rule": [3, 7], "method": 3, "facilit": [3, 7], "reproduc": [3, 7], "research": [3, 4, 7], "what": 3, "offer": 3, "comprehens": [3, 7], "overview": [3, 7], "furthermor": 3, "carefulli": 3, "curat": 3, "approxim": [3, 6], "design": 3, "enabl": 3, "valid": 3, "state": [3, 4, 6, 7], "art": [3, 4, 7], "area": [3, 4], "mai": 3, "th": 3, "registr": 3, "deadlin": 3, "date": 3, "join": [3, 4], "june": 3, "9": 3, "data": [3, 4, 5, 6], "rd": 3, "final": [3, 5, 6], "submiss": 3, "19": 3, "juli": [3, 4], "paper": [3, 4, 6], "decemb": 3, "12": 3, "nd": 3, "16": 3, "asru": [3, 4], "workshop": [3, 4], "possibl": [3, 6], "version": 3, "interest": [3, 4], "whether": 3, "academia": 3, "must": [3, 5, 6], "regist": 3, "complet": 3, "googl": 3, "form": 3, "here": 3, "work": [3, 4], "dai": 3, "send": 3, "invit": 3, "elig": [3, 5], "team": [3, 4], "qualifi": 3, "adher": [3, 5], "publish": [3, 4], "page": [3, 7], "prior": 3, "submit": 3, "descript": [3, 6], "document": 3, "approach": [3, 5], "top": [3, 4], "proceed": 3, "lei": 4, "xie": 4, "professor": 4, "northwestern": 4, "polytechn": 4, "univers": 4, "china": 4, "lxie": 4, "nwpu": 4, "edu": 4, "receiv": 4, "ph": 4, "d": 4, "degre": 4, "scienc": 4, "xi": 4, "2004": 4, "2001": 4, "2002": 4, "he": 4, "depart": 4, "electron": 4, "vrije": 4, "universiteit": 4, "brussel": 4, "vub": 4, "belgium": 4, "visit": 4, "scientist": 4, "2006": 4, "senior": 4, "associ": 4, "center": 4, "media": 4, "school": 4, "creativ": 4, "citi": 4, "hong": 4, "kong": 4, "2007": 4, "postdoctor": 4, "fellow": 4, "human": 4, "commun": 4, "laboratori": 4, "hccl": 4, "xian": 4, "lead": 4, "aslp": 4, "npu": 4, "200": 4, "refer": [4, 6], "journal": 4, "ieee": 4, "acm": 4, "transact": 4, "multimedia": 4, "interspeech": 4, "icassp": 4, "acl": 4, "best": 4, "award": 4, "flagship": 4, "hi": 4, "interact": 4, "dr": 4, "editor": 4, "ae": 4, "tran": 4, "activ": [4, 6], "serv": 4, "chair": 4, "mani": 4, "committe": 4, "member": 4, "aik": 4, "lee": 4, "institut": 4, "infocomm": 4, "star": 4, "singapor": 4, "kongaik": 4, "org": 4, "start": 4, "off": 4, "him": 4, "career": 4, "leader": 4, "strateg": 4, "plan": 4, "2018": 4, "2020": 4, "spent": 4, "half": 4, "nec": 4, "corpor": 4, "japan": 4, "veri": 4, "much": 4, "voic": [4, 6], "biometr": 4, "modal": 4, "proud": 4, "great": 4, "featur": 4, "bio": 4, "idiom": 4, "platform": 4, "return": 4, "now": 4, "analyt": 4, "pi": 4, "elsevi": 4, "sinc": 4, "2016": 4, "2017": 4, "2021": 4, "am": 4, "elect": 4, "2019": 4, "zhiji": 4, "yan": 4, "princip": 4, "engin": 4, "alibaba": 4, "yzj": 4, "inc": 4, "hold": 4, "phd": 4, "electr": 4, "expert": 4, "review": 4, "academ": 4, "synthesi": 4, "voiceprint": 4, "appli": 4, "servic": 4, "ant": 4, "financi": 4, "titl": 4, "One": 4, "100": [4, 6], "grassroot": 4, "shiliang": 4, "zhang": 4, "sly": 4, "zsl": 4, "graduat": 4, "mainli": 4, "understand": 4, "machin": 4, "learn": 4, "40": 4, "mainstream": 4, "dozen": 4, "patent": 4, "after": 4, "obtain": [4, 5, 6], "doctor": 4, "intellig": 4, "direct": 4, "fundament": 4, "damo": 4, "academi": 4, "yanmin": 4, "qian": 4, "shanghai": 4, "jiao": 4, "tong": 4, "yanminqian": 4, "sjtu": 4, "b": 4, "huazhong": 4, "wuhan": 4, "tsinghua": 4, "beij": 4, "2012": 4, "2013": 4, "where": [4, 6], "2015": 4, "cambridg": 4, "k": 4, "isca": 4, "found": 4, "kaldi": 4, "toolkit": 4, "than": 4, "110": 4, "4000": 4, "citat": 4, "kei": 4, "word": 4, "spot": 4, "zhuo": 4, "chen": 4, "microsoft": 4, "usa": 4, "zhuc": 4, "columbia": 4, "york": 4, "ny": 4, "author": 4, "coauthor": 4, "80": 4, "peer": 4, "6000": 4, "ten": 4, "separ": 4, "diaris": 4, "event": 4, "won": 4, "contribut": 4, "sourc": [4, 6], "wsj0": 4, "2mix": 4, "libricss": 4, "benchmark": 4, "jelinek": 4, "student": 4, "push": 4, "jian": 4, "wu": 4, "wujian": 4, "master": 4, "robust": 4, "enhanc": 4, "dereverber": 4, "public": 4, "1200": 4, "chime5": 4, "dn": 4, "ffsvc": 4, "slt": 4, "taslp": 4, "spl": 4, "hui": 4, "bu": 4, "ceo": 4, "foundat": 4, "buhui": 4, "aishelldata": 4, "artifici": 4, "korea": 4, "2014": 4, "founder": 4, "dmash": 4, "mia": 4, "databas": 4, "project": 4, "co": 4, "forum": 4, "should": 5, "augment": 5, "allow": [5, 6], "ad": 5, "speed": 5, "perturb": 5, "tone": 5, "chang": 5, "permit": 5, "purpos": 5, "instead": [5, 6], "util": [5, 6], "tune": 5, "violat": 5, "strictli": [5, 6], "prohibit": [5, 6], "fine": 5, "fusion": 5, "structur": 5, "encourag": 5, "cpcer": [5, 6], "lower": 5, "judg": 5, "superior": 5, "forc": 5, "align": 5, "frame": 5, "level": 5, "classif": 5, "basi": 5, "shallow": 5, "end": 5, "e": [5, 6], "g": 5, "la": 5, "rnnt": 5, "transform": [5, 6], "come": 5, "right": 5, "interpret": 5, "belong": 5, "case": 5, "circumst": 5, "coordin": 5, "assign": 6, "illustr": 6, "aishell4": 6, "constrain": 6, "addition": 6, "corpu": 6, "soon": 6, "simpl": 6, "detect": 6, "vad": 6, "concaten": 6, "minimum": 6, "permut": 6, "charact": 6, "error": 6, "rate": 6, "calcul": 6, "step": 6, "firstli": 6, "hypothesi": 6, "chronolog": 6, "order": 6, "secondli": 6, "cer": 6, "repeat": 6, "lowest": 6, "tthe": 6, "insert": 6, "Ins": 6, "substitut": 6, "delet": 6, "del": 6, "output": 6, "text": 6, "frac": 6, "mathcal": 6, "n_": 6, "usag": 6, "third": 6, "hug": 6, "face": 6, "list": 6, "clearli": 6, "privat": 6, "manual": 6, "simul": 6, "thei": 6, "mandatori": 6, "clear": 6, "scheme": 6, "delight": 7, "introduct": 7, "contact": 7, "index": 7, "modul": 7, "search": 7}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"baselin": 0, "overview": [0, 2], "quick": 0, "start": 0, "result": 0, "contact": 1, "dataset": 2, "train": [2, 6], "data": 2, "detail": 2, "alimeet": 2, "corpu": 2, "get": 2, "introduct": 3, "call": 3, "particip": 3, "timelin": 3, "aoe": 3, "time": 3, "guidelin": 3, "organ": 4, "rule": 5, "track": 6, "evalu": 6, "speaker": 6, "attribut": 6, "asr": 6, "main": 6, "metric": 6, "sub": 6, "arrang": 6, "i": 6, "fix": 6, "condit": 6, "ii": 6, "open": 6, "asru": 7, "2023": 7, "multi": 7, "channel": 7, "parti": 7, "meet": 7, "transcript": 7, "challeng": 7, "2": 7, "0": 7, "m2met2": 7, "content": 7, "indic": 7, "tabl": 7}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 57}, "alltitles": {"Baseline": [[0, "baseline"]], "Overview": [[0, "overview"]], "Quick start": [[0, "quick-start"]], "Baseline results": [[0, "baseline-results"]], "Contact": [[1, "contact"]], "Datasets": [[2, "datasets"]], "Overview of training data": [[2, "overview-of-training-data"]], "Detail of AliMeeting corpus": [[2, "detail-of-alimeeting-corpus"]], "Get the data": [[2, "get-the-data"]], "Introduction": [[3, "introduction"]], "Call for participation": [[3, "call-for-participation"]], "Timeline(AOE Time)": [[3, "timeline-aoe-time"]], "Guidelines": [[3, "guidelines"]], "Organizers": [[4, "organizers"]], "Rules": [[5, "rules"]], "Track & Evaluation": [[6, "track-evaluation"]], "Speaker-Attributed ASR (Main Track)": [[6, "speaker-attributed-asr-main-track"]], "Evaluation metric": [[6, "evaluation-metric"]], "Sub-track arrangement": [[6, "sub-track-arrangement"]], "Sub-track I (Fixed Training Condition):": [[6, "sub-track-i-fixed-training-condition"]], "Sub-track II (Open Training Condition):": [[6, "sub-track-ii-open-training-condition"]], "ASRU 2023 MULTI-CHANNEL MULTI-PARTY MEETING TRANSCRIPTION CHALLENGE 2.0 (M2MeT2.0)": [[7, "asru-2023-multi-channel-multi-party-meeting-transcription-challenge-2-0-m2met2-0"]], "Contents:": [[7, null]], "Indices and tables": [[7, "indices-and-tables"]]}, "indexentries": {}}) \ No newline at end of file diff --git a/docs_m2met2_cn/_build/doctrees/environment.pickle b/docs_m2met2_cn/_build/doctrees/environment.pickle deleted file mode 100644 index 500bee7cc..000000000 Binary files a/docs_m2met2_cn/_build/doctrees/environment.pickle and /dev/null differ diff --git a/docs_m2met2_cn/_build/doctrees/index.doctree b/docs_m2met2_cn/_build/doctrees/index.doctree deleted file mode 100644 index c816bd988..000000000 Binary files a/docs_m2met2_cn/_build/doctrees/index.doctree and /dev/null differ diff --git a/docs_m2met2_cn/_build/html/searchindex.js b/docs_m2met2_cn/_build/html/searchindex.js deleted file mode 100644 index 8042b77c9..000000000 --- a/docs_m2met2_cn/_build/html/searchindex.js +++ /dev/null @@ -1 +0,0 @@ -Search.setIndex({"docnames": ["index", "\u57fa\u7ebf", "\u6570\u636e\u96c6", "\u7b80\u4ecb", "\u7ec4\u59d4\u4f1a", "\u8054\u7cfb\u65b9\u5f0f", "\u89c4\u5219", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30"], "filenames": ["index.rst", "\u57fa\u7ebf.md", "\u6570\u636e\u96c6.md", "\u7b80\u4ecb.md", "\u7ec4\u59d4\u4f1a.md", "\u8054\u7cfb\u65b9\u5f0f.md", "\u89c4\u5219.md", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30.md"], "titles": ["ASRU 2023 \u591a\u901a\u9053\u591a\u65b9\u4f1a\u8bae\u8f6c\u5f55\u6311\u6218 2.0", "\u57fa\u7ebf", "\u6570\u636e\u96c6", "\u7b80\u4ecb", "\u7ec4\u59d4\u4f1a", "\u8054\u7cfb\u65b9\u5f0f", "\u7ade\u8d5b\u89c4\u5219", "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30"], "terms": {"m2met": [0, 3, 5, 7], "asru2023": [0, 3], "m2met2": [0, 3, 5, 7], "contact": [], "funasr": 1, "sa": 1, "asr": [1, 3, 7], "speakerencod": 1, "modelscop": [1, 7], "todo": 1, "fill": 1, "with": 1, "the": 1, "readm": 1, "md": 1, "of": 1, "baselin": [1, 2], "aishel": [2, 7], "cn": [2, 4, 7], "celeb": [2, 7], "test": [2, 6, 7], "2023": [2, 3, 6, 7], "118": 2, "75": 2, "104": 2, "train": 2, "eval": [2, 6], "10": [2, 3, 7], "212": 2, "15": 2, "30": 2, "456": 2, "25": 2, "13": [2, 3], "55": 2, "42": 2, "27": 2, "34": 2, "76": 2, "20": 2, "textgrid": 2, "id": 2, "openslr": 2, "automat": 3, "speech": 3, "recognit": 3, "speaker": 3, "diariz": 3, "rich": 3, "transcript": 3, "evalu": 3, "chime": 3, "comput": 3, "hear": 3, "in": 3, "multisourc": 3, "environ": 3, "misp": 3, "multimod": 3, "inform": 3, "base": 3, "process": 3, "multi": 3, "channel": 3, "parti": 3, "meet": 3, "assp2022": 3, "19": 3, "12": 3, "asru": 3, "workshop": 3, "lxie": 4, "nwpu": 4, "edu": 4, "kong": 4, "aik": 4, "lee": 4, "star": 4, "kongaik": 4, "ieee": 4, "org": 4, "zhiji": 4, "yzj": 4, "alibaba": 4, "inc": 4, "com": [4, 5], "sli": 4, "zsl": 4, "yanminqian": 4, "sjtu": 4, "zhuc": 4, "microsoft": 4, "wujian": 4, "ceo": 4, "buhui": 4, "aishelldata": 4, "alimeet": [5, 7], "gmail": 5, "cpcer": [6, 7], "las": 6, "rnnt": 6, "transform": 6, "aishell4": 7, "vad": 7, "cer": 7, "ins": 7, "sub": 7, "del": 7, "text": 7, "frac": 7, "mathcal": 7, "n_": 7, "total": 7, "time": 7, "100": 7, "hug": 7, "face": 7}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"asru": 0, "2023": 0, "indic": 0, "and": 0, "tabl": 0, "alimeet": 2, "aoe": 3, "contact": []}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 57}, "alltitles": {"ASRU 2023 \u591a\u901a\u9053\u591a\u65b9\u4f1a\u8bae\u8f6c\u5f55\u6311\u6218 2.0": [[0, "asru-2023-2-0"]], "\u76ee\u5f55:": [[0, null]], "Indices and tables": [[0, "indices-and-tables"]], "\u57fa\u7ebf": [[1, "id1"]], "\u57fa\u7ebf\u6982\u8ff0": [[1, "id2"]], "\u5feb\u901f\u5f00\u59cb": [[1, "id3"]], "\u57fa\u7ebf\u7ed3\u679c": [[1, "id4"]], "\u6570\u636e\u96c6": [[2, "id1"]], "\u6570\u636e\u96c6\u6982\u8ff0": [[2, "id2"]], "Alimeeting\u6570\u636e\u96c6\u4ecb\u7ecd": [[2, "alimeeting"]], "\u83b7\u53d6\u6570\u636e": [[2, "id3"]], "\u7b80\u4ecb": [[3, "id1"]], "\u7ade\u8d5b\u4ecb\u7ecd": [[3, "id2"]], "\u65f6\u95f4\u5b89\u6392(AOE\u65f6\u95f4)": [[3, "aoe"]], "\u7ade\u8d5b\u62a5\u540d": [[3, "id3"]], "\u7ade\u8d5b\u89c4\u5219": [[6, "id1"]], "\u8d5b\u9053\u8bbe\u7f6e\u4e0e\u8bc4\u4f30": [[7, "id1"]], "\u8bf4\u8bdd\u4eba\u76f8\u5173\u7684\u8bed\u97f3\u8bc6\u522b (\u4e3b\u8d5b\u9053)": [[7, "id2"]], "\u8bc4\u4f30\u65b9\u6cd5": [[7, "id3"]], "\u5b50\u8d5b\u9053\u8bbe\u7f6e": [[7, "id4"]], "\u5b50\u8d5b\u9053\u4e00 (\u9650\u5b9a\u8bad\u7ec3\u6570\u636e):": [[7, "id5"]], "\u5b50\u8d5b\u9053\u4e8c (\u5f00\u653e\u8bad\u7ec3\u6570\u636e):": [[7, "id6"]], "\u7ec4\u59d4\u4f1a": [[4, "id1"]], "\u8054\u7cfb\u65b9\u5f0f": [[5, "id1"]]}, "indexentries": {}}) \ No newline at end of file diff --git a/egs_modelscope/asr/TEMPLATE/README.md b/egs_modelscope/asr/TEMPLATE/README.md index a064302a2..83c462d98 100644 --- a/egs_modelscope/asr/TEMPLATE/README.md +++ b/egs_modelscope/asr/TEMPLATE/README.md @@ -58,6 +58,22 @@ Full code of demo, please ref to [demo](https://github.com/alibaba-damo-academy/ #### [RNN-T-online model]() Undo +#### [MFCCA Model](https://www.modelscope.cn/models/NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/summary) +For more model detailes, please refer to [docs](https://www.modelscope.cn/models/NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/summary) +```python +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks + +inference_pipeline = pipeline( + task=Tasks.auto_speech_recognition, + model='NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950', + model_revision='v3.0.0' +) + +rec_result = inference_pipeline(audio_in='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav') +print(rec_result) +``` + #### API-reference ##### Define pipeline - `task`: `Tasks.auto_speech_recognition` @@ -94,6 +110,8 @@ FunASR also offer recipes [egs_modelscope/asr/TEMPLATE/infer.sh](https://github. - `njob`: only used for CPU inference (`gpu_inference`=`false`), `64` (Default), the number of jobs for CPU decoding - `checkpoint_dir`: only used for infer finetuned models, the path dir of finetuned models - `checkpoint_name`: only used for infer finetuned models, `valid.cer_ctc.ave.pb` (Default), which checkpoint is used to infer + - `decoding_mode`: `normal` (Default), decoding mode for UniASR model(fast、normal、offline) + - `hotword_txt`: `None` (Default), hotword file for contextual paraformer model(the hotword file name ends with .txt") - Decode with multi GPUs: ```shell diff --git a/egs_modelscope/asr/TEMPLATE/infer.py b/egs_modelscope/asr/TEMPLATE/infer.py index 9f280d50b..5bc205cda 100644 --- a/egs_modelscope/asr/TEMPLATE/infer.py +++ b/egs_modelscope/asr/TEMPLATE/infer.py @@ -11,6 +11,7 @@ def modelscope_infer(args): model=args.model, output_dir=args.output_dir, batch_size=args.batch_size, + param_dict={"decoding_model": args.decoding_mode, "hotword": args.hotword_txt} ) inference_pipeline(audio_in=args.audio_in) @@ -19,7 +20,9 @@ if __name__ == "__main__": parser.add_argument('--model', type=str, default="damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch") parser.add_argument('--audio_in', type=str, default="./data/test/wav.scp") parser.add_argument('--output_dir', type=str, default="./results/") + parser.add_argument('--decoding_mode', type=str, default="normal") + parser.add_argument('--hotword_txt', type=str, default=None) parser.add_argument('--batch_size', type=int, default=64) parser.add_argument('--gpuid', type=str, default="0") args = parser.parse_args() - modelscope_infer(args) \ No newline at end of file + modelscope_infer(args) diff --git a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md deleted file mode 100644 index 16aeada4b..000000000 --- a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# ModelScope Model - -## How to finetune and infer using a pretrained Paraformer-large Model - -### Finetune - -- Modify finetune training related parameters in `finetune.py` - - output_dir: # result dir - - data_dir: # the dataset dir needs to include files: `train/wav.scp`, `train/text`; `validation/wav.scp`, `validation/text` - - dataset_type: # for dataset larger than 1000 hours, set as `large`, otherwise set as `small` - - batch_bins: # batch size. For dataset_type is `small`, `batch_bins` indicates the feature frames. For dataset_type is `large`, `batch_bins` indicates the duration in ms - - max_epoch: # number of training epoch - - lr: # learning rate - -- Then you can run the pipeline to finetune with: -```python - python finetune.py -``` - -### Inference - -Or you can use the finetuned model for inference directly. - -- Setting parameters in `infer.py` - - data_dir: # the dataset dir needs to include `test/wav.scp`. If `test/text` is also exists, CER will be computed - - output_dir: # result dir - - ngpu: # the number of GPUs for decoding - - njob: # the number of jobs for each GPU - -- Then you can run the pipeline to infer with: -```python - python infer.py -``` - -- Results - -The decoding results can be found in `$output_dir/1best_recog/text.sp.cer` and `$output_dir/1best_recog/text.nosp.cer`, which includes recognition results with or without separating character (src) of each sample and the CER metric of the whole test set. - -### Inference using local finetuned model - -- Modify inference related parameters in `infer_after_finetune.py` - - output_dir: # result dir - - data_dir: # the dataset dir needs to include `test/wav.scp`. If `test/text` is also exists, CER will be computed - - decoding_model_name: # set the checkpoint name for decoding, e.g., `valid.cer_ctc.ave.pb` - -- Then you can run the pipeline to finetune with: -```python - python infer_after_finetune.py -``` - -- Results - -The decoding results can be found in `$output_dir/1best_recog/text.sp.cer` and `$output_dir/1best_recog/text.nosp.cer`, which includes recognition results with or without separating character (src) of each sample and the CER metric of the whole test set. diff --git a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md new file mode 120000 index 000000000..bb55ab52e --- /dev/null +++ b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/README.md @@ -0,0 +1 @@ +../../TEMPLATE/README.md \ No newline at end of file diff --git a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.py b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.py index 8abadd719..12ec2ac8c 100755 --- a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.py +++ b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.py @@ -1,102 +1,27 @@ import os import shutil -from multiprocessing import Pool - +import argparse from modelscope.pipelines import pipeline from modelscope.utils.constant import Tasks -from funasr.utils.compute_wer import compute_wer - -def modelscope_infer_core(output_dir, split_dir, njob, idx): - output_dir_job = os.path.join(output_dir, "output.{}".format(idx)) - gpu_id = (int(idx) - 1) // njob - if "CUDA_VISIBLE_DEVICES" in os.environ.keys(): - gpu_list = os.environ['CUDA_VISIBLE_DEVICES'].split(",") - os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_list[gpu_id]) - else: - os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_id) - inference_pipline = pipeline( +def modelscope_infer(args): + os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpuid) + inference_pipeline = pipeline( task=Tasks.auto_speech_recognition, - model='NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950', - model_revision='v3.0.0', - output_dir=output_dir_job, - batch_size=1, + model=args.model, + model_revision=args.model_revision, + output_dir=args.output_dir, + batch_size=args.batch_size, ) - audio_in = os.path.join(split_dir, "wav.{}.scp".format(idx)) - inference_pipline(audio_in=audio_in) - - -def modelscope_infer(params): - # prepare for multi-GPU decoding - ngpu = params["ngpu"] - njob = params["njob"] - output_dir = params["output_dir"] - if os.path.exists(output_dir): - shutil.rmtree(output_dir) - os.mkdir(output_dir) - split_dir = os.path.join(output_dir, "split") - os.mkdir(split_dir) - nj = ngpu * njob - wav_scp_file = os.path.join(params["data_dir"], "wav.scp") - with open(wav_scp_file) as f: - lines = f.readlines() - num_lines = len(lines) - num_job_lines = num_lines // nj - start = 0 - for i in range(nj): - end = start + num_job_lines - file = os.path.join(split_dir, "wav.{}.scp".format(str(i + 1))) - with open(file, "w") as f: - if i == nj - 1: - f.writelines(lines[start:]) - else: - f.writelines(lines[start:end]) - start = end - p = Pool(nj) - for i in range(nj): - p.apply_async(modelscope_infer_core, - args=(output_dir, split_dir, njob, str(i + 1))) - p.close() - p.join() - - # combine decoding results - best_recog_path = os.path.join(output_dir, "1best_recog") - os.mkdir(best_recog_path) - files = ["text", "token", "score"] - for file in files: - with open(os.path.join(best_recog_path, file), "w") as f: - for i in range(nj): - job_file = os.path.join(output_dir, "output.{}/1best_recog".format(str(i + 1)), file) - with open(job_file) as f_job: - lines = f_job.readlines() - f.writelines(lines) - - # If text exists, compute CER - text_in = os.path.join(params["data_dir"], "text") - if os.path.exists(text_in): - text_proc_file = os.path.join(best_recog_path, "token") - text_proc_file2 = os.path.join(best_recog_path, "token_nosep") - with open(text_proc_file, 'r') as hyp_reader: - with open(text_proc_file2, 'w') as hyp_writer: - for line in hyp_reader: - new_context = line.strip().replace("src","").replace(" "," ").replace(" "," ").strip() - hyp_writer.write(new_context+'\n') - text_in2 = os.path.join(best_recog_path, "ref_text_nosep") - with open(text_in, 'r') as ref_reader: - with open(text_in2, 'w') as ref_writer: - for line in ref_reader: - new_context = line.strip().replace("src","").replace(" "," ").replace(" "," ").strip() - ref_writer.write(new_context+'\n') - - - compute_wer(text_in, text_proc_file, os.path.join(best_recog_path, "text.sp.cer")) - compute_wer(text_in2, text_proc_file2, os.path.join(best_recog_path, "text.nosp.cer")) - + inference_pipeline(audio_in=args.audio_in) if __name__ == "__main__": - params = {} - params["data_dir"] = "./example_data/validation" - params["output_dir"] = "./output_dir" - params["ngpu"] = 1 - params["njob"] = 1 - modelscope_infer(params) + parser = argparse.ArgumentParser() + parser.add_argument('--model', type=str, default="NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950") + parser.add_argument('--model_revision', type=str, default="v3.0.0") + parser.add_argument('--audio_in', type=str, default="./data/test/wav.scp") + parser.add_argument('--output_dir', type=str, default="./results/") + parser.add_argument('--batch_size', type=int, default=1) + parser.add_argument('--gpuid', type=str, default="0") + args = parser.parse_args() + modelscope_infer(args) diff --git a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.sh b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.sh new file mode 100755 index 000000000..51a4968bc --- /dev/null +++ b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/infer.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +stage=1 +stop_stage=3 +model="NPU-ASLP/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950" +data_dir="./data/test" +output_dir="./results_pl_gpu" +batch_size=1 +gpu_inference=true # whether to perform gpu decoding +gpuid_list="3,4" # set gpus, e.g., gpuid_list="0,1" +njob=4 # the number of jobs for CPU decoding, if gpu_inference=false, use CPU decoding, please set njob + +. utils/parse_options.sh || exit 1; + +if ${gpu_inference} == "true"; then + nj=$(echo $gpuid_list | awk -F "," '{print NF}') +else + nj=$njob + batch_size=1 + gpuid_list="" + for JOB in $(seq ${nj}); do + gpuid_list=$gpuid_list"-1," + done +fi + +mkdir -p $output_dir/split +split_scps="" +for JOB in $(seq ${nj}); do + split_scps="$split_scps $output_dir/split/wav.$JOB.scp" +done +perl utils/split_scp.pl ${data_dir}/wav.scp ${split_scps} + +if [ $stage -le 1 ] && [ $stop_stage -ge 1 ];then + echo "Decoding ..." + gpuid_list_array=(${gpuid_list//,/ }) + ./utils/run.pl JOB=1:${nj} ${output_dir}/log/infer.JOB.log \ + python infer.py \ + --model ${model} \ + --audio_in ${output_dir}/split/wav.JOB.scp \ + --output_dir ${output_dir}/output.JOB \ + --batch_size ${batch_size} \ + --gpuid ${gpuid_list_array[JOB-1]} + + mkdir -p ${output_dir}/1best_recog + for f in token score text; do + if [ -f "${output_dir}/output.1/1best_recog/${f}" ]; then + for i in $(seq "${nj}"); do + cat "${output_dir}/output.${i}/1best_recog/${f}" + done | sort -k1 >"${output_dir}/1best_recog/${f}" + fi + done +fi + +if [ $stage -le 2 ] && [ $stop_stage -ge 2 ];then + echo "Computing WER ..." + cp ${output_dir}/1best_recog/token ${output_dir}/1best_recog/text.proc + cp ${data_dir}/text ${output_dir}/1best_recog/text.ref + sed -e 's/src//g' ${output_dir}/1best_recog/text.proc | sed -e 's/ \+/ /g' > ${output_dir}/1best_recog/text_nosp.proc + sed -e 's/src//g' ${output_dir}/1best_recog/text.ref | sed -e 's/ \+/ /g' > ${output_dir}/1best_recog/text_nosp.ref + + python utils/compute_wer.py ${output_dir}/1best_recog/text.ref ${output_dir}/1best_recog/text.proc ${output_dir}/1best_recog/text.sp.cer + tail -n 3 ${output_dir}/1best_recog/text.sp.cer + python utils/compute_wer.py ${output_dir}/1best_recog/text_nosp.ref ${output_dir}/1best_recog/text_nosp.proc ${output_dir}/1best_recog/text.nosp.cer + tail -n 3 ${output_dir}/1best_recog/text.nosp.cer +fi + diff --git a/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/utils b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/utils new file mode 120000 index 000000000..2ac163ff4 --- /dev/null +++ b/egs_modelscope/asr/mfcca/speech_mfcca_asr-zh-cn-16k-alimeeting-vocab4950/utils @@ -0,0 +1 @@ +../../../../egs/aishell/transformer/utils \ No newline at end of file diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/demo.py b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/demo.py new file mode 100644 index 000000000..bec6f052e --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/demo.py @@ -0,0 +1,12 @@ +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks + +param_dict = dict() +param_dict['hotword'] = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/hotword.txt" +inference_pipeline = pipeline( + task=Tasks.auto_speech_recognition, + model="damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404", + param_dict=param_dict) + +rec_result = inference_pipeline(audio_in='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_hotword.wav') +print(rec_result) diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py deleted file mode 100644 index 16a57e9af..000000000 --- a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py +++ /dev/null @@ -1,21 +0,0 @@ -from modelscope.pipelines import pipeline -from modelscope.utils.constant import Tasks - - -if __name__ == '__main__': - param_dict = dict() - param_dict['hotword'] = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/hotword.txt" - - audio_in = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_hotword.wav" - output_dir = None - batch_size = 1 - - inference_pipeline = pipeline( - task=Tasks.auto_speech_recognition, - model="damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404", - output_dir=output_dir, - batch_size=batch_size, - param_dict=param_dict) - - rec_result = inference_pipeline(audio_in=audio_in) - print(rec_result) diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py new file mode 120000 index 000000000..128fc31c2 --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.py @@ -0,0 +1 @@ +../../TEMPLATE/infer.py \ No newline at end of file diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.sh b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.sh new file mode 100644 index 000000000..e60f6d973 --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/infer.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +stage=1 +stop_stage=2 +model="damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404" +data_dir="./data/test" +output_dir="./results" +batch_size=64 +gpu_inference=true # whether to perform gpu decoding +gpuid_list="0,1" # set gpus, e.g., gpuid_list="0,1" +njob=64 # the number of jobs for CPU decoding, if gpu_inference=false, use CPU decoding, please set njob +checkpoint_dir= +checkpoint_name="valid.cer_ctc.ave.pb" +hotword_txt=None + +. utils/parse_options.sh || exit 1; + +if ${gpu_inference} == "true"; then + nj=$(echo $gpuid_list | awk -F "," '{print NF}') +else + nj=$njob + batch_size=1 + gpuid_list="" + for JOB in $(seq ${nj}); do + gpuid_list=$gpuid_list"-1," + done +fi + +mkdir -p $output_dir/split +split_scps="" +for JOB in $(seq ${nj}); do + split_scps="$split_scps $output_dir/split/wav.$JOB.scp" +done +perl utils/split_scp.pl ${data_dir}/wav.scp ${split_scps} + +if [ -n "${checkpoint_dir}" ]; then + python utils/prepare_checkpoint.py ${model} ${checkpoint_dir} ${checkpoint_name} + model=${checkpoint_dir}/${model} +fi + +if [ $stage -le 1 ] && [ $stop_stage -ge 1 ];then + echo "Decoding ..." + gpuid_list_array=(${gpuid_list//,/ }) + for JOB in $(seq ${nj}); do + { + id=$((JOB-1)) + gpuid=${gpuid_list_array[$id]} + mkdir -p ${output_dir}/output.$JOB + python infer.py \ + --model ${model} \ + --audio_in ${output_dir}/split/wav.$JOB.scp \ + --output_dir ${output_dir}/output.$JOB \ + --batch_size ${batch_size} \ + --gpuid ${gpuid} \ + --hotword_txt ${hotword_txt} + }& + done + wait + + mkdir -p ${output_dir}/1best_recog + for f in token score text; do + if [ -f "${output_dir}/output.1/1best_recog/${f}" ]; then + for i in $(seq "${nj}"); do + cat "${output_dir}/output.${i}/1best_recog/${f}" + done | sort -k1 >"${output_dir}/1best_recog/${f}" + fi + done +fi + +if [ $stage -le 2 ] && [ $stop_stage -ge 2 ];then + echo "Computing WER ..." + cp ${output_dir}/1best_recog/text ${output_dir}/1best_recog/text.proc + cp ${data_dir}/text ${output_dir}/1best_recog/text.ref + python utils/compute_wer.py ${output_dir}/1best_recog/text.ref ${output_dir}/1best_recog/text.proc ${output_dir}/1best_recog/text.cer + tail -n 3 ${output_dir}/1best_recog/text.cer +fi + +if [ $stage -le 3 ] && [ $stop_stage -ge 3 ];then + echo "SpeechIO TIOBE textnorm" + echo "$0 --> Normalizing REF text ..." + ./utils/textnorm_zh.py \ + --has_key --to_upper \ + ${data_dir}/text \ + ${output_dir}/1best_recog/ref.txt + + echo "$0 --> Normalizing HYP text ..." + ./utils/textnorm_zh.py \ + --has_key --to_upper \ + ${output_dir}/1best_recog/text.proc \ + ${output_dir}/1best_recog/rec.txt + grep -v $'\t$' ${output_dir}/1best_recog/rec.txt > ${output_dir}/1best_recog/rec_non_empty.txt + + echo "$0 --> computing WER/CER and alignment ..." + ./utils/error_rate_zh \ + --tokenizer char \ + --ref ${output_dir}/1best_recog/ref.txt \ + --hyp ${output_dir}/1best_recog/rec_non_empty.txt \ + ${output_dir}/1best_recog/DETAILS.txt | tee ${output_dir}/1best_recog/RESULTS.txt + rm -rf ${output_dir}/1best_recog/rec.txt ${output_dir}/1best_recog/rec_non_empty.txt +fi + diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/utils b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/utils new file mode 120000 index 000000000..2ac163ff4 --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404/utils @@ -0,0 +1 @@ +../../../../egs/aishell/transformer/utils \ No newline at end of file diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/demo.py b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/demo.py new file mode 100644 index 000000000..edc3a050e --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/demo.py @@ -0,0 +1,9 @@ +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks + +inference_pipeline = pipeline( + task=Tasks.auto_speech_recognition, + model='damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch') + +rec_result = inference_pipeline(audio_in='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav') +print(rec_result) diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py deleted file mode 100644 index 9f280d50b..000000000 --- a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import shutil -import argparse -from modelscope.pipelines import pipeline -from modelscope.utils.constant import Tasks - -def modelscope_infer(args): - os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpuid) - inference_pipeline = pipeline( - task=Tasks.auto_speech_recognition, - model=args.model, - output_dir=args.output_dir, - batch_size=args.batch_size, - ) - inference_pipeline(audio_in=args.audio_in) - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument('--model', type=str, default="damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch") - parser.add_argument('--audio_in', type=str, default="./data/test/wav.scp") - parser.add_argument('--output_dir', type=str, default="./results/") - parser.add_argument('--batch_size', type=int, default=64) - parser.add_argument('--gpuid', type=str, default="0") - args = parser.parse_args() - modelscope_infer(args) \ No newline at end of file diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py new file mode 120000 index 000000000..128fc31c2 --- /dev/null +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.py @@ -0,0 +1 @@ +../../TEMPLATE/infer.py \ No newline at end of file diff --git a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.sh b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.sh index b8b011c0a..ef49d7a60 100644 --- a/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.sh +++ b/egs_modelscope/asr/paraformer/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/infer.sh @@ -12,7 +12,9 @@ output_dir="./results" batch_size=64 gpu_inference=true # whether to perform gpu decoding gpuid_list="0,1" # set gpus, e.g., gpuid_list="0,1" -njob=4 # the number of jobs for CPU decoding, if gpu_inference=false, use CPU decoding, please set njob +njob=64 # the number of jobs for CPU decoding, if gpu_inference=false, use CPU decoding, please set njob +checkpoint_dir= +checkpoint_name="valid.cer_ctc.ave.pb" . utils/parse_options.sh || exit 1; @@ -34,6 +36,11 @@ for JOB in $(seq ${nj}); do done perl utils/split_scp.pl ${data_dir}/wav.scp ${split_scps} +if [ -n "${checkpoint_dir}" ]; then + python utils/prepare_checkpoint.py ${model} ${checkpoint_dir} ${checkpoint_name} + model=${checkpoint_dir}/${model} +fi + if [ $stage -le 1 ] && [ $stop_stage -ge 1 ];then echo "Decoding ..." gpuid_list_array=(${gpuid_list//,/ }) diff --git a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/demo.py b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/demo.py new file mode 100644 index 000000000..570f910fe --- /dev/null +++ b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/demo.py @@ -0,0 +1,12 @@ +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks + +decoding_mode="normal" #fast, normal, offline +inference_pipeline = pipeline( + task=Tasks.auto_speech_recognition, + model='damo/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825', + param_dict={"decoding_model": decoding_mode} +) + +rec_result = inference_pipeline(audio_in='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav') +print(rec_result) diff --git a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py deleted file mode 100644 index d28395be4..000000000 --- a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py +++ /dev/null @@ -1,89 +0,0 @@ -import os -import shutil -from multiprocessing import Pool - -from modelscope.pipelines import pipeline -from modelscope.utils.constant import Tasks - -from funasr.utils.compute_wer import compute_wer - - -def modelscope_infer_core(output_dir, split_dir, njob, idx): - output_dir_job = os.path.join(output_dir, "output.{}".format(idx)) - gpu_id = (int(idx) - 1) // njob - if "CUDA_VISIBLE_DEVICES" in os.environ.keys(): - gpu_list = os.environ['CUDA_VISIBLE_DEVICES'].split(",") - os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_list[gpu_id]) - else: - os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_id) - inference_pipline = pipeline( - task=Tasks.auto_speech_recognition, - model="damo/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825", - output_dir=output_dir_job, - batch_size=1 - ) - audio_in = os.path.join(split_dir, "wav.{}.scp".format(idx)) - inference_pipline(audio_in=audio_in, param_dict={"decoding_model": "normal"}) - - -def modelscope_infer(params): - # prepare for multi-GPU decoding - ngpu = params["ngpu"] - njob = params["njob"] - output_dir = params["output_dir"] - if os.path.exists(output_dir): - shutil.rmtree(output_dir) - os.mkdir(output_dir) - split_dir = os.path.join(output_dir, "split") - os.mkdir(split_dir) - nj = ngpu * njob - wav_scp_file = os.path.join(params["data_dir"], "wav.scp") - with open(wav_scp_file) as f: - lines = f.readlines() - num_lines = len(lines) - num_job_lines = num_lines // nj - start = 0 - for i in range(nj): - end = start + num_job_lines - file = os.path.join(split_dir, "wav.{}.scp".format(str(i + 1))) - with open(file, "w") as f: - if i == nj - 1: - f.writelines(lines[start:]) - else: - f.writelines(lines[start:end]) - start = end - - p = Pool(nj) - for i in range(nj): - p.apply_async(modelscope_infer_core, - args=(output_dir, split_dir, njob, str(i + 1))) - p.close() - p.join() - - # combine decoding results - best_recog_path = os.path.join(output_dir, "1best_recog") - os.mkdir(best_recog_path) - files = ["text", "token", "score"] - for file in files: - with open(os.path.join(best_recog_path, file), "w") as f: - for i in range(nj): - job_file = os.path.join(output_dir, "output.{}/1best_recog".format(str(i + 1)), file) - with open(job_file) as f_job: - lines = f_job.readlines() - f.writelines(lines) - - # If text exists, compute CER - text_in = os.path.join(params["data_dir"], "text") - if os.path.exists(text_in): - text_proc_file = os.path.join(best_recog_path, "token") - compute_wer(text_in, text_proc_file, os.path.join(best_recog_path, "text.cer")) - os.system("tail -n 3 {}".format(os.path.join(best_recog_path, "text.cer"))) - - -if __name__ == "__main__": - params = {} - params["data_dir"] = "./data/test" - params["output_dir"] = "./results" - params["ngpu"] = 1 - params["njob"] = 8 - modelscope_infer(params) diff --git a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py new file mode 120000 index 000000000..128fc31c2 --- /dev/null +++ b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.py @@ -0,0 +1 @@ +../../TEMPLATE/infer.py \ No newline at end of file diff --git a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.sh b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.sh new file mode 100644 index 000000000..b44be9f3c --- /dev/null +++ b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/infer.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +stage=1 +stop_stage=2 +model="damo/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825" +data_dir="./data/test" +output_dir="./results" +batch_size=1 +gpu_inference=true # whether to perform gpu decoding +gpuid_list="0,1" # set gpus, e.g., gpuid_list="0,1" +njob=64 # the number of jobs for CPU decoding, if gpu_inference=false, use CPU decoding, please set njob +checkpoint_dir= +checkpoint_name="valid.cer_ctc.ave.pb" +decoding_mode="normal" + +. utils/parse_options.sh || exit 1; + +if ${gpu_inference} == "true"; then + nj=$(echo $gpuid_list | awk -F "," '{print NF}') +else + nj=$njob + batch_size=1 + gpuid_list="" + for JOB in $(seq ${nj}); do + gpuid_list=$gpuid_list"-1," + done +fi + +mkdir -p $output_dir/split +split_scps="" +for JOB in $(seq ${nj}); do + split_scps="$split_scps $output_dir/split/wav.$JOB.scp" +done +perl utils/split_scp.pl ${data_dir}/wav.scp ${split_scps} + +if [ -n "${checkpoint_dir}" ]; then + python utils/prepare_checkpoint.py ${model} ${checkpoint_dir} ${checkpoint_name} + model=${checkpoint_dir}/${model} +fi + +if [ $stage -le 1 ] && [ $stop_stage -ge 1 ];then + echo "Decoding ..." + gpuid_list_array=(${gpuid_list//,/ }) + for JOB in $(seq ${nj}); do + { + id=$((JOB-1)) + gpuid=${gpuid_list_array[$id]} + mkdir -p ${output_dir}/output.$JOB + python infer.py \ + --model ${model} \ + --audio_in ${output_dir}/split/wav.$JOB.scp \ + --output_dir ${output_dir}/output.$JOB \ + --batch_size ${batch_size} \ + --gpuid ${gpuid} \ + --decoding_mode ${decoding_mode} + }& + done + wait + + mkdir -p ${output_dir}/1best_recog + for f in token score text; do + if [ -f "${output_dir}/output.1/1best_recog/${f}" ]; then + for i in $(seq "${nj}"); do + cat "${output_dir}/output.${i}/1best_recog/${f}" + done | sort -k1 >"${output_dir}/1best_recog/${f}" + fi + done +fi + +if [ $stage -le 2 ] && [ $stop_stage -ge 2 ];then + echo "Computing WER ..." + cp ${output_dir}/1best_recog/text ${output_dir}/1best_recog/text.proc + cp ${data_dir}/text ${output_dir}/1best_recog/text.ref + python utils/compute_wer.py ${output_dir}/1best_recog/text.ref ${output_dir}/1best_recog/text.proc ${output_dir}/1best_recog/text.cer + tail -n 3 ${output_dir}/1best_recog/text.cer +fi + +if [ $stage -le 3 ] && [ $stop_stage -ge 3 ];then + echo "SpeechIO TIOBE textnorm" + echo "$0 --> Normalizing REF text ..." + ./utils/textnorm_zh.py \ + --has_key --to_upper \ + ${data_dir}/text \ + ${output_dir}/1best_recog/ref.txt + + echo "$0 --> Normalizing HYP text ..." + ./utils/textnorm_zh.py \ + --has_key --to_upper \ + ${output_dir}/1best_recog/text.proc \ + ${output_dir}/1best_recog/rec.txt + grep -v $'\t$' ${output_dir}/1best_recog/rec.txt > ${output_dir}/1best_recog/rec_non_empty.txt + + echo "$0 --> computing WER/CER and alignment ..." + ./utils/error_rate_zh \ + --tokenizer char \ + --ref ${output_dir}/1best_recog/ref.txt \ + --hyp ${output_dir}/1best_recog/rec_non_empty.txt \ + ${output_dir}/1best_recog/DETAILS.txt | tee ${output_dir}/1best_recog/RESULTS.txt + rm -rf ${output_dir}/1best_recog/rec.txt ${output_dir}/1best_recog/rec_non_empty.txt +fi + diff --git a/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/utils b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/utils new file mode 120000 index 000000000..2ac163ff4 --- /dev/null +++ b/egs_modelscope/asr/uniasr/speech_UniASR_asr_2pass-minnan-16k-common-vocab3825/utils @@ -0,0 +1 @@ +../../../../egs/aishell/transformer/utils \ No newline at end of file diff --git a/funasr/bin/asr_inference_paraformer_streaming.py b/funasr/bin/asr_inference_paraformer_streaming.py index 821f69429..ff8bb8c77 100644 --- a/funasr/bin/asr_inference_paraformer_streaming.py +++ b/funasr/bin/asr_inference_paraformer_streaming.py @@ -8,6 +8,7 @@ import os import codecs import tempfile import requests +import yaml from pathlib import Path from typing import Optional from typing import Sequence @@ -19,7 +20,6 @@ from typing import List import numpy as np import torch -import torchaudio from typeguard import check_argument_types from funasr.fileio.datadir_writer import DatadirWriter @@ -40,11 +40,12 @@ from funasr.utils.types import str2bool from funasr.utils.types import str2triple_str from funasr.utils.types import str_or_none from funasr.utils import asr_utils, wav_utils, postprocess_utils -from funasr.models.frontend.wav_frontend import WavFrontend -from funasr.models.e2e_asr_paraformer import BiCifParaformer, ContextualParaformer +from funasr.models.frontend.wav_frontend import WavFrontend, WavFrontendOnline from funasr.export.models.e2e_asr_paraformer import Paraformer as Paraformer_export + np.set_printoptions(threshold=np.inf) + class Speech2Text: """Speech2Text class @@ -89,7 +90,7 @@ class Speech2Text: ) frontend = None if asr_train_args.frontend is not None and asr_train_args.frontend_conf is not None: - frontend = WavFrontend(cmvn_file=cmvn_file, **asr_train_args.frontend_conf) + frontend = WavFrontendOnline(cmvn_file=cmvn_file, **asr_train_args.frontend_conf) logging.info("asr_model: {}".format(asr_model)) logging.info("asr_train_args: {}".format(asr_train_args)) @@ -189,8 +190,7 @@ class Speech2Text: @torch.no_grad() def __call__( - self, cache: dict, speech: Union[torch.Tensor, np.ndarray], speech_lengths: Union[torch.Tensor, np.ndarray] = None, - begin_time: int = 0, end_time: int = None, + self, cache: dict, speech: Union[torch.Tensor], speech_lengths: Union[torch.Tensor] = None ): """Inference @@ -201,38 +201,59 @@ class Speech2Text: """ assert check_argument_types() - - # Input as audio signal - if isinstance(speech, np.ndarray): - speech = torch.tensor(speech) - if self.frontend is not None: - feats, feats_len = self.frontend.forward(speech, speech_lengths) - feats = to_device(feats, device=self.device) - feats_len = feats_len.int() - self.asr_model.frontend = None + results = [] + cache_en = cache["encoder"] + if speech.shape[1] < 16 * 60 and cache_en["is_final"]: + cache_en["tail_chunk"] = True + feats = cache_en["feats"] + feats_len = torch.tensor([feats.shape[1]]) + results = self.infer(feats, feats_len, cache) + return results else: - feats = speech - feats_len = speech_lengths - lfr_factor = max(1, (feats.size()[-1] // 80) - 1) - feats_len = cache["encoder"]["stride"] + cache["encoder"]["pad_left"] + cache["encoder"]["pad_right"] - feats = feats[:,cache["encoder"]["start_idx"]:cache["encoder"]["start_idx"]+feats_len,:] - feats_len = torch.tensor([feats_len]) - batch = {"speech": feats, "speech_lengths": feats_len, "cache": cache} + if self.frontend is not None: + feats, feats_len = self.frontend.forward(speech, speech_lengths, cache_en["is_final"]) + feats = to_device(feats, device=self.device) + feats_len = feats_len.int() + self.asr_model.frontend = None + else: + feats = speech + feats_len = speech_lengths - # a. To device + if feats.shape[1] != 0: + if cache_en["is_final"]: + if feats.shape[1] + cache_en["chunk_size"][2] < cache_en["chunk_size"][1]: + cache_en["last_chunk"] = True + else: + # first chunk + feats_chunk1 = feats[:, :cache_en["chunk_size"][1], :] + feats_len = torch.tensor([feats_chunk1.shape[1]]) + results_chunk1 = self.infer(feats_chunk1, feats_len, cache) + + # last chunk + cache_en["last_chunk"] = True + feats_chunk2 = feats[:, -(feats.shape[1] + cache_en["chunk_size"][2] - cache_en["chunk_size"][1]):, :] + feats_len = torch.tensor([feats_chunk2.shape[1]]) + results_chunk2 = self.infer(feats_chunk2, feats_len, cache) + + return ["".join(results_chunk1 + results_chunk2)] + + results = self.infer(feats, feats_len, cache) + + return results + + @torch.no_grad() + def infer(self, feats: Union[torch.Tensor], feats_len: Union[torch.Tensor], cache: List = None): + batch = {"speech": feats, "speech_lengths": feats_len} batch = to_device(batch, device=self.device) - # b. Forward Encoder - enc, enc_len = self.asr_model.encode_chunk(feats, feats_len, cache) + enc, enc_len = self.asr_model.encode_chunk(feats, feats_len, cache=cache) if isinstance(enc, tuple): enc = enc[0] # assert len(enc) == 1, len(enc) enc_len_batch_total = torch.sum(enc_len).item() * self.encoder_downsampling_factor predictor_outs = self.asr_model.calc_predictor_chunk(enc, cache) - pre_acoustic_embeds, pre_token_length, alphas, pre_peak_index = predictor_outs[0], predictor_outs[1], \ - predictor_outs[2], predictor_outs[3] - pre_token_length = pre_token_length.floor().long() + pre_acoustic_embeds, pre_token_length= predictor_outs[0], predictor_outs[1] if torch.max(pre_token_length) < 1: return [] decoder_outs = self.asr_model.cal_decoder_with_predictor_chunk(enc, pre_acoustic_embeds, cache) @@ -279,166 +300,12 @@ class Speech2Text: text = self.tokenizer.tokens2text(token) else: text = None - - results.append((text, token, token_int, hyp, enc_len_batch_total, lfr_factor)) + results.append(text) # assert check_return_type(results) return results -class Speech2TextExport: - """Speech2TextExport class - - """ - - def __init__( - self, - asr_train_config: Union[Path, str] = None, - asr_model_file: Union[Path, str] = None, - cmvn_file: Union[Path, str] = None, - lm_train_config: Union[Path, str] = None, - lm_file: Union[Path, str] = None, - token_type: str = None, - bpemodel: str = None, - device: str = "cpu", - maxlenratio: float = 0.0, - minlenratio: float = 0.0, - dtype: str = "float32", - beam_size: int = 20, - ctc_weight: float = 0.5, - lm_weight: float = 1.0, - ngram_weight: float = 0.9, - penalty: float = 0.0, - nbest: int = 1, - frontend_conf: dict = None, - hotword_list_or_file: str = None, - **kwargs, - ): - - # 1. Build ASR model - asr_model, asr_train_args = ASRTask.build_model_from_file( - asr_train_config, asr_model_file, cmvn_file, device - ) - frontend = None - if asr_train_args.frontend is not None and asr_train_args.frontend_conf is not None: - frontend = WavFrontend(cmvn_file=cmvn_file, **asr_train_args.frontend_conf) - - logging.info("asr_model: {}".format(asr_model)) - logging.info("asr_train_args: {}".format(asr_train_args)) - asr_model.to(dtype=getattr(torch, dtype)).eval() - - token_list = asr_model.token_list - - logging.info(f"Decoding device={device}, dtype={dtype}") - - # 5. [Optional] Build Text converter: e.g. bpe-sym -> Text - if token_type is None: - token_type = asr_train_args.token_type - if bpemodel is None: - bpemodel = asr_train_args.bpemodel - - if token_type is None: - tokenizer = None - elif token_type == "bpe": - if bpemodel is not None: - tokenizer = build_tokenizer(token_type=token_type, bpemodel=bpemodel) - else: - tokenizer = None - else: - tokenizer = build_tokenizer(token_type=token_type) - converter = TokenIDConverter(token_list=token_list) - logging.info(f"Text tokenizer: {tokenizer}") - - # self.asr_model = asr_model - self.asr_train_args = asr_train_args - self.converter = converter - self.tokenizer = tokenizer - - self.device = device - self.dtype = dtype - self.nbest = nbest - self.frontend = frontend - - model = Paraformer_export(asr_model, onnx=False) - self.asr_model = model - - @torch.no_grad() - def __call__( - self, speech: Union[torch.Tensor, np.ndarray], speech_lengths: Union[torch.Tensor, np.ndarray] = None - ): - """Inference - - Args: - speech: Input speech data - Returns: - text, token, token_int, hyp - - """ - assert check_argument_types() - - # Input as audio signal - if isinstance(speech, np.ndarray): - speech = torch.tensor(speech) - - if self.frontend is not None: - feats, feats_len = self.frontend.forward(speech, speech_lengths) - feats = to_device(feats, device=self.device) - feats_len = feats_len.int() - self.asr_model.frontend = None - else: - feats = speech - feats_len = speech_lengths - - enc_len_batch_total = feats_len.sum() - lfr_factor = max(1, (feats.size()[-1] // 80) - 1) - batch = {"speech": feats, "speech_lengths": feats_len} - - # a. To device - batch = to_device(batch, device=self.device) - - decoder_outs = self.asr_model(**batch) - decoder_out, ys_pad_lens = decoder_outs[0], decoder_outs[1] - - results = [] - b, n, d = decoder_out.size() - for i in range(b): - am_scores = decoder_out[i, :ys_pad_lens[i], :] - - yseq = am_scores.argmax(dim=-1) - score = am_scores.max(dim=-1)[0] - score = torch.sum(score, dim=-1) - # pad with mask tokens to ensure compatibility with sos/eos tokens - yseq = torch.tensor( - yseq.tolist(), device=yseq.device - ) - nbest_hyps = [Hypothesis(yseq=yseq, score=score)] - - for hyp in nbest_hyps: - assert isinstance(hyp, (Hypothesis)), type(hyp) - - # remove sos/eos and get results - last_pos = -1 - if isinstance(hyp.yseq, list): - token_int = hyp.yseq[1:last_pos] - else: - token_int = hyp.yseq[1:last_pos].tolist() - - # remove blank symbol id, which is assumed to be 0 - token_int = list(filter(lambda x: x != 0 and x != 2, token_int)) - - # Change integer-ids to tokens - token = self.converter.ids2tokens(token_int) - - if self.tokenizer is not None: - text = self.tokenizer.tokens2text(token) - else: - text = None - - results.append((text, token, token_int, hyp, enc_len_batch_total, lfr_factor)) - - return results - - def inference( maxlenratio: float, minlenratio: float, @@ -536,8 +403,6 @@ def inference_modelscope( **kwargs, ): assert check_argument_types() - ncpu = kwargs.get("ncpu", 1) - torch.set_num_threads(ncpu) if word_lm_train_config is not None: raise NotImplementedError("Word LM is not implemented") @@ -580,11 +445,9 @@ def inference_modelscope( penalty=penalty, nbest=nbest, ) - if export_mode: - speech2text = Speech2TextExport(**speech2text_kwargs) - else: - speech2text = Speech2Text(**speech2text_kwargs) - + + speech2text = Speech2Text(**speech2text_kwargs) + def _load_bytes(input): middle_data = np.frombuffer(input, dtype=np.int16) middle_data = np.asarray(middle_data) @@ -599,7 +462,46 @@ def inference_modelscope( offset = i.min + abs_max array = np.frombuffer((middle_data.astype(dtype) - offset) / abs_max, dtype=np.float32) return array - + + def _read_yaml(yaml_path: Union[str, Path]) -> Dict: + if not Path(yaml_path).exists(): + raise FileExistsError(f'The {yaml_path} does not exist.') + + with open(str(yaml_path), 'rb') as f: + data = yaml.load(f, Loader=yaml.Loader) + return data + + def _prepare_cache(cache: dict = {}, chunk_size=[5,10,5], batch_size=1): + if len(cache) > 0: + return cache + config = _read_yaml(asr_train_config) + enc_output_size = config["encoder_conf"]["output_size"] + feats_dims = config["frontend_conf"]["n_mels"] * config["frontend_conf"]["lfr_m"] + cache_en = {"start_idx": 0, "cif_hidden": torch.zeros((batch_size, 1, enc_output_size)), + "cif_alphas": torch.zeros((batch_size, 1)), "chunk_size": chunk_size, "last_chunk": False, + "feats": torch.zeros((batch_size, chunk_size[0] + chunk_size[2], feats_dims)), "tail_chunk": False} + cache["encoder"] = cache_en + + cache_de = {"decode_fsmn": None} + cache["decoder"] = cache_de + + return cache + + def _cache_reset(cache: dict = {}, chunk_size=[5,10,5], batch_size=1): + if len(cache) > 0: + config = _read_yaml(asr_train_config) + enc_output_size = config["encoder_conf"]["output_size"] + feats_dims = config["frontend_conf"]["n_mels"] * config["frontend_conf"]["lfr_m"] + cache_en = {"start_idx": 0, "cif_hidden": torch.zeros((batch_size, 1, enc_output_size)), + "cif_alphas": torch.zeros((batch_size, 1)), "chunk_size": chunk_size, "last_chunk": False, + "feats": torch.zeros((batch_size, chunk_size[0] + chunk_size[2], feats_dims)), "tail_chunk": False} + cache["encoder"] = cache_en + + cache_de = {"decode_fsmn": None} + cache["decoder"] = cache_de + + return cache + def _forward( data_path_and_name_and_type, raw_inputs: Union[np.ndarray, torch.Tensor] = None, @@ -610,123 +512,35 @@ def inference_modelscope( ): # 3. Build data-iterator + if data_path_and_name_and_type is not None and data_path_and_name_and_type[2] == "bytes": + raw_inputs = _load_bytes(data_path_and_name_and_type[0]) + raw_inputs = torch.tensor(raw_inputs) + if data_path_and_name_and_type is None and raw_inputs is not None: + if isinstance(raw_inputs, np.ndarray): + raw_inputs = torch.tensor(raw_inputs) is_final = False cache = {} + chunk_size = [5, 10, 5] if param_dict is not None and "cache" in param_dict: cache = param_dict["cache"] if param_dict is not None and "is_final" in param_dict: is_final = param_dict["is_final"] + if param_dict is not None and "chunk_size" in param_dict: + chunk_size = param_dict["chunk_size"] - if data_path_and_name_and_type is not None and data_path_and_name_and_type[2] == "bytes": - raw_inputs = _load_bytes(data_path_and_name_and_type[0]) - raw_inputs = torch.tensor(raw_inputs) - if data_path_and_name_and_type is not None and data_path_and_name_and_type[2] == "sound": - raw_inputs = torchaudio.load(data_path_and_name_and_type[0])[0][0] - is_final = True - if data_path_and_name_and_type is None and raw_inputs is not None: - if isinstance(raw_inputs, np.ndarray): - raw_inputs = torch.tensor(raw_inputs) # 7 .Start for-loop # FIXME(kamo): The output format should be discussed about + raw_inputs = torch.unsqueeze(raw_inputs, axis=0) + input_lens = torch.tensor([raw_inputs.shape[1]]) asr_result_list = [] - results = [] - asr_result = "" - wait = True - if len(cache) == 0: - cache["encoder"] = {"start_idx": 0, "pad_left": 0, "stride": 10, "pad_right": 5, "cif_hidden": None, "cif_alphas": None, "is_final": is_final, "left": 0, "right": 0} - cache_de = {"decode_fsmn": None} - cache["decoder"] = cache_de - cache["first_chunk"] = True - cache["speech"] = [] - cache["accum_speech"] = 0 - if raw_inputs is not None: - if len(cache["speech"]) == 0: - cache["speech"] = raw_inputs - else: - cache["speech"] = torch.cat([cache["speech"], raw_inputs], dim=0) - cache["accum_speech"] += len(raw_inputs) - while cache["accum_speech"] >= 960: - if cache["first_chunk"]: - if cache["accum_speech"] >= 14400: - speech = torch.unsqueeze(cache["speech"], axis=0) - speech_length = torch.tensor([len(cache["speech"])]) - cache["encoder"]["pad_left"] = 5 - cache["encoder"]["pad_right"] = 5 - cache["encoder"]["stride"] = 10 - cache["encoder"]["left"] = 5 - cache["encoder"]["right"] = 0 - results = speech2text(cache, speech, speech_length) - cache["accum_speech"] -= 4800 - cache["first_chunk"] = False - cache["encoder"]["start_idx"] = -5 - cache["encoder"]["is_final"] = False - wait = False - else: - if is_final: - cache["encoder"]["stride"] = len(cache["speech"]) // 960 - cache["encoder"]["pad_left"] = 0 - cache["encoder"]["pad_right"] = 0 - speech = torch.unsqueeze(cache["speech"], axis=0) - speech_length = torch.tensor([len(cache["speech"])]) - results = speech2text(cache, speech, speech_length) - cache["accum_speech"] = 0 - wait = False - else: - break - else: - if cache["accum_speech"] >= 19200: - cache["encoder"]["start_idx"] += 10 - cache["encoder"]["stride"] = 10 - cache["encoder"]["pad_left"] = 5 - cache["encoder"]["pad_right"] = 5 - cache["encoder"]["left"] = 0 - cache["encoder"]["right"] = 0 - speech = torch.unsqueeze(cache["speech"], axis=0) - speech_length = torch.tensor([len(cache["speech"])]) - results = speech2text(cache, speech, speech_length) - cache["accum_speech"] -= 9600 - wait = False - else: - if is_final: - cache["encoder"]["is_final"] = True - if cache["accum_speech"] >= 14400: - cache["encoder"]["start_idx"] += 10 - cache["encoder"]["stride"] = 10 - cache["encoder"]["pad_left"] = 5 - cache["encoder"]["pad_right"] = 5 - cache["encoder"]["left"] = 0 - cache["encoder"]["right"] = cache["accum_speech"] // 960 - 15 - speech = torch.unsqueeze(cache["speech"], axis=0) - speech_length = torch.tensor([len(cache["speech"])]) - results = speech2text(cache, speech, speech_length) - cache["accum_speech"] -= 9600 - wait = False - else: - cache["encoder"]["start_idx"] += 10 - cache["encoder"]["stride"] = cache["accum_speech"] // 960 - 5 - cache["encoder"]["pad_left"] = 5 - cache["encoder"]["pad_right"] = 0 - cache["encoder"]["left"] = 0 - cache["encoder"]["right"] = 0 - speech = torch.unsqueeze(cache["speech"], axis=0) - speech_length = torch.tensor([len(cache["speech"])]) - results = speech2text(cache, speech, speech_length) - cache["accum_speech"] = 0 - wait = False - else: - break - - if len(results) >= 1: - asr_result += results[0][0] - if asr_result == "": - asr_result = "sil" - if wait: - asr_result = "waiting_for_more_voice" - item = {'key': "utt", 'value': asr_result} - asr_result_list.append(item) - else: - return [] + cache = _prepare_cache(cache, chunk_size=chunk_size, batch_size=1) + cache["encoder"]["is_final"] = is_final + asr_result = speech2text(cache, raw_inputs, input_lens) + item = {'key': "utt", 'value': asr_result} + asr_result_list.append(item) + if is_final: + cache = _cache_reset(cache, chunk_size=chunk_size, batch_size=1) return asr_result_list return _forward @@ -920,5 +734,3 @@ if __name__ == "__main__": # # rec_result = inference_16k_pipline(audio_in='https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav') # print(rec_result) - - diff --git a/funasr/datasets/large_datasets/utils/tokenize.py b/funasr/datasets/large_datasets/utils/tokenize.py index 022d32131..0d2fd84ee 100644 --- a/funasr/datasets/large_datasets/utils/tokenize.py +++ b/funasr/datasets/large_datasets/utils/tokenize.py @@ -17,13 +17,21 @@ def forward_segment(text, seg_dict): return word_list def seg_tokenize(txt, seg_dict): + pattern = re.compile(r'^[\u4E00-\u9FA50-9]+$') out_txt = "" for word in txt: word = word.lower() if word in seg_dict: out_txt += seg_dict[word] + " " else: - out_txt += "" + " " + if pattern.match(word): + for char in word: + if char in seg_dict: + out_txt += seg_dict[char] + " " + else: + out_txt += "" + " " + else: + out_txt += "" + " " return out_txt.strip().split() def tokenize(data, diff --git a/funasr/datasets/preprocessor.py b/funasr/datasets/preprocessor.py index 20a38314a..758c75045 100644 --- a/funasr/datasets/preprocessor.py +++ b/funasr/datasets/preprocessor.py @@ -44,15 +44,22 @@ def forward_segment(text, dic): i += len(longest_word) return word_list - def seg_tokenize(txt, seg_dict): + pattern = re.compile(r'^[\u4E00-\u9FA50-9]+$') out_txt = "" for word in txt: word = word.lower() if word in seg_dict: out_txt += seg_dict[word] + " " else: - out_txt += "" + " " + if pattern.match(word): + for char in word: + if char in seg_dict: + out_txt += seg_dict[char] + " " + else: + out_txt += "" + " " + else: + out_txt += "" + " " return out_txt.strip().split() def seg_tokenize_wo_pattern(txt, seg_dict): diff --git a/funasr/models/e2e_asr_paraformer.py b/funasr/models/e2e_asr_paraformer.py index 699d85fdb..d02783f49 100644 --- a/funasr/models/e2e_asr_paraformer.py +++ b/funasr/models/e2e_asr_paraformer.py @@ -712,9 +712,9 @@ class ParaformerOnline(Paraformer): def calc_predictor_chunk(self, encoder_out, cache=None): - pre_acoustic_embeds, pre_token_length, alphas, pre_peak_index = \ + pre_acoustic_embeds, pre_token_length = \ self.predictor.forward_chunk(encoder_out, cache["encoder"]) - return pre_acoustic_embeds, pre_token_length, alphas, pre_peak_index + return pre_acoustic_embeds, pre_token_length def cal_decoder_with_predictor_chunk(self, encoder_out, sematic_embeds, cache=None): decoder_outs = self.decoder.forward_chunk( diff --git a/funasr/models/e2e_asr_transducer.py b/funasr/models/e2e_asr_transducer.py index 657dd7554..f8ba0f0c6 100644 --- a/funasr/models/e2e_asr_transducer.py +++ b/funasr/models/e2e_asr_transducer.py @@ -386,7 +386,7 @@ class TransducerModel(AbsESPnetModel): if not self.training and (self.report_cer or self.report_wer): if self.error_calculator is None: - from espnet2.asr_transducer.error_calculator import ErrorCalculator + from funasr.modules.e2e_asr_common import ErrorCalculatorTransducer as ErrorCalculator self.error_calculator = ErrorCalculator( self.decoder, @@ -398,7 +398,7 @@ class TransducerModel(AbsESPnetModel): report_wer=self.report_wer, ) - cer_transducer, wer_transducer = self.error_calculator(encoder_out, target) + cer_transducer, wer_transducer = self.error_calculator(encoder_out, target, t_len) return loss_transducer, cer_transducer, wer_transducer @@ -889,6 +889,8 @@ class UnifiedTransducerModel(AbsESPnetModel): if not self.training and (self.report_cer or self.report_wer): if self.error_calculator is None: + from funasr.modules.e2e_asr_common import ErrorCalculatorTransducer as ErrorCalculator + self.error_calculator = ErrorCalculator( self.decoder, self.joint_network, @@ -899,7 +901,7 @@ class UnifiedTransducerModel(AbsESPnetModel): report_wer=self.report_wer, ) - cer_transducer, wer_transducer = self.error_calculator(encoder_out, target) + cer_transducer, wer_transducer = self.error_calculator(encoder_out, target, t_len) return loss_transducer, cer_transducer, wer_transducer return loss_transducer, None, None diff --git a/funasr/models/encoder/sanm_encoder.py b/funasr/models/encoder/sanm_encoder.py index f2502bbb6..969ddadf2 100644 --- a/funasr/models/encoder/sanm_encoder.py +++ b/funasr/models/encoder/sanm_encoder.py @@ -6,9 +6,11 @@ from typing import Union import logging import torch import torch.nn as nn +import torch.nn.functional as F from funasr.modules.streaming_utils.chunk_utilis import overlap_chunk from typeguard import check_argument_types import numpy as np +from funasr.torch_utils.device_funcs import to_device from funasr.modules.nets_utils import make_pad_mask from funasr.modules.attention import MultiHeadedAttention, MultiHeadedAttentionSANM, MultiHeadedAttentionSANMwithMask from funasr.modules.embedding import SinusoidalPositionEncoder, StreamSinusoidalPositionEncoder @@ -349,6 +351,23 @@ class SANMEncoder(AbsEncoder): return (xs_pad, intermediate_outs), olens, None return xs_pad, olens, None + def _add_overlap_chunk(self, feats: np.ndarray, cache: dict = {}): + if len(cache) == 0: + return feats + # process last chunk + cache["feats"] = to_device(cache["feats"], device=feats.device) + overlap_feats = torch.cat((cache["feats"], feats), dim=1) + if cache["is_final"]: + cache["feats"] = overlap_feats[:, -cache["chunk_size"][0]:, :] + if not cache["last_chunk"]: + padding_length = sum(cache["chunk_size"]) - overlap_feats.shape[1] + overlap_feats = overlap_feats.transpose(1, 2) + overlap_feats = F.pad(overlap_feats, (0, padding_length)) + overlap_feats = overlap_feats.transpose(1, 2) + else: + cache["feats"] = overlap_feats[:, -(cache["chunk_size"][0] + cache["chunk_size"][2]):, :] + return overlap_feats + def forward_chunk(self, xs_pad: torch.Tensor, ilens: torch.Tensor, @@ -360,7 +379,10 @@ class SANMEncoder(AbsEncoder): xs_pad = xs_pad else: xs_pad = self.embed(xs_pad, cache) - + if cache["tail_chunk"]: + xs_pad = cache["feats"] + else: + xs_pad = self._add_overlap_chunk(xs_pad, cache) encoder_outs = self.encoders0(xs_pad, None, None, None, None) xs_pad, masks = encoder_outs[0], encoder_outs[1] intermediate_outs = [] diff --git a/funasr/models/predictor/cif.py b/funasr/models/predictor/cif.py index a5273f841..c59e24502 100644 --- a/funasr/models/predictor/cif.py +++ b/funasr/models/predictor/cif.py @@ -2,6 +2,7 @@ import torch from torch import nn import logging import numpy as np +from funasr.torch_utils.device_funcs import to_device from funasr.modules.nets_utils import make_pad_mask from funasr.modules.streaming_utils.utils import sequence_mask @@ -200,7 +201,7 @@ class CifPredictorV2(nn.Module): return acoustic_embeds, token_num, alphas, cif_peak def forward_chunk(self, hidden, cache=None): - b, t, d = hidden.size() + batch_size, len_time, hidden_size = hidden.shape h = hidden context = h.transpose(1, 2) queries = self.pad(context) @@ -211,58 +212,81 @@ class CifPredictorV2(nn.Module): alphas = torch.nn.functional.relu(alphas * self.smooth_factor - self.noise_threshold) alphas = alphas.squeeze(-1) - mask_chunk_predictor = None - if cache is not None: - mask_chunk_predictor = None - mask_chunk_predictor = torch.zeros_like(alphas) - mask_chunk_predictor[:, cache["pad_left"]:cache["stride"] + cache["pad_left"]] = 1.0 - - if mask_chunk_predictor is not None: - alphas = alphas * mask_chunk_predictor - - if cache is not None: - if cache["is_final"]: - alphas[:, cache["stride"] + cache["pad_left"] - 1] += 0.45 - if cache["cif_hidden"] is not None: - hidden = torch.cat((cache["cif_hidden"], hidden), 1) - if cache["cif_alphas"] is not None: - alphas = torch.cat((cache["cif_alphas"], alphas), -1) - token_num = alphas.sum(-1) - acoustic_embeds, cif_peak = cif(hidden, alphas, self.threshold) - len_time = alphas.size(-1) - last_fire_place = len_time - 1 - last_fire_remainds = 0.0 - pre_alphas_length = 0 - last_fire = False - - mask_chunk_peak_predictor = None - if cache is not None: - mask_chunk_peak_predictor = None - mask_chunk_peak_predictor = torch.zeros_like(cif_peak) - if cache["cif_alphas"] is not None: - pre_alphas_length = cache["cif_alphas"].size(-1) - mask_chunk_peak_predictor[:, :pre_alphas_length] = 1.0 - mask_chunk_peak_predictor[:, pre_alphas_length + cache["pad_left"]:pre_alphas_length + cache["stride"] + cache["pad_left"]] = 1.0 - - if mask_chunk_peak_predictor is not None: - cif_peak = cif_peak * mask_chunk_peak_predictor.squeeze(-1) - - for i in range(len_time): - if cif_peak[0][len_time - 1 - i] > self.threshold or cif_peak[0][len_time - 1 - i] == self.threshold: - last_fire_place = len_time - 1 - i - last_fire_remainds = cif_peak[0][len_time - 1 - i] - self.threshold - last_fire = True - break - if last_fire: - last_fire_remainds = torch.tensor([last_fire_remainds], dtype=alphas.dtype).to(alphas.device) - cache["cif_hidden"] = hidden[:, last_fire_place:, :] - cache["cif_alphas"] = torch.cat((last_fire_remainds.unsqueeze(0), alphas[:, last_fire_place+1:]), -1) - else: - cache["cif_hidden"] = hidden - cache["cif_alphas"] = alphas - token_num_int = token_num.floor().type(torch.int32).item() - return acoustic_embeds[:, 0:token_num_int, :], token_num, alphas, cif_peak + token_length = [] + list_fires = [] + list_frames = [] + cache_alphas = [] + cache_hiddens = [] + + if cache is not None and "chunk_size" in cache: + alphas[:, :cache["chunk_size"][0]] = 0.0 + alphas[:, sum(cache["chunk_size"][:2]):] = 0.0 + if cache is not None and "cif_alphas" in cache and "cif_hidden" in cache: + cache["cif_hidden"] = to_device(cache["cif_hidden"], device=hidden.device) + cache["cif_alphas"] = to_device(cache["cif_alphas"], device=alphas.device) + hidden = torch.cat((cache["cif_hidden"], hidden), dim=1) + alphas = torch.cat((cache["cif_alphas"], alphas), dim=1) + if cache is not None and "last_chunk" in cache and cache["last_chunk"]: + tail_hidden = torch.zeros((batch_size, 1, hidden_size), device=hidden.device) + tail_alphas = torch.tensor([[self.tail_threshold]], device=alphas.device) + tail_alphas = torch.tile(tail_alphas, (batch_size, 1)) + hidden = torch.cat((hidden, tail_hidden), dim=1) + alphas = torch.cat((alphas, tail_alphas), dim=1) + + len_time = alphas.shape[1] + for b in range(batch_size): + integrate = 0.0 + frames = torch.zeros((hidden_size), device=hidden.device) + list_frame = [] + list_fire = [] + for t in range(len_time): + alpha = alphas[b][t] + if alpha + integrate < self.threshold: + integrate += alpha + list_fire.append(integrate) + frames += alpha * hidden[b][t] + else: + frames += (self.threshold - integrate) * hidden[b][t] + list_frame.append(frames) + integrate += alpha + list_fire.append(integrate) + integrate -= self.threshold + frames = integrate * hidden[b][t] + + cache_alphas.append(integrate) + if integrate > 0.0: + cache_hiddens.append(frames / integrate) + else: + cache_hiddens.append(frames) + + token_length.append(torch.tensor(len(list_frame), device=alphas.device)) + list_fires.append(list_fire) + list_frames.append(list_frame) + + cache["cif_alphas"] = torch.stack(cache_alphas, axis=0) + cache["cif_alphas"] = torch.unsqueeze(cache["cif_alphas"], axis=0) + cache["cif_hidden"] = torch.stack(cache_hiddens, axis=0) + cache["cif_hidden"] = torch.unsqueeze(cache["cif_hidden"], axis=0) + + max_token_len = max(token_length) + if max_token_len == 0: + return hidden, torch.stack(token_length, 0) + list_ls = [] + for b in range(batch_size): + pad_frames = torch.zeros((max_token_len - token_length[b], hidden_size), device=alphas.device) + if token_length[b] == 0: + list_ls.append(pad_frames) + else: + list_frames[b] = torch.stack(list_frames[b]) + list_ls.append(torch.cat((list_frames[b], pad_frames), dim=0)) + + cache["cif_alphas"] = torch.stack(cache_alphas, axis=0) + cache["cif_alphas"] = torch.unsqueeze(cache["cif_alphas"], axis=0) + cache["cif_hidden"] = torch.stack(cache_hiddens, axis=0) + cache["cif_hidden"] = torch.unsqueeze(cache["cif_hidden"], axis=0) + return torch.stack(list_ls, 0), torch.stack(token_length, 0) + def tail_process_fn(self, hidden, alphas, token_num=None, mask=None): b, t, d = hidden.size() diff --git a/funasr/modules/e2e_asr_common.py b/funasr/modules/e2e_asr_common.py index f430fcb43..98006f948 100644 --- a/funasr/modules/e2e_asr_common.py +++ b/funasr/modules/e2e_asr_common.py @@ -296,12 +296,13 @@ class ErrorCalculatorTransducer: self.report_wer = report_wer def __call__( - self, encoder_out: torch.Tensor, target: torch.Tensor + self, encoder_out: torch.Tensor, target: torch.Tensor, encoder_out_lens: torch.Tensor, ) -> Tuple[Optional[float], Optional[float]]: """Calculate sentence-level WER or/and CER score for Transducer model. Args: encoder_out: Encoder output sequences. (B, T, D_enc) target: Target label ID sequences. (B, L) + encoder_out_lens: Encoder output sequences length. (B,) Returns: : Sentence-level CER score. : Sentence-level WER score. @@ -312,7 +313,10 @@ class ErrorCalculatorTransducer: encoder_out = encoder_out.to(next(self.decoder.parameters()).device) - batch_nbest = [self.beam_search(encoder_out[b]) for b in range(batchsize)] + batch_nbest = [ + self.beam_search(encoder_out[b][: encoder_out_lens[b]]) + for b in range(batchsize) + ] pred = [nbest_hyp[0].yseq[1:] for nbest_hyp in batch_nbest] char_pred, char_target = self.convert_to_char(pred, target) diff --git a/funasr/modules/embedding.py b/funasr/modules/embedding.py index c347e24f1..aaac80a7d 100644 --- a/funasr/modules/embedding.py +++ b/funasr/modules/embedding.py @@ -425,21 +425,14 @@ class StreamSinusoidalPositionEncoder(torch.nn.Module): return encoding.type(dtype) def forward(self, x, cache=None): - start_idx = 0 - pad_left = 0 - pad_right = 0 batch_size, timesteps, input_dim = x.size() + start_idx = 0 if cache is not None: start_idx = cache["start_idx"] - pad_left = cache["left"] - pad_right = cache["right"] + cache["start_idx"] += timesteps positions = torch.arange(1, timesteps+start_idx+1)[None, :] position_encoding = self.encode(positions, input_dim, x.dtype).to(x.device) - outputs = x + position_encoding[:, start_idx: start_idx + timesteps] - outputs = outputs.transpose(1, 2) - outputs = F.pad(outputs, (pad_left, pad_right)) - outputs = outputs.transpose(1, 2) - return outputs + return x + position_encoding[:, start_idx: start_idx + timesteps] class StreamingRelPositionalEncoding(torch.nn.Module): """Relative positional encoding. diff --git a/funasr/runtime/onnxruntime/CMakeLists.txt b/funasr/runtime/onnxruntime/CMakeLists.txt index 9879c4aa6..25b816f98 100644 --- a/funasr/runtime/onnxruntime/CMakeLists.txt +++ b/funasr/runtime/onnxruntime/CMakeLists.txt @@ -1,6 +1,8 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) -project(FunASRonnx) +project(FunASROnnx) + +option(ENABLE_GLOG "Whether to build glog" ON) # set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.") @@ -26,7 +28,15 @@ ELSE() endif() include_directories(${PROJECT_SOURCE_DIR}/third_party/kaldi-native-fbank) +include_directories(${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include) add_subdirectory(third_party/yaml-cpp) add_subdirectory(third_party/kaldi-native-fbank/kaldi-native-fbank/csrc) add_subdirectory(src) + +if(ENABLE_GLOG) + include_directories(${PROJECT_SOURCE_DIR}/third_party/glog) + set(BUILD_TESTING OFF) + add_subdirectory(third_party/glog) +endif() + diff --git a/funasr/runtime/onnxruntime/include/com-define.h b/funasr/runtime/onnxruntime/include/com-define.h index e2c22f425..8c885178e 100644 --- a/funasr/runtime/onnxruntime/include/com-define.h +++ b/funasr/runtime/onnxruntime/include/com-define.h @@ -12,37 +12,51 @@ #define MODEL_SAMPLE_RATE 16000 #endif +// model path +#define VAD_MODEL_PATH "vad-model" +#define VAD_CMVN_PATH "vad-cmvn" +#define VAD_CONFIG_PATH "vad-config" +#define AM_MODEL_PATH "am-model" +#define AM_CMVN_PATH "am-cmvn" +#define AM_CONFIG_PATH "am-config" +#define PUNC_MODEL_PATH "punc-model" +#define PUNC_CONFIG_PATH "punc-config" +#define WAV_PATH "wav-path" +#define WAV_SCP "wav-scp" +#define THREAD_NUM "thread-num" + // vad -#ifndef VAD_SILENCE_DYRATION -#define VAD_SILENCE_DYRATION 15000 +#ifndef VAD_SILENCE_DURATION +#define VAD_SILENCE_DURATION 800 #endif #ifndef VAD_MAX_LEN -#define VAD_MAX_LEN 800 +#define VAD_MAX_LEN 15000 #endif #ifndef VAD_SPEECH_NOISE_THRES #define VAD_SPEECH_NOISE_THRES 0.9 #endif +#ifndef VAD_LFR_M +#define VAD_LFR_M 5 +#endif + +#ifndef VAD_LFR_N +#define VAD_LFR_N 1 +#endif + // punc -#define PUNC_MODEL_FILE "punc_model.onnx" -#define PUNC_YAML_FILE "punc.yaml" #define UNK_CHAR "" +#define TOKEN_LEN 20 -#define INPUT_NUM 2 -#define INPUT_NAME1 "input" -#define INPUT_NAME2 "text_lengths" -#define OUTPUT_NAME "logits" -#define TOKEN_LEN 20 - -#define CANDIDATE_NUM 6 +#define CANDIDATE_NUM 6 #define UNKNOW_INDEX 0 #define NOTPUNC_INDEX 1 #define COMMA_INDEX 2 #define PERIOD_INDEX 3 #define QUESTION_INDEX 4 #define DUN_INDEX 5 -#define CACHE_POP_TRIGGER_LIMIT 200 +#define CACHE_POP_TRIGGER_LIMIT 200 #endif diff --git a/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/feature-fbank.h b/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/feature-fbank.h deleted file mode 100644 index 0786aad10..000000000 --- a/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/feature-fbank.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2022 Xiaomi Corporation (authors: Fangjun Kuang) - * - * See LICENSE for clarification regarding multiple authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file is copied/modified from kaldi/src/feat/feature-fbank.h - -#ifndef KALDI_NATIVE_FBANK_CSRC_FEATURE_FBANK_H_ -#define KALDI_NATIVE_FBANK_CSRC_FEATURE_FBANK_H_ - -#include -#include -#include - -#include "kaldi-native-fbank/csrc/feature-window.h" -#include "kaldi-native-fbank/csrc/mel-computations.h" -#include "kaldi-native-fbank/csrc/rfft.h" - -namespace knf { - -struct FbankOptions { - FrameExtractionOptions frame_opts; - MelBanksOptions mel_opts; - // append an extra dimension with energy to the filter banks - bool use_energy = false; - float energy_floor = 0.0f; // active iff use_energy==true - - // If true, compute log_energy before preemphasis and windowing - // If false, compute log_energy after preemphasis ans windowing - bool raw_energy = true; // active iff use_energy==true - - // If true, put energy last (if using energy) - // If false, put energy first - bool htk_compat = false; // active iff use_energy==true - - // if true (default), produce log-filterbank, else linear - bool use_log_fbank = true; - - // if true (default), use power in filterbank - // analysis, else magnitude. - bool use_power = true; - - FbankOptions() { mel_opts.num_bins = 23; } - - std::string ToString() const { - std::ostringstream os; - os << "frame_opts: \n"; - os << frame_opts << "\n"; - os << "\n"; - - os << "mel_opts: \n"; - os << mel_opts << "\n"; - - os << "use_energy: " << use_energy << "\n"; - os << "energy_floor: " << energy_floor << "\n"; - os << "raw_energy: " << raw_energy << "\n"; - os << "htk_compat: " << htk_compat << "\n"; - os << "use_log_fbank: " << use_log_fbank << "\n"; - os << "use_power: " << use_power << "\n"; - return os.str(); - } -}; - -std::ostream &operator<<(std::ostream &os, const FbankOptions &opts); - -class FbankComputer { - public: - using Options = FbankOptions; - - explicit FbankComputer(const FbankOptions &opts); - ~FbankComputer(); - - int32_t Dim() const { - return opts_.mel_opts.num_bins + (opts_.use_energy ? 1 : 0); - } - - // if true, compute log_energy_pre_window but after dithering and dc removal - bool NeedRawLogEnergy() const { return opts_.use_energy && opts_.raw_energy; } - - const FrameExtractionOptions &GetFrameOptions() const { - return opts_.frame_opts; - } - - const FbankOptions &GetOptions() const { return opts_; } - - /** - Function that computes one frame of features from - one frame of signal. - - @param [in] signal_raw_log_energy The log-energy of the frame of the signal - prior to windowing and pre-emphasis, or - log(numeric_limits::min()), whichever is greater. Must be - ignored by this function if this class returns false from - this->NeedsRawLogEnergy(). - @param [in] vtln_warp The VTLN warping factor that the user wants - to be applied when computing features for this utterance. Will - normally be 1.0, meaning no warping is to be done. The value will - be ignored for feature types that don't support VLTN, such as - spectrogram features. - @param [in] signal_frame One frame of the signal, - as extracted using the function ExtractWindow() using the options - returned by this->GetFrameOptions(). The function will use the - vector as a workspace, which is why it's a non-const pointer. - @param [out] feature Pointer to a vector of size this->Dim(), to which - the computed feature will be written. It should be pre-allocated. - */ - void Compute(float signal_raw_log_energy, float vtln_warp, - std::vector *signal_frame, float *feature); - - private: - const MelBanks *GetMelBanks(float vtln_warp); - - FbankOptions opts_; - float log_energy_floor_; - std::map mel_banks_; // float is VTLN coefficient. - Rfft rfft_; -}; - -} // namespace knf - -#endif // KALDI_NATIVE_FBANK_CSRC_FEATURE_FBANK_H_ diff --git a/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/online-feature.h b/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/online-feature.h deleted file mode 100644 index 5ca551157..000000000 --- a/funasr/runtime/onnxruntime/include/kaldi-native-fbank/csrc/online-feature.h +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2022 Xiaomi Corporation (authors: Fangjun Kuang) - * - * See LICENSE for clarification regarding multiple authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// The content in this file is copied/modified from -// This file is copied/modified from kaldi/src/feat/online-feature.h -#ifndef KALDI_NATIVE_FBANK_CSRC_ONLINE_FEATURE_H_ -#define KALDI_NATIVE_FBANK_CSRC_ONLINE_FEATURE_H_ - -#include -#include -#include - -#include "kaldi-native-fbank/csrc/feature-fbank.h" - -namespace knf { - -/// This class serves as a storage for feature vectors with an option to limit -/// the memory usage by removing old elements. The deleted frames indices are -/// "remembered" so that regardless of the MAX_ITEMS setting, the user always -/// provides the indices as if no deletion was being performed. -/// This is useful when processing very long recordings which would otherwise -/// cause the memory to eventually blow up when the features are not being -/// removed. -class RecyclingVector { - public: - /// By default it does not remove any elements. - explicit RecyclingVector(int32_t items_to_hold = -1); - - ~RecyclingVector() = default; - RecyclingVector(const RecyclingVector &) = delete; - RecyclingVector &operator=(const RecyclingVector &) = delete; - - // The pointer is owned by RecyclingVector - // Users should not free it - const float *At(int32_t index) const; - - void PushBack(std::vector item); - - /// This method returns the size as if no "recycling" had happened, - /// i.e. equivalent to the number of times the PushBack method has been - /// called. - int32_t Size() const; - - private: - std::deque> items_; - int32_t items_to_hold_; - int32_t first_available_index_; -}; - -/// This is a templated class for online feature extraction; -/// it's templated on a class like MfccComputer or PlpComputer -/// that does the basic feature extraction. -template -class OnlineGenericBaseFeature { - public: - // Constructor from options class - explicit OnlineGenericBaseFeature(const typename C::Options &opts); - - int32_t Dim() const { return computer_.Dim(); } - - float FrameShiftInSeconds() const { - return computer_.GetFrameOptions().frame_shift_ms / 1000.0f; - } - - int32_t NumFramesReady() const { return features_.Size(); } - - // Note: IsLastFrame() will only ever return true if you have called - // InputFinished() (and this frame is the last frame). - bool IsLastFrame(int32_t frame) const { - return input_finished_ && frame == NumFramesReady() - 1; - } - - const float *GetFrame(int32_t frame) const { return features_.At(frame); } - - // This would be called from the application, when you get - // more wave data. Note: the sampling_rate is only provided so - // the code can assert that it matches the sampling rate - // expected in the options. - // - // @param sampling_rate The sampling_rate of the input waveform - // @param waveform Pointer to a 1-D array of size n - // @param n Number of entries in waveform - void AcceptWaveform(float sampling_rate, const float *waveform, int32_t n); - - // InputFinished() tells the class you won't be providing any - // more waveform. This will help flush out the last frame or two - // of features, in the case where snip-edges == false; it also - // affects the return value of IsLastFrame(). - void InputFinished(); - - private: - // This function computes any additional feature frames that it is possible to - // compute from 'waveform_remainder_', which at this point may contain more - // than just a remainder-sized quantity (because AcceptWaveform() appends to - // waveform_remainder_ before calling this function). It adds these feature - // frames to features_, and shifts off any now-unneeded samples of input from - // waveform_remainder_ while incrementing waveform_offset_ by the same amount. - void ComputeFeatures(); - - C computer_; // class that does the MFCC or PLP or filterbank computation - - FeatureWindowFunction window_function_; - - // features_ is the Mfcc or Plp or Fbank features that we have already - // computed. - - RecyclingVector features_; - - // True if the user has called "InputFinished()" - bool input_finished_; - - // waveform_offset_ is the number of samples of waveform that we have - // already discarded, i.e. that were prior to 'waveform_remainder_'. - int64_t waveform_offset_; - - // waveform_remainder_ is a short piece of waveform that we may need to keep - // after extracting all the whole frames we can (whatever length of feature - // will be required for the next phase of computation). - // It is a 1-D tensor - std::vector waveform_remainder_; -}; - -using OnlineFbank = OnlineGenericBaseFeature; - -} // namespace knf - -#endif // KALDI_NATIVE_FBANK_CSRC_ONLINE_FEATURE_H_ diff --git a/funasr/runtime/onnxruntime/include/libfunasrapi.h b/funasr/runtime/onnxruntime/include/libfunasrapi.h index 6b6e14801..8dca7f4d6 100644 --- a/funasr/runtime/onnxruntime/include/libfunasrapi.h +++ b/funasr/runtime/onnxruntime/include/libfunasrapi.h @@ -1,4 +1,5 @@ #pragma once +#include #ifdef WIN32 #ifdef _FUNASR_API_EXPORT @@ -47,13 +48,13 @@ typedef enum { typedef void (* QM_CALLBACK)(int cur_step, int n_total); // n_total: total steps; cur_step: Current Step. // APIs for funasr -_FUNASRAPI FUNASR_HANDLE FunASRInit(const char* sz_model_dir, int thread_num, bool quantize=false, bool use_vad=false, bool use_punc=false); +_FUNASRAPI FUNASR_HANDLE FunASRInit(std::map& model_path, int thread_num); // if not give a fn_callback ,it should be NULL -_FUNASRAPI FUNASR_RESULT FunASRRecogBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad=false, bool use_punc=false); -_FUNASRAPI FUNASR_RESULT FunASRRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad=false, bool use_punc=false); -_FUNASRAPI FUNASR_RESULT FunASRRecogPCMFile(FUNASR_HANDLE handle, const char* sz_filename, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad=false, bool use_punc=false); -_FUNASRAPI FUNASR_RESULT FunASRRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad=false, bool use_punc=false); +_FUNASRAPI FUNASR_RESULT FunASRRecogBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, FUNASR_MODE mode, QM_CALLBACK fn_callback); +_FUNASRAPI FUNASR_RESULT FunASRRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback); +_FUNASRAPI FUNASR_RESULT FunASRRecogPCMFile(FUNASR_HANDLE handle, const char* sz_filename, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback); +_FUNASRAPI FUNASR_RESULT FunASRRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback); _FUNASRAPI const char* FunASRGetResult(FUNASR_RESULT result,int n_index); _FUNASRAPI const int FunASRGetRetNumber(FUNASR_RESULT result); diff --git a/funasr/runtime/onnxruntime/include/model.h b/funasr/runtime/onnxruntime/include/model.h index 26a67f021..4b4b582ff 100644 --- a/funasr/runtime/onnxruntime/include/model.h +++ b/funasr/runtime/onnxruntime/include/model.h @@ -3,6 +3,7 @@ #define MODEL_H #include +#include class Model { public: @@ -13,7 +14,9 @@ class Model { virtual std::string Rescoring() = 0; virtual std::vector> VadSeg(std::vector& pcm_data)=0; virtual std::string AddPunc(const char* sz_input)=0; + virtual bool UseVad() =0; + virtual bool UsePunc() =0; }; -Model *CreateModel(const char *path,int thread_num=1,bool quantize=false, bool use_vad=false, bool use_punc=false); +Model *CreateModel(std::map& model_path,int thread_num=1); #endif diff --git a/funasr/runtime/onnxruntime/include/tclap/Arg.h b/funasr/runtime/onnxruntime/include/tclap/Arg.h new file mode 100644 index 000000000..f8c4a5fc5 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/Arg.h @@ -0,0 +1,683 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: Arg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno . + * Copyright (c) 2017 Google Inc. + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_ARGUMENT_H +#define TCLAP_ARGUMENT_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace TCLAP { + +/** + * A virtual base class that defines the essential data for all arguments. + * This class, or one of its existing children, must be subclassed to do + * anything. + */ +class Arg +{ + private: + /** + * Prevent accidental copying. + */ + Arg(const Arg& rhs); + + /** + * Prevent accidental copying. + */ + Arg& operator=(const Arg& rhs); + + /** + * Indicates whether the rest of the arguments should be ignored. + */ + static bool& ignoreRestRef() { static bool ign = false; return ign; } + + /** + * The delimiter that separates an argument flag/name from the + * value. + */ + static char& delimiterRef() { static char delim = ' '; return delim; } + + protected: + + /** + * The single char flag used to identify the argument. + * This value (preceded by a dash {-}), can be used to identify + * an argument on the command line. The _flag can be blank, + * in fact this is how unlabeled args work. Unlabeled args must + * override appropriate functions to get correct handling. Note + * that the _flag does NOT include the dash as part of the flag. + */ + std::string _flag; + + /** + * A single word namd identifying the argument. + * This value (preceded by two dashed {--}) can also be used + * to identify an argument on the command line. Note that the + * _name does NOT include the two dashes as part of the _name. The + * _name cannot be blank. + */ + std::string _name; + + /** + * Description of the argument. + */ + std::string _description; + + /** + * Indicating whether the argument is required. + */ + bool _required; + + /** + * Label to be used in usage description. Normally set to + * "required", but can be changed when necessary. + */ + std::string _requireLabel; + + /** + * Indicates whether a value is required for the argument. + * Note that the value may be required but the argument/value + * combination may not be, as specified by _required. + */ + bool _valueRequired; + + /** + * Indicates whether the argument has been set. + * Indicates that a value on the command line has matched the + * name/flag of this argument and the values have been set accordingly. + */ + bool _alreadySet; + + /** + * A pointer to a visitor object. + * The visitor allows special handling to occur as soon as the + * argument is matched. This defaults to NULL and should not + * be used unless absolutely necessary. + */ + Visitor* _visitor; + + /** + * Whether this argument can be ignored, if desired. + */ + bool _ignoreable; + + /** + * Indicates that the arg was set as part of an XOR and not on the + * command line. + */ + bool _xorSet; + + bool _acceptsMultipleValues; + + /** + * Performs the special handling described by the Visitor. + */ + void _checkWithVisitor() const; + + /** + * Primary constructor. YOU (yes you) should NEVER construct an Arg + * directly, this is a base class that is extended by various children + * that are meant to be used. Use SwitchArg, ValueArg, MultiArg, + * UnlabeledValueArg, or UnlabeledMultiArg instead. + * + * \param flag - The flag identifying the argument. + * \param name - The name identifying the argument. + * \param desc - The description of the argument, used in the usage. + * \param req - Whether the argument is required. + * \param valreq - Whether the a value is required for the argument. + * \param v - The visitor checked by the argument. Defaults to NULL. + */ + Arg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + bool valreq, + Visitor* v = NULL ); + + public: + /** + * Destructor. + */ + virtual ~Arg(); + + /** + * Adds this to the specified list of Args. + * \param argList - The list to add this to. + */ + virtual void addToList( std::list& argList ) const; + + /** + * Begin ignoring arguments since the "--" argument was specified. + */ + static void beginIgnoring() { ignoreRestRef() = true; } + + /** + * Whether to ignore the rest. + */ + static bool ignoreRest() { return ignoreRestRef(); } + + /** + * The delimiter that separates an argument flag/name from the + * value. + */ + static char delimiter() { return delimiterRef(); } + + /** + * The char used as a place holder when SwitchArgs are combined. + * Currently set to the bell char (ASCII 7). + */ + static char blankChar() { return (char)7; } + + /** + * The char that indicates the beginning of a flag. Defaults to '-', but + * clients can define TCLAP_FLAGSTARTCHAR to override. + */ +#ifndef TCLAP_FLAGSTARTCHAR +#define TCLAP_FLAGSTARTCHAR '-' +#endif + static char flagStartChar() { return TCLAP_FLAGSTARTCHAR; } + + /** + * The sting that indicates the beginning of a flag. Defaults to "-", but + * clients can define TCLAP_FLAGSTARTSTRING to override. Should be the same + * as TCLAP_FLAGSTARTCHAR. + */ +#ifndef TCLAP_FLAGSTARTSTRING +#define TCLAP_FLAGSTARTSTRING "-" +#endif + static const std::string flagStartString() { return TCLAP_FLAGSTARTSTRING; } + + /** + * The sting that indicates the beginning of a name. Defaults to "--", but + * clients can define TCLAP_NAMESTARTSTRING to override. + */ +#ifndef TCLAP_NAMESTARTSTRING +#define TCLAP_NAMESTARTSTRING "--" +#endif + static const std::string nameStartString() { return TCLAP_NAMESTARTSTRING; } + + /** + * The name used to identify the ignore rest argument. + */ + static const std::string ignoreNameString() { return "ignore_rest"; } + + /** + * Sets the delimiter for all arguments. + * \param c - The character that delimits flags/names from values. + */ + static void setDelimiter( char c ) { delimiterRef() = c; } + + /** + * Pure virtual method meant to handle the parsing and value assignment + * of the string on the command line. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. What is + * passed in from main. + */ + virtual bool processArg(int *i, std::vector& args) = 0; + + /** + * Operator ==. + * Equality operator. Must be virtual to handle unlabeled args. + * \param a - The Arg to be compared to this. + */ + virtual bool operator==(const Arg& a) const; + + /** + * Returns the argument flag. + */ + const std::string& getFlag() const; + + /** + * Returns the argument name. + */ + const std::string& getName() const; + + /** + * Returns the argument description. + */ + std::string getDescription() const; + + /** + * Indicates whether the argument is required. + */ + virtual bool isRequired() const; + + /** + * Sets _required to true. This is used by the XorHandler. + * You really have no reason to ever use it. + */ + void forceRequired(); + + /** + * Sets the _alreadySet value to true. This is used by the XorHandler. + * You really have no reason to ever use it. + */ + void xorSet(); + + /** + * Indicates whether a value must be specified for argument. + */ + bool isValueRequired() const; + + /** + * Indicates whether the argument has already been set. Only true + * if the arg has been matched on the command line. + */ + bool isSet() const; + + /** + * Indicates whether the argument can be ignored, if desired. + */ + bool isIgnoreable() const; + + /** + * A method that tests whether a string matches this argument. + * This is generally called by the processArg() method. This + * method could be re-implemented by a child to change how + * arguments are specified on the command line. + * \param s - The string to be compared to the flag/name to determine + * whether the arg matches. + */ + virtual bool argMatches( const std::string& s ) const; + + /** + * Returns a simple string representation of the argument. + * Primarily for debugging. + */ + virtual std::string toString() const; + + /** + * Returns a short ID for the usage. + * \param valueId - The value used in the id. + */ + virtual std::string shortID( const std::string& valueId = "val" ) const; + + /** + * Returns a long ID for the usage. + * \param valueId - The value used in the id. + */ + virtual std::string longID( const std::string& valueId = "val" ) const; + + /** + * Trims a value off of the flag. + * \param flag - The string from which the flag and value will be + * trimmed. Contains the flag once the value has been trimmed. + * \param value - Where the value trimmed from the string will + * be stored. + */ + virtual void trimFlag( std::string& flag, std::string& value ) const; + + /** + * Checks whether a given string has blank chars, indicating that + * it is a combined SwitchArg. If so, return true, otherwise return + * false. + * \param s - string to be checked. + */ + bool _hasBlanks( const std::string& s ) const; + + /** + * Sets the requireLabel. Used by XorHandler. You shouldn't ever + * use this. + * \param s - Set the requireLabel to this value. + */ + void setRequireLabel( const std::string& s ); + + /** + * Used for MultiArgs and XorHandler to determine whether args + * can still be set. + */ + virtual bool allowMore(); + + /** + * Use by output classes to determine whether an Arg accepts + * multiple values. + */ + virtual bool acceptsMultipleValues(); + + /** + * Clears the Arg object and allows it to be reused by new + * command lines. + */ + virtual void reset(); +}; + +/** + * Typedef of an Arg list iterator. + */ +typedef std::list::const_iterator ArgListIterator; + +/** + * Typedef of an Arg vector iterator. + */ +typedef std::vector::const_iterator ArgVectorIterator; + +/** + * Typedef of a Visitor list iterator. + */ +typedef std::list::const_iterator VisitorListIterator; + +/* + * Extract a value of type T from it's string representation contained + * in strVal. The ValueLike parameter used to select the correct + * specialization of ExtractValue depending on the value traits of T. + * ValueLike traits use operator>> to assign the value from strVal. + */ +template void +ExtractValue(T &destVal, const std::string& strVal, ValueLike vl) +{ + static_cast(vl); // Avoid warning about unused vl + istringstream is(strVal.c_str()); + + int valuesRead = 0; + while ( is.good() ) { + if ( is.peek() != EOF ) +#ifdef TCLAP_SETBASE_ZERO + is >> std::setbase(0) >> destVal; +#else + is >> destVal; +#endif + else + break; + + valuesRead++; + } + + if ( is.fail() ) + throw( ArgParseException("Couldn't read argument value " + "from string '" + strVal + "'")); + + + if ( valuesRead > 1 ) + throw( ArgParseException("More than one valid value parsed from " + "string '" + strVal + "'")); + +} + +/* + * Extract a value of type T from it's string representation contained + * in strVal. The ValueLike parameter used to select the correct + * specialization of ExtractValue depending on the value traits of T. + * StringLike uses assignment (operator=) to assign from strVal. + */ +template void +ExtractValue(T &destVal, const std::string& strVal, StringLike sl) +{ + static_cast(sl); // Avoid warning about unused sl + SetString(destVal, strVal); +} + +////////////////////////////////////////////////////////////////////// +//BEGIN Arg.cpp +////////////////////////////////////////////////////////////////////// + +inline Arg::Arg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + bool valreq, + Visitor* v) : + _flag(flag), + _name(name), + _description(desc), + _required(req), + _requireLabel("required"), + _valueRequired(valreq), + _alreadySet(false), + _visitor( v ), + _ignoreable(true), + _xorSet(false), + _acceptsMultipleValues(false) +{ + if ( _flag.length() > 1 ) + throw(SpecificationException( + "Argument flag can only be one character long", toString() ) ); + + if ( _name != ignoreNameString() && + ( _flag == Arg::flagStartString() || + _flag == Arg::nameStartString() || + _flag == " " ) ) + throw(SpecificationException("Argument flag cannot be either '" + + Arg::flagStartString() + "' or '" + + Arg::nameStartString() + "' or a space.", + toString() ) ); + + if ( ( _name.substr( 0, Arg::flagStartString().length() ) == Arg::flagStartString() ) || + ( _name.substr( 0, Arg::nameStartString().length() ) == Arg::nameStartString() ) || + ( _name.find( " ", 0 ) != std::string::npos ) ) + throw(SpecificationException("Argument name begin with either '" + + Arg::flagStartString() + "' or '" + + Arg::nameStartString() + "' or space.", + toString() ) ); + +} + +inline Arg::~Arg() { } + +inline std::string Arg::shortID( const std::string& valueId ) const +{ + std::string id = ""; + + if ( _flag != "" ) + id = Arg::flagStartString() + _flag; + else + id = Arg::nameStartString() + _name; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + if ( !_required ) + id = "[" + id + "]"; + + return id; +} + +inline std::string Arg::longID( const std::string& valueId ) const +{ + std::string id = ""; + + if ( _flag != "" ) + { + id += Arg::flagStartString() + _flag; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + id += ", "; + } + + id += Arg::nameStartString() + _name; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + return id; + +} + +inline bool Arg::operator==(const Arg& a) const +{ + if ( ( _flag != "" && _flag == a._flag ) || _name == a._name) + return true; + else + return false; +} + +inline std::string Arg::getDescription() const +{ + std::string desc = ""; + if ( _required ) + desc = "(" + _requireLabel + ") "; + +// if ( _valueRequired ) +// desc += "(value required) "; + + desc += _description; + return desc; +} + +inline const std::string& Arg::getFlag() const { return _flag; } + +inline const std::string& Arg::getName() const { return _name; } + +inline bool Arg::isRequired() const { return _required; } + +inline bool Arg::isValueRequired() const { return _valueRequired; } + +inline bool Arg::isSet() const +{ + if ( _alreadySet && !_xorSet ) + return true; + else + return false; +} + +inline bool Arg::isIgnoreable() const { return _ignoreable; } + +inline void Arg::setRequireLabel( const std::string& s) +{ + _requireLabel = s; +} + +inline bool Arg::argMatches( const std::string& argFlag ) const +{ + if ( ( argFlag == Arg::flagStartString() + _flag && _flag != "" ) || + argFlag == Arg::nameStartString() + _name ) + return true; + else + return false; +} + +inline std::string Arg::toString() const +{ + std::string s = ""; + + if ( _flag != "" ) + s += Arg::flagStartString() + _flag + " "; + + s += "(" + Arg::nameStartString() + _name + ")"; + + return s; +} + +inline void Arg::_checkWithVisitor() const +{ + if ( _visitor != NULL ) + _visitor->visit(); +} + +/** + * Implementation of trimFlag. + */ +inline void Arg::trimFlag(std::string& flag, std::string& value) const +{ + int stop = 0; + for ( int i = 0; static_cast(i) < flag.length(); i++ ) + if ( flag[i] == Arg::delimiter() ) + { + stop = i; + break; + } + + if ( stop > 1 ) + { + value = flag.substr(stop+1); + flag = flag.substr(0,stop); + } + +} + +/** + * Implementation of _hasBlanks. + */ +inline bool Arg::_hasBlanks( const std::string& s ) const +{ + for ( int i = 1; static_cast(i) < s.length(); i++ ) + if ( s[i] == Arg::blankChar() ) + return true; + + return false; +} + +inline void Arg::forceRequired() +{ + _required = true; +} + +inline void Arg::xorSet() +{ + _alreadySet = true; + _xorSet = true; +} + +/** + * Overridden by Args that need to added to the end of the list. + */ +inline void Arg::addToList( std::list& argList ) const +{ + argList.push_front( const_cast(this) ); +} + +inline bool Arg::allowMore() +{ + return false; +} + +inline bool Arg::acceptsMultipleValues() +{ + return _acceptsMultipleValues; +} + +inline void Arg::reset() +{ + _xorSet = false; + _alreadySet = false; +} + +////////////////////////////////////////////////////////////////////// +//END Arg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif + diff --git a/funasr/runtime/onnxruntime/include/tclap/ArgException.h b/funasr/runtime/onnxruntime/include/tclap/ArgException.h new file mode 100644 index 000000000..1e0f65919 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/ArgException.h @@ -0,0 +1,213 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ArgException.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2017 Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_ARG_EXCEPTION_H +#define TCLAP_ARG_EXCEPTION_H + +#include +#include + +namespace TCLAP { + +/** + * A simple class that defines and argument exception. Should be caught + * whenever a CmdLine is created and parsed. + */ +class ArgException : public std::exception +{ + public: + + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source. + * \param td - Text describing the type of ArgException it is. + * of the exception. + */ + ArgException( const std::string& text = "undefined exception", + const std::string& id = "undefined", + const std::string& td = "Generic ArgException") + : std::exception(), + _errorText(text), + _argId( id ), + _typeDescription(td) + { } + + /** + * Destructor. + */ + virtual ~ArgException() throw() { } + + /** + * Returns the error text. + */ + std::string error() const { return ( _errorText ); } + + /** + * Returns the argument id. + */ + std::string argId() const + { + if ( _argId == "undefined" ) + return " "; + else + return ( "Argument: " + _argId ); + } + + /** + * Returns the arg id and error text. + */ + const char* what() const throw() + { + static std::string ex; + ex = _argId + " -- " + _errorText; + return ex.c_str(); + } + + /** + * Returns the type of the exception. Used to explain and distinguish + * between different child exceptions. + */ + std::string typeDescription() const + { + return _typeDescription; + } + + + private: + + /** + * The text of the exception message. + */ + std::string _errorText; + + /** + * The argument related to this exception. + */ + std::string _argId; + + /** + * Describes the type of the exception. Used to distinguish + * between different child exceptions. + */ + std::string _typeDescription; + +}; + +/** + * Thrown from within the child Arg classes when it fails to properly + * parse the argument it has been passed. + */ +class ArgParseException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + ArgParseException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string( "Exception found while parsing " ) + + std::string( "the value the Arg has been passed." )) + { } +}; + +/** + * Thrown from CmdLine when the arguments on the command line are not + * properly specified, e.g. too many arguments, required argument missing, etc. + */ +class CmdLineParseException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + CmdLineParseException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string( "Exception found when the values ") + + std::string( "on the command line do not meet ") + + std::string( "the requirements of the defined ") + + std::string( "Args." )) + { } +}; + +/** + * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. + * same flag as another Arg, same name, etc. + */ +class SpecificationException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + SpecificationException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string("Exception found when an Arg object ")+ + std::string("is improperly defined by the ") + + std::string("developer." )) + { } + +}; + +/** + * Thrown when TCLAP thinks the program should exit. + * + * For example after parse error this exception will be thrown (and + * normally caught). This allows any resource to be clened properly + * before exit. + * + * If exception handling is disabled (CmdLine::setExceptionHandling), + * this exception will propagate to the call site, allowing the + * program to catch it and avoid program termination, or do it's own + * cleanup. See for example, https://sourceforge.net/p/tclap/bugs/29. + */ +class ExitException { +public: + ExitException(int estat) : _estat(estat) {} + + int getExitStatus() const { return _estat; } + +private: + int _estat; +}; + +} // namespace TCLAP + +#endif + diff --git a/funasr/runtime/onnxruntime/include/tclap/ArgTraits.h b/funasr/runtime/onnxruntime/include/tclap/ArgTraits.h new file mode 100644 index 000000000..0ccf5e36b --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/ArgTraits.h @@ -0,0 +1,122 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ArgTraits.h + * + * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . + * Copyright (c) 2017 Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +// This is an internal tclap file, you should probably not have to +// include this directly + +#ifndef TCLAP_ARGTRAITS_H +#define TCLAP_ARGTRAITS_H + +namespace TCLAP { + +// We use two empty structs to get compile type specialization +// function to work + +/** + * A value like argument value type is a value that can be set using + * operator>>. This is the default value type. + */ +struct ValueLike { + typedef ValueLike ValueCategory; + virtual ~ValueLike() {} +}; + +/** + * A string like argument value type is a value that can be set using + * operator=(string). Useful if the value type contains spaces which + * will be broken up into individual tokens by operator>>. + */ +struct StringLike { + virtual ~StringLike() {} +}; + +/** + * A class can inherit from this object to make it have string like + * traits. This is a compile time thing and does not add any overhead + * to the inherenting class. + */ +struct StringLikeTrait { + typedef StringLike ValueCategory; + virtual ~StringLikeTrait() {} +}; + +/** + * A class can inherit from this object to make it have value like + * traits. This is a compile time thing and does not add any overhead + * to the inherenting class. + */ +struct ValueLikeTrait { + typedef ValueLike ValueCategory; + virtual ~ValueLikeTrait() {} +}; + +/** + * Arg traits are used to get compile type specialization when parsing + * argument values. Using an ArgTraits you can specify the way that + * values gets assigned to any particular type during parsing. The two + * supported types are StringLike and ValueLike. ValueLike is the + * default and means that operator>> will be used to assign values to + * the type. + */ +template +class ArgTraits { + // This is a bit silly, but what we want to do is: + // 1) If there exists a specialization of ArgTraits for type X, + // use it. + // + // 2) If no specialization exists but X has the typename + // X::ValueCategory, use the specialization for X::ValueCategory. + // + // 3) If neither (1) nor (2) defines the trait, use the default + // which is ValueLike. + + // This is the "how": + // + // test(0) (where 0 is the NULL ptr) will match + // test(typename C::ValueCategory*) iff type T has the + // corresponding typedef. If it does not test(...) will be + // matched. This allows us to determine if T::ValueCategory + // exists by checking the sizeof for the test function (return + // value must have different sizeof). + template static short test(typename C::ValueCategory*); + template static long test(...); + static const bool hasTrait = sizeof(test(0)) == sizeof(short); + + template + struct DefaultArgTrait { + typedef ValueLike ValueCategory; + }; + + template + struct DefaultArgTrait { + typedef typename C::ValueCategory ValueCategory; + }; + +public: + typedef typename DefaultArgTrait::ValueCategory ValueCategory; +}; + +} // namespace + +#endif + diff --git a/funasr/runtime/onnxruntime/include/tclap/CmdLine.h b/funasr/runtime/onnxruntime/include/tclap/CmdLine.h new file mode 100644 index 000000000..dc49bae24 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/CmdLine.h @@ -0,0 +1,657 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: CmdLine.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CMDLINE_H +#define TCLAP_CMDLINE_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include // Needed for exit(), which isn't defined in some envs. + +namespace TCLAP { + +template void DelPtr(T ptr) +{ + delete ptr; +} + +template void ClearContainer(C &c) +{ + typedef typename C::value_type value_type; + std::for_each(c.begin(), c.end(), DelPtr); + c.clear(); +} + + +/** + * The base class that manages the command line definition and passes + * along the parsing to the appropriate Arg classes. + */ +class CmdLine : public CmdLineInterface +{ + protected: + + /** + * The list of arguments that will be tested against the + * command line. + */ + std::list _argList; + + /** + * The name of the program. Set to argv[0]. + */ + std::string _progName; + + /** + * A message used to describe the program. Used in the usage output. + */ + std::string _message; + + /** + * The version to be displayed with the --version switch. + */ + std::string _version; + + /** + * The number of arguments that are required to be present on + * the command line. This is set dynamically, based on the + * Args added to the CmdLine object. + */ + int _numRequired; + + /** + * The character that is used to separate the argument flag/name + * from the value. Defaults to ' ' (space). + */ + char _delimiter; + + /** + * The handler that manages xoring lists of args. + */ + XorHandler _xorHandler; + + /** + * A list of Args to be explicitly deleted when the destructor + * is called. At the moment, this only includes the three default + * Args. + */ + std::list _argDeleteOnExitList; + + /** + * A list of Visitors to be explicitly deleted when the destructor + * is called. At the moment, these are the Visitors created for the + * default Args. + */ + std::list _visitorDeleteOnExitList; + + /** + * Object that handles all output for the CmdLine. + */ + CmdLineOutput* _output; + + /** + * Should CmdLine handle parsing exceptions internally? + */ + bool _handleExceptions; + + /** + * Throws an exception listing the missing args. + */ + void missingArgsException(); + + /** + * Checks whether a name/flag string matches entirely matches + * the Arg::blankChar. Used when multiple switches are combined + * into a single argument. + * \param s - The message to be used in the usage. + */ + bool _emptyCombined(const std::string& s); + + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Arg* ptr); + + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Visitor* ptr); + +private: + + /** + * Prevent accidental copying. + */ + CmdLine(const CmdLine& rhs); + CmdLine& operator=(const CmdLine& rhs); + + /** + * Encapsulates the code common to the constructors + * (which is all of it). + */ + void _constructor(); + + + /** + * Is set to true when a user sets the output object. We use this so + * that we don't delete objects that are created outside of this lib. + */ + bool _userSetOutput; + + /** + * Whether or not to automatically create help and version switches. + */ + bool _helpAndVersion; + + /** + * Whether or not to ignore unmatched args. + */ + bool _ignoreUnmatched; + + public: + + /** + * Command line constructor. Defines how the arguments will be + * parsed. + * \param message - The message to be used in the usage + * output. + * \param delimiter - The character that is used to separate + * the argument flag/name from the value. Defaults to ' ' (space). + * \param version - The version number to be used in the + * --version switch. + * \param helpAndVersion - Whether or not to create the Help and + * Version switches. Defaults to true. + */ + CmdLine(const std::string& message, + const char delimiter = ' ', + const std::string& version = "none", + bool helpAndVersion = true); + + /** + * Deletes any resources allocated by a CmdLine object. + */ + virtual ~CmdLine(); + + /** + * Adds an argument to the list of arguments to be parsed. + * \param a - Argument to be added. + */ + void add( Arg& a ); + + /** + * An alternative add. Functionally identical. + * \param a - Argument to be added. + */ + void add( Arg* a ); + + /** + * Add two Args that will be xor'd. If this method is used, add does + * not need to be called. + * \param a - Argument to be added and xor'd. + * \param b - Argument to be added and xor'd. + */ + void xorAdd( Arg& a, Arg& b ); + + /** + * Add a list of Args that will be xor'd. If this method is used, + * add does not need to be called. + * \param xors - List of Args to be added and xor'd. + */ + void xorAdd( const std::vector& xors ); + + /** + * Parses the command line. + * \param argc - Number of arguments. + * \param argv - Array of arguments. + */ + void parse(int argc, const char * const * argv); + + /** + * Parses the command line. + * \param args - A vector of strings representing the args. + * args[0] is still the program name. + */ + void parse(std::vector& args); + + /** + * + */ + CmdLineOutput* getOutput(); + + /** + * + */ + void setOutput(CmdLineOutput* co); + + /** + * + */ + std::string& getVersion(); + + /** + * + */ + std::string& getProgramName(); + + /** + * + */ + std::list& getArgList(); + + /** + * + */ + XorHandler& getXorHandler(); + + /** + * + */ + char getDelimiter(); + + /** + * + */ + std::string& getMessage(); + + /** + * + */ + bool hasHelpAndVersion(); + + /** + * Disables or enables CmdLine's internal parsing exception handling. + * + * @param state Should CmdLine handle parsing exceptions internally? + */ + void setExceptionHandling(const bool state); + + /** + * Returns the current state of the internal exception handling. + * + * @retval true Parsing exceptions are handled internally. + * @retval false Parsing exceptions are propagated to the caller. + */ + bool getExceptionHandling() const; + + /** + * Allows the CmdLine object to be reused. + */ + void reset(); + + /** + * Allows unmatched args to be ignored. By default false. + * + * @param ignore If true the cmdline will ignore any unmatched args + * and if false it will behave as normal. + */ + void ignoreUnmatched(const bool ignore); +}; + + +/////////////////////////////////////////////////////////////////////////////// +//Begin CmdLine.cpp +/////////////////////////////////////////////////////////////////////////////// + +inline CmdLine::CmdLine(const std::string& m, + char delim, + const std::string& v, + bool help ) + : + _argList(std::list()), + _progName("not_set_yet"), + _message(m), + _version(v), + _numRequired(0), + _delimiter(delim), + _xorHandler(XorHandler()), + _argDeleteOnExitList(std::list()), + _visitorDeleteOnExitList(std::list()), + _output(0), + _handleExceptions(true), + _userSetOutput(false), + _helpAndVersion(help), + _ignoreUnmatched(false) +{ + _constructor(); +} + +inline CmdLine::~CmdLine() +{ + ClearContainer(_argDeleteOnExitList); + ClearContainer(_visitorDeleteOnExitList); + + if ( !_userSetOutput ) { + delete _output; + _output = 0; + } +} + +inline void CmdLine::_constructor() +{ + _output = new StdOutput; + + Arg::setDelimiter( _delimiter ); + + Visitor* v; + + if ( _helpAndVersion ) + { + v = new HelpVisitor( this, &_output ); + SwitchArg* help = new SwitchArg("h","help", + "Displays usage information and exits.", + false, v); + add( help ); + deleteOnExit(help); + deleteOnExit(v); + + v = new VersionVisitor( this, &_output ); + SwitchArg* vers = new SwitchArg("","version", + "Displays version information and exits.", + false, v); + add( vers ); + deleteOnExit(vers); + deleteOnExit(v); + } + + v = new IgnoreRestVisitor(); + SwitchArg* ignore = new SwitchArg(Arg::flagStartString(), + Arg::ignoreNameString(), + "Ignores the rest of the labeled arguments following this flag.", + false, v); + add( ignore ); + deleteOnExit(ignore); + deleteOnExit(v); +} + +inline void CmdLine::xorAdd( const std::vector& ors ) +{ + _xorHandler.add( ors ); + + for (ArgVectorIterator it = ors.begin(); it != ors.end(); it++) + { + (*it)->forceRequired(); + (*it)->setRequireLabel( "OR required" ); + add( *it ); + } +} + +inline void CmdLine::xorAdd( Arg& a, Arg& b ) +{ + std::vector ors; + ors.push_back( &a ); + ors.push_back( &b ); + xorAdd( ors ); +} + +inline void CmdLine::add( Arg& a ) +{ + add( &a ); +} + +inline void CmdLine::add( Arg* a ) +{ + for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ ) + if ( *a == *(*it) ) + throw( SpecificationException( + "Argument with same flag/name already exists!", + a->longID() ) ); + + a->addToList( _argList ); + + if ( a->isRequired() ) + _numRequired++; +} + + +inline void CmdLine::parse(int argc, const char * const * argv) +{ + // this step is necessary so that we have easy access to + // mutable strings. + std::vector args; + for (int i = 0; i < argc; i++) + args.push_back(argv[i]); + + parse(args); +} + +inline void CmdLine::parse(std::vector& args) +{ + bool shouldExit = false; + int estat = 0; + try { + if (args.empty()) { + // https://sourceforge.net/p/tclap/bugs/30/ + throw CmdLineParseException("The args vector must not be empty, " + "the first entry should contain the " + "program's name."); + } + + _progName = args.front(); + args.erase(args.begin()); + + int requiredCount = 0; + + for (int i = 0; static_cast(i) < args.size(); i++) + { + bool matched = false; + for (ArgListIterator it = _argList.begin(); + it != _argList.end(); it++) { + if ( (*it)->processArg( &i, args ) ) + { + requiredCount += _xorHandler.check( *it ); + matched = true; + break; + } + } + + // checks to see if the argument is an empty combined + // switch and if so, then we've actually matched it + if ( !matched && _emptyCombined( args[i] ) ) + matched = true; + + if ( !matched && !Arg::ignoreRest() && !_ignoreUnmatched) + throw(CmdLineParseException("Couldn't find match " + "for argument", + args[i])); + } + + if ( requiredCount < _numRequired ) + missingArgsException(); + + if ( requiredCount > _numRequired ) + throw(CmdLineParseException("Too many arguments!")); + + } catch ( ArgException& e ) { + // If we're not handling the exceptions, rethrow. + if ( !_handleExceptions) { + throw; + } + + try { + _output->failure(*this,e); + } catch ( ExitException &ee ) { + estat = ee.getExitStatus(); + shouldExit = true; + } + } catch (ExitException &ee) { + // If we're not handling the exceptions, rethrow. + if ( !_handleExceptions) { + throw; + } + + estat = ee.getExitStatus(); + shouldExit = true; + } + + if (shouldExit) + exit(estat); +} + +inline bool CmdLine::_emptyCombined(const std::string& s) +{ + if ( s.length() > 0 && s[0] != Arg::flagStartChar() ) + return false; + + for ( int i = 1; static_cast(i) < s.length(); i++ ) + if ( s[i] != Arg::blankChar() ) + return false; + + return true; +} + +inline void CmdLine::missingArgsException() +{ + int count = 0; + + std::string missingArgList; + for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++) + { + if ( (*it)->isRequired() && !(*it)->isSet() ) + { + missingArgList += (*it)->getName(); + missingArgList += ", "; + count++; + } + } + missingArgList = missingArgList.substr(0,missingArgList.length()-2); + + std::string msg; + if ( count > 1 ) + msg = "Required arguments missing: "; + else + msg = "Required argument missing: "; + + msg += missingArgList; + + throw(CmdLineParseException(msg)); +} + +inline void CmdLine::deleteOnExit(Arg* ptr) +{ + _argDeleteOnExitList.push_back(ptr); +} + +inline void CmdLine::deleteOnExit(Visitor* ptr) +{ + _visitorDeleteOnExitList.push_back(ptr); +} + +inline CmdLineOutput* CmdLine::getOutput() +{ + return _output; +} + +inline void CmdLine::setOutput(CmdLineOutput* co) +{ + if ( !_userSetOutput ) + delete _output; + _userSetOutput = true; + _output = co; +} + +inline std::string& CmdLine::getVersion() +{ + return _version; +} + +inline std::string& CmdLine::getProgramName() +{ + return _progName; +} + +inline std::list& CmdLine::getArgList() +{ + return _argList; +} + +inline XorHandler& CmdLine::getXorHandler() +{ + return _xorHandler; +} + +inline char CmdLine::getDelimiter() +{ + return _delimiter; +} + +inline std::string& CmdLine::getMessage() +{ + return _message; +} + +inline bool CmdLine::hasHelpAndVersion() +{ + return _helpAndVersion; +} + +inline void CmdLine::setExceptionHandling(const bool state) +{ + _handleExceptions = state; +} + +inline bool CmdLine::getExceptionHandling() const +{ + return _handleExceptions; +} + +inline void CmdLine::reset() +{ + for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ ) + (*it)->reset(); + + _progName.clear(); +} + +inline void CmdLine::ignoreUnmatched(const bool ignore) +{ + _ignoreUnmatched = ignore; +} + +/////////////////////////////////////////////////////////////////////////////// +//End CmdLine.cpp +/////////////////////////////////////////////////////////////////////////////// + + + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/CmdLineInterface.h b/funasr/runtime/onnxruntime/include/tclap/CmdLineInterface.h new file mode 100644 index 000000000..a9bdca09b --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/CmdLineInterface.h @@ -0,0 +1,153 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: CmdLineInterface.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_COMMANDLINE_INTERFACE_H +#define TCLAP_COMMANDLINE_INTERFACE_H + +#include +#include +#include +#include +#include + + +namespace TCLAP { + +class Arg; +class CmdLineOutput; +class XorHandler; + +/** + * The base class that manages the command line definition and passes + * along the parsing to the appropriate Arg classes. + */ +class CmdLineInterface +{ + public: + + /** + * Destructor + */ + virtual ~CmdLineInterface() {} + + /** + * Adds an argument to the list of arguments to be parsed. + * \param a - Argument to be added. + */ + virtual void add( Arg& a )=0; + + /** + * An alternative add. Functionally identical. + * \param a - Argument to be added. + */ + virtual void add( Arg* a )=0; + + /** + * Add two Args that will be xor'd. + * If this method is used, add does + * not need to be called. + * \param a - Argument to be added and xor'd. + * \param b - Argument to be added and xor'd. + */ + virtual void xorAdd( Arg& a, Arg& b )=0; + + /** + * Add a list of Args that will be xor'd. If this method is used, + * add does not need to be called. + * \param xors - List of Args to be added and xor'd. + */ + virtual void xorAdd( const std::vector& xors )=0; + + /** + * Parses the command line. + * \param argc - Number of arguments. + * \param argv - Array of arguments. + */ + virtual void parse(int argc, const char * const * argv)=0; + + /** + * Parses the command line. + * \param args - A vector of strings representing the args. + * args[0] is still the program name. + */ + void parse(std::vector& args); + + /** + * Returns the CmdLineOutput object. + */ + virtual CmdLineOutput* getOutput()=0; + + /** + * \param co - CmdLineOutput object that we want to use instead. + */ + virtual void setOutput(CmdLineOutput* co)=0; + + /** + * Returns the version string. + */ + virtual std::string& getVersion()=0; + + /** + * Returns the program name string. + */ + virtual std::string& getProgramName()=0; + + /** + * Returns the argList. + */ + virtual std::list& getArgList()=0; + + /** + * Returns the XorHandler. + */ + virtual XorHandler& getXorHandler()=0; + + /** + * Returns the delimiter string. + */ + virtual char getDelimiter()=0; + + /** + * Returns the message string. + */ + virtual std::string& getMessage()=0; + + /** + * Indicates whether or not the help and version switches were created + * automatically. + */ + virtual bool hasHelpAndVersion()=0; + + /** + * Resets the instance as if it had just been constructed so that the + * instance can be reused. + */ + virtual void reset()=0; +}; + +} //namespace + + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/CmdLineOutput.h b/funasr/runtime/onnxruntime/include/tclap/CmdLineOutput.h new file mode 100644 index 000000000..cbc9a327a --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/CmdLineOutput.h @@ -0,0 +1,77 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + + +/****************************************************************************** + * + * file: CmdLineOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CMDLINEOUTPUT_H +#define TCLAP_CMDLINEOUTPUT_H + +#include +#include +#include +#include +#include +#include + +namespace TCLAP { + +class CmdLineInterface; +class ArgException; + +/** + * The interface that any output object must implement. + */ +class CmdLineOutput +{ + + public: + + /** + * Virtual destructor. + */ + virtual ~CmdLineOutput() {} + + /** + * Generates some sort of output for the USAGE. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c)=0; + + /** + * Generates some sort of output for the version. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c)=0; + + /** + * Generates some sort of output for a failure. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure( CmdLineInterface& c, + ArgException& e )=0; + +}; + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/Constraint.h b/funasr/runtime/onnxruntime/include/tclap/Constraint.h new file mode 100644 index 000000000..ff869cc78 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/Constraint.h @@ -0,0 +1,78 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: Constraint.h + * + * Copyright (c) 2005, Michael E. Smoot + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CONSTRAINT_H +#define TCLAP_CONSTRAINT_H + +#include +#include +#include +#include +#include +#include +#include + +namespace TCLAP { + +/** + * The interface that defines the interaction between the Arg and Constraint. + */ +template +class Constraint +{ + + public: + /** + * Returns a description of the Constraint. + */ + virtual std::string description() const =0; + + /** + * Returns the short ID for the Constraint. + */ + virtual std::string shortID() const =0; + + /** + * The method used to verify that the value parsed from the command + * line meets the constraint. + * \param value - The value that will be checked. + */ + virtual bool check(const T& value) const =0; + + /** + * Destructor. + * Silences warnings about Constraint being a base class with virtual + * functions but without a virtual destructor. + */ + virtual ~Constraint() { ; } + + static std::string shortID(Constraint *constraint) { + if (!constraint) + throw std::logic_error("Cannot create a ValueArg with a NULL constraint"); + return constraint->shortID(); + } +}; + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/DocBookOutput.h b/funasr/runtime/onnxruntime/include/tclap/DocBookOutput.h new file mode 100644 index 000000000..80b10e522 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/DocBookOutput.h @@ -0,0 +1,303 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: DocBookOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_DOCBOOKOUTPUT_H +#define TCLAP_DOCBOOKOUTPUT_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace TCLAP { + +/** + * A class that generates DocBook output for usage() method for the + * given CmdLine and its Args. + */ +class DocBookOutput : public CmdLineOutput +{ + + public: + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + DocBookOutput() : theDelimiter('=') {} + protected: + + /** + * Substitutes the char r for string x in string s. + * \param s - The string to operate on. + * \param r - The char to replace. + * \param x - What to replace r with. + */ + void substituteSpecialChars( std::string& s, char r, std::string& x ); + void removeChar( std::string& s, char r); + void basename( std::string& s ); + + void printShortArg(Arg* it); + void printLongArg(Arg* it); + + char theDelimiter; +}; + + +inline void DocBookOutput::version(CmdLineInterface& _cmd) +{ + std::cout << _cmd.getVersion() << std::endl; +} + +inline void DocBookOutput::usage(CmdLineInterface& _cmd ) +{ + std::list argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + std::string xversion = _cmd.getVersion(); + theDelimiter = _cmd.getDelimiter(); + XorHandler xorHandler = _cmd.getXorHandler(); + const std::vector< std::vector > xorList = xorHandler.getXorList(); + basename(progName); + + std::cout << "" << std::endl; + std::cout << "" << std::endl << std::endl; + + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "" << progName << "" << std::endl; + std::cout << "1" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "" << progName << "" << std::endl; + std::cout << "" << _cmd.getMessage() << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << progName << "" << std::endl; + + // xor + for ( int i = 0; (unsigned int)i < xorList.size(); i++ ) + { + std::cout << "" << std::endl; + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); it++ ) + printShortArg((*it)); + + std::cout << "" << std::endl; + } + + // rest of args + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + printShortArg((*it)); + + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "Description" << std::endl; + std::cout << "" << std::endl; + std::cout << _cmd.getMessage() << std::endl; + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "Options" << std::endl; + + std::cout << "" << std::endl; + + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + printLongArg((*it)); + + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "Version" << std::endl; + std::cout << "" << std::endl; + std::cout << xversion << std::endl; + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + +} + +inline void DocBookOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + static_cast(_cmd); // unused + std::cout << e.what() << std::endl; + throw ExitException(1); +} + +inline void DocBookOutput::substituteSpecialChars( std::string& s, + char r, + std::string& x ) +{ + size_t p; + while ( (p = s.find_first_of(r)) != std::string::npos ) + { + s.erase(p,1); + s.insert(p,x); + } +} + +inline void DocBookOutput::removeChar( std::string& s, char r) +{ + size_t p; + while ( (p = s.find_first_of(r)) != std::string::npos ) + { + s.erase(p,1); + } +} + +inline void DocBookOutput::basename( std::string& s ) +{ + size_t p = s.find_last_of('/'); + if ( p != std::string::npos ) + { + s.erase(0, p + 1); + } +} + +inline void DocBookOutput::printShortArg(Arg* a) +{ + std::string lt = "<"; + std::string gt = ">"; + + std::string id = a->shortID(); + substituteSpecialChars(id,'<',lt); + substituteSpecialChars(id,'>',gt); + removeChar(id,'['); + removeChar(id,']'); + + std::string choice = "opt"; + if ( a->isRequired() ) + choice = "plain"; + + std::cout << "acceptsMultipleValues() ) + std::cout << " rep='repeat'"; + + + std::cout << '>'; + if ( !a->getFlag().empty() ) + std::cout << a->flagStartChar() << a->getFlag(); + else + std::cout << a->nameStartString() << a->getName(); + if ( a->isValueRequired() ) + { + std::string arg = a->shortID(); + removeChar(arg,'['); + removeChar(arg,']'); + removeChar(arg,'<'); + removeChar(arg,'>'); + removeChar(arg,'.'); + arg.erase(0, arg.find_last_of(theDelimiter) + 1); + std::cout << theDelimiter; + std::cout << "" << arg << ""; + } + std::cout << "" << std::endl; + +} + +inline void DocBookOutput::printLongArg(Arg* a) +{ + std::string lt = "<"; + std::string gt = ">"; + + std::string desc = a->getDescription(); + substituteSpecialChars(desc,'<',lt); + substituteSpecialChars(desc,'>',gt); + + std::cout << "" << std::endl; + + if ( !a->getFlag().empty() ) + { + std::cout << "" << std::endl; + std::cout << "" << std::endl; + std::cout << "" << std::endl; + } + + std::cout << "" << std::endl; + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; + std::cout << "" << std::endl; + std::cout << desc << std::endl; + std::cout << "" << std::endl; + std::cout << "" << std::endl; + + std::cout << "" << std::endl; +} + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/HelpVisitor.h b/funasr/runtime/onnxruntime/include/tclap/HelpVisitor.h new file mode 100644 index 000000000..5ee3756fa --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/HelpVisitor.h @@ -0,0 +1,78 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: HelpVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_HELP_VISITOR_H +#define TCLAP_HELP_VISITOR_H + +#include +#include +#include + +namespace TCLAP { + +/** + * A Visitor object that calls the usage method of the given CmdLineOutput + * object for the specified CmdLine object. + */ +class HelpVisitor: public Visitor +{ + private: + /** + * Prevent accidental copying. + */ + HelpVisitor(const HelpVisitor& rhs); + HelpVisitor& operator=(const HelpVisitor& rhs); + + protected: + + /** + * The CmdLine the output will be generated for. + */ + CmdLineInterface* _cmd; + + /** + * The output object. + */ + CmdLineOutput** _out; + + public: + + /** + * Constructor. + * \param cmd - The CmdLine the output will be generated for. + * \param out - The type of output. + */ + HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) + : Visitor(), _cmd( cmd ), _out( out ) { } + + /** + * Calls the usage method of the CmdLineOutput for the + * specified CmdLine. + */ + void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } + +}; + +} + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/IgnoreRestVisitor.h b/funasr/runtime/onnxruntime/include/tclap/IgnoreRestVisitor.h new file mode 100644 index 000000000..1824c3c4b --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/IgnoreRestVisitor.h @@ -0,0 +1,54 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: IgnoreRestVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_IGNORE_REST_VISITOR_H +#define TCLAP_IGNORE_REST_VISITOR_H + +#include +#include + +namespace TCLAP { + +/** + * A Visitor that tells the CmdLine to begin ignoring arguments after + * this one is parsed. + */ +class IgnoreRestVisitor: public Visitor +{ + public: + + /** + * Constructor. + */ + IgnoreRestVisitor() : Visitor() {} + + /** + * Sets Arg::_ignoreRest. + */ + void visit() { Arg::beginIgnoring(); } +}; + +} + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/MultiArg.h b/funasr/runtime/onnxruntime/include/tclap/MultiArg.h new file mode 100644 index 000000000..e0df8b957 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/MultiArg.h @@ -0,0 +1,433 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: MultiArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_MULTIPLE_ARGUMENT_H +#define TCLAP_MULTIPLE_ARGUMENT_H + +#include +#include + +#include +#include + +namespace TCLAP { +/** + * An argument that allows multiple values of type T to be specified. Very + * similar to a ValueArg, except a vector of values will be returned + * instead of just one. + */ +template +class MultiArg : public Arg +{ +public: + typedef std::vector container_type; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + +protected: + + /** + * The list of values parsed from the CmdLine. + */ + std::vector _values; + + /** + * The description of type T to be used in the usage. + */ + std::string _typeDesc; + + /** + * A list of constraint on this Arg. + */ + Constraint* _constraint; + + /** + * Extracts the value from the string. + * Attempts to parse string as type T, if this fails an exception + * is thrown. + * \param val - The string to be read. + */ + void _extractValue( const std::string& val ); + + /** + * Used by XorHandler to decide whether to keep parsing for this arg. + */ + bool _allowMore; + +public: + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + Visitor* v = NULL); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + Visitor* v = NULL ); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed from main(). + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Returns a vector of type T containing the values parsed from + * the command line. + */ + const std::vector& getValue() const { return _values; } + + /** + * Returns an iterator over the values parsed from the command + * line. + */ + const_iterator begin() const { return _values.begin(); } + + /** + * Returns the end of the values parsed from the command + * line. + */ + const_iterator end() const { return _values.end(); } + + /** + * Returns the a short id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Returns the a long id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Once we've matched the first value, then the arg is no longer + * required. + */ + virtual bool isRequired() const; + + virtual bool allowMore(); + + virtual void reset(); + +private: + /** + * Prevent accidental copying + */ + MultiArg(const MultiArg& rhs); + MultiArg& operator=(const MultiArg& rhs); + +}; + +template +MultiArg::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + Visitor* v) : + Arg( flag, name, desc, req, true, v ), + _values(std::vector()), + _typeDesc( typeDesc ), + _constraint( NULL ), + _allowMore(false) +{ + _acceptsMultipleValues = true; +} + +template +MultiArg::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _values(std::vector()), + _typeDesc( typeDesc ), + _constraint( NULL ), + _allowMore(false) +{ + parser.add( this ); + _acceptsMultipleValues = true; +} + +/** + * + */ +template +MultiArg::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _values(std::vector()), + _typeDesc( Constraint::shortID(constraint) ), + _constraint( constraint ), + _allowMore(false) +{ + _acceptsMultipleValues = true; +} + +template +MultiArg::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + CmdLineInterface& parser, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _values(std::vector()), + _typeDesc( Constraint::shortID(constraint) ), + _constraint( constraint ), + _allowMore(false) +{ + parser.add( this ); + _acceptsMultipleValues = true; +} + +template +bool MultiArg::processArg(int *i, std::vector& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + std::string flag = args[*i]; + std::string value = ""; + + trimFlag( flag, value ); + + if ( argMatches( flag ) ) + { + if ( Arg::delimiter() != ' ' && value == "" ) + throw( ArgParseException( + "Couldn't find delimiter for this argument!", + toString() ) ); + + // always take the first one, regardless of start string + if ( value == "" ) + { + (*i)++; + if ( static_cast(*i) < args.size() ) + _extractValue( args[*i] ); + else + throw( ArgParseException("Missing a value for this argument!", + toString() ) ); + } + else + _extractValue( value ); + + /* + // continuing taking the args until we hit one with a start string + while ( (unsigned int)(*i)+1 < args.size() && + args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && + args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) + _extractValue( args[++(*i)] ); + */ + + _alreadySet = true; + _checkWithVisitor(); + + return true; + } + else + return false; +} + +/** + * + */ +template +std::string MultiArg::shortID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return Arg::shortID(_typeDesc) + " ..."; +} + +/** + * + */ +template +std::string MultiArg::longID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return Arg::longID(_typeDesc) + " (accepted multiple times)"; +} + +/** + * Once we've matched the first value, then the arg is no longer + * required. + */ +template +bool MultiArg::isRequired() const +{ + if ( _required ) + { + if ( _values.size() > 1 ) + return false; + else + return true; + } + else + return false; + +} + +template +void MultiArg::_extractValue( const std::string& val ) +{ + try { + T tmp; + ExtractValue(tmp, val, typename ArgTraits::ValueCategory()); + _values.push_back(tmp); + } catch( ArgParseException &e) { + throw ArgParseException(e.error(), toString()); + } + + if ( _constraint != NULL ) + if ( ! _constraint->check( _values.back() ) ) + throw( CmdLineParseException( "Value '" + val + + "' does not meet constraint: " + + _constraint->description(), + toString() ) ); +} + +template +bool MultiArg::allowMore() +{ + bool am = _allowMore; + _allowMore = true; + return am; +} + +template +void MultiArg::reset() +{ + Arg::reset(); + _values.clear(); +} + +} // namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/MultiSwitchArg.h b/funasr/runtime/onnxruntime/include/tclap/MultiSwitchArg.h new file mode 100644 index 000000000..e333ea7b1 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/MultiSwitchArg.h @@ -0,0 +1,217 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** +* +* file: MultiSwitchArg.h +* +* Copyright (c) 2003, Michael E. Smoot . +* Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. +* Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek. +* Copyright (c) 2017, Google LLC +* All rights reserved. +* +* See the file COPYING in the top directory of this distribution for +* more information. +* +* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ + + +#ifndef TCLAP_MULTI_SWITCH_ARG_H +#define TCLAP_MULTI_SWITCH_ARG_H + +#include +#include + +#include + +namespace TCLAP { + +/** +* A multiple switch argument. If the switch is set on the command line, then +* the getValue method will return the number of times the switch appears. +*/ +class MultiSwitchArg : public SwitchArg +{ + protected: + + /** + * The value of the switch. + */ + int _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + int _default; + + public: + + /** + * MultiSwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param init - Optional. The initial/default value of this Arg. + * Defaults to 0. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + int init = 0, + Visitor* v = NULL); + + + /** + * MultiSwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param parser - A CmdLine parser object to add this Arg to + * \param init - Optional. The initial/default value of this Arg. + * Defaults to 0. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + int init = 0, + Visitor* v = NULL); + + + /** + * Handles the processing of the argument. + * This re-implements the SwitchArg version of this method to set the + * _value of the argument appropriately. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Returns int, the number of times the switch has been set. + */ + int getValue() const { return _value; } + + /** + * Returns the shortID for this Arg. + */ + std::string shortID(const std::string& val) const; + + /** + * Returns the longID for this Arg. + */ + std::string longID(const std::string& val) const; + + void reset(); + +}; + +////////////////////////////////////////////////////////////////////// +//BEGIN MultiSwitchArg.cpp +////////////////////////////////////////////////////////////////////// +inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + int init, + Visitor* v ) +: SwitchArg(flag, name, desc, false, v), +_value( init ), +_default( init ) +{ } + +inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + int init, + Visitor* v ) +: SwitchArg(flag, name, desc, false, v), +_value( init ), +_default( init ) +{ + parser.add( this ); +} + +inline bool MultiSwitchArg::processArg(int *i, std::vector& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( argMatches( args[*i] )) + { + // so the isSet() method will work + _alreadySet = true; + + // Matched argument: increment value. + ++_value; + + _checkWithVisitor(); + + return true; + } + else if ( combinedSwitchesMatch( args[*i] ) ) + { + // so the isSet() method will work + _alreadySet = true; + + // Matched argument: increment value. + ++_value; + + // Check for more in argument and increment value. + while ( combinedSwitchesMatch( args[*i] ) ) + ++_value; + + _checkWithVisitor(); + + return false; + } + else + return false; +} + +inline std::string +MultiSwitchArg::shortID(const std::string& val) const +{ + return Arg::shortID(val) + " ..."; +} + +inline std::string +MultiSwitchArg::longID(const std::string& val) const +{ + return Arg::longID(val) + " (accepted multiple times)"; +} + +inline void +MultiSwitchArg::reset() +{ + MultiSwitchArg::_value = MultiSwitchArg::_default; +} + +////////////////////////////////////////////////////////////////////// +//END MultiSwitchArg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/OptionalUnlabeledTracker.h b/funasr/runtime/onnxruntime/include/tclap/OptionalUnlabeledTracker.h new file mode 100644 index 000000000..aa64116dc --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/OptionalUnlabeledTracker.h @@ -0,0 +1,64 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + + +/****************************************************************************** + * + * file: OptionalUnlabeledTracker.h + * + * Copyright (c) 2005, Michael E. Smoot . + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H +#define TCLAP_OPTIONAL_UNLABELED_TRACKER_H + +#include + +namespace TCLAP { + +class OptionalUnlabeledTracker +{ + + public: + + static void check( bool req, const std::string& argName ); + + static void gotOptional() { alreadyOptionalRef() = true; } + + static bool& alreadyOptional() { return alreadyOptionalRef(); } + + private: + + static bool& alreadyOptionalRef() { static bool ct = false; return ct; } +}; + + +inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) +{ + if ( OptionalUnlabeledTracker::alreadyOptional() ) + throw( SpecificationException( + "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", + argName ) ); + + if ( !req ) + OptionalUnlabeledTracker::gotOptional(); +} + + +} // namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/StandardTraits.h b/funasr/runtime/onnxruntime/include/tclap/StandardTraits.h new file mode 100644 index 000000000..5864f7787 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/StandardTraits.h @@ -0,0 +1,63 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: StandardTraits.h + * + * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +// This is an internal tclap file, you should probably not have to +// include this directly + +#ifndef TCLAP_STANDARD_TRAITS_H +#define TCLAP_STANDARD_TRAITS_H + +#ifdef HAVE_CONFIG_H +#include // To check for long long +#endif + +// If Microsoft has already typedef'd wchar_t as an unsigned +// short, then compiles will break because it's as if we're +// creating ArgTraits twice for unsigned short. Thus... +#ifdef _MSC_VER +#ifndef _NATIVE_WCHAR_T_DEFINED +#define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS +#endif +#endif + +namespace TCLAP { + +// Integer types (signed, unsigned and bool) and floating point types all +// have value-like semantics. + +// Strings have string like argument traits. +template<> +struct ArgTraits { + typedef StringLike ValueCategory; +}; + +template +void SetString(T &dst, const std::string &src) +{ + dst = src; +} + +} // namespace + +#endif + diff --git a/funasr/runtime/onnxruntime/include/tclap/StdOutput.h b/funasr/runtime/onnxruntime/include/tclap/StdOutput.h new file mode 100644 index 000000000..cfef79a14 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/StdOutput.h @@ -0,0 +1,300 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: StdOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_STDCMDLINEOUTPUT_H +#define TCLAP_STDCMDLINEOUTPUT_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace TCLAP { + +/** + * A class that isolates any output from the CmdLine object so that it + * may be easily modified. + */ +class StdOutput : public CmdLineOutput +{ + + public: + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + protected: + + /** + * Writes a brief usage message with short args. + * \param c - The CmdLine object the output is generated for. + * \param os - The stream to write the message to. + */ + void _shortUsage( CmdLineInterface& c, std::ostream& os ) const; + + /** + * Writes a longer usage message with long and short args, + * provides descriptions and prints message. + * \param c - The CmdLine object the output is generated for. + * \param os - The stream to write the message to. + */ + void _longUsage( CmdLineInterface& c, std::ostream& os ) const; + + /** + * This function inserts line breaks and indents long strings + * according the params input. It will only break lines at spaces, + * commas and pipes. + * \param os - The stream to be printed to. + * \param s - The string to be printed. + * \param maxWidth - The maxWidth allowed for the output line. + * \param indentSpaces - The number of spaces to indent the first line. + * \param secondLineOffset - The number of spaces to indent the second + * and all subsequent lines in addition to indentSpaces. + */ + void spacePrint( std::ostream& os, + const std::string& s, + int maxWidth, + int indentSpaces, + int secondLineOffset ) const; + +}; + + +inline void StdOutput::version(CmdLineInterface& _cmd) +{ + std::string progName = _cmd.getProgramName(); + std::string xversion = _cmd.getVersion(); + + std::cout << std::endl << progName << " version: " + << xversion << std::endl << std::endl; +} + +inline void StdOutput::usage(CmdLineInterface& _cmd ) +{ + std::cout << std::endl << "USAGE: " << std::endl << std::endl; + + _shortUsage( _cmd, std::cout ); + + std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; + + _longUsage( _cmd, std::cout ); + + std::cout << std::endl; + +} + +inline void StdOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + std::string progName = _cmd.getProgramName(); + + std::cerr << "PARSE ERROR: " << e.argId() << std::endl + << " " << e.error() << std::endl << std::endl; + + if ( _cmd.hasHelpAndVersion() ) + { + std::cerr << "Brief USAGE: " << std::endl; + + _shortUsage( _cmd, std::cerr ); + + std::cerr << std::endl << "For complete USAGE and HELP type: " + << std::endl << " " << progName << " " + << Arg::nameStartString() << "help" + << std::endl << std::endl; + } + else + usage(_cmd); + + throw ExitException(1); +} + +inline void +StdOutput::_shortUsage( CmdLineInterface& _cmd, + std::ostream& os ) const +{ + std::list argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector > xorList = xorHandler.getXorList(); + + std::string s = progName + " "; + + // first the xor + for ( int i = 0; static_cast(i) < xorList.size(); i++ ) + { + s += " {"; + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); it++ ) + s += (*it)->shortID() + "|"; + + s[s.length()-1] = '}'; + } + + // then the rest + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + s += " " + (*it)->shortID(); + + // if the program name is too long, then adjust the second line offset + int secondLineOffset = static_cast(progName.length()) + 2; + if ( secondLineOffset > 75/2 ) + secondLineOffset = static_cast(75/2); + + spacePrint( os, s, 75, 3, secondLineOffset ); +} + +inline void +StdOutput::_longUsage( CmdLineInterface& _cmd, + std::ostream& os ) const +{ + std::list argList = _cmd.getArgList(); + std::string message = _cmd.getMessage(); + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector > xorList = xorHandler.getXorList(); + + // first the xor + for ( int i = 0; static_cast(i) < xorList.size(); i++ ) + { + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++ ) + { + spacePrint( os, (*it)->longID(), 75, 3, 3 ); + spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); + + if ( it+1 != xorList[i].end() ) + spacePrint(os, "-- OR --", 75, 9, 0); + } + os << std::endl << std::endl; + } + + // then the rest + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + { + spacePrint( os, (*it)->longID(), 75, 3, 3 ); + spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); + os << std::endl; + } + + os << std::endl; + + spacePrint( os, message, 75, 3, 0 ); +} + +inline void StdOutput::spacePrint( std::ostream& os, + const std::string& s, + int maxWidth, + int indentSpaces, + int secondLineOffset ) const +{ + int len = static_cast(s.length()); + + if ( (len + indentSpaces > maxWidth) && maxWidth > 0 ) + { + int allowedLen = maxWidth - indentSpaces; + int start = 0; + while ( start < len ) + { + // find the substring length + // int stringLen = std::min( len - start, allowedLen ); + // doing it this way to support a VisualC++ 2005 bug + using namespace std; + int stringLen = min( len - start, allowedLen ); + + // trim the length so it doesn't end in middle of a word + if ( stringLen == allowedLen ) + while ( stringLen >= 0 && + s[stringLen+start] != ' ' && + s[stringLen+start] != ',' && + s[stringLen+start] != '|' ) + stringLen--; + + // ok, the word is longer than the line, so just split + // wherever the line ends + if ( stringLen <= 0 ) + stringLen = allowedLen; + + // check for newlines + for ( int i = 0; i < stringLen; i++ ) + if ( s[start+i] == '\n' ) + stringLen = i+1; + + // print the indent + for ( int i = 0; i < indentSpaces; i++ ) + os << " "; + + if ( start == 0 ) + { + // handle second line offsets + indentSpaces += secondLineOffset; + + // adjust allowed len + allowedLen -= secondLineOffset; + } + + os << s.substr(start,stringLen) << std::endl; + + // so we don't start a line with a space + while ( s[stringLen+start] == ' ' && start < len ) + start++; + + start += stringLen; + } + } + else + { + for ( int i = 0; i < indentSpaces; i++ ) + os << " "; + os << s << std::endl; + } +} + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/SwitchArg.h b/funasr/runtime/onnxruntime/include/tclap/SwitchArg.h new file mode 100644 index 000000000..4ca130da4 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/SwitchArg.h @@ -0,0 +1,273 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: SwitchArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_SWITCH_ARG_H +#define TCLAP_SWITCH_ARG_H + +#include +#include + +#include + +namespace TCLAP { + +/** + * A simple switch argument. If the switch is set on the command line, then + * the getValue method will return the opposite of the default value for the + * switch. + */ +class SwitchArg : public Arg +{ +protected: + + /** + * The value of the switch. + */ + bool _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + bool _default; + +public: + + /** + * SwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param def - The default value for this Switch. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool def = false, + Visitor* v = NULL); + + + /** + * SwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param parser - A CmdLine parser object to add this Arg to + * \param def - The default value for this Switch. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + bool def = false, + Visitor* v = NULL); + + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Checks a string to see if any of the chars in the string + * match the flag for this Switch. + */ + bool combinedSwitchesMatch(std::string& combined); + + /** + * Returns bool, whether or not the switch has been set. + */ + bool getValue() const { return _value; } + + /** + * A SwitchArg can be used as a boolean, indicating + * whether or not the switch has been set. This is the + * same as calling getValue() + */ + operator bool() const { return _value; } + + virtual void reset(); + +private: + /** + * Checks to see if we've found the last match in + * a combined string. + */ + bool lastCombined(std::string& combined); + + /** + * Does the common processing of processArg. + */ + void commonProcessing(); +}; + +////////////////////////////////////////////////////////////////////// +//BEGIN SwitchArg.cpp +////////////////////////////////////////////////////////////////////// +inline SwitchArg::SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool default_val, + Visitor* v ) + : Arg(flag, name, desc, false, false, v), + _value( default_val ), + _default( default_val ) +{ } + +inline SwitchArg::SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + bool default_val, + Visitor* v ) + : Arg(flag, name, desc, false, false, v), + _value( default_val ), + _default(default_val) +{ + parser.add( this ); +} + +inline bool SwitchArg::lastCombined(std::string& combinedSwitches ) +{ + for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) + if ( combinedSwitches[i] != Arg::blankChar() ) + return false; + + return true; +} + +inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) +{ + // make sure this is actually a combined switch + if ( combinedSwitches.length() > 0 && + combinedSwitches[0] != Arg::flagStartString()[0] ) + return false; + + // make sure it isn't a long name + if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) == + Arg::nameStartString() ) + return false; + + // make sure the delimiter isn't in the string + if ( combinedSwitches.find_first_of(Arg::delimiter()) != std::string::npos) + return false; + + // ok, we're not specifying a ValueArg, so we know that we have + // a combined switch list. + for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) + if ( _flag.length() > 0 && + combinedSwitches[i] == _flag[0] && + _flag[0] != Arg::flagStartString()[0] ) + { + // update the combined switches so this one is no longer present + // this is necessary so that no unlabeled args are matched + // later in the processing. + //combinedSwitches.erase(i,1); + combinedSwitches[i] = Arg::blankChar(); + return true; + } + + // none of the switches passed in the list match. + return false; +} + +inline void SwitchArg::commonProcessing() +{ + if ( _xorSet ) + throw(CmdLineParseException( + "Mutually exclusive argument already set!", toString())); + + if ( _alreadySet ) + throw(CmdLineParseException("Argument already set!", toString())); + + _alreadySet = true; + + if ( _value == true ) + _value = false; + else + _value = true; + + _checkWithVisitor(); +} + +inline bool SwitchArg::processArg(int *i, std::vector& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + // if the whole string matches the flag or name string + if ( argMatches( args[*i] ) ) + { + commonProcessing(); + + return true; + } + // if a substring matches the flag as part of a combination + else if ( combinedSwitchesMatch( args[*i] ) ) + { + // check again to ensure we don't misinterpret + // this as a MultiSwitchArg + if ( combinedSwitchesMatch( args[*i] ) ) + throw(CmdLineParseException("Argument already set!", + toString())); + + commonProcessing(); + + // We only want to return true if we've found the last combined + // match in the string, otherwise we return true so that other + // switches in the combination will have a chance to match. + return lastCombined( args[*i] ); + } + else + return false; +} + +inline void SwitchArg::reset() +{ + Arg::reset(); + _value = _default; +} +////////////////////////////////////////////////////////////////////// +//End SwitchArg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/UnlabeledMultiArg.h b/funasr/runtime/onnxruntime/include/tclap/UnlabeledMultiArg.h new file mode 100644 index 000000000..48feb84ed --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/UnlabeledMultiArg.h @@ -0,0 +1,304 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: UnlabeledMultiArg.h + * + * Copyright (c) 2003, Michael E. Smoot. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H +#define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H + +#include +#include + +#include +#include + +namespace TCLAP { + +/** + * Just like a MultiArg, except that the arguments are unlabeled. Basically, + * this Arg will slurp up everything that hasn't been matched to another + * Arg. + */ +template +class UnlabeledMultiArg : public MultiArg +{ + + // If compiler has two stage name lookup (as gcc >= 3.4 does) + // this is required to prevent undef. symbols + using MultiArg::_ignoreable; + using MultiArg::_hasBlanks; + using MultiArg::_extractValue; + using MultiArg::_typeDesc; + using MultiArg::_name; + using MultiArg::_description; + using MultiArg::_alreadySet; + using MultiArg::toString; + + public: + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + bool ignoreable = false, + Visitor* v = NULL ); + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed from main(). + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Returns the a short id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Returns the a long id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Operator ==. + * \param a - The Arg to be compared to this. + */ + virtual bool operator==(const Arg& a) const; + + /** + * Pushes this to back of list rather than front. + * \param argList - The list this should be added to. + */ + virtual void addToList( std::list& argList ) const; +}; + +template +UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + bool ignoreable, + Visitor* v) +: MultiArg("", name, desc, req, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); +} + +template +UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: MultiArg("", name, desc, req, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); + parser.add( this ); +} + + +template +UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + bool ignoreable, + Visitor* v) +: MultiArg("", name, desc, req, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); +} + +template +UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + Constraint* constraint, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: MultiArg("", name, desc, req, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); + parser.add( this ); +} + + +template +bool UnlabeledMultiArg::processArg(int *i, std::vector& args) +{ + + if ( _hasBlanks( args[*i] ) ) + return false; + + // never ignore an unlabeled multi arg + + + // always take the first value, regardless of the start string + _extractValue( args[(*i)] ); + + /* + // continue taking args until we hit the end or a start string + while ( (unsigned int)(*i)+1 < args.size() && + args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && + args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) + _extractValue( args[++(*i)] ); + */ + + _alreadySet = true; + + return true; +} + +template +std::string UnlabeledMultiArg::shortID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + "> ..."; +} + +template +std::string UnlabeledMultiArg::longID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + "> (accepted multiple times)"; +} + +template +bool UnlabeledMultiArg::operator==(const Arg& a) const +{ + if ( _name == a.getName() || _description == a.getDescription() ) + return true; + else + return false; +} + +template +void UnlabeledMultiArg::addToList( std::list& argList ) const +{ + argList.push_back( const_cast(static_cast(this)) ); +} + +} + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/UnlabeledValueArg.h b/funasr/runtime/onnxruntime/include/tclap/UnlabeledValueArg.h new file mode 100644 index 000000000..341a3c062 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/UnlabeledValueArg.h @@ -0,0 +1,343 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: UnlabeledValueArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H +#define TCLAP_UNLABELED_VALUE_ARGUMENT_H + +#include +#include + +#include +#include + + +namespace TCLAP { + +/** + * The basic unlabeled argument that parses a value. + * This is a template class, which means the type T defines the type + * that a given object will attempt to parse when an UnlabeledValueArg + * is reached in the list of args that the CmdLine iterates over. + */ +template +class UnlabeledValueArg : public ValueArg +{ + + // If compiler has two stage name lookup (as gcc >= 3.4 does) + // this is required to prevent undef. symbols + using ValueArg::_ignoreable; + using ValueArg::_hasBlanks; + using ValueArg::_extractValue; + using ValueArg::_typeDesc; + using ValueArg::_name; + using ValueArg::_description; + using ValueArg::_alreadySet; + using ValueArg::toString; + + public: + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Visitor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + bool ignoreable = false, + Visitor* v = NULL); + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Visitor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Visitor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint* constraint, + bool ignoreable = false, + Visitor* v = NULL ); + + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Visitor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint* constraint, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. Handling specific to + * unlabeled arguments. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Overrides shortID for specific behavior. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Overrides longID for specific behavior. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Overrides operator== for specific behavior. + */ + virtual bool operator==(const Arg& a ) const; + + /** + * Instead of pushing to the front of list, push to the back. + * \param argList - The list to add this to. + */ + virtual void addToList( std::list& argList ) const; + +}; + +/** + * Constructor implementation. + */ +template +UnlabeledValueArg::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + bool ignoreable, + Visitor* v) +: ValueArg("", name, desc, req, val, typeDesc, v) +{ + _ignoreable = ignoreable; + + OptionalUnlabeledTracker::check(req, toString()); + +} + +template +UnlabeledValueArg::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: ValueArg("", name, desc, req, val, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); + parser.add( this ); +} + +/** + * Constructor implementation. + */ +template +UnlabeledValueArg::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint* constraint, + bool ignoreable, + Visitor* v) +: ValueArg("", name, desc, req, val, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); +} + +template +UnlabeledValueArg::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint* constraint, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: ValueArg("", name, desc, req, val, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); + parser.add( this ); +} + +/** + * Implementation of processArg(). + */ +template +bool UnlabeledValueArg::processArg(int *i, std::vector& args) +{ + + if ( _alreadySet ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + // never ignore an unlabeled arg + + _extractValue( args[*i] ); + _alreadySet = true; + return true; +} + +/** + * Overriding shortID for specific output. + */ +template +std::string UnlabeledValueArg::shortID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + ">"; +} + +/** + * Overriding longID for specific output. + */ +template +std::string UnlabeledValueArg::longID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + + // Ideally we would like to be able to use RTTI to return the name + // of the type required for this argument. However, g++ at least, + // doesn't appear to return terribly useful "names" of the types. + return std::string("<") + _typeDesc + ">"; +} + +/** + * Overriding operator== for specific behavior. + */ +template +bool UnlabeledValueArg::operator==(const Arg& a ) const +{ + if ( _name == a.getName() || _description == a.getDescription() ) + return true; + else + return false; +} + +template +void UnlabeledValueArg::addToList( std::list& argList ) const +{ + argList.push_back( const_cast(static_cast(this)) ); +} + +} +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/ValueArg.h b/funasr/runtime/onnxruntime/include/tclap/ValueArg.h new file mode 100644 index 000000000..791d93f96 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/ValueArg.h @@ -0,0 +1,430 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ValueArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VALUE_ARGUMENT_H +#define TCLAP_VALUE_ARGUMENT_H + +#include +#include + +#include +#include + +namespace TCLAP { + +/** + * The basic labeled argument that parses a value. + * This is a template class, which means the type T defines the type + * that a given object will attempt to parse when the flag/name is matched + * on the command line. While there is nothing stopping you from creating + * an unflagged ValueArg, it is unwise and would cause significant problems. + * Instead use an UnlabeledValueArg. + */ +template +class ValueArg : public Arg +{ +protected: + + /** + * The value parsed from the command line. + * Can be of any type, as long as the >> operator for the type + * is defined. + */ + T _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + T _default; + + /** + * A human readable description of the type to be parsed. + * This is a hack, plain and simple. Ideally we would use RTTI to + * return the name of type T, but until there is some sort of + * consistent support for human readable names, we are left to our + * own devices. + */ + std::string _typeDesc; + + /** + * A Constraint this Arg must conform to. + */ + Constraint* _constraint; + + /** + * Extracts the value from the string. + * Attempts to parse string as type T, if this fails an exception + * is thrown. + * \param val - value to be parsed. + */ + void _extractValue( const std::string& val ); + +public: + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + Visitor* v = NULL); + + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint* constraint, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint* constraint, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector& args); + + /** + * Returns the value of the argument. + */ + const T& getValue() const { return _value; } + + // TODO(macbishop): Non-const variant is deprecated, don't + // use. Remove in next major. + T& getValue() { return _value; } + + /** + * A ValueArg can be used as as its value type (T) This is the + * same as calling getValue() + */ + operator const T&() const { return getValue(); } + + /** + * Specialization of shortID. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val = "val") const; + + /** + * Specialization of longID. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val = "val") const; + + virtual void reset() ; + +private: + /** + * Prevent accidental copying + */ + ValueArg(const ValueArg& rhs); + ValueArg& operator=(const ValueArg& rhs); +}; + + +/** + * Constructor implementation. + */ +template +ValueArg::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + Visitor* v) + : Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( typeDesc ), + _constraint( NULL ) +{ } + +template +ValueArg::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v) + : Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( typeDesc ), + _constraint( NULL ) +{ + parser.add( this ); +} + +template +ValueArg::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint* constraint, + Visitor* v) + : Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( Constraint::shortID(constraint) ), + _constraint( constraint ) +{ } + +template +ValueArg::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint* constraint, + CmdLineInterface& parser, + Visitor* v) + : Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( Constraint::shortID(constraint) ), // TODO(macbishop): Will crash + // if constraint is NULL + _constraint( constraint ) +{ + parser.add( this ); +} + +/** + * Implementation of processArg(). + */ +template +bool ValueArg::processArg(int *i, std::vector& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + std::string flag = args[*i]; + + std::string value = ""; + trimFlag( flag, value ); + + if ( argMatches( flag ) ) + { + if ( _alreadySet ) + { + if ( _xorSet ) + throw( CmdLineParseException("Mutually exclusive argument" + " already set!", toString())); + else + throw( CmdLineParseException("Argument already set!", + toString()) ); + } + + if ( Arg::delimiter() != ' ' && value == "" ) + throw( ArgParseException("Couldn't find delimiter for this argument!", + toString() ) ); + + if ( value == "" ) + { + (*i)++; + if ( static_cast(*i) < args.size() ) + _extractValue( args[*i] ); + else + throw( ArgParseException("Missing a value for this argument!", + toString() ) ); + } + else + _extractValue( value ); + + _alreadySet = true; + _checkWithVisitor(); + return true; + } + else + return false; +} + +/** + * Implementation of shortID. + */ +template +std::string ValueArg::shortID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return Arg::shortID( _typeDesc ); +} + +/** + * Implementation of longID. + */ +template +std::string ValueArg::longID(const std::string& val) const +{ + static_cast(val); // Ignore input, don't warn + return Arg::longID( _typeDesc ); +} + +template +void ValueArg::_extractValue( const std::string& val ) +{ + try { + ExtractValue(_value, val, typename ArgTraits::ValueCategory()); + } catch( ArgParseException &e) { + throw ArgParseException(e.error(), toString()); + } + + if ( _constraint != NULL ) + if ( ! _constraint->check( _value ) ) + throw( CmdLineParseException( "Value '" + val + + + "' does not meet constraint: " + + _constraint->description(), + toString() ) ); +} + +template +void ValueArg::reset() +{ + Arg::reset(); + _value = _default; +} + +} // namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/ValuesConstraint.h b/funasr/runtime/onnxruntime/include/tclap/ValuesConstraint.h new file mode 100644 index 000000000..985143293 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/ValuesConstraint.h @@ -0,0 +1,134 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + + +/****************************************************************************** + * + * file: ValuesConstraint.h + * + * Copyright (c) 2005, Michael E. Smoot + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_VALUESCONSTRAINT_H +#define TCLAP_VALUESCONSTRAINT_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +namespace TCLAP { + +/** + * A Constraint that constrains the Arg to only those values specified + * in the constraint. + */ +template +class ValuesConstraint : public Constraint +{ + + public: + + /** + * Constructor. + * \param allowed - vector of allowed values. + */ + ValuesConstraint(std::vectorconst& allowed); + + /** + * Virtual destructor. + */ + virtual ~ValuesConstraint() {} + + /** + * Returns a description of the Constraint. + */ + virtual std::string description() const; + + /** + * Returns the short ID for the Constraint. + */ + virtual std::string shortID() const; + + /** + * The method used to verify that the value parsed from the command + * line meets the constraint. + * \param value - The value that will be checked. + */ + virtual bool check(const T& value) const; + + protected: + + /** + * The list of valid values. + */ + std::vector _allowed; + + /** + * The string used to describe the allowed values of this constraint. + */ + std::string _typeDesc; + +}; + +template +ValuesConstraint::ValuesConstraint(std::vector const& allowed) +: _allowed(allowed), + _typeDesc("") +{ + for ( unsigned int i = 0; i < _allowed.size(); i++ ) + { + std::ostringstream os; + os << _allowed[i]; + + std::string temp( os.str() ); + + if ( i > 0 ) + _typeDesc += "|"; + _typeDesc += temp; + } +} + +template +bool ValuesConstraint::check( const T& val ) const +{ + if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) + return false; + else + return true; +} + +template +std::string ValuesConstraint::shortID() const +{ + return _typeDesc; +} + +template +std::string ValuesConstraint::description() const +{ + return _typeDesc; +} + + +} //namespace TCLAP +#endif + diff --git a/funasr/runtime/onnxruntime/include/tclap/VersionVisitor.h b/funasr/runtime/onnxruntime/include/tclap/VersionVisitor.h new file mode 100644 index 000000000..3ef8b584e --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/VersionVisitor.h @@ -0,0 +1,81 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: VersionVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VERSION_VISITOR_H +#define TCLAP_VERSION_VISITOR_H + +#include +#include +#include + +namespace TCLAP { + +/** + * A Visitor that will call the version method of the given CmdLineOutput + * for the specified CmdLine object and then exit. + */ +class VersionVisitor: public Visitor +{ + private: + /** + * Prevent accidental copying + */ + VersionVisitor(const VersionVisitor& rhs); + VersionVisitor& operator=(const VersionVisitor& rhs); + + protected: + + /** + * The CmdLine of interest. + */ + CmdLineInterface* _cmd; + + /** + * The output object. + */ + CmdLineOutput** _out; + + public: + + /** + * Constructor. + * \param cmd - The CmdLine the output is generated for. + * \param out - The type of output. + */ + VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) + : Visitor(), _cmd( cmd ), _out( out ) { } + + /** + * Calls the version method of the output object using the + * specified CmdLine. + */ + void visit() { + (*_out)->version(*_cmd); + throw ExitException(0); + } + +}; + +} + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/Visitor.h b/funasr/runtime/onnxruntime/include/tclap/Visitor.h new file mode 100644 index 000000000..2a7bfd165 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/Visitor.h @@ -0,0 +1,57 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: Visitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2017, Google LLC + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VISITOR_H +#define TCLAP_VISITOR_H + +namespace TCLAP { + +/** + * A base class that defines the interface for visitors. + */ +class Visitor +{ + public: + + /** + * Constructor. Does nothing. + */ + Visitor() { } + + /** + * Destructor. Does nothing. + */ + virtual ~Visitor() { } + + /** + * This method (to implemented by children) will be + * called when the visitor is visited. + */ + virtual void visit() = 0; +}; + +} + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/XorHandler.h b/funasr/runtime/onnxruntime/include/tclap/XorHandler.h new file mode 100644 index 000000000..e80f9ee3a --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/XorHandler.h @@ -0,0 +1,168 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + + +/****************************************************************************** + * + * file: XorHandler.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_XORHANDLER_H +#define TCLAP_XORHANDLER_H + +#include +#include +#include +#include +#include + +namespace TCLAP { + +/** + * This class handles lists of Arg's that are to be XOR'd on the command + * line. This is used by CmdLine and you shouldn't ever use it. + */ +class XorHandler +{ + protected: + + /** + * The list of of lists of Arg's to be or'd together. + */ + std::vector< std::vector > _orList; + + public: + + /** + * Constructor. Does nothing. + */ + XorHandler( ) : _orList(std::vector< std::vector >()) {} + + /** + * Add a list of Arg*'s that will be xor'd together. + * \param ors - list of Arg* that will be xor'd. + */ + void add( const std::vector& ors ); + + /** + * Checks whether the specified Arg is in one of the xor lists and + * if it does match one, returns the size of the xor list that the + * Arg matched. If the Arg matches, then it also sets the rest of + * the Arg's in the list. You shouldn't use this. + * \param a - The Arg to be checked. + */ + int check( const Arg* a ); + + /** + * Returns the XOR specific short usage. + */ + std::string shortUsage(); + + /** + * Prints the XOR specific long usage. + * \param os - Stream to print to. + */ + void printLongUsage(std::ostream& os); + + /** + * Simply checks whether the Arg is contained in one of the arg + * lists. + * \param a - The Arg to be checked. + */ + bool contains( const Arg* a ); + + const std::vector< std::vector >& getXorList() const; + +}; + + +////////////////////////////////////////////////////////////////////// +//BEGIN XOR.cpp +////////////////////////////////////////////////////////////////////// +inline void XorHandler::add( const std::vector& ors ) +{ + _orList.push_back( ors ); +} + +inline int XorHandler::check( const Arg* a ) +{ + // iterate over each XOR list + for ( int i = 0; static_cast(i) < _orList.size(); i++ ) + { + // if the XOR list contains the arg.. + ArgVectorIterator ait = std::find( _orList[i].begin(), + _orList[i].end(), a ); + if ( ait != _orList[i].end() ) + { + // first check to see if a mutually exclusive switch + // has not already been set + for ( ArgVectorIterator it = _orList[i].begin(); + it != _orList[i].end(); + it++ ) + if ( a != (*it) && (*it)->isSet() ) + throw(CmdLineParseException( + "Mutually exclusive argument already set!", + (*it)->toString())); + + // go through and set each arg that is not a + for ( ArgVectorIterator it = _orList[i].begin(); + it != _orList[i].end(); + it++ ) + if ( a != (*it) ) + (*it)->xorSet(); + + // return the number of required args that have now been set + if ( (*ait)->allowMore() ) + return 0; + else + return static_cast(_orList[i].size()); + } + } + + if ( a->isRequired() ) + return 1; + else + return 0; +} + +inline bool XorHandler::contains( const Arg* a ) +{ + for ( int i = 0; static_cast(i) < _orList.size(); i++ ) + for ( ArgVectorIterator it = _orList[i].begin(); + it != _orList[i].end(); + it++ ) + if ( a == (*it) ) + return true; + + return false; +} + +inline const std::vector< std::vector >& XorHandler::getXorList() const +{ + return _orList; +} + + + +////////////////////////////////////////////////////////////////////// +//END XOR.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/ZshCompletionOutput.h b/funasr/runtime/onnxruntime/include/tclap/ZshCompletionOutput.h new file mode 100644 index 000000000..5a9268c87 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/ZshCompletionOutput.h @@ -0,0 +1,336 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ZshCompletionOutput.h + * + * Copyright (c) 2006, Oliver Kiddle + * Copyright (c) 2017 Google Inc. + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H +#define TCLAP_ZSHCOMPLETIONOUTPUT_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace TCLAP { + +/** + * A class that generates a Zsh completion function as output from the usage() + * method for the given CmdLine and its Args. + */ +class ZshCompletionOutput : public CmdLineOutput +{ + + public: + + ZshCompletionOutput(); + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + protected: + + void basename( std::string& s ); + void quoteSpecialChars( std::string& s ); + + std::string getMutexList( CmdLineInterface& _cmd, Arg* a ); + void printOption( Arg* it, std::string mutex ); + void printArg( Arg* it ); + + std::map common; + char theDelimiter; +}; + +ZshCompletionOutput::ZshCompletionOutput() +: common(std::map()), + theDelimiter('=') +{ + common["host"] = "_hosts"; + common["hostname"] = "_hosts"; + common["file"] = "_files"; + common["filename"] = "_files"; + common["user"] = "_users"; + common["username"] = "_users"; + common["directory"] = "_directories"; + common["path"] = "_directories"; + common["url"] = "_urls"; +} + +inline void ZshCompletionOutput::version(CmdLineInterface& _cmd) +{ + std::cout << _cmd.getVersion() << std::endl; +} + +inline void ZshCompletionOutput::usage(CmdLineInterface& _cmd ) +{ + std::list argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + std::string xversion = _cmd.getVersion(); + theDelimiter = _cmd.getDelimiter(); + basename(progName); + + std::cout << "#compdef " << progName << std::endl << std::endl << + "# " << progName << " version " << _cmd.getVersion() << std::endl << std::endl << + "_arguments -s -S"; + + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + { + if ( (*it)->shortID().at(0) == '<' ) + printArg((*it)); + else if ( (*it)->getFlag() != "-" ) + printOption((*it), getMutexList(_cmd, *it)); + } + + std::cout << std::endl; +} + +inline void ZshCompletionOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + static_cast(_cmd); // unused + std::cout << e.what() << std::endl; +} + +inline void ZshCompletionOutput::quoteSpecialChars( std::string& s ) +{ + size_t idx = s.find_last_of(':'); + while ( idx != std::string::npos ) + { + s.insert(idx, 1, '\\'); + idx = s.find_last_of(':', idx); + } + idx = s.find_last_of('\''); + while ( idx != std::string::npos ) + { + s.insert(idx, "'\\'"); + if (idx == 0) + idx = std::string::npos; + else + idx = s.find_last_of('\'', --idx); + } +} + +inline void ZshCompletionOutput::basename( std::string& s ) +{ + size_t p = s.find_last_of('/'); + if ( p != std::string::npos ) + { + s.erase(0, p + 1); + } +} + +inline void ZshCompletionOutput::printArg(Arg* a) +{ + static int count = 1; + + std::cout << " \\" << std::endl << " '"; + if ( a->acceptsMultipleValues() ) + std::cout << '*'; + else + std::cout << count++; + std::cout << ':'; + if ( !a->isRequired() ) + std::cout << ':'; + + std::cout << a->getName() << ':'; + std::map::iterator compArg = common.find(a->getName()); + if ( compArg != common.end() ) + { + std::cout << compArg->second; + } + else + { + std::cout << "_guard \"^-*\" " << a->getName(); + } + std::cout << '\''; +} + +inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) +{ + std::string flag = a->flagStartChar() + a->getFlag(); + std::string name = a->nameStartString() + a->getName(); + std::string desc = a->getDescription(); + + // remove full stop and capitalization from description as + // this is the convention for zsh function + if (!desc.compare(0, 12, "(required) ")) + { + desc.erase(0, 12); + } + if (!desc.compare(0, 15, "(OR required) ")) + { + desc.erase(0, 15); + } + size_t len = desc.length(); + if (len && desc.at(--len) == '.') + { + desc.erase(len); + } + if (len) + { + desc.replace(0, 1, 1, tolower(desc.at(0))); + } + + std::cout << " \\" << std::endl << " '" << mutex; + + if ( a->getFlag().empty() ) + { + std::cout << name; + } + else + { + std::cout << "'{" << flag << ',' << name << "}'"; + } + if ( theDelimiter == '=' && a->isValueRequired() ) + std::cout << "=-"; + quoteSpecialChars(desc); + std::cout << '[' << desc << ']'; + + if ( a->isValueRequired() ) + { + std::string arg = a->shortID(); + // Example arg: "[-A ] ..." + size_t pos = arg.rfind(" ..."); + + if (pos != std::string::npos) { + arg.erase(pos); + } + + arg.erase(0, arg.find_last_of(theDelimiter) + 1); + if ( arg.at(arg.length()-1) == ']' ) + arg.erase(arg.length()-1); + if ( arg.at(arg.length()-1) == ']' ) + { + arg.erase(arg.length()-1); + } + if ( arg.at(0) == '<' ) + { + arg.erase(arg.length()-1); + arg.erase(0, 1); + } + size_t p = arg.find('|'); + if ( p != std::string::npos ) + { + do + { + arg.replace(p, 1, 1, ' '); + } + while ( (p = arg.find_first_of('|', p)) != std::string::npos ); + quoteSpecialChars(arg); + std::cout << ": :(" << arg << ')'; + } + else + { + std::cout << ':' << arg; + std::map::iterator compArg = common.find(arg); + if ( compArg != common.end() ) + { + std::cout << ':' << compArg->second; + } + } + } + + std::cout << '\''; +} + +inline std::string ZshCompletionOutput::getMutexList( CmdLineInterface& _cmd, Arg* a) +{ + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector > xorList = xorHandler.getXorList(); + + if (a->getName() == "help" || a->getName() == "version") + { + return "(-)"; + } + + ostringstream list; + if ( a->acceptsMultipleValues() ) + { + list << '*'; + } + + for ( int i = 0; static_cast(i) < xorList.size(); i++ ) + { + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++) + if ( a == (*it) ) + { + list << '('; + for ( ArgVectorIterator iu = xorList[i].begin(); + iu != xorList[i].end(); + iu++ ) + { + bool notCur = (*iu) != a; + bool hasFlag = !(*iu)->getFlag().empty(); + if ( iu != xorList[i].begin() && (notCur || hasFlag) ) + list << ' '; + if (hasFlag) + list << (*iu)->flagStartChar() << (*iu)->getFlag() << ' '; + if ( notCur || hasFlag ) + list << (*iu)->nameStartString() << (*iu)->getName(); + } + list << ')'; + return list.str(); + } + } + + // wasn't found in xor list + if (!a->getFlag().empty()) { + list << "(" << a->flagStartChar() << a->getFlag() << ' ' << + a->nameStartString() << a->getName() << ')'; + } + + return list.str(); +} + +} //namespace TCLAP +#endif diff --git a/funasr/runtime/onnxruntime/include/tclap/sstream.h b/funasr/runtime/onnxruntime/include/tclap/sstream.h new file mode 100644 index 000000000..0118b76b1 --- /dev/null +++ b/funasr/runtime/onnxruntime/include/tclap/sstream.h @@ -0,0 +1,50 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: sstream.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno . + * Copyright (c) 2017 Google Inc. + * All rights reserved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_SSTREAM_H +#define TCLAP_SSTREAM_H + +#if !defined(HAVE_STRSTREAM) +// Assume sstream is available if strstream is not specified +// (https://sourceforge.net/p/tclap/bugs/23/) +#define HAVE_SSTREAM +#endif + +#if defined(HAVE_SSTREAM) +#include +namespace TCLAP { + typedef std::istringstream istringstream; + typedef std::ostringstream ostringstream; +} +#elif defined(HAVE_STRSTREAM) +#include +namespace TCLAP { + typedef std::istrstream istringstream; + typedef std::ostrstream ostringstream; +} +#else +#error "Need a stringstream (sstream or strstream) to compile!" +#endif + +#endif // TCLAP_SSTREAM_H diff --git a/funasr/runtime/onnxruntime/include/win_func.h b/funasr/runtime/onnxruntime/include/win_func.h deleted file mode 100644 index 1baaae53f..000000000 --- a/funasr/runtime/onnxruntime/include/win_func.h +++ /dev/null @@ -1,28 +0,0 @@ -#include -#ifdef WIN32 -#include -#else -#include -#endif -#ifdef WIN32 -int gettimeofday(struct timeval* tp, void* tzp) -{ - time_t clock; - struct tm tm; - SYSTEMTIME wtm; - - GetLocalTime(&wtm); - tm.tm_year = wtm.wYear - 1900; - tm.tm_mon = wtm.wMonth - 1; - tm.tm_mday = wtm.wDay; - tm.tm_hour = wtm.wHour; - tm.tm_min = wtm.wMinute; - tm.tm_sec = wtm.wSecond; - tm.tm_isdst = -1; - - clock = mktime(&tm); - tp->tv_sec = clock; - tp->tv_usec = wtm.wMilliseconds * 1000; - return (0); -} -#endif \ No newline at end of file diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/anchor.h b/funasr/runtime/onnxruntime/include/yaml-cpp/anchor.h deleted file mode 100644 index 06759c724..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/anchor.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML { -typedef std::size_t anchor_t; -const anchor_t NullAnchor = 0; -} - -#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/binary.h b/funasr/runtime/onnxruntime/include/yaml-cpp/binary.h deleted file mode 100644 index 29d5dbd02..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/binary.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -YAML_CPP_API std::string EncodeBase64(const unsigned char *data, - std::size_t size); -YAML_CPP_API std::vector DecodeBase64(const std::string &input); - -class YAML_CPP_API Binary { - public: - Binary() : m_unownedData(0), m_unownedSize(0) {} - Binary(const unsigned char *data_, std::size_t size_) - : m_unownedData(data_), m_unownedSize(size_) {} - - bool owned() const { return !m_unownedData; } - std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } - const unsigned char *data() const { - return owned() ? &m_data[0] : m_unownedData; - } - - void swap(std::vector &rhs) { - if (m_unownedData) { - m_data.swap(rhs); - rhs.clear(); - rhs.resize(m_unownedSize); - std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); - m_unownedData = 0; - m_unownedSize = 0; - } else { - m_data.swap(rhs); - } - } - - bool operator==(const Binary &rhs) const { - const std::size_t s = size(); - if (s != rhs.size()) - return false; - const unsigned char *d1 = data(); - const unsigned char *d2 = rhs.data(); - for (std::size_t i = 0; i < s; i++) { - if (*d1++ != *d2++) - return false; - } - return true; - } - - bool operator!=(const Binary &rhs) const { return !(*this == rhs); } - - private: - std::vector m_data; - const unsigned char *m_unownedData; - std::size_t m_unownedSize; -}; -} - -#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/anchordict.h b/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/anchordict.h deleted file mode 100644 index 78db9ec92..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/anchordict.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "../anchor.h" - -namespace YAML { -/** - * An object that stores and retrieves values correlating to {@link anchor_t} - * values. - * - *

    Efficient implementation that can make assumptions about how - * {@code anchor_t} values are assigned by the {@link Parser} class. - */ -template -class AnchorDict { - public: - void Register(anchor_t anchor, T value) { - if (anchor > m_data.size()) { - m_data.resize(anchor); - } - m_data[anchor - 1] = value; - } - - T Get(anchor_t anchor) const { return m_data[anchor - 1]; } - - private: - std::vector m_data; -}; -} - -#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/graphbuilder.h b/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/graphbuilder.h deleted file mode 100644 index f0a38f288..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/contrib/graphbuilder.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/mark.h" -#include - -namespace YAML { -class Parser; - -// GraphBuilderInterface -// . Abstraction of node creation -// . pParentNode is always NULL or the return value of one of the NewXXX() -// functions. -class GraphBuilderInterface { - public: - virtual ~GraphBuilderInterface() = 0; - - // Create and return a new node with a null value. - virtual void *NewNull(const Mark &mark, void *pParentNode) = 0; - - // Create and return a new node with the given tag and value. - virtual void *NewScalar(const Mark &mark, const std::string &tag, - void *pParentNode, const std::string &value) = 0; - - // Create and return a new sequence node - virtual void *NewSequence(const Mark &mark, const std::string &tag, - void *pParentNode) = 0; - - // Add pNode to pSequence. pNode was created with one of the NewXxx() - // functions and pSequence with NewSequence(). - virtual void AppendToSequence(void *pSequence, void *pNode) = 0; - - // Note that no moew entries will be added to pSequence - virtual void SequenceComplete(void *pSequence) { (void)pSequence; } - - // Create and return a new map node - virtual void *NewMap(const Mark &mark, const std::string &tag, - void *pParentNode) = 0; - - // Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode - // were created with one of the NewXxx() methods and pMap with NewMap(). - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; - - // Note that no more assignments will be made in pMap - virtual void MapComplete(void *pMap) { (void)pMap; } - - // Return the node that should be used in place of an alias referencing - // pNode (pNode by default) - virtual void *AnchorReference(const Mark &mark, void *pNode) { - (void)mark; - return pNode; - } -}; - -// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines -// Node, Sequence, and Map types. Sequence and Map must derive from Node -// (unless Node is defined as void). Impl must also implement function with -// all of the same names as the virtual functions in GraphBuilderInterface -// -- including the ones with default implementations -- but with the -// prototypes changed to accept an explicit Node*, Sequence*, or Map* where -// appropriate. -template -class GraphBuilder : public GraphBuilderInterface { - public: - typedef typename Impl::Node Node; - typedef typename Impl::Sequence Sequence; - typedef typename Impl::Map Map; - - GraphBuilder(Impl &impl) : m_impl(impl) { - Map *pMap = NULL; - Sequence *pSeq = NULL; - Node *pNode = NULL; - - // Type consistency checks - pNode = pMap; - pNode = pSeq; - } - - GraphBuilderInterface &AsBuilderInterface() { return *this; } - - virtual void *NewNull(const Mark &mark, void *pParentNode) { - return CheckType(m_impl.NewNull(mark, AsNode(pParentNode))); - } - - virtual void *NewScalar(const Mark &mark, const std::string &tag, - void *pParentNode, const std::string &value) { - return CheckType( - m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); - } - - virtual void *NewSequence(const Mark &mark, const std::string &tag, - void *pParentNode) { - return CheckType( - m_impl.NewSequence(mark, tag, AsNode(pParentNode))); - } - virtual void AppendToSequence(void *pSequence, void *pNode) { - m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); - } - virtual void SequenceComplete(void *pSequence) { - m_impl.SequenceComplete(AsSequence(pSequence)); - } - - virtual void *NewMap(const Mark &mark, const std::string &tag, - void *pParentNode) { - return CheckType(m_impl.NewMap(mark, tag, AsNode(pParentNode))); - } - virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { - m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); - } - virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); } - - virtual void *AnchorReference(const Mark &mark, void *pNode) { - return CheckType(m_impl.AnchorReference(mark, AsNode(pNode))); - } - - private: - Impl &m_impl; - - // Static check for pointer to T - template - static T *CheckType(U *p) { - return p; - } - - static Node *AsNode(void *pNode) { return static_cast(pNode); } - static Sequence *AsSequence(void *pSeq) { - return static_cast(pSeq); - } - static Map *AsMap(void *pMap) { return static_cast(pMap); } -}; - -void *BuildGraphOfNextDocument(Parser &parser, - GraphBuilderInterface &graphBuilder); - -template -typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) { - GraphBuilder graphBuilder(impl); - return static_cast( - BuildGraphOfNextDocument(parser, graphBuilder)); -} -} - -#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/dll.h b/funasr/runtime/onnxruntime/include/yaml-cpp/dll.h deleted file mode 100644 index a32c06b2e..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/dll.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -// The following ifdef block is the standard way of creating macros which make -// exporting from a DLL simpler. All files within this DLL are compiled with the -// yaml_cpp_EXPORTS symbol defined on the command line. This symbol should not -// be defined on any project that uses this DLL. This way any other project -// whose source files include this file see YAML_CPP_API functions as being -// imported from a DLL, whereas this DLL sees symbols defined with this macro as -// being exported. -#undef YAML_CPP_API - -#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined - // manually) -#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake - // or defined manually) -// #pragma message( "Defining YAML_CPP_API for DLL export" ) -#define YAML_CPP_API __declspec(dllexport) -#else // yaml_cpp_EXPORTS -// #pragma message( "Defining YAML_CPP_API for DLL import" ) -#define YAML_CPP_API __declspec(dllimport) -#endif // yaml_cpp_EXPORTS -#else // YAML_CPP_DLL -#define YAML_CPP_API -#endif // YAML_CPP_DLL - -#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/emitfromevents.h b/funasr/runtime/onnxruntime/include/yaml-cpp/emitfromevents.h deleted file mode 100644 index f14b051ab..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/emitfromevents.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/anchor.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/eventhandler.h" - -namespace YAML { -struct Mark; -} // namespace YAML - -namespace YAML { -class Emitter; - -class EmitFromEvents : public EventHandler { - public: - EmitFromEvents(Emitter& emitter); - - virtual void OnDocumentStart(const Mark& mark); - virtual void OnDocumentEnd(); - - virtual void OnNull(const Mark& mark, anchor_t anchor); - virtual void OnAlias(const Mark& mark, anchor_t anchor); - virtual void OnScalar(const Mark& mark, const std::string& tag, - anchor_t anchor, const std::string& value); - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style); - virtual void OnSequenceEnd(); - - virtual void OnMapStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style); - virtual void OnMapEnd(); - - private: - void BeginNode(); - void EmitProps(const std::string& tag, anchor_t anchor); - - private: - Emitter& m_emitter; - - struct State { - enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; - }; - std::stack m_stateStack; -}; -} - -#endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/emitter.h b/funasr/runtime/onnxruntime/include/yaml-cpp/emitter.h deleted file mode 100644 index ef92cc403..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/emitter.h +++ /dev/null @@ -1,254 +0,0 @@ -#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include - -#include "yaml-cpp/binary.h" -#include "yaml-cpp/dll.h" -#include "yaml-cpp/emitterdef.h" -#include "yaml-cpp/emittermanip.h" -#include "yaml-cpp/noncopyable.h" -#include "yaml-cpp/null.h" -#include "yaml-cpp/ostream_wrapper.h" - -namespace YAML { -class Binary; -struct _Null; -} // namespace YAML - -namespace YAML { -class EmitterState; - -class YAML_CPP_API Emitter : private noncopyable { - public: - Emitter(); - explicit Emitter(std::ostream& stream); - ~Emitter(); - - // output - const char* c_str() const; - std::size_t size() const; - - // state checking - bool good() const; - const std::string GetLastError() const; - - // global setters - bool SetOutputCharset(EMITTER_MANIP value); - bool SetStringFormat(EMITTER_MANIP value); - bool SetBoolFormat(EMITTER_MANIP value); - bool SetIntBase(EMITTER_MANIP value); - bool SetSeqFormat(EMITTER_MANIP value); - bool SetMapFormat(EMITTER_MANIP value); - bool SetIndent(std::size_t n); - bool SetPreCommentIndent(std::size_t n); - bool SetPostCommentIndent(std::size_t n); - bool SetFloatPrecision(std::size_t n); - bool SetDoublePrecision(std::size_t n); - - // local setters - Emitter& SetLocalValue(EMITTER_MANIP value); - Emitter& SetLocalIndent(const _Indent& indent); - Emitter& SetLocalPrecision(const _Precision& precision); - - // overloads of write - Emitter& Write(const std::string& str); - Emitter& Write(bool b); - Emitter& Write(char ch); - Emitter& Write(const _Alias& alias); - Emitter& Write(const _Anchor& anchor); - Emitter& Write(const _Tag& tag); - Emitter& Write(const _Comment& comment); - Emitter& Write(const _Null& n); - Emitter& Write(const Binary& binary); - - template - Emitter& WriteIntegralType(T value); - - template - Emitter& WriteStreamable(T value); - - private: - template - void SetStreamablePrecision(std::stringstream&) {} - std::size_t GetFloatPrecision() const; - std::size_t GetDoublePrecision() const; - - void PrepareIntegralStream(std::stringstream& stream) const; - void StartedScalar(); - - private: - void EmitBeginDoc(); - void EmitEndDoc(); - void EmitBeginSeq(); - void EmitEndSeq(); - void EmitBeginMap(); - void EmitEndMap(); - void EmitNewline(); - void EmitKindTag(); - void EmitTag(bool verbatim, const _Tag& tag); - - void PrepareNode(EmitterNodeType::value child); - void PrepareTopNode(EmitterNodeType::value child); - void FlowSeqPrepareNode(EmitterNodeType::value child); - void BlockSeqPrepareNode(EmitterNodeType::value child); - - void FlowMapPrepareNode(EmitterNodeType::value child); - - void FlowMapPrepareLongKey(EmitterNodeType::value child); - void FlowMapPrepareLongKeyValue(EmitterNodeType::value child); - void FlowMapPrepareSimpleKey(EmitterNodeType::value child); - void FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child); - - void BlockMapPrepareNode(EmitterNodeType::value child); - - void BlockMapPrepareLongKey(EmitterNodeType::value child); - void BlockMapPrepareLongKeyValue(EmitterNodeType::value child); - void BlockMapPrepareSimpleKey(EmitterNodeType::value child); - void BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child); - - void SpaceOrIndentTo(bool requireSpace, std::size_t indent); - - const char* ComputeFullBoolName(bool b) const; - bool CanEmitNewline() const; - - private: - std::unique_ptr m_pState; - ostream_wrapper m_stream; -}; - -template -inline Emitter& Emitter::WriteIntegralType(T value) { - if (!good()) - return *this; - - PrepareNode(EmitterNodeType::Scalar); - - std::stringstream stream; - PrepareIntegralStream(stream); - stream << value; - m_stream << stream.str(); - - StartedScalar(); - - return *this; -} - -template -inline Emitter& Emitter::WriteStreamable(T value) { - if (!good()) - return *this; - - PrepareNode(EmitterNodeType::Scalar); - - std::stringstream stream; - SetStreamablePrecision(stream); - stream << value; - m_stream << stream.str(); - - StartedScalar(); - - return *this; -} - -template <> -inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { - stream.precision(static_cast(GetFloatPrecision())); -} - -template <> -inline void Emitter::SetStreamablePrecision(std::stringstream& stream) { - stream.precision(static_cast(GetDoublePrecision())); -} - -// overloads of insertion -inline Emitter& operator<<(Emitter& emitter, const std::string& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, bool v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, char v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned char v) { - return emitter.Write(static_cast(v)); -} -inline Emitter& operator<<(Emitter& emitter, const _Alias& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Anchor& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Tag& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Comment& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const _Null& v) { - return emitter.Write(v); -} -inline Emitter& operator<<(Emitter& emitter, const Binary& b) { - return emitter.Write(b); -} - -inline Emitter& operator<<(Emitter& emitter, const char* v) { - return emitter.Write(std::string(v)); -} - -inline Emitter& operator<<(Emitter& emitter, int v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned int v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, short v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned short v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, long long v) { - return emitter.WriteIntegralType(v); -} -inline Emitter& operator<<(Emitter& emitter, unsigned long long v) { - return emitter.WriteIntegralType(v); -} - -inline Emitter& operator<<(Emitter& emitter, float v) { - return emitter.WriteStreamable(v); -} -inline Emitter& operator<<(Emitter& emitter, double v) { - return emitter.WriteStreamable(v); -} - -inline Emitter& operator<<(Emitter& emitter, EMITTER_MANIP value) { - return emitter.SetLocalValue(value); -} - -inline Emitter& operator<<(Emitter& emitter, _Indent indent) { - return emitter.SetLocalIndent(indent); -} - -inline Emitter& operator<<(Emitter& emitter, _Precision precision) { - return emitter.SetLocalPrecision(precision); -} -} - -#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/emitterdef.h b/funasr/runtime/onnxruntime/include/yaml-cpp/emitterdef.h deleted file mode 100644 index 0b426957f..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/emitterdef.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct EmitterNodeType { - enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; -}; -} - -#endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/emittermanip.h b/funasr/runtime/onnxruntime/include/yaml-cpp/emittermanip.h deleted file mode 100644 index 89f725671..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/emittermanip.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -namespace YAML { -enum EMITTER_MANIP { - // general manipulators - Auto, - TagByKind, - Newline, - - // output character set - EmitNonAscii, - EscapeNonAscii, - - // string manipulators - // Auto, // duplicate - SingleQuoted, - DoubleQuoted, - Literal, - - // bool manipulators - YesNoBool, // yes, no - TrueFalseBool, // true, false - OnOffBool, // on, off - UpperCase, // TRUE, N - LowerCase, // f, yes - CamelCase, // No, Off - LongBool, // yes, On - ShortBool, // y, t - - // int manipulators - Dec, - Hex, - Oct, - - // document manipulators - BeginDoc, - EndDoc, - - // sequence manipulators - BeginSeq, - EndSeq, - Flow, - Block, - - // map manipulators - BeginMap, - EndMap, - Key, - Value, - // Flow, // duplicate - // Block, // duplicate - // Auto, // duplicate - LongKey -}; - -struct _Indent { - _Indent(int value_) : value(value_) {} - int value; -}; - -inline _Indent Indent(int value) { return _Indent(value); } - -struct _Alias { - _Alias(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Alias Alias(const std::string content) { return _Alias(content); } - -struct _Anchor { - _Anchor(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Anchor Anchor(const std::string content) { return _Anchor(content); } - -struct _Tag { - struct Type { - enum value { Verbatim, PrimaryHandle, NamedHandle }; - }; - - explicit _Tag(const std::string& prefix_, const std::string& content_, - Type::value type_) - : prefix(prefix_), content(content_), type(type_) {} - std::string prefix; - std::string content; - Type::value type; -}; - -inline _Tag VerbatimTag(const std::string content) { - return _Tag("", content, _Tag::Type::Verbatim); -} - -inline _Tag LocalTag(const std::string content) { - return _Tag("", content, _Tag::Type::PrimaryHandle); -} - -inline _Tag LocalTag(const std::string& prefix, const std::string content) { - return _Tag(prefix, content, _Tag::Type::NamedHandle); -} - -inline _Tag SecondaryTag(const std::string content) { - return _Tag("", content, _Tag::Type::NamedHandle); -} - -struct _Comment { - _Comment(const std::string& content_) : content(content_) {} - std::string content; -}; - -inline _Comment Comment(const std::string content) { return _Comment(content); } - -struct _Precision { - _Precision(int floatPrecision_, int doublePrecision_) - : floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} - - int floatPrecision; - int doublePrecision; -}; - -inline _Precision FloatPrecision(int n) { return _Precision(n, -1); } - -inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } - -inline _Precision Precision(int n) { return _Precision(n, n); } -} - -#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/emitterstyle.h b/funasr/runtime/onnxruntime/include/yaml-cpp/emitterstyle.h deleted file mode 100644 index 67bb3981b..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/emitterstyle.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct EmitterStyle { - enum value { Default, Block, Flow }; -}; -} - -#endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/eventhandler.h b/funasr/runtime/onnxruntime/include/yaml-cpp/eventhandler.h deleted file mode 100644 index efe381c62..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/eventhandler.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/anchor.h" -#include "yaml-cpp/emitterstyle.h" - -namespace YAML { -struct Mark; - -class EventHandler { - public: - virtual ~EventHandler() {} - - virtual void OnDocumentStart(const Mark& mark) = 0; - virtual void OnDocumentEnd() = 0; - - virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; - virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; - virtual void OnScalar(const Mark& mark, const std::string& tag, - anchor_t anchor, const std::string& value) = 0; - - virtual void OnSequenceStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style) = 0; - virtual void OnSequenceEnd() = 0; - - virtual void OnMapStart(const Mark& mark, const std::string& tag, - anchor_t anchor, EmitterStyle::value style) = 0; - virtual void OnMapEnd() = 0; -}; -} - -#endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/exceptions.h b/funasr/runtime/onnxruntime/include/yaml-cpp/exceptions.h deleted file mode 100644 index 9c96859b2..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/exceptions.h +++ /dev/null @@ -1,267 +0,0 @@ -#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/mark.h" -#include "yaml-cpp/traits.h" -#include -#include -#include - -// This is here for compatibility with older versions of Visual Studio -// which don't support noexcept -#ifdef _MSC_VER - #define YAML_CPP_NOEXCEPT _NOEXCEPT -#else - #define YAML_CPP_NOEXCEPT noexcept -#endif - -namespace YAML { -// error messages -namespace ErrorMsg { -const char* const YAML_DIRECTIVE_ARGS = - "YAML directives must have exactly one argument"; -const char* const YAML_VERSION = "bad YAML version: "; -const char* const YAML_MAJOR_VERSION = "YAML major version too large"; -const char* const REPEATED_YAML_DIRECTIVE = "repeated YAML directive"; -const char* const TAG_DIRECTIVE_ARGS = - "TAG directives must have exactly two arguments"; -const char* const REPEATED_TAG_DIRECTIVE = "repeated TAG directive"; -const char* const CHAR_IN_TAG_HANDLE = - "illegal character found while scanning tag handle"; -const char* const TAG_WITH_NO_SUFFIX = "tag handle with no suffix"; -const char* const END_OF_VERBATIM_TAG = "end of verbatim tag not found"; -const char* const END_OF_MAP = "end of map not found"; -const char* const END_OF_MAP_FLOW = "end of map flow not found"; -const char* const END_OF_SEQ = "end of sequence not found"; -const char* const END_OF_SEQ_FLOW = "end of sequence flow not found"; -const char* const MULTIPLE_TAGS = - "cannot assign multiple tags to the same node"; -const char* const MULTIPLE_ANCHORS = - "cannot assign multiple anchors to the same node"; -const char* const MULTIPLE_ALIASES = - "cannot assign multiple aliases to the same node"; -const char* const ALIAS_CONTENT = - "aliases can't have any content, *including* tags"; -const char* const INVALID_HEX = "bad character found while scanning hex number"; -const char* const INVALID_UNICODE = "invalid unicode: "; -const char* const INVALID_ESCAPE = "unknown escape character: "; -const char* const UNKNOWN_TOKEN = "unknown token"; -const char* const DOC_IN_SCALAR = "illegal document indicator in scalar"; -const char* const EOF_IN_SCALAR = "illegal EOF in scalar"; -const char* const CHAR_IN_SCALAR = "illegal character in scalar"; -const char* const TAB_IN_INDENTATION = - "illegal tab when looking for indentation"; -const char* const FLOW_END = "illegal flow end"; -const char* const BLOCK_ENTRY = "illegal block entry"; -const char* const MAP_KEY = "illegal map key"; -const char* const MAP_VALUE = "illegal map value"; -const char* const ALIAS_NOT_FOUND = "alias not found after *"; -const char* const ANCHOR_NOT_FOUND = "anchor not found after &"; -const char* const CHAR_IN_ALIAS = - "illegal character found while scanning alias"; -const char* const CHAR_IN_ANCHOR = - "illegal character found while scanning anchor"; -const char* const ZERO_INDENT_IN_BLOCK = - "cannot set zero indentation for a block scalar"; -const char* const CHAR_IN_BLOCK = "unexpected character in block scalar"; -const char* const AMBIGUOUS_ANCHOR = - "cannot assign the same alias to multiple nodes"; -const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined"; - -const char* const INVALID_NODE = - "invalid node; this may result from using a map iterator as a sequence " - "iterator, or vice-versa"; -const char* const INVALID_SCALAR = "invalid scalar"; -const char* const KEY_NOT_FOUND = "key not found"; -const char* const BAD_CONVERSION = "bad conversion"; -const char* const BAD_DEREFERENCE = "bad dereference"; -const char* const BAD_SUBSCRIPT = "operator[] call on a scalar"; -const char* const BAD_PUSHBACK = "appending to a non-sequence"; -const char* const BAD_INSERT = "inserting in a non-convertible-to-map"; - -const char* const UNMATCHED_GROUP_TAG = "unmatched group tag"; -const char* const UNEXPECTED_END_SEQ = "unexpected end sequence token"; -const char* const UNEXPECTED_END_MAP = "unexpected end map token"; -const char* const SINGLE_QUOTED_CHAR = - "invalid character in single-quoted string"; -const char* const INVALID_ANCHOR = "invalid anchor"; -const char* const INVALID_ALIAS = "invalid alias"; -const char* const INVALID_TAG = "invalid tag"; -const char* const BAD_FILE = "bad file"; - -template -inline const std::string KEY_NOT_FOUND_WITH_KEY( - const T&, typename disable_if>::type* = 0) { - return KEY_NOT_FOUND; -} - -inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); -} - -template -inline const std::string KEY_NOT_FOUND_WITH_KEY( - const T& key, typename enable_if>::type* = 0) { - std::stringstream stream; - stream << KEY_NOT_FOUND << ": " << key; - return stream.str(); -} -} - -class YAML_CPP_API Exception : public std::runtime_error { - public: - Exception(const Mark& mark_, const std::string& msg_) - : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} - virtual ~Exception() YAML_CPP_NOEXCEPT; - - Exception(const Exception&) = default; - - Mark mark; - std::string msg; - - private: - static const std::string build_what(const Mark& mark, - const std::string& msg) { - if (mark.is_null()) { - return msg.c_str(); - } - - std::stringstream output; - output << "yaml-cpp: error at line " << mark.line + 1 << ", column " - << mark.column + 1 << ": " << msg; - return output.str(); - } -}; - -class YAML_CPP_API ParserException : public Exception { - public: - ParserException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - ParserException(const ParserException&) = default; - virtual ~ParserException() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API RepresentationException : public Exception { - public: - RepresentationException(const Mark& mark_, const std::string& msg_) - : Exception(mark_, msg_) {} - RepresentationException(const RepresentationException&) = default; - virtual ~RepresentationException() YAML_CPP_NOEXCEPT; -}; - -// representation exceptions -class YAML_CPP_API InvalidScalar : public RepresentationException { - public: - InvalidScalar(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} - InvalidScalar(const InvalidScalar&) = default; - virtual ~InvalidScalar() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API KeyNotFound : public RepresentationException { - public: - template - KeyNotFound(const Mark& mark_, const T& key_) - : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) { - } - KeyNotFound(const KeyNotFound&) = default; - virtual ~KeyNotFound() YAML_CPP_NOEXCEPT; -}; - -template -class YAML_CPP_API TypedKeyNotFound : public KeyNotFound { - public: - TypedKeyNotFound(const Mark& mark_, const T& key_) - : KeyNotFound(mark_, key_), key(key_) {} - virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT {} - - T key; -}; - -template -inline TypedKeyNotFound MakeTypedKeyNotFound(const Mark& mark, - const T& key) { - return TypedKeyNotFound(mark, key); -} - -class YAML_CPP_API InvalidNode : public RepresentationException { - public: - InvalidNode() - : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} - InvalidNode(const InvalidNode&) = default; - virtual ~InvalidNode() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API BadConversion : public RepresentationException { - public: - explicit BadConversion(const Mark& mark_) - : RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {} - BadConversion(const BadConversion&) = default; - virtual ~BadConversion() YAML_CPP_NOEXCEPT; -}; - -template -class TypedBadConversion : public BadConversion { - public: - explicit TypedBadConversion(const Mark& mark_) : BadConversion(mark_) {} -}; - -class YAML_CPP_API BadDereference : public RepresentationException { - public: - BadDereference() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} - BadDereference(const BadDereference&) = default; - virtual ~BadDereference() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API BadSubscript : public RepresentationException { - public: - BadSubscript() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} - BadSubscript(const BadSubscript&) = default; - virtual ~BadSubscript() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API BadPushback : public RepresentationException { - public: - BadPushback() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} - BadPushback(const BadPushback&) = default; - virtual ~BadPushback() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API BadInsert : public RepresentationException { - public: - BadInsert() - : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} - BadInsert(const BadInsert&) = default; - virtual ~BadInsert() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API EmitterException : public Exception { - public: - EmitterException(const std::string& msg_) - : Exception(Mark::null_mark(), msg_) {} - EmitterException(const EmitterException&) = default; - virtual ~EmitterException() YAML_CPP_NOEXCEPT; -}; - -class YAML_CPP_API BadFile : public Exception { - public: - BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} - BadFile(const BadFile&) = default; - virtual ~BadFile() YAML_CPP_NOEXCEPT; -}; -} - -#undef YAML_CPP_NOEXCEPT - -#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/mark.h b/funasr/runtime/onnxruntime/include/yaml-cpp/mark.h deleted file mode 100644 index bf94b4f41..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/mark.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" - -namespace YAML { -struct YAML_CPP_API Mark { - Mark() : pos(0), line(0), column(0) {} - - static const Mark null_mark() { return Mark(-1, -1, -1); } - - bool is_null() const { return pos == -1 && line == -1 && column == -1; } - - int pos; - int line, column; - - private: - Mark(int pos_, int line_, int column_) - : pos(pos_), line(line_), column(column_) {} -}; -} - -#endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/convert.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/convert.h deleted file mode 100644 index 45a878ab0..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/convert.h +++ /dev/null @@ -1,331 +0,0 @@ -#ifndef NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include -#include -#include - -#include "yaml-cpp/binary.h" -#include "yaml-cpp/node/impl.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/null.h" - -namespace YAML { -class Binary; -struct _Null; -template -struct convert; -} // namespace YAML - -namespace YAML { -namespace conversion { -inline bool IsInfinity(const std::string& input) { - return input == ".inf" || input == ".Inf" || input == ".INF" || - input == "+.inf" || input == "+.Inf" || input == "+.INF"; -} - -inline bool IsNegativeInfinity(const std::string& input) { - return input == "-.inf" || input == "-.Inf" || input == "-.INF"; -} - -inline bool IsNaN(const std::string& input) { - return input == ".nan" || input == ".NaN" || input == ".NAN"; -} -} - -// Node -template <> -struct convert { - static Node encode(const Node& rhs) { return rhs; } - - static bool decode(const Node& node, Node& rhs) { - rhs.reset(node); - return true; - } -}; - -// std::string -template <> -struct convert { - static Node encode(const std::string& rhs) { return Node(rhs); } - - static bool decode(const Node& node, std::string& rhs) { - if (!node.IsScalar()) - return false; - rhs = node.Scalar(); - return true; - } -}; - -// C-strings can only be encoded -template <> -struct convert { - static Node encode(const char*& rhs) { return Node(rhs); } -}; - -template -struct convert { - static Node encode(const char(&rhs)[N]) { return Node(rhs); } -}; - -template <> -struct convert<_Null> { - static Node encode(const _Null& /* rhs */) { return Node(); } - - static bool decode(const Node& node, _Null& /* rhs */) { - return node.IsNull(); - } -}; - -#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \ - template <> \ - struct convert { \ - static Node encode(const type& rhs) { \ - std::stringstream stream; \ - stream.precision(std::numeric_limits::digits10 + 1); \ - stream << rhs; \ - return Node(stream.str()); \ - } \ - \ - static bool decode(const Node& node, type& rhs) { \ - if (node.Type() != NodeType::Scalar) \ - return false; \ - const std::string& input = node.Scalar(); \ - std::stringstream stream(input); \ - stream.unsetf(std::ios::dec); \ - if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \ - return true; \ - if (std::numeric_limits::has_infinity) { \ - if (conversion::IsInfinity(input)) { \ - rhs = std::numeric_limits::infinity(); \ - return true; \ - } else if (conversion::IsNegativeInfinity(input)) { \ - rhs = negative_op std::numeric_limits::infinity(); \ - return true; \ - } \ - } \ - \ - if (std::numeric_limits::has_quiet_NaN && \ - conversion::IsNaN(input)) { \ - rhs = std::numeric_limits::quiet_NaN(); \ - return true; \ - } \ - \ - return false; \ - } \ - } - -#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \ - YAML_DEFINE_CONVERT_STREAMABLE(type, -) - -#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type) \ - YAML_DEFINE_CONVERT_STREAMABLE(type, +) - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long); - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(signed char); -YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char); - -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double); -YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double); - -#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED -#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED -#undef YAML_DEFINE_CONVERT_STREAMABLE - -// bool -template <> -struct convert { - static Node encode(bool rhs) { return rhs ? Node("true") : Node("false"); } - - YAML_CPP_API static bool decode(const Node& node, bool& rhs); -}; - -// std::map -template -struct convert> { - static Node encode(const std::map& rhs) { - Node node(NodeType::Map); - for (typename std::map::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.force_insert(it->first, it->second); - return node; - } - - static bool decode(const Node& node, std::map& rhs) { - if (!node.IsMap()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs[it->first.template as()] = it->second.template as(); -#else - rhs[it->first.as()] = it->second.as(); -#endif - return true; - } -}; - -// std::vector -template -struct convert> { - static Node encode(const std::vector& rhs) { - Node node(NodeType::Sequence); - for (typename std::vector::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.push_back(*it); - return node; - } - - static bool decode(const Node& node, std::vector& rhs) { - if (!node.IsSequence()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.push_back(it->template as()); -#else - rhs.push_back(it->as()); -#endif - return true; - } -}; - -// std::list -template -struct convert> { - static Node encode(const std::list& rhs) { - Node node(NodeType::Sequence); - for (typename std::list::const_iterator it = rhs.begin(); - it != rhs.end(); ++it) - node.push_back(*it); - return node; - } - - static bool decode(const Node& node, std::list& rhs) { - if (!node.IsSequence()) - return false; - - rhs.clear(); - for (const_iterator it = node.begin(); it != node.end(); ++it) -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.push_back(it->template as()); -#else - rhs.push_back(it->as()); -#endif - return true; - } -}; - -// std::array -template -struct convert> { - static Node encode(const std::array& rhs) { - Node node(NodeType::Sequence); - for (const auto& element : rhs) { - node.push_back(element); - } - return node; - } - - static bool decode(const Node& node, std::array& rhs) { - if (!isNodeValid(node)) { - return false; - } - - for (auto i = 0u; i < node.size(); ++i) { -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs[i] = node[i].template as(); -#else - rhs[i] = node[i].as(); -#endif - } - return true; - } - - private: - static bool isNodeValid(const Node& node) { - return node.IsSequence() && node.size() == N; - } -}; - -// std::pair -template -struct convert> { - static Node encode(const std::pair& rhs) { - Node node(NodeType::Sequence); - node.push_back(rhs.first); - node.push_back(rhs.second); - return node; - } - - static bool decode(const Node& node, std::pair& rhs) { - if (!node.IsSequence()) - return false; - if (node.size() != 2) - return false; - -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.first = node[0].template as(); -#else - rhs.first = node[0].as(); -#endif -#if defined(__GNUC__) && __GNUC__ < 4 - // workaround for GCC 3: - rhs.second = node[1].template as(); -#else - rhs.second = node[1].as(); -#endif - return true; - } -}; - -// binary -template <> -struct convert { - static Node encode(const Binary& rhs) { - return Node(EncodeBase64(rhs.data(), rhs.size())); - } - - static bool decode(const Node& node, Binary& rhs) { - if (!node.IsScalar()) - return false; - - std::vector data = DecodeBase64(node.Scalar()); - if (data.empty() && !node.Scalar().empty()) - return false; - - rhs.swap(data); - return true; - } -}; -} - -#endif // NODE_CONVERT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/bool_type.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/bool_type.h deleted file mode 100644 index 2c80705c9..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/bool_type.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -namespace detail { -struct unspecified_bool { - struct NOT_ALLOWED; - static void true_value(NOT_ALLOWED*) {} -}; -typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*); -} -} - -#define YAML_CPP_OPERATOR_BOOL() \ - operator YAML::detail::unspecified_bool_type() const { \ - return this->operator!() ? 0 \ - : &YAML::detail::unspecified_bool::true_value; \ - } - -#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/impl.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/impl.h deleted file mode 100644 index 09e55f838..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/impl.h +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/node/detail/node.h" -#include "yaml-cpp/node/detail/node_data.h" -#include - -namespace YAML { -namespace detail { -template -struct get_idx { - static node* get(const std::vector& /* sequence */, - const Key& /* key */, shared_memory_holder /* pMemory */) { - return 0; - } -}; - -template -struct get_idx::value && - !std::is_same::value>::type> { - static node* get(const std::vector& sequence, const Key& key, - shared_memory_holder /* pMemory */) { - return key < sequence.size() ? sequence[key] : 0; - } - - static node* get(std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined())) - return 0; - if (key == sequence.size()) - sequence.push_back(&pMemory->create_node()); - return sequence[key]; - } -}; - -template -struct get_idx::value>::type> { - static node* get(const std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - return key >= 0 ? get_idx::get( - sequence, static_cast(key), pMemory) - : 0; - } - static node* get(std::vector& sequence, const Key& key, - shared_memory_holder pMemory) { - return key >= 0 ? get_idx::get( - sequence, static_cast(key), pMemory) - : 0; - } -}; - -template -inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { - T lhs; - if (convert::decode(Node(*this, pMemory), lhs)) { - return lhs == rhs; - } - return false; -} - -inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { - return equals(rhs, pMemory); -} - -// indexing -template -inline node* node_data::get(const Key& key, - shared_memory_holder pMemory) const { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - return NULL; - case NodeType::Sequence: - if (node* pNode = get_idx::get(m_sequence, key, pMemory)) - return pNode; - return NULL; - case NodeType::Scalar: - throw BadSubscript(); - } - - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return it->second; - } - } - - return NULL; -} - -template -inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - case NodeType::Sequence: - if (node* pNode = get_idx::get(m_sequence, key, pMemory)) { - m_type = NodeType::Sequence; - return *pNode; - } - - convert_to_map(pMemory); - break; - case NodeType::Scalar: - throw BadSubscript(); - } - - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return *it->second; - } - } - - node& k = convert_to_node(key, pMemory); - node& v = pMemory->create_node(); - insert_map_pair(k, v); - return v; -} - -template -inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) { - if (m_type != NodeType::Map) - return false; - - for (kv_pairs::iterator it = m_undefinedPairs.begin(); - it != m_undefinedPairs.end();) { - kv_pairs::iterator jt = std::next(it); - if (it->first->equals(key, pMemory)) - m_undefinedPairs.erase(it); - it = jt; - } - - for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - m_map.erase(it); - return true; - } - } - - return false; -} - -// map -template -inline void node_data::force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - switch (m_type) { - case NodeType::Map: - break; - case NodeType::Undefined: - case NodeType::Null: - case NodeType::Sequence: - convert_to_map(pMemory); - break; - case NodeType::Scalar: - throw BadInsert(); - } - - node& k = convert_to_node(key, pMemory); - node& v = convert_to_node(value, pMemory); - insert_map_pair(k, v); -} - -template -inline node& node_data::convert_to_node(const T& rhs, - shared_memory_holder pMemory) { - Node value = convert::encode(rhs); - value.EnsureNodeExists(); - pMemory->merge(*value.m_pMemory); - return *value.m_pNode; -} -} -} - -#endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator.h deleted file mode 100644 index deec8fb62..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_iterator.h" -#include -#include - -namespace YAML { -namespace detail { -struct iterator_value; - -template -class iterator_base : public std::iterator { - - private: - template - friend class iterator_base; - struct enabler {}; - typedef node_iterator base_type; - - struct proxy { - explicit proxy(const V& x) : m_ref(x) {} - V* operator->() { return std::addressof(m_ref); } - operator V*() { return std::addressof(m_ref); } - - V m_ref; - }; - - public: - typedef typename iterator_base::value_type value_type; - - public: - iterator_base() : m_iterator(), m_pMemory() {} - explicit iterator_base(base_type rhs, shared_memory_holder pMemory) - : m_iterator(rhs), m_pMemory(pMemory) {} - - template - iterator_base(const iterator_base& rhs, - typename std::enable_if::value, - enabler>::type = enabler()) - : m_iterator(rhs.m_iterator), m_pMemory(rhs.m_pMemory) {} - - iterator_base& operator++() { - ++m_iterator; - return *this; - } - - iterator_base operator++(int) { - iterator_base iterator_pre(*this); - ++(*this); - return iterator_pre; - } - - template - bool operator==(const iterator_base& rhs) const { - return m_iterator == rhs.m_iterator; - } - - template - bool operator!=(const iterator_base& rhs) const { - return m_iterator != rhs.m_iterator; - } - - value_type operator*() const { - const typename base_type::value_type& v = *m_iterator; - if (v.pNode) - return value_type(Node(*v, m_pMemory)); - if (v.first && v.second) - return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory)); - return value_type(); - } - - proxy operator->() const { return proxy(**this); } - - private: - base_type m_iterator; - shared_memory_holder m_pMemory; -}; -} -} - -#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator_fwd.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator_fwd.h deleted file mode 100644 index 5f1ffe743..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/iterator_fwd.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include -#include -#include - -namespace YAML { - -namespace detail { -struct iterator_value; -template -class iterator_base; -} - -typedef detail::iterator_base iterator; -typedef detail::iterator_base const_iterator; -} - -#endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/memory.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/memory.h deleted file mode 100644 index 8f2bc2657..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/memory.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/ptr.h" - -namespace YAML { -namespace detail { -class node; -} // namespace detail -} // namespace YAML - -namespace YAML { -namespace detail { -class YAML_CPP_API memory { - public: - node& create_node(); - void merge(const memory& rhs); - - private: - typedef std::set Nodes; - Nodes m_nodes; -}; - -class YAML_CPP_API memory_holder { - public: - memory_holder() : m_pMemory(new memory) {} - - node& create_node() { return m_pMemory->create_node(); } - void merge(memory_holder& rhs); - - private: - shared_memory m_pMemory; -}; -} -} - -#endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node.h deleted file mode 100644 index 8a776f62a..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_ref.h" -#include - -namespace YAML { -namespace detail { -class node { - public: - node() : m_pRef(new node_ref) {} - node(const node&) = delete; - node& operator=(const node&) = delete; - - bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } - const node_ref* ref() const { return m_pRef.get(); } - - bool is_defined() const { return m_pRef->is_defined(); } - const Mark& mark() const { return m_pRef->mark(); } - NodeType::value type() const { return m_pRef->type(); } - - const std::string& scalar() const { return m_pRef->scalar(); } - const std::string& tag() const { return m_pRef->tag(); } - EmitterStyle::value style() const { return m_pRef->style(); } - - template - bool equals(const T& rhs, shared_memory_holder pMemory); - bool equals(const char* rhs, shared_memory_holder pMemory); - - void mark_defined() { - if (is_defined()) - return; - - m_pRef->mark_defined(); - for (nodes::iterator it = m_dependencies.begin(); - it != m_dependencies.end(); ++it) - (*it)->mark_defined(); - m_dependencies.clear(); - } - - void add_dependency(node& rhs) { - if (is_defined()) - rhs.mark_defined(); - else - m_dependencies.insert(&rhs); - } - - void set_ref(const node& rhs) { - if (rhs.is_defined()) - mark_defined(); - m_pRef = rhs.m_pRef; - } - void set_data(const node& rhs) { - if (rhs.is_defined()) - mark_defined(); - m_pRef->set_data(*rhs.m_pRef); - } - - void set_mark(const Mark& mark) { m_pRef->set_mark(mark); } - - void set_type(NodeType::value type) { - if (type != NodeType::Undefined) - mark_defined(); - m_pRef->set_type(type); - } - void set_null() { - mark_defined(); - m_pRef->set_null(); - } - void set_scalar(const std::string& scalar) { - mark_defined(); - m_pRef->set_scalar(scalar); - } - void set_tag(const std::string& tag) { - mark_defined(); - m_pRef->set_tag(tag); - } - - // style - void set_style(EmitterStyle::value style) { - mark_defined(); - m_pRef->set_style(style); - } - - // size/iterator - std::size_t size() const { return m_pRef->size(); } - - const_node_iterator begin() const { - return static_cast(*m_pRef).begin(); - } - node_iterator begin() { return m_pRef->begin(); } - - const_node_iterator end() const { - return static_cast(*m_pRef).end(); - } - node_iterator end() { return m_pRef->end(); } - - // sequence - void push_back(node& input, shared_memory_holder pMemory) { - m_pRef->push_back(input, pMemory); - input.add_dependency(*this); - } - void insert(node& key, node& value, shared_memory_holder pMemory) { - m_pRef->insert(key, value, pMemory); - key.add_dependency(*this); - value.add_dependency(*this); - } - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const { - // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such - // key). - return static_cast(*m_pRef).get(key, pMemory); - } - template - node& get(const Key& key, shared_memory_holder pMemory) { - node& value = m_pRef->get(key, pMemory); - value.add_dependency(*this); - return value; - } - template - bool remove(const Key& key, shared_memory_holder pMemory) { - return m_pRef->remove(key, pMemory); - } - - node* get(node& key, shared_memory_holder pMemory) const { - // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such - // key). - return static_cast(*m_pRef).get(key, pMemory); - } - node& get(node& key, shared_memory_holder pMemory) { - node& value = m_pRef->get(key, pMemory); - key.add_dependency(*this); - value.add_dependency(*this); - return value; - } - bool remove(node& key, shared_memory_holder pMemory) { - return m_pRef->remove(key, pMemory); - } - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - m_pRef->force_insert(key, value, pMemory); - } - - private: - shared_node_ref m_pRef; - typedef std::set nodes; - nodes m_dependencies; -}; -} -} - -#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_data.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_data.h deleted file mode 100644 index 50bcd7435..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_data.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/detail/node_iterator.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/type.h" - -namespace YAML { -namespace detail { -class node; -} // namespace detail -} // namespace YAML - -namespace YAML { -namespace detail { -class YAML_CPP_API node_data { - public: - node_data(); - node_data(const node_data&) = delete; - node_data& operator=(const node_data&) = delete; - - void mark_defined(); - void set_mark(const Mark& mark); - void set_type(NodeType::value type); - void set_tag(const std::string& tag); - void set_null(); - void set_scalar(const std::string& scalar); - void set_style(EmitterStyle::value style); - - bool is_defined() const { return m_isDefined; } - const Mark& mark() const { return m_mark; } - NodeType::value type() const { - return m_isDefined ? m_type : NodeType::Undefined; - } - const std::string& scalar() const { return m_scalar; } - const std::string& tag() const { return m_tag; } - EmitterStyle::value style() const { return m_style; } - - // size/iterator - std::size_t size() const; - - const_node_iterator begin() const; - node_iterator begin(); - - const_node_iterator end() const; - node_iterator end(); - - // sequence - void push_back(node& node, shared_memory_holder pMemory); - void insert(node& key, node& value, shared_memory_holder pMemory); - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const; - template - node& get(const Key& key, shared_memory_holder pMemory); - template - bool remove(const Key& key, shared_memory_holder pMemory); - - node* get(node& key, shared_memory_holder pMemory) const; - node& get(node& key, shared_memory_holder pMemory); - bool remove(node& key, shared_memory_holder pMemory); - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory); - - public: - static std::string empty_scalar; - - private: - void compute_seq_size() const; - void compute_map_size() const; - - void reset_sequence(); - void reset_map(); - - void insert_map_pair(node& key, node& value); - void convert_to_map(shared_memory_holder pMemory); - void convert_sequence_to_map(shared_memory_holder pMemory); - - template - static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); - - private: - bool m_isDefined; - Mark m_mark; - NodeType::value m_type; - std::string m_tag; - EmitterStyle::value m_style; - - // scalar - std::string m_scalar; - - // sequence - typedef std::vector node_seq; - node_seq m_sequence; - - mutable std::size_t m_seqSize; - - // map - typedef std::vector> node_map; - node_map m_map; - - typedef std::pair kv_pair; - typedef std::list kv_pairs; - mutable kv_pairs m_undefinedPairs; -}; -} -} - -#endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_iterator.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_iterator.h deleted file mode 100644 index 088090fe7..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_iterator.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/ptr.h" -#include -#include -#include -#include -#include -#include - -namespace YAML { -namespace detail { -struct iterator_type { - enum value { NoneType, Sequence, Map }; -}; - -template -struct node_iterator_value : public std::pair { - typedef std::pair kv; - - node_iterator_value() : kv(), pNode(0) {} - explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {} - explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {} - - V& operator*() const { return *pNode; } - V& operator->() const { return *pNode; } - - V* pNode; -}; - -typedef std::vector node_seq; -typedef std::vector> node_map; - -template -struct node_iterator_type { - typedef node_seq::iterator seq; - typedef node_map::iterator map; -}; - -template -struct node_iterator_type { - typedef node_seq::const_iterator seq; - typedef node_map::const_iterator map; -}; - -template -class node_iterator_base - : public std::iterator, - std::ptrdiff_t, node_iterator_value*, - node_iterator_value> { - private: - struct enabler {}; - - struct proxy { - explicit proxy(const node_iterator_value& x) : m_ref(x) {} - node_iterator_value* operator->() { return std::addressof(m_ref); } - operator node_iterator_value*() { return std::addressof(m_ref); } - - node_iterator_value m_ref; - }; - - public: - typedef typename node_iterator_type::seq SeqIter; - typedef typename node_iterator_type::map MapIter; - typedef node_iterator_value value_type; - - node_iterator_base() - : m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {} - explicit node_iterator_base(SeqIter seqIt) - : m_type(iterator_type::Sequence), - m_seqIt(seqIt), - m_mapIt(), - m_mapEnd() {} - explicit node_iterator_base(MapIter mapIt, MapIter mapEnd) - : m_type(iterator_type::Map), - m_seqIt(), - m_mapIt(mapIt), - m_mapEnd(mapEnd) { - m_mapIt = increment_until_defined(m_mapIt); - } - - template - node_iterator_base(const node_iterator_base& rhs, - typename std::enable_if::value, - enabler>::type = enabler()) - : m_type(rhs.m_type), - m_seqIt(rhs.m_seqIt), - m_mapIt(rhs.m_mapIt), - m_mapEnd(rhs.m_mapEnd) {} - - template - friend class node_iterator_base; - - template - bool operator==(const node_iterator_base& rhs) const { - if (m_type != rhs.m_type) - return false; - - switch (m_type) { - case iterator_type::NoneType: - return true; - case iterator_type::Sequence: - return m_seqIt == rhs.m_seqIt; - case iterator_type::Map: - return m_mapIt == rhs.m_mapIt; - } - return true; - } - - template - bool operator!=(const node_iterator_base& rhs) const { - return !(*this == rhs); - } - - node_iterator_base& operator++() { - switch (m_type) { - case iterator_type::NoneType: - break; - case iterator_type::Sequence: - ++m_seqIt; - break; - case iterator_type::Map: - ++m_mapIt; - m_mapIt = increment_until_defined(m_mapIt); - break; - } - return *this; - } - - node_iterator_base operator++(int) { - node_iterator_base iterator_pre(*this); - ++(*this); - return iterator_pre; - } - - value_type operator*() const { - switch (m_type) { - case iterator_type::NoneType: - return value_type(); - case iterator_type::Sequence: - return value_type(**m_seqIt); - case iterator_type::Map: - return value_type(*m_mapIt->first, *m_mapIt->second); - } - return value_type(); - } - - proxy operator->() const { return proxy(**this); } - - MapIter increment_until_defined(MapIter it) { - while (it != m_mapEnd && !is_defined(it)) - ++it; - return it; - } - - bool is_defined(MapIter it) const { - return it->first->is_defined() && it->second->is_defined(); - } - - private: - typename iterator_type::value m_type; - - SeqIter m_seqIt; - MapIter m_mapIt, m_mapEnd; -}; - -typedef node_iterator_base node_iterator; -typedef node_iterator_base const_node_iterator; -} -} - -#endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_ref.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_ref.h deleted file mode 100644 index d8a94f8b8..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/detail/node_ref.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_data.h" - -namespace YAML { -namespace detail { -class node_ref { - public: - node_ref() : m_pData(new node_data) {} - node_ref(const node_ref&) = delete; - node_ref& operator=(const node_ref&) = delete; - - bool is_defined() const { return m_pData->is_defined(); } - const Mark& mark() const { return m_pData->mark(); } - NodeType::value type() const { return m_pData->type(); } - const std::string& scalar() const { return m_pData->scalar(); } - const std::string& tag() const { return m_pData->tag(); } - EmitterStyle::value style() const { return m_pData->style(); } - - void mark_defined() { m_pData->mark_defined(); } - void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; } - - void set_mark(const Mark& mark) { m_pData->set_mark(mark); } - void set_type(NodeType::value type) { m_pData->set_type(type); } - void set_tag(const std::string& tag) { m_pData->set_tag(tag); } - void set_null() { m_pData->set_null(); } - void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); } - void set_style(EmitterStyle::value style) { m_pData->set_style(style); } - - // size/iterator - std::size_t size() const { return m_pData->size(); } - - const_node_iterator begin() const { - return static_cast(*m_pData).begin(); - } - node_iterator begin() { return m_pData->begin(); } - - const_node_iterator end() const { - return static_cast(*m_pData).end(); - } - node_iterator end() { return m_pData->end(); } - - // sequence - void push_back(node& node, shared_memory_holder pMemory) { - m_pData->push_back(node, pMemory); - } - void insert(node& key, node& value, shared_memory_holder pMemory) { - m_pData->insert(key, value, pMemory); - } - - // indexing - template - node* get(const Key& key, shared_memory_holder pMemory) const { - return static_cast(*m_pData).get(key, pMemory); - } - template - node& get(const Key& key, shared_memory_holder pMemory) { - return m_pData->get(key, pMemory); - } - template - bool remove(const Key& key, shared_memory_holder pMemory) { - return m_pData->remove(key, pMemory); - } - - node* get(node& key, shared_memory_holder pMemory) const { - return static_cast(*m_pData).get(key, pMemory); - } - node& get(node& key, shared_memory_holder pMemory) { - return m_pData->get(key, pMemory); - } - bool remove(node& key, shared_memory_holder pMemory) { - return m_pData->remove(key, pMemory); - } - - // map - template - void force_insert(const Key& key, const Value& value, - shared_memory_holder pMemory) { - m_pData->force_insert(key, value, pMemory); - } - - private: - shared_node_data m_pData; -}; -} -} - -#endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/emit.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/emit.h deleted file mode 100644 index 032268c5d..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/emit.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class Emitter; -class Node; - -/** - * Emits the node to the given {@link Emitter}. If there is an error in writing, - * {@link Emitter#good} will return false. - */ -YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node); - -/** Emits the node to the given output stream. */ -YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node); - -/** Converts the node to a YAML string. */ -YAML_CPP_API std::string Dump(const Node& node); -} // namespace YAML - -#endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/impl.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/impl.h deleted file mode 100644 index 20c487a68..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/impl.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/detail/memory.h" -#include "yaml-cpp/node/detail/node.h" -#include "yaml-cpp/exceptions.h" -#include - -namespace YAML { -inline Node::Node() : m_isValid(true), m_pNode(NULL) {} - -inline Node::Node(NodeType::value type) - : m_isValid(true), - m_pMemory(new detail::memory_holder), - m_pNode(&m_pMemory->create_node()) { - m_pNode->set_type(type); -} - -template -inline Node::Node(const T& rhs) - : m_isValid(true), - m_pMemory(new detail::memory_holder), - m_pNode(&m_pMemory->create_node()) { - Assign(rhs); -} - -inline Node::Node(const detail::iterator_value& rhs) - : m_isValid(rhs.m_isValid), - m_pMemory(rhs.m_pMemory), - m_pNode(rhs.m_pNode) {} - -inline Node::Node(const Node& rhs) - : m_isValid(rhs.m_isValid), - m_pMemory(rhs.m_pMemory), - m_pNode(rhs.m_pNode) {} - -inline Node::Node(Zombie) : m_isValid(false), m_pNode(NULL) {} - -inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory) - : m_isValid(true), m_pMemory(pMemory), m_pNode(&node) {} - -inline Node::~Node() {} - -inline void Node::EnsureNodeExists() const { - if (!m_isValid) - throw InvalidNode(); - if (!m_pNode) { - m_pMemory.reset(new detail::memory_holder); - m_pNode = &m_pMemory->create_node(); - m_pNode->set_null(); - } -} - -inline bool Node::IsDefined() const { - if (!m_isValid) { - return false; - } - return m_pNode ? m_pNode->is_defined() : true; -} - -inline Mark Node::Mark() const { - if (!m_isValid) { - throw InvalidNode(); - } - return m_pNode ? m_pNode->mark() : Mark::null_mark(); -} - -inline NodeType::value Node::Type() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->type() : NodeType::Null; -} - -// access - -// template helpers -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - T operator()(const S& fallback) const { - if (!node.m_pNode) - return fallback; - - T t; - if (convert::decode(node, t)) - return t; - return fallback; - } -}; - -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - std::string operator()(const S& fallback) const { - if (node.Type() != NodeType::Scalar) - return fallback; - return node.Scalar(); - } -}; - -template -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - T operator()() const { - if (!node.m_pNode) - throw TypedBadConversion(node.Mark()); - - T t; - if (convert::decode(node, t)) - return t; - throw TypedBadConversion(node.Mark()); - } -}; - -template <> -struct as_if { - explicit as_if(const Node& node_) : node(node_) {} - const Node& node; - - std::string operator()() const { - if (node.Type() != NodeType::Scalar) - throw TypedBadConversion(node.Mark()); - return node.Scalar(); - } -}; - -// access functions -template -inline T Node::as() const { - if (!m_isValid) - throw InvalidNode(); - return as_if(*this)(); -} - -template -inline T Node::as(const S& fallback) const { - if (!m_isValid) - return fallback; - return as_if(*this)(fallback); -} - -inline const std::string& Node::Scalar() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar; -} - -inline const std::string& Node::Tag() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar; -} - -inline void Node::SetTag(const std::string& tag) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_tag(tag); -} - -inline EmitterStyle::value Node::Style() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->style() : EmitterStyle::Default; -} - -inline void Node::SetStyle(EmitterStyle::value style) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_style(style); -} - -// assignment -inline bool Node::is(const Node& rhs) const { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - if (!m_pNode || !rhs.m_pNode) - return false; - return m_pNode->is(*rhs.m_pNode); -} - -template -inline Node& Node::operator=(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - Assign(rhs); - return *this; -} - -inline void Node::reset(const YAML::Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - m_pMemory = rhs.m_pMemory; - m_pNode = rhs.m_pNode; -} - -template -inline void Node::Assign(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - AssignData(convert::encode(rhs)); -} - -template <> -inline void Node::Assign(const std::string& rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline void Node::Assign(const char* rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline void Node::Assign(char* rhs) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->set_scalar(rhs); -} - -inline Node& Node::operator=(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - if (is(rhs)) - return *this; - AssignNode(rhs); - return *this; -} - -inline void Node::AssignData(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - rhs.EnsureNodeExists(); - - m_pNode->set_data(*rhs.m_pNode); - m_pMemory->merge(*rhs.m_pMemory); -} - -inline void Node::AssignNode(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - rhs.EnsureNodeExists(); - - if (!m_pNode) { - m_pNode = rhs.m_pNode; - m_pMemory = rhs.m_pMemory; - return; - } - - m_pNode->set_ref(*rhs.m_pNode); - m_pMemory->merge(*rhs.m_pMemory); - m_pNode = rhs.m_pNode; -} - -// size/iterator -inline std::size_t Node::size() const { - if (!m_isValid) - throw InvalidNode(); - return m_pNode ? m_pNode->size() : 0; -} - -inline const_iterator Node::begin() const { - if (!m_isValid) - return const_iterator(); - return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory) - : const_iterator(); -} - -inline iterator Node::begin() { - if (!m_isValid) - return iterator(); - return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator(); -} - -inline const_iterator Node::end() const { - if (!m_isValid) - return const_iterator(); - return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator(); -} - -inline iterator Node::end() { - if (!m_isValid) - return iterator(); - return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator(); -} - -// sequence -template -inline void Node::push_back(const T& rhs) { - if (!m_isValid) - throw InvalidNode(); - push_back(Node(rhs)); -} - -inline void Node::push_back(const Node& rhs) { - if (!m_isValid || !rhs.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - rhs.EnsureNodeExists(); - - m_pNode->push_back(*rhs.m_pNode, m_pMemory); - m_pMemory->merge(*rhs.m_pMemory); -} - -// helpers for indexing -namespace detail { -template -struct to_value_t { - explicit to_value_t(const T& t_) : t(t_) {} - const T& t; - typedef const T& return_type; - - const T& operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -template <> -struct to_value_t { - explicit to_value_t(char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -template -struct to_value_t { - explicit to_value_t(const char* t_) : t(t_) {} - const char* t; - typedef std::string return_type; - - const std::string operator()() const { return t; } -}; - -// converts C-strings to std::strings so they can be copied -template -inline typename to_value_t::return_type to_value(const T& t) { - return to_value_t(t)(); -} -} - -// indexing -template -inline const Node Node::operator[](const Key& key) const { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - detail::node* value = static_cast(*m_pNode) - .get(detail::to_value(key), m_pMemory); - if (!value) { - return Node(ZombieNode); - } - return Node(*value, m_pMemory); -} - -template -inline Node Node::operator[](const Key& key) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - detail::node& value = m_pNode->get(detail::to_value(key), m_pMemory); - return Node(value, m_pMemory); -} - -template -inline bool Node::remove(const Key& key) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - return m_pNode->remove(detail::to_value(key), m_pMemory); -} - -inline const Node Node::operator[](const Node& key) const { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - m_pMemory->merge(*key.m_pMemory); - detail::node* value = - static_cast(*m_pNode).get(*key.m_pNode, m_pMemory); - if (!value) { - return Node(ZombieNode); - } - return Node(*value, m_pMemory); -} - -inline Node Node::operator[](const Node& key) { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - m_pMemory->merge(*key.m_pMemory); - detail::node& value = m_pNode->get(*key.m_pNode, m_pMemory); - return Node(value, m_pMemory); -} - -inline bool Node::remove(const Node& key) { - if (!m_isValid || !key.m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - key.EnsureNodeExists(); - return m_pNode->remove(*key.m_pNode, m_pMemory); -} - -// map -template -inline void Node::force_insert(const Key& key, const Value& value) { - if (!m_isValid) - throw InvalidNode(); - EnsureNodeExists(); - m_pNode->force_insert(detail::to_value(key), detail::to_value(value), - m_pMemory); -} - -// free functions -inline bool operator==(const Node& lhs, const Node& rhs) { return lhs.is(rhs); } -} - -#endif // NODE_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/iterator.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/iterator.h deleted file mode 100644 index 366a9c807..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/iterator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/detail/iterator_fwd.h" -#include "yaml-cpp/node/detail/iterator.h" -#include -#include -#include - -namespace YAML { -namespace detail { -struct iterator_value : public Node, std::pair { - iterator_value() {} - explicit iterator_value(const Node& rhs) - : Node(rhs), - std::pair(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} - explicit iterator_value(const Node& key, const Node& value) - : Node(Node::ZombieNode), std::pair(key, value) {} -}; -} -} - -#endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/node.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/node.h deleted file mode 100644 index 1ded7d27b..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/node.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/mark.h" -#include "yaml-cpp/node/detail/bool_type.h" -#include "yaml-cpp/node/detail/iterator_fwd.h" -#include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/type.h" - -namespace YAML { -namespace detail { -class node; -class node_data; -struct iterator_value; -} // namespace detail -} // namespace YAML - -namespace YAML { -class YAML_CPP_API Node { - public: - friend class NodeBuilder; - friend class NodeEvents; - friend struct detail::iterator_value; - friend class detail::node; - friend class detail::node_data; - template - friend class detail::iterator_base; - template - friend struct as_if; - - typedef YAML::iterator iterator; - typedef YAML::const_iterator const_iterator; - - Node(); - explicit Node(NodeType::value type); - template - explicit Node(const T& rhs); - explicit Node(const detail::iterator_value& rhs); - Node(const Node& rhs); - ~Node(); - - YAML::Mark Mark() const; - NodeType::value Type() const; - bool IsDefined() const; - bool IsNull() const { return Type() == NodeType::Null; } - bool IsScalar() const { return Type() == NodeType::Scalar; } - bool IsSequence() const { return Type() == NodeType::Sequence; } - bool IsMap() const { return Type() == NodeType::Map; } - - // bool conversions - YAML_CPP_OPERATOR_BOOL() - bool operator!() const { return !IsDefined(); } - - // access - template - T as() const; - template - T as(const S& fallback) const; - const std::string& Scalar() const; - - const std::string& Tag() const; - void SetTag(const std::string& tag); - - // style - // WARNING: This API might change in future releases. - EmitterStyle::value Style() const; - void SetStyle(EmitterStyle::value style); - - // assignment - bool is(const Node& rhs) const; - template - Node& operator=(const T& rhs); - Node& operator=(const Node& rhs); - void reset(const Node& rhs = Node()); - - // size/iterator - std::size_t size() const; - - const_iterator begin() const; - iterator begin(); - - const_iterator end() const; - iterator end(); - - // sequence - template - void push_back(const T& rhs); - void push_back(const Node& rhs); - - // indexing - template - const Node operator[](const Key& key) const; - template - Node operator[](const Key& key); - template - bool remove(const Key& key); - - const Node operator[](const Node& key) const; - Node operator[](const Node& key); - bool remove(const Node& key); - - // map - template - void force_insert(const Key& key, const Value& value); - - private: - enum Zombie { ZombieNode }; - explicit Node(Zombie); - explicit Node(detail::node& node, detail::shared_memory_holder pMemory); - - void EnsureNodeExists() const; - - template - void Assign(const T& rhs); - void Assign(const char* rhs); - void Assign(char* rhs); - - void AssignData(const Node& rhs); - void AssignNode(const Node& rhs); - - private: - bool m_isValid; - mutable detail::shared_memory_holder m_pMemory; - mutable detail::node* m_pNode; -}; - -YAML_CPP_API bool operator==(const Node& lhs, const Node& rhs); - -YAML_CPP_API Node Clone(const Node& node); - -template -struct convert; -} - -#endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/parse.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/parse.h deleted file mode 100644 index 7745fd724..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/parse.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class Node; - -/** - * Loads the input string as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(const std::string& input); - -/** - * Loads the input string as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(const char* input); - -/** - * Loads the input stream as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API Node Load(std::istream& input); - -/** - * Loads the input file as a single YAML document. - * - * @throws {@link ParserException} if it is malformed. - * @throws {@link BadFile} if the file cannot be loaded. - */ -YAML_CPP_API Node LoadFile(const std::string& filename); - -/** - * Loads the input string as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(const std::string& input); - -/** - * Loads the input string as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(const char* input); - -/** - * Loads the input stream as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - */ -YAML_CPP_API std::vector LoadAll(std::istream& input); - -/** - * Loads the input file as a list of YAML documents. - * - * @throws {@link ParserException} if it is malformed. - * @throws {@link BadFile} if the file cannot be loaded. - */ -YAML_CPP_API std::vector LoadAllFromFile(const std::string& filename); -} // namespace YAML - -#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/ptr.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/ptr.h deleted file mode 100644 index ce085dd5c..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/ptr.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include - -namespace YAML { -namespace detail { -class node; -class node_ref; -class node_data; -class memory; -class memory_holder; - -typedef std::shared_ptr shared_node; -typedef std::shared_ptr shared_node_ref; -typedef std::shared_ptr shared_node_data; -typedef std::shared_ptr shared_memory_holder; -typedef std::shared_ptr shared_memory; -} -} - -#endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/node/type.h b/funasr/runtime/onnxruntime/include/yaml-cpp/node/type.h deleted file mode 100644 index 9d55ca966..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/node/type.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -struct NodeType { - enum value { Undefined, Null, Scalar, Sequence, Map }; -}; -} - -#endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/noncopyable.h b/funasr/runtime/onnxruntime/include/yaml-cpp/noncopyable.h deleted file mode 100644 index a26104073..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/noncopyable.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" - -namespace YAML { -// this is basically boost::noncopyable -class YAML_CPP_API noncopyable { - protected: - noncopyable() {} - ~noncopyable() {} - - private: - noncopyable(const noncopyable&); - const noncopyable& operator=(const noncopyable&); -}; -} - -#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/null.h b/funasr/runtime/onnxruntime/include/yaml-cpp/null.h deleted file mode 100644 index b9521d488..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/null.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/dll.h" -#include - -namespace YAML { -class Node; - -struct YAML_CPP_API _Null {}; -inline bool operator==(const _Null&, const _Null&) { return true; } -inline bool operator!=(const _Null&, const _Null&) { return false; } - -YAML_CPP_API bool IsNull(const Node& node); // old API only -YAML_CPP_API bool IsNullString(const std::string& str); - -extern YAML_CPP_API _Null Null; -} - -#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/ostream_wrapper.h b/funasr/runtime/onnxruntime/include/yaml-cpp/ostream_wrapper.h deleted file mode 100644 index 09d45f39b..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/ostream_wrapper.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" - -namespace YAML { -class YAML_CPP_API ostream_wrapper { - public: - ostream_wrapper(); - explicit ostream_wrapper(std::ostream& stream); - ~ostream_wrapper(); - - void write(const std::string& str); - void write(const char* str, std::size_t size); - - void set_comment() { m_comment = true; } - - const char* str() const { - if (m_pStream) { - return 0; - } else { - m_buffer[m_pos] = '\0'; - return &m_buffer[0]; - } - } - - std::size_t row() const { return m_row; } - std::size_t col() const { return m_col; } - std::size_t pos() const { return m_pos; } - bool comment() const { return m_comment; } - - private: - void update_pos(char ch); - - private: - mutable std::vector m_buffer; - std::ostream* const m_pStream; - - std::size_t m_pos; - std::size_t m_row, m_col; - bool m_comment; -}; - -template -inline ostream_wrapper& operator<<(ostream_wrapper& stream, - const char(&str)[N]) { - stream.write(str, N - 1); - return stream; -} - -inline ostream_wrapper& operator<<(ostream_wrapper& stream, - const std::string& str) { - stream.write(str); - return stream; -} - -inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) { - stream.write(&ch, 1); - return stream; -} -} - -#endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/parser.h b/funasr/runtime/onnxruntime/include/yaml-cpp/parser.h deleted file mode 100644 index ceac22d02..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/parser.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include - -#include "yaml-cpp/dll.h" -#include "yaml-cpp/noncopyable.h" - -namespace YAML { -class EventHandler; -class Node; -class Scanner; -struct Directives; -struct Token; - -/** - * A parser turns a stream of bytes into one stream of "events" per YAML - * document in the input stream. - */ -class YAML_CPP_API Parser : private noncopyable { - public: - /** Constructs an empty parser (with no input. */ - Parser(); - - /** - * Constructs a parser from the given input stream. The input stream must - * live as long as the parser. - */ - explicit Parser(std::istream& in); - - ~Parser(); - - /** Evaluates to true if the parser has some valid input to be read. */ - explicit operator bool() const; - - /** - * Resets the parser with the given input stream. Any existing state is - * erased. - */ - void Load(std::istream& in); - - /** - * Handles the next document by calling events on the {@code eventHandler}. - * - * @throw a ParserException on error. - * @return false if there are no more documents - */ - bool HandleNextDocument(EventHandler& eventHandler); - - void PrintTokens(std::ostream& out); - - private: - /** - * Reads any directives that are next in the queue, setting the internal - * {@code m_pDirectives} state. - */ - void ParseDirectives(); - - void HandleDirective(const Token& token); - - /** - * Handles a "YAML" directive, which should be of the form 'major.minor' (like - * a version number). - */ - void HandleYamlDirective(const Token& token); - - /** - * Handles a "TAG" directive, which should be of the form 'handle prefix', - * where 'handle' is converted to 'prefix' in the file. - */ - void HandleTagDirective(const Token& token); - - private: - std::unique_ptr m_pScanner; - std::unique_ptr m_pDirectives; -}; -} - -#endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/stlemitter.h b/funasr/runtime/onnxruntime/include/yaml-cpp/stlemitter.h deleted file mode 100644 index 06780c861..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/stlemitter.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include -#include -#include -#include - -namespace YAML { -template -inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { - emitter << BeginSeq; - for (typename Seq::const_iterator it = seq.begin(); it != seq.end(); ++it) - emitter << *it; - emitter << EndSeq; - return emitter; -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::vector& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::list& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::set& v) { - return EmitSeq(emitter, v); -} - -template -inline Emitter& operator<<(Emitter& emitter, const std::map& m) { - typedef typename std::map map; - emitter << BeginMap; - for (typename map::const_iterator it = m.begin(); it != m.end(); ++it) - emitter << Key << it->first << Value << it->second; - emitter << EndMap; - return emitter; -} -} - -#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/traits.h b/funasr/runtime/onnxruntime/include/yaml-cpp/traits.h deleted file mode 100644 index f33d0e1f6..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/traits.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -namespace YAML { -template -struct is_numeric { - enum { value = false }; -}; - -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#if defined(_MSC_VER) && (_MSC_VER < 1310) -template <> -struct is_numeric<__int64> { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#else -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -#endif -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; -template <> -struct is_numeric { - enum { value = true }; -}; - -template -struct enable_if_c { - typedef T type; -}; - -template -struct enable_if_c {}; - -template -struct enable_if : public enable_if_c {}; - -template -struct disable_if_c { - typedef T type; -}; - -template -struct disable_if_c {}; - -template -struct disable_if : public disable_if_c {}; -} - -#endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/include/yaml-cpp/yaml.h b/funasr/runtime/onnxruntime/include/yaml-cpp/yaml.h deleted file mode 100644 index 7f515efb9..000000000 --- a/funasr/runtime/onnxruntime/include/yaml-cpp/yaml.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 - -#if defined(_MSC_VER) || \ - (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ - (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 -#pragma once -#endif - -#include "yaml-cpp/parser.h" -#include "yaml-cpp/emitter.h" -#include "yaml-cpp/emitterstyle.h" -#include "yaml-cpp/stlemitter.h" -#include "yaml-cpp/exceptions.h" - -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/impl.h" -#include "yaml-cpp/node/convert.h" -#include "yaml-cpp/node/iterator.h" -#include "yaml-cpp/node/detail/impl.h" -#include "yaml-cpp/node/parse.h" -#include "yaml-cpp/node/emit.h" - -#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/funasr/runtime/onnxruntime/readme.md b/funasr/runtime/onnxruntime/readme.md index 6886d58d6..95840e530 100644 --- a/funasr/runtime/onnxruntime/readme.md +++ b/funasr/runtime/onnxruntime/readme.md @@ -38,35 +38,44 @@ mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=release .. -DONNXRUNTIME_DIR=/path/to/onnxruntime-linux-x64-1.14.0 make ``` - -[//]: # (### The structure of a qualified onnxruntime package.) - -[//]: # (```) - -[//]: # (onnxruntime_xxx) - -[//]: # (├───include) - -[//]: # (└───lib) - -[//]: # (```) - -## Building for Windows - -Ref to win/ - - ## Run the demo ```shell -funasr-onnx-offline /path/models_dir /path/wave_file quantize(true or false) use_vad(true or false) use_punc(true or false) -``` +./funasr-onnx-offline [--wav-scp ] [--wav-path ] + [--punc-config ] [--punc-model ] + --am-config --am-cmvn + --am-model [--vad-config ] + [--vad-cmvn ] [--vad-model ] [--] + [--version] [-h] +Where: + --wav-scp + wave scp path + --wav-path + wave file path -The structure of /path/models_dir -``` -config.yaml, am.mvn, model.onnx(or model_quant.onnx), (vad_model.onnx, vad.mvn if you use vad), (punc_model.onnx, punc.yaml if you use vad) -``` + --punc-config + punc config path + --punc-model + punc model path + --am-config + (required) am config path + --am-cmvn + (required) am cmvn path + --am-model + (required) am model path + + --vad-config + vad config path + --vad-cmvn + vad cmvn path + --vad-model + vad model path + + Required: --am-config --am-cmvn --am-model + If use vad, please add: [--vad-config ] [--vad-cmvn ] [--vad-model ] + If use punc, please add: [--punc-config ] [--punc-model ] +``` ## Acknowledge 1. This project is maintained by [FunASR community](https://github.com/alibaba-damo-academy/FunASR). diff --git a/funasr/runtime/onnxruntime/src/CMakeLists.txt b/funasr/runtime/onnxruntime/src/CMakeLists.txt index e00edc1a8..28a67b4be 100644 --- a/funasr/runtime/onnxruntime/src/CMakeLists.txt +++ b/funasr/runtime/onnxruntime/src/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_library(funasr ${files}) if(WIN32) - set(EXTRA_LIBS pthread yaml-cpp csrc) + set(EXTRA_LIBS pthread yaml-cpp csrc glog) if(CMAKE_CL_64) target_link_directories(funasr PUBLIC ${CMAKE_SOURCE_DIR}/win/lib/x64) else() @@ -18,7 +18,7 @@ if(WIN32) target_compile_definitions(funasr PUBLIC -D_FUNASR_API_EXPORT) else() - set(EXTRA_LIBS pthread yaml-cpp csrc) + set(EXTRA_LIBS pthread yaml-cpp csrc glog ) include_directories(${ONNXRUNTIME_DIR}/include) endif() diff --git a/funasr/runtime/onnxruntime/src/audio.cpp b/funasr/runtime/onnxruntime/src/audio.cpp index ef48fa1b6..d104500d1 100644 --- a/funasr/runtime/onnxruntime/src/audio.cpp +++ b/funasr/runtime/onnxruntime/src/audio.cpp @@ -153,8 +153,7 @@ int AudioFrame::GetLen() int AudioFrame::Disp() { - printf("not imp!!!!\n"); - + LOG(ERROR) << "Not imp!!!!"; return 0; }; @@ -187,8 +186,7 @@ Audio::~Audio() void Audio::Disp() { - printf("Audio time is %f s. len is %d\n", (float)speech_len / MODEL_SAMPLE_RATE, - speech_len); + LOG(INFO) << "Audio time is " << (float)speech_len / MODEL_SAMPLE_RATE << " s. len is " << speech_len; } float Audio::GetTimeLen() @@ -199,19 +197,15 @@ float Audio::GetTimeLen() void Audio::WavResample(int32_t sampling_rate, const float *waveform, int32_t n) { - printf( - "Creating a resampler:\n" - " in_sample_rate: %d\n" - " output_sample_rate: %d\n", - sampling_rate, static_cast(MODEL_SAMPLE_RATE)); + LOG(INFO) << "Creating a resampler:\n" + << " in_sample_rate: "<< sampling_rate << "\n" + << " output_sample_rate: " << static_cast(MODEL_SAMPLE_RATE); float min_freq = std::min(sampling_rate, MODEL_SAMPLE_RATE); float lowpass_cutoff = 0.99 * 0.5 * min_freq; int32_t lowpass_filter_width = 6; - //FIXME - //auto resampler = new LinearResample( - // sampling_rate, model_sample_rate, lowpass_cutoff, lowpass_filter_width); + auto resampler = std::make_unique( sampling_rate, MODEL_SAMPLE_RATE, lowpass_cutoff, lowpass_filter_width); std::vector samples; @@ -240,7 +234,7 @@ bool Audio::LoadWav(const char *filename, int32_t* sampling_rate) std::ifstream is(filename, std::ifstream::binary); is.read(reinterpret_cast(&header), sizeof(header)); if(!is){ - fprintf(stderr, "Failed to read %s\n", filename); + LOG(ERROR) << "Failed to read " << filename; return false; } @@ -255,7 +249,7 @@ bool Audio::LoadWav(const char *filename, int32_t* sampling_rate) memset(speech_buff, 0, sizeof(int16_t) * speech_len); is.read(reinterpret_cast(speech_buff), header.subchunk2_size); if (!is) { - fprintf(stderr, "Failed to read %s\n", filename); + LOG(ERROR) << "Failed to read " << filename; return false; } speech_data = (float*)malloc(sizeof(float) * speech_len); @@ -386,6 +380,7 @@ bool Audio::LoadPcmwav(const char* filename, int32_t* sampling_rate) FILE* fp; fp = fopen(filename, "rb"); if (fp == nullptr) + LOG(ERROR) << "Failed to read " << filename; return false; fseek(fp, 0, SEEK_END); uint32_t n_file_len = ftell(fp); diff --git a/funasr/runtime/onnxruntime/src/ct-transformer.cpp b/funasr/runtime/onnxruntime/src/ct-transformer.cpp index 3d66dcd97..ecde636ab 100644 --- a/funasr/runtime/onnxruntime/src/ct-transformer.cpp +++ b/funasr/runtime/onnxruntime/src/ct-transformer.cpp @@ -1,28 +1,28 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + #include "precomp.h" -CTTransformer::CTTransformer(const char* sz_model_dir, int thread_num) +CTTransformer::CTTransformer() :env_(ORT_LOGGING_LEVEL_ERROR, ""),session_options{} { +} + +void CTTransformer::InitPunc(const std::string &punc_model, const std::string &punc_config, int thread_num){ session_options.SetIntraOpNumThreads(thread_num); session_options.SetGraphOptimizationLevel(ORT_ENABLE_ALL); session_options.DisableCpuMemArena(); - string strModelPath = PathAppend(sz_model_dir, PUNC_MODEL_FILE); - string strYamlPath = PathAppend(sz_model_dir, PUNC_YAML_FILE); - try{ -#ifdef _WIN32 - std::wstring detPath = strToWstr(strModelPath); - m_session = std::make_unique(env_, detPath.c_str(), session_options); -#else - m_session = std::make_unique(env_, strModelPath.c_str(), session_options); -#endif + m_session = std::make_unique(env_, punc_model.c_str(), session_options); } - catch(exception e) - { - printf(e.what()); + catch (std::exception const &e) { + LOG(ERROR) << "Error when load punc onnx model: " << e.what(); + exit(0); } - // read inputnames outputnamess + // read inputnames outputnames string strName; GetInputName(m_session.get(), strName); m_strInputNames.push_back(strName.c_str()); @@ -37,7 +37,7 @@ CTTransformer::CTTransformer(const char* sz_model_dir, int thread_num) for (auto& item : m_strOutputNames) m_szOutputNames.push_back(item.c_str()); - m_tokenizer.OpenYaml(strYamlPath.c_str()); + m_tokenizer.OpenYaml(punc_config.c_str()); } CTTransformer::~CTTransformer() @@ -179,10 +179,9 @@ vector CTTransformer::Infer(vector input_data) } catch (std::exception const &e) { - printf(e.what()); + LOG(ERROR) << "Error when run punc onnx forword: " << (e.what()); + exit(0); } return punction; } - - diff --git a/funasr/runtime/onnxruntime/src/ct-transformer.h b/funasr/runtime/onnxruntime/src/ct-transformer.h index 77972c73e..d965bb33a 100644 --- a/funasr/runtime/onnxruntime/src/ct-transformer.h +++ b/funasr/runtime/onnxruntime/src/ct-transformer.h @@ -1,3 +1,8 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + #pragma once class CTTransformer { @@ -19,7 +24,8 @@ private: Ort::SessionOptions session_options; public: - CTTransformer(const char* sz_model_dir, int thread_num); + CTTransformer(); + void InitPunc(const std::string &punc_model, const std::string &punc_config, int thread_num); ~CTTransformer(); vector Infer(vector input_data); string AddPunc(const char* sz_input); diff --git a/funasr/runtime/onnxruntime/src/e2e-vad.h b/funasr/runtime/onnxruntime/src/e2e-vad.h index e029dc35f..90f2635f6 100644 --- a/funasr/runtime/onnxruntime/src/e2e-vad.h +++ b/funasr/runtime/onnxruntime/src/e2e-vad.h @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #include #include diff --git a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp index 0f87cb2f1..fbb682b69 100644 --- a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp +++ b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp @@ -1,43 +1,63 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #include #include "precomp.h" -//#include "glog/logging.h" - -void FsmnVad::InitVad(const std::string &vad_model, const std::string &vad_cmvn, int vad_sample_rate, int vad_silence_duration, int vad_max_len, - float vad_speech_noise_thres) { +void FsmnVad::InitVad(const std::string &vad_model, const std::string &vad_cmvn, const std::string &vad_config) { session_options_.SetIntraOpNumThreads(1); session_options_.SetGraphOptimizationLevel(ORT_ENABLE_ALL); session_options_.DisableCpuMemArena(); - this->vad_sample_rate_ = vad_sample_rate; - this->vad_silence_duration_=vad_silence_duration; - this->vad_max_len_=vad_max_len; - this->vad_speech_noise_thres_=vad_speech_noise_thres; - ReadModel(vad_model); + ReadModel(vad_model.c_str()); LoadCmvn(vad_cmvn.c_str()); + LoadConfigFromYaml(vad_config.c_str()); InitCache(); - - fbank_opts.frame_opts.dither = 0; - fbank_opts.mel_opts.num_bins = 80; - fbank_opts.frame_opts.samp_freq = vad_sample_rate; - fbank_opts.frame_opts.window_type = "hamming"; - fbank_opts.frame_opts.frame_shift_ms = 10; - fbank_opts.frame_opts.frame_length_ms = 25; - fbank_opts.energy_floor = 0; - fbank_opts.mel_opts.debug_mel = false; - } -void FsmnVad::ReadModel(const std::string &vad_model) { +void FsmnVad::LoadConfigFromYaml(const char* filename){ + + YAML::Node config; + try{ + config = YAML::LoadFile(filename); + }catch(exception const &e){ + LOG(ERROR) << "Error loading file, yaml file error or not exist."; + exit(-1); + } + + try{ + YAML::Node frontend_conf = config["frontend_conf"]; + YAML::Node post_conf = config["vad_post_conf"]; + + this->vad_sample_rate_ = frontend_conf["fs"].as(); + this->vad_silence_duration_ = post_conf["max_end_silence_time"].as(); + this->vad_max_len_ = post_conf["max_single_segment_time"].as(); + this->vad_speech_noise_thres_ = post_conf["speech_noise_thres"].as(); + + fbank_opts.frame_opts.dither = frontend_conf["dither"].as(); + fbank_opts.mel_opts.num_bins = frontend_conf["n_mels"].as(); + fbank_opts.frame_opts.samp_freq = (float)vad_sample_rate_; + fbank_opts.frame_opts.window_type = frontend_conf["window"].as(); + fbank_opts.frame_opts.frame_shift_ms = frontend_conf["frame_shift"].as(); + fbank_opts.frame_opts.frame_length_ms = frontend_conf["frame_length"].as(); + fbank_opts.energy_floor = 0; + fbank_opts.mel_opts.debug_mel = false; + }catch(exception const &e){ + LOG(ERROR) << "Error when load argument from vad config YAML."; + exit(-1); + } +} + +void FsmnVad::ReadModel(const char* vad_model) { try { vad_session_ = std::make_shared( - env_, vad_model.c_str(), session_options_); + env_, vad_model, session_options_); } catch (std::exception const &e) { - //LOG(ERROR) << "Error when load onnx model: " << e.what(); + LOG(ERROR) << "Error when load vad onnx model: " << e.what(); exit(0); } - //LOG(INFO) << "vad onnx:"; GetInputOutputInfo(vad_session_, &vad_in_names_, &vad_out_names_); } @@ -119,13 +139,12 @@ void FsmnVad::Forward( // 4. Onnx infer std::vector vad_ort_outputs; try { - // VLOG(3) << "Start infer"; vad_ort_outputs = vad_session_->Run( Ort::RunOptions{nullptr}, vad_in_names_.data(), vad_inputs.data(), vad_inputs.size(), vad_out_names_.data(), vad_out_names_.size()); } catch (std::exception const &e) { - // LOG(ERROR) << e.what(); - return; + LOG(ERROR) << "Error when run vad onnx forword: " << (e.what()); + exit(0); } // 5. Change infer result to output shapes @@ -163,40 +182,49 @@ void FsmnVad::FbankKaldi(float sample_rate, std::vector> &vad void FsmnVad::LoadCmvn(const char *filename) { - using namespace std; - ifstream cmvn_stream(filename); - string line; + try{ + using namespace std; + ifstream cmvn_stream(filename); + if (!cmvn_stream.is_open()) { + LOG(ERROR) << "Failed to open file: " << filename; + exit(0); + } + string line; - while (getline(cmvn_stream, line)) { - istringstream iss(line); - vector line_item{istream_iterator{iss}, istream_iterator{}}; - if (line_item[0] == "") { - getline(cmvn_stream, line); - istringstream means_lines_stream(line); - vector means_lines{istream_iterator{means_lines_stream}, istream_iterator{}}; - if (means_lines[0] == "") { - for (int j = 3; j < means_lines.size() - 1; j++) { - means_list.push_back(stof(means_lines[j])); + while (getline(cmvn_stream, line)) { + istringstream iss(line); + vector line_item{istream_iterator{iss}, istream_iterator{}}; + if (line_item[0] == "") { + getline(cmvn_stream, line); + istringstream means_lines_stream(line); + vector means_lines{istream_iterator{means_lines_stream}, istream_iterator{}}; + if (means_lines[0] == "") { + for (int j = 3; j < means_lines.size() - 1; j++) { + means_list.push_back(stof(means_lines[j])); + } + continue; + } + } + else if (line_item[0] == "") { + getline(cmvn_stream, line); + istringstream vars_lines_stream(line); + vector vars_lines{istream_iterator{vars_lines_stream}, istream_iterator{}}; + if (vars_lines[0] == "") { + for (int j = 3; j < vars_lines.size() - 1; j++) { + // vars_list.push_back(stof(vars_lines[j])*scale); + vars_list.push_back(stof(vars_lines[j])); + } + continue; } - continue; - } - } - else if (line_item[0] == "") { - getline(cmvn_stream, line); - istringstream vars_lines_stream(line); - vector vars_lines{istream_iterator{vars_lines_stream}, istream_iterator{}}; - if (vars_lines[0] == "") { - for (int j = 3; j < vars_lines.size() - 1; j++) { - // vars_list.push_back(stof(vars_lines[j])*scale); - vars_list.push_back(stof(vars_lines[j])); - } - continue; } } + }catch(std::exception const &e) { + LOG(ERROR) << "Error when load vad cmvn : " << e.what(); + exit(0); } } -std::vector> &FsmnVad::LfrCmvn(std::vector> &vad_feats, int lfr_m, int lfr_n) { +std::vector> &FsmnVad::LfrCmvn(std::vector> &vad_feats) { std::vector> out_feats; int T = vad_feats.size(); @@ -243,7 +271,7 @@ FsmnVad::Infer(const std::vector &waves) { std::vector> vad_feats; std::vector> vad_probs; FbankKaldi(vad_sample_rate_, vad_feats, waves); - vad_feats = LfrCmvn(vad_feats, 5, 1); + vad_feats = LfrCmvn(vad_feats); Forward(vad_feats, &vad_probs); E2EVadModel vad_scorer = E2EVadModel(); @@ -251,7 +279,6 @@ FsmnVad::Infer(const std::vector &waves) { vad_segments = vad_scorer(vad_probs, waves, true, false, vad_silence_duration_, vad_max_len_, vad_speech_noise_thres_, vad_sample_rate_); return vad_segments; - } void FsmnVad::InitCache(){ diff --git a/funasr/runtime/onnxruntime/src/fsmn-vad.h b/funasr/runtime/onnxruntime/src/fsmn-vad.h index e8569f93c..1d5f68c56 100644 --- a/funasr/runtime/onnxruntime/src/fsmn-vad.h +++ b/funasr/runtime/onnxruntime/src/fsmn-vad.h @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #ifndef VAD_SERVER_FSMNVAD_H #define VAD_SERVER_FSMNVAD_H @@ -14,15 +18,15 @@ class FsmnVad { public: FsmnVad(); void Test(); - void InitVad(const std::string &vad_model, const std::string &vad_cmvn, int vad_sample_rate, int vad_silence_duration, int vad_max_len, - float vad_speech_noise_thres); + void InitVad(const std::string &vad_model, const std::string &vad_cmvn, const std::string &vad_config); std::vector> Infer(const std::vector &waves); void Reset(); private: - void ReadModel(const std::string &vad_model); + void ReadModel(const char* vad_model); + void LoadConfigFromYaml(const char* filename); static void GetInputOutputInfo( const std::shared_ptr &session, @@ -31,7 +35,7 @@ private: void FbankKaldi(float sample_rate, std::vector> &vad_feats, const std::vector &waves); - std::vector> &LfrCmvn(std::vector> &vad_feats, int lfr_m, int lfr_n); + std::vector> &LfrCmvn(std::vector> &vad_feats); void Forward( const std::vector> &chunk_feats, @@ -50,10 +54,13 @@ private: knf::FbankOptions fbank_opts; std::vector means_list; std::vector vars_list; - int vad_sample_rate_ = 16000; - int vad_silence_duration_ = 800; - int vad_max_len_ = 15000; - double vad_speech_noise_thres_ = 0.9; + + int vad_sample_rate_ = MODEL_SAMPLE_RATE; + int vad_silence_duration_ = VAD_SILENCE_DURATION; + int vad_max_len_ = VAD_MAX_LEN; + double vad_speech_noise_thres_ = VAD_SPEECH_NOISE_THRES; + int lfr_m = VAD_LFR_M; + int lfr_n = VAD_LFR_N; }; diff --git a/funasr/runtime/onnxruntime/src/funasr-onnx-offline-rtf.cpp b/funasr/runtime/onnxruntime/src/funasr-onnx-offline-rtf.cpp index 1d822a0f2..45b6196a2 100644 --- a/funasr/runtime/onnxruntime/src/funasr-onnx-offline-rtf.cpp +++ b/funasr/runtime/onnxruntime/src/funasr-onnx-offline-rtf.cpp @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #ifndef _WIN32 #include @@ -5,7 +9,10 @@ #include #endif +#include #include "libfunasrapi.h" +#include "tclap/CmdLine.h" +#include "com-define.h" #include #include @@ -14,9 +21,11 @@ #include #include #include +#include + using namespace std; -std::atomic index(0); +std::atomic wav_index(0); std::mutex mtx; void runReg(FUNASR_HANDLE asr_handle, vector wav_list, @@ -35,7 +44,7 @@ void runReg(FUNASR_HANDLE asr_handle, vector wav_list, while (true) { // 使用原子变量获取索引并递增 - int i = index.fetch_add(1); + int i = wav_index.fetch_add(1); if (i >= wav_list.size()) { break; } @@ -50,13 +59,13 @@ void runReg(FUNASR_HANDLE asr_handle, vector wav_list, if(result){ string msg = FunASRGetResult(result, 0); - printf("Thread: %d Result: %s \n", this_thread::get_id(), msg.c_str()); + LOG(INFO) << "Thread: " << this_thread::get_id() <<" Result: " << msg.c_str(); float snippet_time = FunASRGetRetSnippetTime(result); n_total_length += snippet_time; FunASRFreeResult(result); }else{ - cout <<"No return data!"; + LOG(ERROR) << ("No return data!\n"); } } { @@ -68,59 +77,98 @@ void runReg(FUNASR_HANDLE asr_handle, vector wav_list, } } +void GetValue(TCLAP::ValueArg& value_arg, string key, std::map& model_path) +{ + if (value_arg.isSet()){ + model_path.insert({key, value_arg.getValue()}); + LOG(INFO)<< key << " : " << value_arg.getValue(); + } +} + int main(int argc, char *argv[]) { + google::InitGoogleLogging(argv[0]); + FLAGS_logtostderr = true; - if (argc < 5) - { - printf("Usage: %s /path/to/model_dir /path/to/wav.scp quantize(true or false) thread_num \n", argv[0]); - exit(-1); - } + TCLAP::CmdLine cmd("funasr-onnx-offline-rtf", ' ', "1.0"); + TCLAP::ValueArg vad_model("", VAD_MODEL_PATH, "vad model path", false, "", "string"); + TCLAP::ValueArg vad_cmvn("", VAD_CMVN_PATH, "vad cmvn path", false, "", "string"); + TCLAP::ValueArg vad_config("", VAD_CONFIG_PATH, "vad config path", false, "", "string"); - // read wav.scp - vector wav_list; - ifstream in(argv[2]); - if (!in.is_open()) { - printf("Failed to open file: %s", argv[2]); - return 0; - } - string line; - while(getline(in, line)) - { - istringstream iss(line); - string column1, column2; - iss >> column1 >> column2; - wav_list.push_back(column2); - } - in.close(); + TCLAP::ValueArg am_model("", AM_MODEL_PATH, "am model path", false, "", "string"); + TCLAP::ValueArg am_cmvn("", AM_CMVN_PATH, "am cmvn path", false, "", "string"); + TCLAP::ValueArg am_config("", AM_CONFIG_PATH, "am config path", false, "", "string"); + + TCLAP::ValueArg punc_model("", PUNC_MODEL_PATH, "punc model path", false, "", "string"); + TCLAP::ValueArg punc_config("", PUNC_CONFIG_PATH, "punc config path", false, "", "string"); + + TCLAP::ValueArg wav_scp("", WAV_SCP, "wave scp path", true, "", "string"); + TCLAP::ValueArg thread_num("", THREAD_NUM, "multi-thread num for rtf", true, 0, "int32_t"); + + cmd.add(vad_model); + cmd.add(vad_cmvn); + cmd.add(vad_config); + cmd.add(am_model); + cmd.add(am_cmvn); + cmd.add(am_config); + cmd.add(punc_model); + cmd.add(punc_config); + cmd.add(wav_scp); + cmd.add(thread_num); + cmd.parse(argc, argv); + + std::map model_path; + GetValue(vad_model, VAD_MODEL_PATH, model_path); + GetValue(vad_cmvn, VAD_CMVN_PATH, model_path); + GetValue(vad_config, VAD_CONFIG_PATH, model_path); + GetValue(am_model, AM_MODEL_PATH, model_path); + GetValue(am_cmvn, AM_CMVN_PATH, model_path); + GetValue(am_config, AM_CONFIG_PATH, model_path); + GetValue(punc_model, PUNC_MODEL_PATH, model_path); + GetValue(punc_config, PUNC_CONFIG_PATH, model_path); + GetValue(wav_scp, WAV_SCP, model_path); - // model init struct timeval start, end; gettimeofday(&start, NULL); - // is quantize - bool quantize = false; - istringstream(argv[3]) >> boolalpha >> quantize; - // thread num - int thread_num = 1; - thread_num = atoi(argv[4]); + FUNASR_HANDLE asr_handle=FunASRInit(model_path, 1); - FUNASR_HANDLE asr_handle=FunASRInit(argv[1], 1, quantize); if (!asr_handle) { - printf("Cannot load ASR Model from: %s, there must be files model.onnx and vocab.txt", argv[1]); + LOG(ERROR) << "FunASR init failed"; exit(-1); } + gettimeofday(&end, NULL); long seconds = (end.tv_sec - start.tv_sec); long modle_init_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); - printf("Model initialization takes %lfs.\n", (double)modle_init_micros / 1000000); + LOG(INFO) << "Model initialization takes " << (double)modle_init_micros / 1000000 << " s"; + + // read wav_scp + vector wav_list; + if(model_path.find(WAV_SCP)!=model_path.end()){ + ifstream in(model_path.at(WAV_SCP)); + if (!in.is_open()) { + LOG(ERROR) << "Failed to open file: " << model_path.at(WAV_SCP); + return 0; + } + string line; + while(getline(in, line)) + { + istringstream iss(line); + string column1, column2; + iss >> column1 >> column2; + wav_list.emplace_back(column2); + } + in.close(); + } // 多线程测试 float total_length = 0.0f; long total_time = 0; std::vector threads; - for (int i = 0; i < thread_num; i++) + int rtf_threds = thread_num.getValue(); + for (int i = 0; i < rtf_threds; i++) { threads.emplace_back(thread(runReg, asr_handle, wav_list, &total_length, &total_time, i)); } @@ -130,10 +178,10 @@ int main(int argc, char *argv[]) thread.join(); } - printf("total_time_wav %ld ms.\n", (long)(total_length * 1000)); - printf("total_time_comput %ld ms.\n", total_time / 1000); - printf("total_rtf %05lf .\n", (double)total_time/ (total_length*1000000)); - printf("speedup %05lf .\n", 1.0/((double)total_time/ (total_length*1000000))); + LOG(INFO) << "total_time_wav " << (long)(total_length * 1000) << " ms"; + LOG(INFO) << "total_time_comput " << total_time / 1000 << " ms"; + LOG(INFO) << "total_rtf " << (double)total_time/ (total_length*1000000); + LOG(INFO) << "speedup " << 1.0/((double)total_time/ (total_length*1000000)); FunASRUninit(asr_handle); return 0; diff --git a/funasr/runtime/onnxruntime/src/funasr-onnx-offline.cpp b/funasr/runtime/onnxruntime/src/funasr-onnx-offline.cpp index b0d2e4d8a..2d61bbb30 100644 --- a/funasr/runtime/onnxruntime/src/funasr-onnx-offline.cpp +++ b/funasr/runtime/onnxruntime/src/funasr-onnx-offline.cpp @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #ifndef _WIN32 #include @@ -5,67 +9,136 @@ #include #endif -#include "libfunasrapi.h" +#include +#include #include +#include +#include +#include "libfunasrapi.h" +#include "tclap/CmdLine.h" +#include "com-define.h" + using namespace std; +void GetValue(TCLAP::ValueArg& value_arg, string key, std::map& model_path) +{ + if (value_arg.isSet()){ + model_path.insert({key, value_arg.getValue()}); + LOG(INFO)<< key << " : " << value_arg.getValue(); + } +} + int main(int argc, char *argv[]) { - if (argc < 6) - { - printf("Usage: %s /path/to/model_dir /path/to/wav/file quantize(true or false) use_vad(true or false) use_punc(true or false)\n", argv[0]); - exit(-1); - } + google::InitGoogleLogging(argv[0]); + FLAGS_logtostderr = true; + + TCLAP::CmdLine cmd("funasr-onnx-offline", ' ', "1.0"); + TCLAP::ValueArg vad_model("", VAD_MODEL_PATH, "vad model path", false, "", "string"); + TCLAP::ValueArg vad_cmvn("", VAD_CMVN_PATH, "vad cmvn path", false, "", "string"); + TCLAP::ValueArg vad_config("", VAD_CONFIG_PATH, "vad config path", false, "", "string"); + + TCLAP::ValueArg am_model("", AM_MODEL_PATH, "am model path", true, "", "string"); + TCLAP::ValueArg am_cmvn("", AM_CMVN_PATH, "am cmvn path", true, "", "string"); + TCLAP::ValueArg am_config("", AM_CONFIG_PATH, "am config path", true, "", "string"); + + TCLAP::ValueArg punc_model("", PUNC_MODEL_PATH, "punc model path", false, "", "string"); + TCLAP::ValueArg punc_config("", PUNC_CONFIG_PATH, "punc config path", false, "", "string"); + + TCLAP::ValueArg wav_path("", WAV_PATH, "wave file path", false, "", "string"); + TCLAP::ValueArg wav_scp("", WAV_SCP, "wave scp path", false, "", "string"); + + cmd.add(vad_model); + cmd.add(vad_cmvn); + cmd.add(vad_config); + cmd.add(am_model); + cmd.add(am_cmvn); + cmd.add(am_config); + cmd.add(punc_model); + cmd.add(punc_config); + cmd.add(wav_path); + cmd.add(wav_scp); + cmd.parse(argc, argv); + + std::map model_path; + GetValue(vad_model, VAD_MODEL_PATH, model_path); + GetValue(vad_cmvn, VAD_CMVN_PATH, model_path); + GetValue(vad_config, VAD_CONFIG_PATH, model_path); + GetValue(am_model, AM_MODEL_PATH, model_path); + GetValue(am_cmvn, AM_CMVN_PATH, model_path); + GetValue(am_config, AM_CONFIG_PATH, model_path); + GetValue(punc_model, PUNC_MODEL_PATH, model_path); + GetValue(punc_config, PUNC_CONFIG_PATH, model_path); + GetValue(wav_path, WAV_PATH, model_path); + GetValue(wav_scp, WAV_SCP, model_path); + + struct timeval start, end; gettimeofday(&start, NULL); int thread_num = 1; - // is quantize - bool quantize = false; - bool use_vad = false; - bool use_punc = false; - istringstream(argv[3]) >> boolalpha >> quantize; - istringstream(argv[4]) >> boolalpha >> use_vad; - istringstream(argv[5]) >> boolalpha >> use_punc; - FUNASR_HANDLE asr_hanlde=FunASRInit(argv[1], thread_num, quantize, use_vad, use_punc); + FUNASR_HANDLE asr_hanlde=FunASRInit(model_path, thread_num); if (!asr_hanlde) { - printf("Cannot load ASR Model from: %s, there must be files model.onnx and vocab.txt", argv[1]); + LOG(ERROR) << "FunASR init failed"; exit(-1); } gettimeofday(&end, NULL); long seconds = (end.tv_sec - start.tv_sec); long modle_init_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); - printf("Model initialization takes %lfs.\n", (double)modle_init_micros / 1000000); + LOG(INFO) << "Model initialization takes " << (double)modle_init_micros / 1000000 << " s"; - gettimeofday(&start, NULL); - FUNASR_RESULT result=FunASRRecogFile(asr_hanlde, argv[2], RASR_NONE, NULL, use_vad, use_punc); - gettimeofday(&end, NULL); + // read wav_path and wav_scp + vector wav_list; - float snippet_time = 0.0f; - if (result) - { - string msg = FunASRGetResult(result, 0); - setbuf(stdout, NULL); - printf("Result: %s \n", msg.c_str()); - snippet_time = FunASRGetRetSnippetTime(result); - FunASRFreeResult(result); + if(model_path.find(WAV_PATH)!=model_path.end()){ + wav_list.emplace_back(model_path.at(WAV_PATH)); } - else - { - printf("no return data!\n"); + if(model_path.find(WAV_SCP)!=model_path.end()){ + ifstream in(model_path.at(WAV_SCP)); + if (!in.is_open()) { + LOG(ERROR) << "Failed to open file: " << model_path.at(WAV_SCP) ; + return 0; + } + string line; + while(getline(in, line)) + { + istringstream iss(line); + string column1, column2; + iss >> column1 >> column2; + wav_list.emplace_back(column2); + } + in.close(); + } + + float snippet_time = 0.0f; + long taking_micros = 0; + for(auto& wav_file : wav_list){ + gettimeofday(&start, NULL); + FUNASR_RESULT result=FunASRRecogFile(asr_hanlde, wav_file.c_str(), RASR_NONE, NULL); + gettimeofday(&end, NULL); + seconds = (end.tv_sec - start.tv_sec); + taking_micros += ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + if (result) + { + string msg = FunASRGetResult(result, 0); + setbuf(stdout, NULL); + printf("Result: %s \n", msg.c_str()); + snippet_time += FunASRGetRetSnippetTime(result); + FunASRFreeResult(result); + } + else + { + LOG(ERROR) << ("No return data!\n"); + } } - printf("Audio length %lfs.\n", (double)snippet_time); - seconds = (end.tv_sec - start.tv_sec); - long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); - printf("Model inference takes %lfs.\n", (double)taking_micros / 1000000); - printf("Model inference RTF: %04lf.\n", (double)taking_micros/ (snippet_time*1000000)); - + LOG(INFO) << "Audio length: " << (double)snippet_time << " s"; + LOG(INFO) << "Model inference takes: " << (double)taking_micros / 1000000 <<" s"; + LOG(INFO) << "Model inference RTF: " << (double)taking_micros/ (snippet_time*1000000); FunASRUninit(asr_hanlde); - return 0; } - diff --git a/funasr/runtime/onnxruntime/src/libfunasrapi.cpp b/funasr/runtime/onnxruntime/src/libfunasrapi.cpp index 10c061eb1..93434bb73 100644 --- a/funasr/runtime/onnxruntime/src/libfunasrapi.cpp +++ b/funasr/runtime/onnxruntime/src/libfunasrapi.cpp @@ -5,13 +5,13 @@ extern "C" { #endif // APIs for funasr - _FUNASRAPI FUNASR_HANDLE FunASRInit(const char* sz_model_dir, int thread_num, bool quantize, bool use_vad, bool use_punc) + _FUNASRAPI FUNASR_HANDLE FunASRInit(std::map& model_path, int thread_num) { - Model* mm = CreateModel(sz_model_dir, thread_num, quantize, use_vad, use_punc); + Model* mm = CreateModel(model_path, thread_num); return mm; } - _FUNASRAPI FUNASR_RESULT FunASRRecogBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad, bool use_punc) + _FUNASRAPI FUNASR_RESULT FunASRRecogBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, FUNASR_MODE mode, QM_CALLBACK fn_callback) { Model* recog_obj = (Model*)handle; if (!recog_obj) @@ -21,7 +21,7 @@ extern "C" { Audio audio(1); if (!audio.LoadWav(sz_buf, n_len, &sampling_rate)) return nullptr; - if(use_vad){ + if(recog_obj->UseVad()){ audio.Split(recog_obj); } @@ -39,7 +39,7 @@ extern "C" { if (fn_callback) fn_callback(n_step, n_total); } - if(use_punc){ + if(recog_obj->UsePunc()){ string punc_res = recog_obj->AddPunc((p_result->msg).c_str()); p_result->msg = punc_res; } @@ -47,7 +47,7 @@ extern "C" { return p_result; } - _FUNASRAPI FUNASR_RESULT FunASRRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad, bool use_punc) + _FUNASRAPI FUNASR_RESULT FunASRRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback) { Model* recog_obj = (Model*)handle; if (!recog_obj) @@ -56,7 +56,7 @@ extern "C" { Audio audio(1); if (!audio.LoadPcmwav(sz_buf, n_len, &sampling_rate)) return nullptr; - if(use_vad){ + if(recog_obj->UseVad()){ audio.Split(recog_obj); } @@ -74,7 +74,7 @@ extern "C" { if (fn_callback) fn_callback(n_step, n_total); } - if(use_punc){ + if(recog_obj->UsePunc()){ string punc_res = recog_obj->AddPunc((p_result->msg).c_str()); p_result->msg = punc_res; } @@ -82,7 +82,7 @@ extern "C" { return p_result; } - _FUNASRAPI FUNASR_RESULT FunASRRecogPCMFile(FUNASR_HANDLE handle, const char* sz_filename, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad, bool use_punc) + _FUNASRAPI FUNASR_RESULT FunASRRecogPCMFile(FUNASR_HANDLE handle, const char* sz_filename, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback) { Model* recog_obj = (Model*)handle; if (!recog_obj) @@ -91,7 +91,7 @@ extern "C" { Audio audio(1); if (!audio.LoadPcmwav(sz_filename, &sampling_rate)) return nullptr; - if(use_vad){ + if(recog_obj->UseVad()){ audio.Split(recog_obj); } @@ -109,7 +109,7 @@ extern "C" { if (fn_callback) fn_callback(n_step, n_total); } - if(use_punc){ + if(recog_obj->UsePunc()){ string punc_res = recog_obj->AddPunc((p_result->msg).c_str()); p_result->msg = punc_res; } @@ -117,7 +117,7 @@ extern "C" { return p_result; } - _FUNASRAPI FUNASR_RESULT FunASRRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback, bool use_vad, bool use_punc) + _FUNASRAPI FUNASR_RESULT FunASRRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback) { Model* recog_obj = (Model*)handle; if (!recog_obj) @@ -127,7 +127,7 @@ extern "C" { Audio audio(1); if(!audio.LoadWav(sz_wavfile, &sampling_rate)) return nullptr; - if(use_vad){ + if(recog_obj->UseVad()){ audio.Split(recog_obj); } @@ -145,7 +145,7 @@ extern "C" { if (fn_callback) fn_callback(n_step, n_total); } - if(use_punc){ + if(recog_obj->UsePunc()){ string punc_res = recog_obj->AddPunc((p_result->msg).c_str()); p_result->msg = punc_res; } diff --git a/funasr/runtime/onnxruntime/src/model.cpp b/funasr/runtime/onnxruntime/src/model.cpp index a582f829e..52ce7ba7c 100644 --- a/funasr/runtime/onnxruntime/src/model.cpp +++ b/funasr/runtime/onnxruntime/src/model.cpp @@ -1,8 +1,8 @@ #include "precomp.h" -Model *CreateModel(const char *path, int thread_num, bool quantize, bool use_vad, bool use_punc) +Model *CreateModel(std::map& model_path, int thread_num) { Model *mm; - mm = new paraformer::Paraformer(path, thread_num, quantize, use_vad, use_punc); + mm = new paraformer::Paraformer(model_path, thread_num); return mm; } diff --git a/funasr/runtime/onnxruntime/src/online-feature.cpp b/funasr/runtime/onnxruntime/src/online-feature.cpp index 36e27700e..3f57e0b9d 100644 --- a/funasr/runtime/onnxruntime/src/online-feature.cpp +++ b/funasr/runtime/onnxruntime/src/online-feature.cpp @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #include "online-feature.h" #include diff --git a/funasr/runtime/onnxruntime/src/online-feature.h b/funasr/runtime/onnxruntime/src/online-feature.h index 78245de52..decaaf4e7 100644 --- a/funasr/runtime/onnxruntime/src/online-feature.h +++ b/funasr/runtime/onnxruntime/src/online-feature.h @@ -1,3 +1,7 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ #include #include "precomp.h" diff --git a/funasr/runtime/onnxruntime/src/paraformer.cpp b/funasr/runtime/onnxruntime/src/paraformer.cpp index 72127f8be..136d22808 100644 --- a/funasr/runtime/onnxruntime/src/paraformer.cpp +++ b/funasr/runtime/onnxruntime/src/paraformer.cpp @@ -1,36 +1,72 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + #include "precomp.h" using namespace std; using namespace paraformer; -Paraformer::Paraformer(const char* path,int thread_num, bool quantize, bool use_vad, bool use_punc) +Paraformer::Paraformer(std::map& model_path,int thread_num) :env_(ORT_LOGGING_LEVEL_ERROR, "paraformer"),session_options{}{ - string model_path; - string cmvn_path; - string config_path; // VAD model - if(use_vad){ - string vad_path = PathAppend(path, "vad_model.onnx"); - string mvn_path = PathAppend(path, "vad.mvn"); + if(model_path.find(VAD_MODEL_PATH) != model_path.end()){ + use_vad = true; + string vad_model_path; + string vad_cmvn_path; + string vad_config_path; + + try{ + vad_model_path = model_path.at(VAD_MODEL_PATH); + vad_cmvn_path = model_path.at(VAD_CMVN_PATH); + vad_config_path = model_path.at(VAD_CONFIG_PATH); + }catch(const out_of_range& e){ + LOG(ERROR) << "Error when read "<< VAD_CMVN_PATH << " or " << VAD_CONFIG_PATH <<" :" << e.what(); + exit(0); + } vad_handle = make_unique(); - vad_handle->InitVad(vad_path, mvn_path, MODEL_SAMPLE_RATE, VAD_MAX_LEN, VAD_SILENCE_DYRATION, VAD_SPEECH_NOISE_THRES); + vad_handle->InitVad(vad_model_path, vad_cmvn_path, vad_config_path); + } + + // AM model + if(model_path.find(AM_MODEL_PATH) != model_path.end()){ + string am_model_path; + string am_cmvn_path; + string am_config_path; + + try{ + am_model_path = model_path.at(AM_MODEL_PATH); + am_cmvn_path = model_path.at(AM_CMVN_PATH); + am_config_path = model_path.at(AM_CONFIG_PATH); + }catch(const out_of_range& e){ + LOG(ERROR) << "Error when read "<< AM_CONFIG_PATH << " or " << AM_CMVN_PATH <<" :" << e.what(); + exit(0); + } + InitAM(am_model_path, am_cmvn_path, am_config_path, thread_num); } // PUNC model - if(use_punc){ - punc_handle = make_unique(path, thread_num); - } + if(model_path.find(PUNC_MODEL_PATH) != model_path.end()){ + use_punc = true; + string punc_model_path; + string punc_config_path; + + try{ + punc_model_path = model_path.at(PUNC_MODEL_PATH); + punc_config_path = model_path.at(PUNC_CONFIG_PATH); + }catch(const out_of_range& e){ + LOG(ERROR) << "Error when read "<< PUNC_CONFIG_PATH <<" :" << e.what(); + exit(0); + } - if(quantize) - { - model_path = PathAppend(path, "model_quant.onnx"); - }else{ - model_path = PathAppend(path, "model.onnx"); + punc_handle = make_unique(); + punc_handle->InitPunc(punc_model_path, punc_config_path, thread_num); } - cmvn_path = PathAppend(path, "am.mvn"); - config_path = PathAppend(path, "config.yaml"); +} +void Paraformer::InitAM(const std::string &am_model, const std::string &am_cmvn, const std::string &am_config, int thread_num){ // knf options fbank_opts.frame_opts.dither = 0; fbank_opts.mel_opts.num_bins = 80; @@ -48,12 +84,12 @@ Paraformer::Paraformer(const char* path,int thread_num, bool quantize, bool use_ // DisableCpuMemArena can improve performance session_options.DisableCpuMemArena(); -#ifdef _WIN32 - wstring wstrPath = strToWstr(model_path); - m_session = std::make_unique(env_, model_path.c_str(), session_options); -#else - m_session = std::make_unique(env_, model_path.c_str(), session_options); -#endif + try { + m_session = std::make_unique(env_, am_model.c_str(), session_options); + } catch (std::exception const &e) { + LOG(ERROR) << "Error when load am onnx model: " << e.what(); + exit(0); + } string strName; GetInputName(m_session.get(), strName); @@ -70,8 +106,8 @@ Paraformer::Paraformer(const char* path,int thread_num, bool quantize, bool use_ m_szInputNames.push_back(item.c_str()); for (auto& item : m_strOutputNames) m_szOutputNames.push_back(item.c_str()); - vocab = new Vocab(config_path.c_str()); - LoadCmvn(cmvn_path.c_str()); + vocab = new Vocab(am_config.c_str()); + LoadCmvn(am_cmvn.c_str()); } Paraformer::~Paraformer() @@ -113,6 +149,10 @@ vector Paraformer::FbankKaldi(float sample_rate, const float* waves, int void Paraformer::LoadCmvn(const char *filename) { ifstream cmvn_stream(filename); + if (!cmvn_stream.is_open()) { + LOG(ERROR) << "Failed to open file: " << filename; + exit(0); + } string line; while (getline(cmvn_stream, line)) { diff --git a/funasr/runtime/onnxruntime/src/paraformer.h b/funasr/runtime/onnxruntime/src/paraformer.h index 53019326c..f3eb0599b 100644 --- a/funasr/runtime/onnxruntime/src/paraformer.h +++ b/funasr/runtime/onnxruntime/src/paraformer.h @@ -1,3 +1,8 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + #pragma once @@ -41,10 +46,13 @@ namespace paraformer { vector m_strInputNames, m_strOutputNames; vector m_szInputNames; vector m_szOutputNames; + bool use_vad=false; + bool use_punc=false; public: - Paraformer(const char* path, int thread_num=0, bool quantize=false, bool use_vad=false, bool use_punc=false); + Paraformer(std::map& model_path, int thread_num=0); ~Paraformer(); + void InitAM(const std::string &am_model, const std::string &am_cmvn, const std::string &am_config, int thread_num); void Reset(); vector FbankKaldi(float sample_rate, const float* waves, int len); string ForwardChunk(float* din, int len, int flag); @@ -52,6 +60,8 @@ namespace paraformer { string Rescoring(); std::vector> VadSeg(std::vector& pcm_data); string AddPunc(const char* sz_input); + bool UseVad(){return use_vad;}; + bool UsePunc(){return use_punc;}; }; } // namespace paraformer diff --git a/funasr/runtime/onnxruntime/src/precomp.h b/funasr/runtime/onnxruntime/src/precomp.h index d567f15a1..cf69ad976 100644 --- a/funasr/runtime/onnxruntime/src/precomp.h +++ b/funasr/runtime/onnxruntime/src/precomp.h @@ -21,10 +21,11 @@ using namespace std; // third part #include "onnxruntime_run_options_config_keys.h" #include "onnxruntime_cxx_api.h" -#include "kaldi-native-fbank/csrc/feature-fbank.h" -#include "kaldi-native-fbank/csrc/online-feature.h" +#include +#include // mine +#include #include "common-struct.h" #include "com-define.h" #include "commonfunc.h" diff --git a/funasr/runtime/onnxruntime/src/tokenizer.cpp b/funasr/runtime/onnxruntime/src/tokenizer.cpp index ef0c53362..5f29b46f0 100644 --- a/funasr/runtime/onnxruntime/src/tokenizer.cpp +++ b/funasr/runtime/onnxruntime/src/tokenizer.cpp @@ -1,4 +1,9 @@ - #include "precomp.h" + /** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + +#include "precomp.h" CTokenizer::CTokenizer(const char* sz_yamlfile):m_ready(false) { @@ -24,15 +29,20 @@ void CTokenizer::ReadYaml(const YAML::Node& node) } } if (node.IsScalar()) {//�DZ����� - cout << node.as() << endl; + LOG(INFO) << node.as(); } } bool CTokenizer::OpenYaml(const char* sz_yamlfile) { - YAML::Node m_Config = YAML::LoadFile(sz_yamlfile); - if (m_Config.IsNull()) - return false; + YAML::Node m_Config; + try{ + m_Config = YAML::LoadFile(sz_yamlfile); + }catch(exception const &e){ + LOG(INFO) << "Error loading file, yaml file error or not exist."; + exit(-1); + } + try { auto Tokens = m_Config["token_list"]; @@ -61,7 +71,7 @@ bool CTokenizer::OpenYaml(const char* sz_yamlfile) } } catch (YAML::BadFile& e) { - std::cout << "read error!" << std::endl; + LOG(ERROR) << "Read error!"; return false; } m_ready = true; diff --git a/funasr/runtime/onnxruntime/src/tokenizer.h b/funasr/runtime/onnxruntime/src/tokenizer.h index 319975ab6..4ff1809cf 100644 --- a/funasr/runtime/onnxruntime/src/tokenizer.h +++ b/funasr/runtime/onnxruntime/src/tokenizer.h @@ -1,5 +1,10 @@ +/** + * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved. + * MIT License (https://opensource.org/licenses/MIT) +*/ + #pragma once -#include "yaml-cpp/yaml.h" +#include class CTokenizer { private: diff --git a/funasr/runtime/onnxruntime/src/vocab.cpp b/funasr/runtime/onnxruntime/src/vocab.cpp index ba041b833..53233b341 100644 --- a/funasr/runtime/onnxruntime/src/vocab.cpp +++ b/funasr/runtime/onnxruntime/src/vocab.cpp @@ -1,5 +1,6 @@ #include "vocab.h" -#include "yaml-cpp/yaml.h" +#include +#include #include #include @@ -22,8 +23,8 @@ void Vocab::LoadVocabFromYaml(const char* filename){ YAML::Node config; try{ config = YAML::LoadFile(filename); - }catch(...){ - printf("error loading file, yaml file error or not exist.\n"); + }catch(exception const &e){ + LOG(INFO) << "Error loading file, yaml file error or not exist."; exit(-1); } YAML::Node myList = config["token_list"]; diff --git a/funasr/runtime/onnxruntime/third_party/glog/.bazelci/presubmit.yml b/funasr/runtime/onnxruntime/third_party/glog/.bazelci/presubmit.yml new file mode 100644 index 000000000..04a538507 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.bazelci/presubmit.yml @@ -0,0 +1,62 @@ +--- +tasks: + ubuntu1804: + name: "Ubuntu 18.04" + platform: ubuntu1804 + build_flags: + - "--features=layering_check" + - "--copt=-Werror" + build_targets: + - "//..." + test_flags: + - "--features=layering_check" + - "--copt=-Werror" + test_targets: + - "//..." + macos: + name: "macOS: latest Xcode" + platform: macos + build_flags: + - "--features=layering_check" + - "--copt=-Werror" + build_targets: + - "//..." + test_flags: + - "--features=layering_check" + - "--copt=-Werror" + test_targets: + - "//..." + windows-msvc: + name: "Windows: MSVC 2017" + platform: windows + environment: + BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC" + build_flags: + - "--features=layering_check" + - "--copt=/WX" + build_targets: + - "//..." + test_flags: + - "--features=layering_check" + - "--copt=/WX" + test_targets: + - "//..." + windows-clang-cl: + name: "Windows: Clang" + platform: windows + environment: + BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC" + build_flags: + - "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl" + - "--extra_execution_platforms=//:x64_windows-clang-cl" + - "--compiler=clang-cl" + - "--features=layering_check" + build_targets: + - "//..." + test_flags: + - "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl" + - "--extra_execution_platforms=//:x64_windows-clang-cl" + - "--compiler=clang-cl" + - "--features=layering_check" + test_targets: + - "//..." diff --git a/funasr/runtime/onnxruntime/third_party/glog/.clang-format b/funasr/runtime/onnxruntime/third_party/glog/.clang-format new file mode 100644 index 000000000..039559d63 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.clang-format @@ -0,0 +1,168 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + - Regex: '.*' + Priority: 3 + SortPriority: 0 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: c++14 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +... + diff --git a/funasr/runtime/onnxruntime/third_party/glog/.clang-tidy b/funasr/runtime/onnxruntime/third_party/glog/.clang-tidy new file mode 100644 index 000000000..1f4ea16fd --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.clang-tidy @@ -0,0 +1,59 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,google-*,modernize-*,-modernize-use-trailing-return-type,readability-*,portability-*,performance-*,bugprone-*,android-*,darwin-*,clang-analyzer-*' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: file +CheckOptions: + - key: cert-dcl16-c.NewSuffixes + value: 'L;LL;LU;LLU' + - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField + value: '0' + - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors + value: '1' + - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: '1' + - key: google-build-namespaces.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-global-names-in-headers.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.BranchThreshold + value: '4294967295' + - key: google-readability-function-size.LineThreshold + value: '4294967295' + - key: google-readability-function-size.NestingThreshold + value: '4294967295' + - key: google-readability-function-size.ParameterThreshold + value: '4294967295' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-function-size.VariableThreshold + value: '4294967295' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: '' + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: google-runtime-references.WhiteListTypes + value: '' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-nullptr.NullMacros + value: 'NULL' +... + diff --git a/funasr/runtime/onnxruntime/third_party/glog/.gitattributes b/funasr/runtime/onnxruntime/third_party/glog/.gitattributes new file mode 100644 index 000000000..2f6d49472 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.gitattributes @@ -0,0 +1 @@ +*.h linguist-language=C++ diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/android.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/android.yml new file mode 100644 index 000000000..e860d0a3f --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/android.yml @@ -0,0 +1,55 @@ +name: Android + +on: [push, pull_request] + +jobs: + build-android: + name: NDK-C++${{matrix.std}}-${{matrix.abi}}-${{matrix.build_type}} + runs-on: ubuntu-latest + defaults: + run: + shell: bash + env: + NDK_VERSION: 25.0.8775105 + strategy: + fail-fast: true + matrix: + std: [14, 17, 20] + abi: [arm64-v8a, armeabi-v7a, x86_64, x86] + build_type: [Debug, Release] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Ninja + uses: ashutoshvarma/setup-ninja@master + with: + version: 1.10.0 + + - name: Setup NDK + env: + ANDROID_SDK_ROOT: /usr/local/lib/android/sdk + run: | + echo 'y' | ${{env.ANDROID_SDK_ROOT}}/cmdline-tools/latest/bin/sdkmanager --install 'ndk;${{env.NDK_VERSION}}' + + - name: Configure + env: + CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}} + run: | + cmake -S . -B build_${{matrix.abi}} \ + -DCMAKE_ANDROID_API=28 \ + -DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \ + -DCMAKE_ANDROID_NDK=/usr/local/lib/android/sdk/ndk/${{env.NDK_VERSION}} \ + -DCMAKE_ANDROID_STL_TYPE=c++_shared \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_SYSTEM_NAME=Android \ + -G Ninja \ + -Werror + + - name: Build + run: | + cmake --build build_${{matrix.abi}} \ + --config ${{matrix.build_type}} diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/cifuzz.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/cifuzz.yml new file mode 100644 index 000000000..091024b88 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/cifuzz.yml @@ -0,0 +1,26 @@ +name: CIFuzz +on: [pull_request] +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'glog' + dry-run: false + language: c++ + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'glog' + fuzz-seconds: 60 + dry-run: false + language: c++ + - name: Upload Crash + uses: actions/upload-artifact@v3 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/emscripten.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/emscripten.yml new file mode 100644 index 000000000..4bbb6dc56 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/emscripten.yml @@ -0,0 +1,52 @@ +name: Emscripten + +on: [push, pull_request] + +jobs: + build-linux: + defaults: + run: + shell: bash + name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}} + runs-on: ubuntu-latest + container: emscripten/emsdk + strategy: + fail-fast: true + matrix: + build_type: [Release, Debug] + lib: [static] + std: [14, 17, 20] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Dependencies + run: | + apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ + cmake \ + ninja-build + + - name: Configure + env: + CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -Wno-error=wasm-exception-spec ${{env.CXXFLAGS}} + run: | + cmake -S . -B build_${{matrix.build_type}} \ + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \ + -DCMAKE_AR=$(which emar) \ + -DCMAKE_CXX_COMPILER=$(which em++) \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \ + -DCMAKE_RANLIB=$(which emranlib) \ + -G Ninja \ + -Werror + + - name: Build + run: | + cmake --build build_${{matrix.build_type}} \ + --config ${{matrix.build_type}} diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/linux.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/linux.yml new file mode 100644 index 000000000..9d29f597b --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/linux.yml @@ -0,0 +1,143 @@ +name: Linux + +on: [push, pull_request] + +jobs: + build-linux: + defaults: + run: + shell: bash + name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}} + runs-on: ubuntu-22.04 + strategy: + fail-fast: true + matrix: + build_type: [Release, Debug] + lib: [shared, static] + std: [14, 17, 20] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Dependencies + run: | + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ + build-essential \ + cmake \ + lcov \ + libgflags-dev \ + libunwind-dev \ + ninja-build + + - name: Cache GTest + id: cache-gtest + uses: actions/cache@v3 + with: + path: gtest/ + key: ${{runner.os}}-gtest-1.11 + + - name: Download GTest + if: steps.cache-gtest.outputs.cache-hit != 'true' + run: | + wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz + tar xvf release-1.11.0.tar.gz + + - name: Build GTest + if: steps.cache-gtest.outputs.cache-hit != 'true' + run: | + cmake -S googletest-release-1.11.0 -B build-googletest \ + -DBUILD_SHARED_LIBS=${{matrix.shared}} \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest \ + -G Ninja + cmake --build build-googletest --target install + + - name: Setup Environment + if: matrix.build_type == 'Debug' + run: | + echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV + echo 'GTest_ROOT=${{github.workspace}}/gtest' >> $GITHUB_ENV + + - name: Configure + env: + CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}} + run: | + cmake -S . -B build_${{matrix.build_type}} \ + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \ + -G Ninja \ + -Werror + + - name: Build + run: | + cmake --build build_${{matrix.build_type}} \ + --config ${{matrix.build_type}} + + - name: Install + run: | + cmake --build build_${{matrix.build_type}} \ + --config ${{matrix.build_type}} \ + --target install + + cmake build_${{matrix.build_type}} \ + -DCMAKE_INSTALL_INCLUDEDIR=${{runner.workspace}}/foo/include \ + -DCMAKE_INSTALL_LIBDIR=${{runner.workspace}}/foo/lib \ + -DCMAKE_INSTALL_DATAROOTDIR=${{runner.workspace}}/foo/share + cmake --build build_${{matrix.build_type}} \ + --config ${{matrix.build_type}} \ + --target install + + - name: Test CMake Package (relative GNUInstallDirs) + run: | + cmake -S src/package_config_unittest/working_config \ + -B build_${{matrix.build_type}}_package \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_PREFIX_PATH=${{github.workspace}}/install \ + -G Ninja + cmake --build build_${{matrix.build_type}}_package \ + --config ${{matrix.build_type}} + + - name: Test CMake Package (absolute GNUInstallDirs) + run: | + cmake -S src/package_config_unittest/working_config \ + -B build_${{matrix.build_type}}_package_foo \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_PREFIX_PATH=${{runner.workspace}}/foo \ + -G Ninja + cmake --build build_${{matrix.build_type}}_package_foo \ + --config ${{matrix.build_type}} + + - name: Test + run: | + ctest --test-dir build_${{matrix.build_type}} -j$(nproc) --output-on-failure + + - name: Generate Coverage + if: matrix.build_type == 'Debug' + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info \ + '${{github.workspace}}/gtest/*' \ + '*/src/*_unittest.cc' \ + '*/src/googletest.h' \ + '*/src/mock-log.h' \ + '/usr/*' \ + --output-file coverage.info + + for file in src/glog/*.h.in; do + name=$(basename ${file}) + name_we=${name%.h.in} + sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info + done + + lcov --list coverage.info + + - name: Upload Coverage to Codecov + if: matrix.build_type == 'Debug' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/macos.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/macos.yml new file mode 100644 index 000000000..51cf7ffb6 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/macos.yml @@ -0,0 +1,83 @@ +name: macOS + +on: [push, pull_request] + +jobs: + build-macos: + name: AppleClang-C++${{matrix.std}}-${{matrix.build_type}} + runs-on: macos-12 + strategy: + fail-fast: true + matrix: + std: [14, 17, 20] + include: + - generator: Ninja + - build_type: Debug + + steps: + - uses: actions/checkout@v3 + + - name: Setup Ninja + uses: ashutoshvarma/setup-ninja@master + with: + version: 1.10.0 + + - name: Setup Dependencies + run: | + brew install lcov + + - name: Setup Environment + if: matrix.build_type == 'Debug' + run: | + echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV + + - name: Configure + shell: bash + env: + CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}} + run: | + cmake -S . -B build_${{matrix.build_type}} \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCMAKE_CXX_FLAGS_DEBUG=-pedantic-errors \ + -DCMAKE_CXX_FLAGS_RELEASE=-pedantic-errors \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -G "${{matrix.generator}}" \ + -Werror + + - name: Build + run: | + cmake --build build_${{matrix.build_type}} \ + --config ${{matrix.build_type}} + + - name: Test + run: | + ctest --test-dir build_${{matrix.build_type}} \ + --output-on-failure + + - name: Generate Coverage + if: matrix.build_type == 'Debug' + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info \ + '*/src/*_unittest.cc' \ + '*/src/googletest.h' \ + '*/src/mock-log.h' \ + '*/usr/*' \ + --output-file coverage.info + + for file in src/glog/*.h.in; do + name=$(basename ${file}) + name_we=${name%.h.in} + sed -i "" "s|${{github.workspace}}/glog/${name_we}.h\$|${file}|g" coverage.info + done + + lcov --list coverage.info + + - name: Upload Coverage to Codecov + if: matrix.build_type == 'Debug' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true diff --git a/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/windows.yml b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/windows.yml new file mode 100644 index 000000000..158e8d1db --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/.github/workflows/windows.yml @@ -0,0 +1,224 @@ +name: Windows + +on: [push, pull_request] + +jobs: + build-msvc: + name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}} + runs-on: ${{matrix.os}} + defaults: + run: + shell: powershell + env: + CL: /MP + CXXFLAGS: /WX /permissive- + strategy: + fail-fast: true + matrix: + arch: [Win32, x64] + build_type: [Debug, Release] + lib: [shared, static] + msvc: [VS-16-2019, VS-17-2022] + std: [14, 17, 20] + include: + - msvc: VS-16-2019 + os: windows-2019 + generator: 'Visual Studio 16 2019' + - msvc: VS-17-2022 + os: windows-2022 + generator: 'Visual Studio 17 2022' + + steps: + - uses: actions/checkout@v3 + + - name: Cache GTest + id: cache-gtest + uses: actions/cache@v3 + with: + path: gtest/ + key: ${{runner.os}}-gtest-1.11-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}} + + - name: Download GTest + if: steps.cache-gtest.outputs.cache-hit != 'true' + run: | + (New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip", "release-1.11.0.zip") + Expand-Archive release-1.11.0.zip . + + - name: Build GTest + if: steps.cache-gtest.outputs.cache-hit != 'true' + run: | + cmake -S googletest-release-1.11.0 -B build-googletest ` + -A ${{matrix.arch}} ` + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} ` + -Dgtest_force_shared_crt=ON ` + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest + cmake --build build-googletest ` + --config ${{matrix.build_type}} ` + --target install + + - name: Cache gflags + id: cache-gflags + uses: actions/cache@v3 + with: + path: gflags/ + key: ${{runner.os}}-gflags-2.2.2-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}} + + - name: Download gflags + if: steps.cache-gflags.outputs.cache-hit != 'true' + run: | + (New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip") + Expand-Archive v2.2.2.zip . + + - name: Build gflags + if: steps.cache-gflags.outputs.cache-hit != 'true' + run: | + cmake -S gflags-2.2.2 -B build-gflags ` + -A ${{matrix.arch}} ` + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} ` + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags + cmake --build build-gflags ` + --config ${{matrix.build_type}} ` + --target install + + - name: Setup Environment + run: | + echo "GTest_ROOT=$((Get-Item .).FullName)/gtest" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "gflags_ROOT=$((Get-Item .).FullName)/gflags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "${{github.workspace}}/gtest/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "${{github.workspace}}/gflags/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Setup Release Environment + if: matrix.build_type != 'Debug' + run: | + echo "CXXFLAGS=/Zi ${{env.CXXFLAGS}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Configure + run: | + cmake -S . -B build_${{matrix.build_type}} ` + -A ${{matrix.arch}} ` + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} ` + -DCMAKE_CXX_EXTENSIONS=OFF ` + -DCMAKE_CXX_STANDARD=${{matrix.std}} ` + -DCMAKE_CXX_STANDARD_REQUIRED=ON ` + -DCMAKE_EXE_LINKER_FLAGS='/NOIMPLIB' ` + -DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' ` + -DCMAKE_INSTALL_PREFIX:PATH=./install ` + -DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$:Debug>DLL' ` + -G "${{matrix.generator}}" ` + -Werror + + - name: Build + run: cmake --build build_${{matrix.build_type}} ` + --config ${{matrix.build_type}} + + - name: Test + env: + CTEST_OUTPUT_ON_FAILURE: 1 + run: | + cmake --build build_${{matrix.build_type}}/ ` + --config ${{matrix.build_type}} ` + --target RUN_TESTS + + - name: Install + run: | + cmake --build build_${{matrix.build_type}}/ ` + --config ${{matrix.build_type}} ` + --target install + + build-mingw: + name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}} + runs-on: windows-2022 + env: + BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}' + defaults: + run: + shell: msys2 {0} + strategy: + fail-fast: true + matrix: + build_type: [Debug] + lib: [shared, static] + std: [14, 17, 20] + sys: [mingw32, mingw64] + include: + - sys: mingw32 + env: i686 + - sys: mingw64 + env: x86_64 + + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + install: >- + lcov + mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-gflags + mingw-w64-${{matrix.env}}-ninja + + - name: Setup Environment + if: matrix.build_type == 'Debug' + run: | + echo 'CXXFLAGS=--coverage ${{env.CXXFLAGS}}' >> $GITHUB_ENV + + - name: Configure + env: + CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}} + run: | + cmake -S . -B build_${{matrix.build_type}}/ \ + -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_INSTALL_PREFIX:PATH=./install \ + -G Ninja \ + -Werror + + - name: Build + run: | + cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} + + - name: Test + env: + CTEST_OUTPUT_ON_FAILURE: 1 + run: | + cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} \ + --target test + + - name: Install + run: | + cmake --build build_${{matrix.build_type}}/ \ + --config ${{matrix.build_type}} \ + --target install + + - name: Generate Coverage + if: matrix.build_type == 'Debug' + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info \ + '*/install/include/*' \ + '*/msys64/mingw32/*' \ + '*/msys64/mingw64/*' \ + '*/src/*_unittest.cc' \ + '*/src/googletest.h' \ + '*/src/mock-log.h' \ + --output-file coverage.info + + for file in src/glog/*.h.in; do + name=$(basename ${file}) + name_we=${name%.h.in} + sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info + done + + lcov --list coverage.info + + - name: Upload Coverage to Codecov + if: matrix.build_type == 'Debug' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true diff --git a/funasr/runtime/onnxruntime/third_party/glog/AUTHORS b/funasr/runtime/onnxruntime/third_party/glog/AUTHORS new file mode 100644 index 000000000..9d711ec62 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/AUTHORS @@ -0,0 +1,29 @@ +# This is the official list of glog authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. +# +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. +# +# Please keep the list sorted. + +Abhishek Dasgupta +Abhishek Parmar +Andrew Schwartzmeyer +Andy Ying +Brian Silverman +Dmitriy Arbitman +Google Inc. +Guillaume Dumont +Marco Wang +Michael Tanner +MiniLight +romange +Roman Perepelitsa +Sergiu Deitsch +tbennun +Teddy Reed +Vijaymahantesh Sattigeri +Zhongming Qu +Zhuoran Shen diff --git a/funasr/runtime/onnxruntime/third_party/glog/BUILD.bazel b/funasr/runtime/onnxruntime/third_party/glog/BUILD.bazel new file mode 100644 index 000000000..0acdc72b6 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/BUILD.bazel @@ -0,0 +1,22 @@ +licenses(["notice"]) + +exports_files(["COPYING"]) + +load(":bazel/glog.bzl", "glog_library") + +glog_library() + +# platform() to build with clang-cl on Bazel CI. This is enabled with +# the flags in .bazelci/presubmit.yml: +# +# --incompatible_enable_cc_toolchain_resolution +# --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl +# --extra_execution_platforms=//:x64_windows-clang-cl +platform( + name = "x64_windows-clang-cl", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:windows", + "@bazel_tools//tools/cpp:clang-cl", + ], +) diff --git a/funasr/runtime/onnxruntime/third_party/glog/CMakeLists.txt b/funasr/runtime/onnxruntime/third_party/glog/CMakeLists.txt new file mode 100644 index 000000000..f5c1e5535 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/CMakeLists.txt @@ -0,0 +1,941 @@ +cmake_minimum_required (VERSION 3.16) +project (glog + VERSION 0.7.0 + DESCRIPTION "C++ implementation of the Google logging module" + HOMEPAGE_URL https://github.com/google/glog + LANGUAGES CXX +) + +set (CPACK_PACKAGE_NAME glog) +set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Google logging library") +set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + +list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +include (CheckCXXCompilerFlag) +include (CheckCXXSourceCompiles) +include (CheckCXXSourceRuns) +include (CheckCXXSymbolExists) +include (CheckFunctionExists) +include (CheckIncludeFileCXX) +include (CheckLibraryExists) +include (CheckStructHasMember) +include (CheckTypeSize) +include (CMakeDependentOption) +include (CMakePackageConfigHelpers) +include (CMakePushCheckState) +include (CPack) +include (CTest) +include (DetermineGflagsNamespace) +include (GenerateExportHeader) +include (GetCacheVariables) +include (GNUInstallDirs) + +option (BUILD_SHARED_LIBS "Build shared libraries" ON) +option (PRINT_UNSYMBOLIZED_STACK_TRACES + "Print file offsets in traces instead of symbolizing" OFF) +option (WITH_GFLAGS "Use gflags" ON) +option (WITH_GTEST "Use Google Test" ON) +option (WITH_PKGCONFIG "Enable pkg-config support" ON) +option (WITH_SYMBOLIZE "Enable symbolize module" ON) +option (WITH_THREADS "Enable multithreading support" ON) +option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON) +option (WITH_UNWIND "Enable libunwind support" ON) + +cmake_dependent_option (WITH_GMOCK "Use Google Mock" ON WITH_GTEST OFF) + +set (WITH_FUZZING none CACHE STRING "Fuzzing engine") +set_property (CACHE WITH_FUZZING PROPERTY STRINGS none libfuzzer ossfuzz) + +if (NOT WITH_UNWIND) + set (CMAKE_DISABLE_FIND_PACKAGE_Unwind ON) +endif (NOT WITH_UNWIND) + +if (NOT WITH_GTEST) + set (CMAKE_DISABLE_FIND_PACKAGE_GTest ON) +endif (NOT WITH_GTEST) + +if (NOT WITH_THREADS) + set (CMAKE_DISABLE_FIND_PACKAGE_Threads ON) +endif (NOT WITH_THREADS) + +set (CMAKE_C_VISIBILITY_PRESET hidden) +set (CMAKE_CXX_VISIBILITY_PRESET hidden) +set (CMAKE_POSITION_INDEPENDENT_CODE ON) +set (CMAKE_VISIBILITY_INLINES_HIDDEN ON) + +set (CMAKE_DEBUG_POSTFIX d) +set (CMAKE_THREAD_PREFER_PTHREAD 1) + +find_package (GTest NO_MODULE) + +if (GTest_FOUND) + set (HAVE_LIB_GTEST 1) +endif (GTest_FOUND) + +if (WITH_GMOCK AND TARGET GTest::gmock) + set (HAVE_LIB_GMOCK 1) +endif (WITH_GMOCK AND TARGET GTest::gmock) + +if (WITH_GFLAGS) + find_package (gflags 2.2.2) + + if (gflags_FOUND) + set (HAVE_LIB_GFLAGS 1) + determine_gflags_namespace (gflags_NAMESPACE) + endif (gflags_FOUND) +endif (WITH_GFLAGS) + +find_package (Threads) +find_package (Unwind) + +if (Unwind_FOUND) + set (HAVE_LIB_UNWIND 1) +else (Unwind_FOUND) + # Check whether linking actually succeeds. ARM toolchains of LLVM unwind + # implementation do not necessarily provide the _Unwind_Backtrace function + # which causes the previous check to succeed but the linking to fail. + check_cxx_symbol_exists (_Unwind_Backtrace unwind.h HAVE__UNWIND_BACKTRACE) + check_cxx_symbol_exists (_Unwind_GetIP unwind.h HAVE__UNWIND_GETIP) +endif (Unwind_FOUND) + +check_include_file_cxx (dlfcn.h HAVE_DLFCN_H) +check_include_file_cxx (glob.h HAVE_GLOB_H) +check_include_file_cxx (memory.h HAVE_MEMORY_H) +check_include_file_cxx (pwd.h HAVE_PWD_H) +check_include_file_cxx (strings.h HAVE_STRINGS_H) +check_include_file_cxx (sys/stat.h HAVE_SYS_STAT_H) +check_include_file_cxx (sys/syscall.h HAVE_SYS_SYSCALL_H) +check_include_file_cxx (sys/time.h HAVE_SYS_TIME_H) +check_include_file_cxx (sys/types.h HAVE_SYS_TYPES_H) +check_include_file_cxx (sys/utsname.h HAVE_SYS_UTSNAME_H) +check_include_file_cxx (sys/wait.h HAVE_SYS_WAIT_H) +check_include_file_cxx (syscall.h HAVE_SYSCALL_H) +check_include_file_cxx (syslog.h HAVE_SYSLOG_H) +check_include_file_cxx (ucontext.h HAVE_UCONTEXT_H) +check_include_file_cxx (unistd.h HAVE_UNISTD_H) + +check_type_size (mode_t HAVE_MODE_T LANGUAGE CXX) +check_type_size (ssize_t HAVE_SSIZE_T LANGUAGE CXX) + +check_function_exists (dladdr HAVE_DLADDR) +check_function_exists (fcntl HAVE_FCNTL) +check_function_exists (pread HAVE_PREAD) +check_function_exists (pwrite HAVE_PWRITE) +check_function_exists (sigaction HAVE_SIGACTION) +check_function_exists (sigaltstack HAVE_SIGALTSTACK) + +check_cxx_symbol_exists (backtrace execinfo.h HAVE_EXECINFO_BACKTRACE) +check_cxx_symbol_exists (backtrace_symbols execinfo.h + HAVE_EXECINFO_BACKTRACE_SYMBOLS) + +# NOTE gcc does not fail if you pass a non-existent -Wno-* option as an +# argument. However, it will happily fail if you pass the corresponding -W* +# option. So, we check whether options that disable warnings exist by testing +# the availability of the corresponding option that enables the warning. This +# eliminates the need to check for compiler for several (mainly Clang) options. + +check_cxx_compiler_flag (-Wdeprecated HAVE_NO_DEPRECATED) +check_cxx_compiler_flag (-Wunnamed-type-template-args + HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS) + +cmake_push_check_state (RESET) + +if (Threads_FOUND) + set (CMAKE_REQUIRED_LIBRARIES Threads::Threads) +endif (Threads_FOUND) + +check_cxx_symbol_exists (pthread_threadid_np "pthread.h" HAVE_PTHREAD_THREADID_NP) +cmake_pop_check_state () + +# NOTE: Cannot use check_function_exists here since >=vc-14.0 can define +# snprintf as an inline function +check_cxx_symbol_exists (snprintf cstdio HAVE_SNPRINTF) + +check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP) + +check_cxx_source_compiles (" +#include +static void foo(void) __attribute__ ((unused)); +int main(void) { return 0; } +" HAVE___ATTRIBUTE__) + +check_cxx_source_compiles (" +#include +static void foo(void) __attribute__ ((visibility(\"default\"))); +int main(void) { return 0; } +" HAVE___ATTRIBUTE__VISIBILITY_DEFAULT) + +check_cxx_source_compiles (" +#include +static void foo(void) __attribute__ ((visibility(\"hidden\"))); +int main(void) { return 0; } +" HAVE___ATTRIBUTE__VISIBILITY_HIDDEN) + +check_cxx_source_compiles (" +int main(void) { if (__builtin_expect(0, 0)) return 1; return 0; } +" HAVE___BUILTIN_EXPECT) + +check_cxx_source_compiles (" +int main(void) +{ + int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0; +} +" HAVE___SYNC_VAL_COMPARE_AND_SWAP) + +if (Threads_FOUND) + cmake_push_check_state (RESET) + set (CMAKE_REQUIRED_LIBRARIES Threads::Threads) + check_cxx_source_compiles (" +#define _XOPEN_SOURCE 500 +#include +int main(void) +{ + pthread_rwlock_t l; + pthread_rwlock_init(&l, NULL); + pthread_rwlock_rdlock(&l); + return 0; +} + " HAVE_RWLOCK) + cmake_pop_check_state () +endif (Threads_FOUND) + +check_cxx_source_compiles (" +__declspec(selectany) int a; +int main(void) { return 0; } +" HAVE___DECLSPEC) + +if (WITH_TLS) + set (GLOG_THREAD_LOCAL_STORAGE 1) +endif (WITH_TLS) + +set (_PC_FIELDS + "gregs[REG_PC]" + "gregs[REG_EIP]" + "gregs[REG_RIP]" + "sc_ip" + "uc_regs->gregs[PT_NIP]" + "gregs[R15]" + "arm_pc" + "mc_eip" + "mc_rip" + "__gregs[REG_EIP]" + "__gregs[REG_RIP]" + "ss.eip" + "__ss.__eip" + "ss.rip" + "__ss.__rip" + "ss.srr0" + "__ss.__srr0" +) + +set (_PC_HEADERS ucontext.h signal.h) + +if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT) + foreach (_PC_FIELD ${_PC_FIELDS}) + foreach (_PC_HEADER ${_PC_HEADERS}) + set (_TMP + ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.cpp) + file (WRITE ${_TMP} " +#define _GNU_SOURCE 1 +#include <${_PC_HEADER}> +int main(void) +{ + ucontext_t u; + return u.${_PC_FIELD} == 0; +} +") + try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP} + COMPILE_DEFINITIONS _GNU_SOURCE=1) + + if (HAVE_PC_FROM_UCONTEXT) + set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE) + endif (HAVE_PC_FROM_UCONTEXT) + endforeach (_PC_HEADER) + endforeach (_PC_FIELD) +endif (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT) + +set (GOOGLE_NAMESPACE google) +set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {") +set (_END_GOOGLE_NAMESPACE_ "}") +set (ac_cv_have_glog_export 1) + +if (HAVE_LIB_GFLAGS) + set (ac_cv_have_libgflags 1) +else (HAVE_LIB_GFLAGS) + set (ac_cv_have_libgflags 0) +endif (HAVE_LIB_GFLAGS) + +if (HAVE_SYS_TYPES_H) + set (ac_cv_have_systypes_h 1) +else (HAVE_SYS_TYPES_H) + set (ac_cv_have_systypes_h 0) +endif (HAVE_SYS_TYPES_H) + +if (HAVE_SSIZE_T) + set (ac_cv_have_ssize_t 1) +else (HAVE_SSIZE_T) + set (ac_cv_have_ssize_t 0) +endif (HAVE_SSIZE_T) + +if (HAVE_MODE_T) + set (ac_cv_have_mode_t 1) +else (HAVE_MODE_T) + set (ac_cv_have_mode_t 0) +endif (HAVE_MODE_T) + +if (HAVE_UNISTD_H) + set (ac_cv_have_unistd_h 1) +else (HAVE_UNISTD_H) + set (ac_cv_have_unistd_h 0) +endif (HAVE_UNISTD_H) + +set (ac_google_namespace ${GOOGLE_NAMESPACE}) +set (ac_google_end_namespace ${_END_GOOGLE_NAMESPACE_}) +set (ac_google_start_namespace ${_START_GOOGLE_NAMESPACE_}) + +if (HAVE___ATTRIBUTE__) + set (ac_cv___attribute___noinline "__attribute__((noinline))") + set (ac_cv___attribute___printf_4_5 "__attribute__((__format__(__printf__, 4, 5)))") +elseif (HAVE___DECLSPEC) + #set (ac_cv___attribute___noinline "__declspec(noinline)") +endif (HAVE___ATTRIBUTE__) + +if (HAVE___BUILTIN_EXPECT) + set (ac_cv_have___builtin_expect 1) +else (HAVE___BUILTIN_EXPECT) + set (ac_cv_have___builtin_expect 0) +endif (HAVE___BUILTIN_EXPECT) + +if (HAVE_EXECINFO_BACKTRACE AND HAVE_EXECINFO_BACKTRACE_SYMBOLS) + set (HAVE_STACKTRACE 1) +endif (HAVE_EXECINFO_BACKTRACE AND HAVE_EXECINFO_BACKTRACE_SYMBOLS) + +if (WITH_SYMBOLIZE) + if (WIN32 OR CYGWIN) + cmake_push_check_state (RESET) + set (CMAKE_REQUIRED_LIBRARIES DbgHelp) + + check_cxx_source_runs ([=[ + #include + #include + #include + + void foobar() { } + + int main() + { + HANDLE process = GetCurrentProcess(); + + if (!SymInitialize(process, NULL, TRUE)) + return EXIT_FAILURE; + + char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; + SYMBOL_INFO *symbol = reinterpret_cast(buf); + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + + void* const pc = reinterpret_cast(&foobar); + BOOL ret = SymFromAddr(process, reinterpret_cast(pc), 0, symbol); + + return ret ? EXIT_SUCCESS : EXIT_FAILURE; + } + ]=] HAVE_SYMBOLIZE) + + cmake_pop_check_state () + + if (HAVE_SYMBOLIZE) + set (HAVE_STACKTRACE 1) + endif (HAVE_SYMBOLIZE) + elseif (UNIX) + cmake_push_check_state (RESET) + check_cxx_source_compiles ([=[ + int main() + { + #ifndef __ELF__ + #error __ELF__ not defined + #endif + } + ]=] HAVE_SYMBOLIZE) + cmake_pop_check_state () + elseif (APPLE AND HAVE_DLADDR) + set (HAVE_SYMBOLIZE 1) + endif (WIN32 OR CYGWIN) +endif (WITH_SYMBOLIZE) + +# CMake manages symbolize availability. The definition is necessary only when +# building the library. +add_compile_definitions (GLOG_NO_SYMBOLIZE_DETECTION) + +check_cxx_source_compiles (" +#include +#include +int main() +{ + time_t timep; + struct tm result; + localtime_r(&timep, &result); + return EXIT_SUCCESS; +} +" HAVE_LOCALTIME_R) + +set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) + +if (WITH_THREADS AND Threads_FOUND) + if (CMAKE_USE_PTHREADS_INIT) + set (HAVE_PTHREAD 1) + endif (CMAKE_USE_PTHREADS_INIT) +else (WITH_THREADS AND Threads_FOUND) + set (NO_THREADS 1) +endif (WITH_THREADS AND Threads_FOUND) + +# fopen/open on Cygwin can not handle unix-type paths like /home/.... +# therefore we translate TEST_SRC_DIR to windows-path. +if (CYGWIN) + execute_process (COMMAND cygpath.exe -m ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE TEST_SRC_DIR) + set (TEST_SRC_DIR \"${TEST_SRC_DIR}\") +else (CYGWIN) + set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\") +endif (CYGWIN) + +configure_file (src/config.h.cmake.in config.h) +configure_file (src/glog/logging.h.in glog/logging.h @ONLY) +configure_file (src/glog/raw_logging.h.in glog/raw_logging.h @ONLY) +configure_file (src/glog/stl_logging.h.in glog/stl_logging.h @ONLY) +configure_file (src/glog/vlog_is_on.h.in glog/vlog_is_on.h @ONLY) + +add_compile_options ($<$,$>>:-Wno-unnamed-type-template-args>) + +set (_glog_CMake_BINDIR ${CMAKE_INSTALL_BINDIR}) +set (_glog_CMake_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) +set (_glog_CMake_LIBDIR ${CMAKE_INSTALL_LIBDIR}) +set (_glog_CMake_INSTALLDIR ${_glog_CMake_LIBDIR}/cmake/glog) + +set (_glog_CMake_DIR glog/cmake) +set (_glog_CMake_DATADIR ${CMAKE_INSTALL_DATAROOTDIR}/${_glog_CMake_DIR}) +set (_glog_BINARY_CMake_DATADIR + ${CMAKE_CURRENT_BINARY_DIR}/${_glog_CMake_DATADIR}) + +# Add additional CMake find modules here. +set (_glog_CMake_MODULES) + +if (Unwind_FOUND) + # Copy the module only if libunwind is actually used. + list (APPEND _glog_CMake_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindUnwind.cmake) +endif (Unwind_FOUND) + +# Generate file name for each module in the binary directory +foreach (_file ${_glog_CMake_MODULES}) + get_filename_component (_module "${_file}" NAME) + + list (APPEND _glog_BINARY_CMake_MODULES + ${_glog_BINARY_CMake_DATADIR}/${_module}) +endforeach (_file) + +if (_glog_CMake_MODULES) + # Copy modules to binary directory during the build + add_custom_command (OUTPUT ${_glog_BINARY_CMake_MODULES} + COMMAND ${CMAKE_COMMAND} -E make_directory + ${_glog_BINARY_CMake_DATADIR} + COMMAND ${CMAKE_COMMAND} -E copy ${_glog_CMake_MODULES} + ${_glog_BINARY_CMake_DATADIR} + DEPENDS ${_glog_CMake_MODULES} + COMMENT "Copying find modules..." + ) +endif (_glog_CMake_MODULES) + +set (GLOG_PUBLIC_H + ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h + ${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h + ${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h + ${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h + ${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h + src/glog/log_severity.h + src/glog/platform.h +) + +set (GLOG_SRCS + ${GLOG_PUBLIC_H} + src/base/commandlineflags.h + src/base/googleinit.h + src/base/mutex.h + src/demangle.cc + src/demangle.h + src/logging.cc + src/raw_logging.cc + src/symbolize.cc + src/symbolize.h + src/utilities.cc + src/utilities.h + src/vlog_is_on.cc +) + +if (HAVE_PTHREAD OR WIN32 OR CYGWIN) + list (APPEND GLOG_SRCS src/signalhandler.cc) +endif (HAVE_PTHREAD OR WIN32 OR CYGWIN) + +if (CYGWIN OR WIN32) + list (APPEND GLOG_SRCS + src/windows/port.cc + src/windows/port.h + ) +endif (CYGWIN OR WIN32) + +add_library (glog_internal OBJECT + ${_glog_BINARY_CMake_MODULES} + ${GLOG_SRCS} +) +target_compile_features (glog_internal PUBLIC $) + +add_library (glog + $ +) +target_compile_features (glog PUBLIC cxx_std_14) + +add_library (glog::glog ALIAS glog) + +set (glog_libraries_options_for_static_linking) + +if (Unwind_FOUND) + target_link_libraries (glog PRIVATE unwind::unwind) + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -lunwind") + set (Unwind_DEPENDENCY "find_dependency (Unwind ${Unwind_VERSION})") +endif (Unwind_FOUND) + +if (HAVE_DBGHELP) + target_link_libraries (glog PRIVATE dbghelp) + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -ldbghelp") +endif (HAVE_DBGHELP) + +if (HAVE_PTHREAD) + target_link_libraries (glog PRIVATE ${CMAKE_THREAD_LIBS_INIT}) + + if (CMAKE_THREAD_LIBS_INIT) + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} ${CMAKE_THREAD_LIBS_INIT}") + endif (CMAKE_THREAD_LIBS_INIT) +endif (HAVE_PTHREAD) + +if (gflags_FOUND) + # Prefer the gflags target that uses double colon convention + if (TARGET gflags::gflags) + target_link_libraries (glog PUBLIC gflags::gflags) + else (TARGET gflags::gflags) + target_link_libraries (glog PUBLIC gflags) + endif (TARGET gflags::gflags) + + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -lgflags") +endif (gflags_FOUND) + +if (ANDROID) + target_link_libraries (glog PRIVATE log) + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -llog") +endif (ANDROID) + +set_target_properties (glog PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties (glog PROPERTIES SOVERSION 1) + +if (CYGWIN OR WIN32) + target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES) +endif (CYGWIN OR WIN32) + +set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}") + +target_include_directories (glog BEFORE PUBLIC + "$" + "$" + "$" + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + +if (CYGWIN OR WIN32) + target_include_directories (glog_internal PUBLIC + "$" + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows) + + target_include_directories (glog PUBLIC + "$" + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows) +endif (CYGWIN OR WIN32) + +set_target_properties (glog PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL) + +target_include_directories (glog_internal PUBLIC + $) +target_compile_definitions (glog_internal PUBLIC + $ + PRIVATE GOOGLE_GLOG_IS_A_DLL) + +generate_export_header (glog + EXPORT_MACRO_NAME GLOG_EXPORT + EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h) + +string (STRIP "${glog_libraries_options_for_static_linking}" glog_libraries_options_for_static_linking) + +if (WITH_PKGCONFIG) + set (VERSION ${PROJECT_VERSION}) + set (prefix ${CMAKE_INSTALL_PREFIX}) + set (exec_prefix ${CMAKE_INSTALL_FULL_BINDIR}) + set (libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + set (includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + + configure_file ( + "${PROJECT_SOURCE_DIR}/libglog.pc.in" + "${PROJECT_BINARY_DIR}/libglog.pc" + @ONLY + ) + + unset (VERSION) + unset (prefix) + unset (exec_prefix) + unset (libdir) + unset (includedir) +endif (WITH_PKGCONFIG) + +# Unit testing + +if (NOT WITH_FUZZING STREQUAL "none") + add_executable (fuzz_demangle + src/fuzz_demangle.cc + ) + + if (WITH_FUZZING STREQUAL "ossfuzz") + set (LIB_FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE}) + target_link_libraries (fuzz_demangle PRIVATE glog ${LIB_FUZZING_ENGINE}) + elseif (WITH_FUZZING STREQUAL "libfuzzer") + target_compile_options (fuzz_demangle PRIVATE -fsanitize=fuzzer) + target_link_libraries (fuzz_demangle PRIVATE glog) + else (WITH_FUZZING STREQUAL "libfuzzer") + message (FATAL_ERROR "Unsupported fuzzing engine ${WITH_FUZZING}") + endif (WITH_FUZZING STREQUAL "ossfuzz") +endif (NOT WITH_FUZZING STREQUAL "none") + +if (BUILD_TESTING) + add_library (glogtest STATIC + $ + ) + + target_include_directories (glogtest PUBLIC + $) + target_compile_definitions (glogtest PUBLIC + $ GLOG_STATIC_DEFINE) + target_link_libraries (glogtest PUBLIC + $) + + set (_GLOG_TEST_LIBS glogtest) + + if (HAVE_LIB_GTEST) + list (APPEND _GLOG_TEST_LIBS GTest::gtest) + endif (HAVE_LIB_GTEST) + + if (HAVE_LIB_GMOCK) + list (APPEND _GLOG_TEST_LIBS GTest::gmock) + endif (HAVE_LIB_GMOCK) + + add_executable (logging_unittest + src/logging_unittest.cc + ) + + target_link_libraries (logging_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + add_executable (stl_logging_unittest + src/stl_logging_unittest.cc + ) + + target_link_libraries (stl_logging_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + if (HAVE_NO_DEPRECATED) + set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS + -Wno-deprecated) + endif (HAVE_NO_DEPRECATED) + + if (HAVE_EXT_SLIST) + target_compile_definitions (stl_logging_unittest PRIVATE + GLOG_STL_LOGGING_FOR_EXT_SLIST) + endif (HAVE_EXT_SLIST) + + if (HAVE_SYMBOLIZE) + add_executable (symbolize_unittest + src/symbolize_unittest.cc + ) + + target_link_libraries (symbolize_unittest PRIVATE ${_GLOG_TEST_LIBS}) + endif (HAVE_SYMBOLIZE) + + add_executable (demangle_unittest + src/demangle_unittest.cc + ) + + target_link_libraries (demangle_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + if (HAVE_STACKTRACE) + add_executable (stacktrace_unittest + src/stacktrace_unittest.cc + ) + + target_link_libraries (stacktrace_unittest PRIVATE ${_GLOG_TEST_LIBS}) + endif (HAVE_STACKTRACE) + + add_executable (utilities_unittest + src/utilities_unittest.cc + ) + + target_link_libraries (utilities_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE) + add_executable (signalhandler_unittest + src/signalhandler_unittest.cc + ) + + target_link_libraries (signalhandler_unittest PRIVATE ${_GLOG_TEST_LIBS}) + endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE) + + add_test (NAME demangle COMMAND demangle_unittest) + add_test (NAME logging COMMAND logging_unittest) + + set_tests_properties (logging PROPERTIES TIMEOUT 30) + # MacOS diff is not deterministic: use the output to determine whether the + # test passed. + set_tests_properties (logging PROPERTIES PASS_REGULAR_EXPRESSION ".*\nPASS\n.*") + + # FIXME: Skip flaky test + set_tests_properties (logging PROPERTIES SKIP_REGULAR_EXPRESSION + "Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS") + + if (APPLE) + # FIXME: Skip flaky test + set_property (TEST logging APPEND PROPERTY SKIP_REGULAR_EXPRESSION + "unexpected new.*PASS\nTest with golden file failed. We'll try to show the diff:") + endif (APPLE) + + if (TARGET signalhandler_unittest) + add_test (NAME signalhandler COMMAND signalhandler_unittest) + endif (TARGET signalhandler_unittest) + + if (TARGET stacktrace_unittest) + add_test (NAME stacktrace COMMAND stacktrace_unittest) + set_tests_properties (stacktrace PROPERTIES TIMEOUT 30) + endif (TARGET stacktrace_unittest) + + add_test (NAME stl_logging COMMAND stl_logging_unittest) + + if (TARGET symbolize_unittest) + add_test (NAME symbolize COMMAND symbolize_unittest) + + # FIXME: Skip flaky test when compiled in C++20 mode + set_tests_properties (symbolize PROPERTIES SKIP_REGULAR_EXPRESSION + [=[Check failed: streq\("nonstatic_func"\, TrySymbolize\(\(void \*\)\(&nonstatic_func\)\)\)]=]) + endif (TARGET symbolize_unittest) + + if (HAVE_LIB_GMOCK) + add_executable (mock-log_unittest + src/mock-log_unittest.cc + src/mock-log.h + ) + + target_link_libraries (mock-log_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + add_test (NAME mock-log COMMAND mock-log_unittest) + endif (HAVE_LIB_GMOCK) + + # Generate an initial cache + + get_cache_variables (_CACHEVARS) + + set (_INITIAL_CACHE + ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/glog_package_config_initial_cache.cmake) + + # Package config test + + add_test (NAME cmake_package_config_init COMMAND ${CMAKE_COMMAND} + -DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config + -DINITIAL_CACHE=${_INITIAL_CACHE} + -DCACHEVARS=${_CACHEVARS} + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInitPackageConfig.cmake + ) + + add_test (NAME cmake_package_config_generate COMMAND ${CMAKE_COMMAND} + -DGENERATOR=${CMAKE_GENERATOR} + -DGENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} + -DGENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} + -DINITIAL_CACHE=${_INITIAL_CACHE} + -DPACKAGE_DIR=${CMAKE_CURRENT_BINARY_DIR} + -DPATH=$ENV{PATH} + -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/package_config_unittest/working_config + -DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestPackageConfig.cmake + ) + + add_test (NAME cmake_package_config_build COMMAND + ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config + --config $ + ) + + add_test (NAME cmake_package_config_cleanup COMMAND ${CMAKE_COMMAND} -E + remove_directory + ${CMAKE_CURRENT_BINARY_DIR}/test_package_config + ) + + # Fixtures setup + set_tests_properties (cmake_package_config_init PROPERTIES FIXTURES_SETUP + cmake_package_config) + set_tests_properties (cmake_package_config_generate PROPERTIES FIXTURES_SETUP + cmake_package_config_working) + + # Fixtures cleanup + set_tests_properties (cmake_package_config_cleanup PROPERTIES FIXTURES_CLEANUP + cmake_package_config) + + # Fixture requirements + set_tests_properties (cmake_package_config_generate PROPERTIES + FIXTURES_REQUIRED cmake_package_config) + set_tests_properties (cmake_package_config_build PROPERTIES + FIXTURES_REQUIRED "cmake_package_config;cmake_package_config_working") + + add_executable (cleanup_immediately_unittest + src/cleanup_immediately_unittest.cc) + + target_link_libraries (cleanup_immediately_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + add_executable (cleanup_with_absolute_prefix_unittest + src/cleanup_with_absolute_prefix_unittest.cc) + + target_link_libraries (cleanup_with_absolute_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + add_executable (cleanup_with_relative_prefix_unittest + src/cleanup_with_relative_prefix_unittest.cc) + + target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS}) + + set (CLEANUP_LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/cleanup_tests) + + add_test (NAME cleanup_init COMMAND + ${CMAKE_COMMAND} -E make_directory ${CLEANUP_LOG_DIR}) + add_test (NAME cleanup_logdir COMMAND + ${CMAKE_COMMAND} -E remove_directory ${CLEANUP_LOG_DIR}) + add_test (NAME cleanup_immediately COMMAND + ${CMAKE_COMMAND} + -DLOGCLEANUP=$ + # NOTE The trailing slash is important + -DTEST_DIR=${CLEANUP_LOG_DIR}/ + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest1.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_test (NAME cleanup_with_absolute_prefix COMMAND + ${CMAKE_COMMAND} + -DLOGCLEANUP=$ + -DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/ + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest2.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_test (NAME cleanup_with_relative_prefix COMMAND + ${CMAKE_COMMAND} + -DLOGCLEANUP=$ + -DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/ + -DTEST_SUBDIR=test_subdir/ + -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCleanerTest3.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + # Fixtures setup + set_tests_properties (cleanup_init PROPERTIES FIXTURES_SETUP logcleanuptest) + ## Fixtures cleanup + set_tests_properties (cleanup_logdir PROPERTIES FIXTURES_CLEANUP logcleanuptest) + # Fixture requirements + set_tests_properties (cleanup_immediately PROPERTIES FIXTURES_REQUIRED logcleanuptest) + set_tests_properties (cleanup_with_absolute_prefix PROPERTIES FIXTURES_REQUIRED logcleanuptest) + set_tests_properties (cleanup_with_relative_prefix PROPERTIES FIXTURES_REQUIRED logcleanuptest) +endif (BUILD_TESTING) + +install (TARGETS glog + EXPORT glog-targets + RUNTIME DESTINATION ${_glog_CMake_BINDIR} + PUBLIC_HEADER DESTINATION ${_glog_CMake_INCLUDE_DIR}/glog + LIBRARY DESTINATION ${_glog_CMake_LIBDIR} + ARCHIVE DESTINATION ${_glog_CMake_LIBDIR}) + +if (WITH_PKGCONFIG) + install ( + FILES "${PROJECT_BINARY_DIR}/libglog.pc" + DESTINATION "${_glog_CMake_LIBDIR}/pkgconfig" + ) +endif (WITH_PKGCONFIG) + +set (glog_CMake_VERSION 3.0) + +if (gflags_FOUND) + # Ensure clients locate only the package config and not third party find + # modules having the same name. This avoid cmake_policy PUSH/POP errors. + if (CMAKE_VERSION VERSION_LESS 3.9) + set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})") + else (CMAKE_VERSION VERSION_LESS 3.9) + # Passing additional find_package arguments to find_dependency is possible + # starting with CMake 3.9. + set (glog_CMake_VERSION 3.9) + set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION} NO_MODULE)") + endif (CMAKE_VERSION VERSION_LESS 3.9) +endif (gflags_FOUND) + +configure_package_config_file (glog-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake + INSTALL_DESTINATION ${_glog_CMake_INSTALLDIR} + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + +write_basic_package_version_file ( + ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake + COMPATIBILITY SameMajorVersion) + +export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake) +export (PACKAGE glog) + +get_filename_component (_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) + +# Directory containing the find modules relative to the config install +# directory. +file (RELATIVE_PATH glog_REL_CMake_MODULES + ${_PREFIX}/${_glog_CMake_INSTALLDIR} + ${_PREFIX}/${_glog_CMake_DATADIR}/glog-modules.cmake) + +get_filename_component (glog_REL_CMake_DATADIR ${glog_REL_CMake_MODULES} + DIRECTORY) + +set (glog_FULL_CMake_DATADIR + ${CMAKE_CURRENT_BINARY_DIR}/${_glog_CMake_DATADIR}) + +configure_file (glog-modules.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/glog-modules.cmake @ONLY) + +install (CODE +" +set (glog_FULL_CMake_DATADIR \"\\\${CMAKE_CURRENT_LIST_DIR}/${glog_REL_CMake_DATADIR}\") +set (glog_DATADIR_DESTINATION ${_glog_CMake_INSTALLDIR}) + +if (NOT IS_ABSOLUTE ${_glog_CMake_INSTALLDIR}) + set (glog_DATADIR_DESTINATION \"\${CMAKE_INSTALL_PREFIX}/\${glog_DATADIR_DESTINATION}\") +endif (NOT IS_ABSOLUTE ${_glog_CMake_INSTALLDIR}) + +configure_file (\"${CMAKE_CURRENT_SOURCE_DIR}/glog-modules.cmake.in\" + \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" @ONLY) +file (INSTALL + \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" + DESTINATION + \"\${glog_DATADIR_DESTINATION}\") +" + COMPONENT Development +) + +install (FILES + ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake + DESTINATION ${_glog_CMake_INSTALLDIR}) + +# Find modules in share/glog/cmake +install (DIRECTORY ${_glog_BINARY_CMake_DATADIR} + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/glog + COMPONENT Development + FILES_MATCHING PATTERN "*.cmake" +) + +install (EXPORT glog-targets NAMESPACE glog:: DESTINATION + ${_glog_CMake_INSTALLDIR}) diff --git a/funasr/runtime/onnxruntime/third_party/glog/CONTRIBUTORS b/funasr/runtime/onnxruntime/third_party/glog/CONTRIBUTORS new file mode 100644 index 000000000..05cb688cd --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/CONTRIBUTORS @@ -0,0 +1,52 @@ +# People who have agreed to one of the CLAs and can contribute patches. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# Names should be added to this file only after verifying that +# the individual or the individual's organization has agreed to +# the appropriate Contributor License Agreement, found here: +# +# https://developers.google.com/open-source/cla/individual +# https://developers.google.com/open-source/cla/corporate +# +# The agreement for individuals can be filled out on the web. +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file, depending on whether the +# individual or corporate CLA was used. +# +# Names should be added to this file as: +# Name +# +# Please keep the list sorted. + +Abhishek Dasgupta +Abhishek Parmar +Andrew Schwartzmeyer +Andy Ying +Bret McKee +Brian Silverman +Dmitriy Arbitman +Fumitoshi Ukai +Guillaume Dumont +Håkan L. S. Younes +Ivan Penkov +Jacob Trimble +Jim Ray +Marco Wang +Michael Darr +Michael Tanner +MiniLight +Peter Collingbourne +Rodrigo Queiro +romange +Roman Perepelitsa +Sergiu Deitsch +Shinichiro Hamaji +tbennun +Teddy Reed +Vijaymahantesh Sattigeri +Zhongming Qu +Zhuoran Shen diff --git a/funasr/runtime/onnxruntime/third_party/glog/COPYING b/funasr/runtime/onnxruntime/third_party/glog/COPYING new file mode 100644 index 000000000..38396b580 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/COPYING @@ -0,0 +1,65 @@ +Copyright (c) 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +A function gettimeofday in utilities.cc is based on + +http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd + +The license of this code is: + +Copyright (c) 2003-2008, Jouni Malinen and contributors +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name(s) of the above-listed copyright holder(s) nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/funasr/runtime/onnxruntime/third_party/glog/ChangeLog b/funasr/runtime/onnxruntime/third_party/glog/ChangeLog new file mode 100644 index 000000000..a107e9391 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/ChangeLog @@ -0,0 +1,109 @@ +2022-04-05 Google Inc. + + * google-glog: version 0.6.0. + * See git log for the details. + +2021-05-08 Google Inc. + + * google-glog: version 0.5.0. + * See git log for the details. + +2019-01-22 Google Inc. + + * google-glog: version 0.4.0. + * See git log for the details. + +2017-05-09 Google Inc. + + * google-glog: version 0.3.5 + * See git log for the details. + +2015-03-09 Google Inc. + + * google-glog: version 0.3.4 + * See git log for the details. + +2013-02-01 Google Inc. + + * google-glog: version 0.3.3 + * Add --disable-rtti option for configure. + * Visual Studio build and test fix. + * QNX build fix (thanks vanuan). + * Reduce warnings. + * Fixed LOG_SYSRESULT (thanks ukai). + * FreeBSD build fix (thanks yyanagisawa). + * Clang build fix. + * Now users can re-initialize glog after ShutdownGoogleLogging. + * Color output support by GLOG_colorlogtostderr (thanks alexs). + * Now glog's ABI around flags are compatible with gflags. + * Document mentions how to modify flags from user programs. + +2012-01-12 Google Inc. + + * google-glog: version 0.3.2 + * Clang support. + * Demangler and stacktrace improvement for newer GCCs. + * Now fork(2) doesn't mess up log files. + * Make valgrind happier. + * Reduce warnings for more -W options. + * Provide a workaround for ERROR defined by windows.h. + +2010-06-15 Google Inc. + + * google-glog: version 0.3.1 + * GLOG_* environment variables now work even when gflags is installed. + * Snow leopard support. + * Now we can build and test from out side tree. + * Add DCHECK_NOTNULL. + * Add ShutdownGoogleLogging to close syslog (thanks DGunchev) + * Fix --enable-frame-pointers option (thanks kazuki.ohta) + * Fix libunwind detection (thanks giantchen) + +2009-07-30 Google Inc. + + * google-glog: version 0.3.0 + * Fix a deadlock happened when user uses glog with recent gflags. + * Suppress several unnecessary warnings (thanks keir). + * NetBSD and OpenBSD support. + * Use Win32API GetComputeNameA properly (thanks magila). + * Fix user name detection for Windows (thanks ademin). + * Fix several minor bugs. + +2009-04-10 Google Inc. + * google-glog: version 0.2.1 + * Fix timestamps of VC++ version. + * Add pkg-config support (thanks Tomasz) + * Fix build problem when building with gtest (thanks Michael) + * Add --with-gflags option for configure (thanks Michael) + * Fixes for GCC 4.4 (thanks John) + +2009-01-23 Google Inc. + * google-glog: version 0.2 + * Add initial Windows VC++ support. + * Google testing/mocking frameworks integration. + * Link pthread library automatically. + * Flush logs in signal handlers. + * Add macros LOG_TO_STRING, LOG_AT_LEVEL, DVLOG, and LOG_TO_SINK_ONLY. + * Log microseconds. + * Add --log_backtrace_at option. + * Fix some minor bugs. + +2008-11-18 Google Inc. + * google-glog: version 0.1.2 + * Add InstallFailureSignalHandler(). (satorux) + * Re-organize the way to produce stacktraces. + * Don't define unnecessary macro DISALLOW_EVIL_CONSTRUCTORS. + +2008-10-15 Google Inc. + * google-glog: version 0.1.1 + * Support symbolize for MacOSX 10.5. + * BUG FIX: --vmodule didn't work with gflags. + * BUG FIX: symbolize_unittest failed with GCC 4.3. + * Several fixes on the document. + +2008-10-07 Google Inc. + + * google-glog: initial release: + The glog package contains a library that implements application-level + logging. This library provides logging APIs based on C++-style + streams and various helper macros. diff --git a/funasr/runtime/onnxruntime/third_party/glog/README.rst b/funasr/runtime/onnxruntime/third_party/glog/README.rst new file mode 100644 index 000000000..29a38d57a --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/README.rst @@ -0,0 +1,890 @@ +Google Logging Library +====================== + +|Linux Github actions| |Windows Github actions| |macOS Github actions| |Codecov| + +Google Logging (glog) is a C++14 library that implements application-level +logging. The library provides logging APIs based on C++-style streams and +various helper macros. + +.. role:: cmake(code) + :language: cmake + +.. role:: cmd(code) + :language: bash + +.. role:: cpp(code) + :language: cpp + +.. role:: bazel(code) + :language: starlark + + +Getting Started +--------------- + +You can log a message by simply streaming things to ``LOG``\ (`__>), e.g., + +.. code:: cpp + + #include + + int main(int argc, char* argv[]) { + // Initialize Google’s logging library. + google::InitGoogleLogging(argv[0]); + + // ... + LOG(INFO) << "Found " << num_cookies << " cookies"; + } + + +For a detailed overview of glog features and their usage, please refer +to the `user guide <#user-guide>`__. + +.. contents:: Table of Contents + + +Building from Source +-------------------- + +glog supports multiple build systems for compiling the project from +source: `Bazel <#bazel>`__, `CMake <#cmake>`__, `vcpkg <#vcpkg>`__, and `conan <#conan>`__. + +Bazel +~~~~~ + +To use glog within a project which uses the +`Bazel `__ build tool, add the following lines to +your ``WORKSPACE`` file: + +.. code:: bazel + + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + + http_archive( + name = "com_github_gflags_gflags", + sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", + strip_prefix = "gflags-2.2.2", + urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"], + ) + + http_archive( + name = "com_github_google_glog", + sha256 = "122fb6b712808ef43fbf80f75c52a21c9760683dae470154f02bddfc61135022", + strip_prefix = "glog-0.6.0", + urls = ["https://github.com/google/glog/archive/v0.6.0.zip"], + ) + +You can then add :bazel:`@com_github_google_glog//:glog` to the deps section +of a :bazel:`cc_binary` or :bazel:`cc_library` rule, and :code:`#include +` to include it in your source code. Here’s a simple example: + +.. code:: bazel + + cc_binary( + name = "main", + srcs = ["main.cc"], + deps = ["@com_github_google_glog//:glog"], + ) + +CMake +~~~~~ + +glog also supports CMake that can be used to build the project on a wide +range of platforms. If you don’t have CMake installed already, you can +download it for from CMake’s `official +website `__. + +CMake works by generating native makefiles or build projects that can be +used in the compiler environment of your choice. You can either build +glog with CMake as a standalone project or it can be incorporated into +an existing CMake build for another project. + +Building glog with CMake +^^^^^^^^^^^^^^^^^^^^^^^^ + +When building glog as a standalone project, on Unix-like systems with +GNU Make as build tool, the typical workflow is: + +1. Get the source code and change to it. e.g., cloning with git: + + .. code:: bash + + git clone https://github.com/google/glog.git + cd glog + +2. Run CMake to configure the build tree. + + .. code:: bash + + cmake -S . -B build -G "Unix Makefiles" + + CMake provides different generators, and by default will pick the most + relevant one to your environment. If you need a specific version of Visual + Studio, use :cmd:`cmake . -G `, and see :cmd:`cmake --help` + for the available generators. Also see :cmd:`-T `, which can + be used to request the native x64 toolchain with :cmd:`-T host=x64`. + +3. Afterwards, generated files can be used to compile the project. + + .. code:: bash + + cmake --build build + +4. Test the build software (optional). + + .. code:: bash + + cmake --build build --target test + +5. Install the built files (optional). + + .. code:: bash + + cmake --build build --target install + +Consuming glog in a CMake Project +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you have glog installed in your system, you can use the CMake command +:cmake:`find_package` to build against glog in your CMake Project as follows: + +.. code:: cmake + + cmake_minimum_required (VERSION 3.16) + project (myproj VERSION 1.0) + + find_package (glog 0.6.0 REQUIRED) + + add_executable (myapp main.cpp) + target_link_libraries (myapp glog::glog) + +Compile definitions and options will be added automatically to your +target as needed. + +Incorporating glog into a CMake Project +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can also use the CMake command :cmake:`add_subdirectory` to include glog +directly from a subdirectory of your project by replacing the +:cmake:`find_package` call from the previous example by +:cmake:`add_subdirectory`. The :cmake:`glog::glog` target is in this case an +:cmake:`ALIAS` library target for the ``glog`` library target. + +Again, compile definitions and options will be added automatically to +your target as needed. + +vcpkg +~~~~~ + +You can download and install glog using the `vcpkg +`__ dependency manager: + +.. code:: bash + + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh + ./vcpkg integrate install + ./vcpkg install glog + +The glog port in vcpkg is kept up to date by Microsoft team members and +community contributors. If the version is out of date, please create an +issue or pull request on the vcpkg repository. + +conan +~~~~~ + +You can download and install glog using the `conan +`__ package manager: + +.. code:: bash + + pip install conan + conan install -r conancenter glob/@ + +The glog recipe in conan center is kept up to date by conan center index community +contributors. If the version is out of date, please create an +issue or pull request on the `conan-center-index +`__ repository. + +User Guide +---------- + +glog defines a series of macros that simplify many common logging tasks. +You can log messages by severity level, control logging behavior from +the command line, log based on conditionals, abort the program when +expected conditions are not met, introduce your own verbose logging +levels, customize the prefix attached to log messages, and more. + +Following sections describe the functionality supported by glog. Please note +this description may not be complete but limited to the most useful ones. If you +want to find less common features, please check header files under `src/glog +`__ directory. + +Severity Levels +~~~~~~~~~~~~~~~ + +You can specify one of the following severity levels (in increasing +order of severity): ``INFO``, ``WARNING``, ``ERROR``, and ``FATAL``. +Logging a ``FATAL`` message terminates the program (after the message is +logged). Note that messages of a given severity are logged not only in +the logfile for that severity, but also in all logfiles of lower +severity. E.g., a message of severity ``FATAL`` will be logged to the +logfiles of severity ``FATAL``, ``ERROR``, ``WARNING``, and ``INFO``. + +The ``DFATAL`` severity logs a ``FATAL`` error in debug mode (i.e., +there is no ``NDEBUG`` macro defined), but avoids halting the program in +production by automatically reducing the severity to ``ERROR``. + +Unless otherwise specified, glog writes to the filename +``/tmp/\.\.\.log.\.\-\.\`` +(e.g., +``/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474``). +By default, glog copies the log messages of severity level ``ERROR`` or +``FATAL`` to standard error (``stderr``) in addition to log files. + +Setting Flags +~~~~~~~~~~~~~ + +Several flags influence glog’s output behavior. If the `Google gflags library +`__ is installed on your machine, the build +system will automatically detect and use it, allowing you to pass flags on the +command line. For example, if you want to turn the flag :cmd:`--logtostderr` on, +you can start your application with the following command line: + +.. code:: bash + + ./your_application --logtostderr=1 + +If the Google gflags library isn’t installed, you set flags via +environment variables, prefixing the flag name with ``GLOG_``, e.g., + +.. code:: bash + + GLOG_logtostderr=1 ./your_application + +The following flags are most commonly used: + +``logtostderr`` (``bool``, default=\ ``false``) + Log messages to ``stderr`` instead of logfiles. Note: you can set + binary flags to ``true`` by specifying ``1``, ``true``, or ``yes`` + (case insensitive). Also, you can set binary flags to ``false`` by + specifying ``0``, ``false``, or ``no`` (again, case insensitive). + +``stderrthreshold`` (``int``, default=2, which is ``ERROR``) + Copy log messages at or above this level to stderr in addition to + logfiles. The numbers of severity levels ``INFO``, ``WARNING``, + ``ERROR``, and ``FATAL`` are 0, 1, 2, and 3, respectively. + +``minloglevel`` (``int``, default=0, which is ``INFO``) + Log messages at or above this level. Again, the numbers of severity + levels ``INFO``, ``WARNING``, ``ERROR``, and ``FATAL`` are 0, 1, 2, + and 3, respectively. + +``log_dir`` (``string``, default="") + If specified, logfiles are written into this directory instead of the + default logging directory. + +``v`` (``int``, default=0) + Show all ``VLOG(m)`` messages for ``m`` less or equal the value of + this flag. Overridable by :cmd:`--vmodule`. See `the section about + verbose logging <#verbose-logging>`__ for more detail. + +``vmodule`` (``string``, default="") + Per-module verbose level. The argument has to contain a + comma-separated list of =. is a + glob pattern (e.g., ``gfs*`` for all modules whose name starts with + "gfs"), matched against the filename base (that is, name ignoring + .cc/.h./-inl.h). overrides any value given by :cmd:`--v`. + See also `the section about verbose logging <#verbose-logging>`__. + +There are some other flags defined in logging.cc. Please grep the source +code for ``DEFINE_`` to see a complete list of all flags. + +You can also modify flag values in your program by modifying global +variables ``FLAGS_*`` . Most settings start working immediately after +you update ``FLAGS_*`` . The exceptions are the flags related to +destination files. For example, you might want to set ``FLAGS_log_dir`` +before calling :cpp:`google::InitGoogleLogging` . Here is an example: + +.. code:: cpp + + LOG(INFO) << "file"; + // Most flags work immediately after updating values. + FLAGS_logtostderr = 1; + LOG(INFO) << "stderr"; + FLAGS_logtostderr = 0; + // This won’t change the log destination. If you want to set this + // value, you should do this before google::InitGoogleLogging . + FLAGS_log_dir = "/some/log/directory"; + LOG(INFO) << "the same file"; + +Conditional / Occasional Logging +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sometimes, you may only want to log a message under certain conditions. +You can use the following macros to perform conditional logging: + +.. code:: cpp + + LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; + +The "Got lots of cookies" message is logged only when the variable +``num_cookies`` exceeds 10. If a line of code is executed many times, it +may be useful to only log a message at certain intervals. This kind of +logging is most useful for informational messages. + +.. code:: cpp + + LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; + +The above line outputs a log messages on the 1st, 11th, 21st, ... times +it is executed. Note that the special ``google::COUNTER`` value is used +to identify which repetition is happening. + +You can combine conditional and occasional logging with the following +macro. + +.. code:: cpp + + LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER + << "th big cookie"; + +Instead of outputting a message every nth time, you can also limit the +output to the first n occurrences: + +.. code:: cpp + + LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie"; + +Outputs log messages for the first 20 times it is executed. Again, the +``google::COUNTER`` identifier indicates which repetition is happening. + +Other times, it is desired to only log a message periodically based on a time. +So for example, to log a message every 10ms: + +.. code:: cpp + + LOG_EVERY_T(INFO, 0.01) << "Got a cookie"; + +Or every 2.35s: + +.. code:: cpp + + LOG_EVERY_T(INFO, 2.35) << "Got a cookie"; + +Debug Mode Support +~~~~~~~~~~~~~~~~~~ + +Special "debug mode" logging macros only have an effect in debug mode +and are compiled away to nothing for non-debug mode compiles. Use these +macros to avoid slowing down your production application due to +excessive logging. + +.. code:: cpp + + DLOG(INFO) << "Found cookies"; + DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; + DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; + + +``CHECK`` Macros +~~~~~~~~~~~~~~~~ + +It is a good practice to check expected conditions in your program +frequently to detect errors as early as possible. The ``CHECK`` macro +provides the ability to abort the application when a condition is not +met, similar to the ``assert`` macro defined in the standard C library. + +``CHECK`` aborts the application if a condition is not true. Unlike +``assert``, it is \*not\* controlled by ``NDEBUG``, so the check will be +executed regardless of compilation mode. Therefore, ``fp->Write(x)`` in +the following example is always executed: + +.. code:: cpp + + CHECK(fp->Write(x) == 4) << "Write failed!"; + +There are various helper macros for equality/inequality checks - +``CHECK_EQ``, ``CHECK_NE``, ``CHECK_LE``, ``CHECK_LT``, ``CHECK_GE``, +and ``CHECK_GT``. They compare two values, and log a ``FATAL`` message +including the two values when the result is not as expected. The values +must have :cpp:`operator<<(ostream, ...)` defined. + +You may append to the error message like so: + +.. code:: cpp + + CHECK_NE(1, 2) << ": The world must be ending!"; + +We are very careful to ensure that each argument is evaluated exactly +once, and that anything which is legal to pass as a function argument is +legal here. In particular, the arguments may be temporary expressions +which will end up being destroyed at the end of the apparent statement, +for example: + +.. code:: cpp + + CHECK_EQ(string("abc")[1], ’b’); + +The compiler reports an error if one of the arguments is a pointer and the other +is :cpp:`nullptr`. To work around this, simply :cpp:`static_cast` :cpp:`nullptr` to +the type of the desired pointer. + +.. code:: cpp + + CHECK_EQ(some_ptr, static_cast(nullptr)); + +Better yet, use the ``CHECK_NOTNULL`` macro: + +.. code:: cpp + + CHECK_NOTNULL(some_ptr); + some_ptr->DoSomething(); + +Since this macro returns the given pointer, this is very useful in +constructor initializer lists. + +.. code:: cpp + + struct S { + S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {} + Something* ptr_; + }; + +Note that you cannot use this macro as a C++ stream due to this feature. +Please use ``CHECK_EQ`` described above to log a custom message before +aborting the application. + +If you are comparing C strings (:cpp:`char *`), a handy set of macros performs +case sensitive as well as case insensitive comparisons - ``CHECK_STREQ``, +``CHECK_STRNE``, ``CHECK_STRCASEEQ``, and ``CHECK_STRCASENE``. The CASE versions +are case-insensitive. You can safely pass :cpp:`nullptr` pointers for this macro. They +treat :cpp:`nullptr` and any non-:cpp:`nullptr` string as not equal. Two :cpp:`nullptr`\ +s are equal. + +Note that both arguments may be temporary strings which are destructed +at the end of the current "full expression" (e.g., +:cpp:`CHECK_STREQ(Foo().c_str(), Bar().c_str())` where ``Foo`` and ``Bar`` +return C++’s :cpp:`std::string`). + +The ``CHECK_DOUBLE_EQ`` macro checks the equality of two floating point +values, accepting a small error margin. ``CHECK_NEAR`` accepts a third +floating point argument, which specifies the acceptable error margin. + +Verbose Logging +~~~~~~~~~~~~~~~ + +When you are chasing difficult bugs, thorough log messages are very useful. +However, you may want to ignore too verbose messages in usual development. For +such verbose logging, glog provides the ``VLOG`` macro, which allows you to +define your own numeric logging levels. The :cmd:`--v` command line option +controls which verbose messages are logged: + +.. code:: cpp + + VLOG(1) << "I’m printed when you run the program with --v=1 or higher"; + VLOG(2) << "I’m printed when you run the program with --v=2 or higher"; + +With ``VLOG``, the lower the verbose level, the more likely messages are to be +logged. For example, if :cmd:`--v==1`, ``VLOG(1)`` will log, but ``VLOG(2)`` +will not log. This is opposite of the severity level, where ``INFO`` is 0, and +``ERROR`` is 2. :cmd:`--minloglevel` of 1 will log ``WARNING`` and above. Though +you can specify any integers for both ``VLOG`` macro and :cmd:`--v` flag, the +common values for them are small positive integers. For example, if you write +``VLOG(0)``, you should specify :cmd:`--v=-1` or lower to silence it. This is +less useful since we may not want verbose logs by default in most cases. The +``VLOG`` macros always log at the ``INFO`` log level (when they log at all). + +Verbose logging can be controlled from the command line on a per-module +basis: + +.. code:: bash + + --vmodule=mapreduce=2,file=1,gfs*=3 --v=0 + +will: + +(a) Print ``VLOG(2)`` and lower messages from mapreduce.{h,cc} +(b) Print ``VLOG(1)`` and lower messages from file.{h,cc} +(c) Print ``VLOG(3)`` and lower messages from files prefixed with "gfs" +(d) Print ``VLOG(0)`` and lower messages from elsewhere + +The wildcarding functionality shown by (c) supports both ’*’ (matches 0 +or more characters) and ’?’ (matches any single character) wildcards. +Please also check the section about `command line flags <#setting-flags>`__. + +There’s also ``VLOG_IS_ON(n)`` "verbose level" condition macro. This +macro returns true when the :cmd:`--v` is equal or greater than ``n``. To +be used as + +.. code:: cpp + + if (VLOG_IS_ON(2)) { + // do some logging preparation and logging + // that can’t be accomplished with just VLOG(2) << ...; + } + +Verbose level condition macros ``VLOG_IF``, ``VLOG_EVERY_N`` and +``VLOG_IF_EVERY_N`` behave analogous to ``LOG_IF``, ``LOG_EVERY_N``, +``LOF_IF_EVERY``, but accept a numeric verbosity level as opposed to a +severity level. + +.. code:: cpp + + VLOG_IF(1, (size > 1024)) + << "I’m printed when size is more than 1024 and when you run the " + "program with --v=1 or more"; + VLOG_EVERY_N(1, 10) + << "I’m printed every 10th occurrence, and when you run the program " + "with --v=1 or more. Present occurence is " << google::COUNTER; + VLOG_IF_EVERY_N(1, (size > 1024), 10) + << "I’m printed on every 10th occurence of case when size is more " + " than 1024, when you run the program with --v=1 or more. "; + "Present occurence is " << google::COUNTER; + + +Custom Log Prefix Format +~~~~~~~~~~~~~~~~~~~~~~~~ + +glog supports changing the format of the prefix attached to log messages by +receiving a user-provided callback to be used to generate such strings. + +For each log entry, the callback will be invoked with a ``LogMessageInfo`` +struct containing the severity, filename, line number, thread ID, and time of +the event. It will also be given a reference to the output stream, whose +contents will be prepended to the actual message in the final log line. + +For example: + +.. code:: cpp + + /* This function writes a prefix that matches glog's default format. + * (The third parameter can be used to receive user-supplied data, and is + * nullptr by default.) + */ + void CustomPrefix(std::ostream &s, const LogMessageInfo &l, void*) { + s << l.severity[0] + << setw(4) << 1900 + l.time.year() + << setw(2) << 1 + l.time.month() + << setw(2) << l.time.day() + << ' ' + << setw(2) << l.time.hour() << ':' + << setw(2) << l.time.min() << ':' + << setw(2) << l.time.sec() << "." + << setw(6) << l.time.usec() + << ' ' + << setfill(' ') << setw(5) + << l.thread_id << setfill('0') + << ' ' + << l.filename << ':' << l.line_number << "]"; + } + + +To enable the use of ``CustomPrefix()``, simply give glog a pointer to it +during initialization: ``InitGoogleLogging(argv[0], &CustomPrefix);``. + +Optionally, ``InitGoogleLogging()`` takes a third argument of type ``void*`` +to pass on to the callback function. + +Failure Signal Handler +~~~~~~~~~~~~~~~~~~~~~~ + +The library provides a convenient signal handler that will dump useful +information when the program crashes on certain signals such as ``SIGSEGV``. The +signal handler can be installed by :cpp:`google::InstallFailureSignalHandler()`. +The following is an example of output from the signal handler. + +:: + + *** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date *** + *** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: *** + PC: @ 0x412eb1 TestWaitingLogSink::send() + @ 0x7f892fb417d0 (unknown) + @ 0x412eb1 TestWaitingLogSink::send() + @ 0x7f89304f7f06 google::LogMessage::SendToLog() + @ 0x7f89304f35af google::LogMessage::Flush() + @ 0x7f89304f3739 google::LogMessage::~LogMessage() + @ 0x408cf4 TestLogSinkWaitTillSent() + @ 0x4115de main + @ 0x7f892f7ef1c4 (unknown) + @ 0x4046f9 (unknown) + +By default, the signal handler writes the failure dump to the standard +error. You can customize the destination by :cpp:`InstallFailureWriter()`. + +Performance of Messages +~~~~~~~~~~~~~~~~~~~~~~~ + +The conditional logging macros provided by glog (e.g., ``CHECK``, +``LOG_IF``, ``VLOG``, etc.) are carefully implemented and don’t execute +the right hand side expressions when the conditions are false. So, the +following check may not sacrifice the performance of your application. + +.. code:: cpp + + CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow(); + +User-defined Failure Function +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``FATAL`` severity level messages or unsatisfied ``CHECK`` condition +terminate your program. You can change the behavior of the termination +by :cpp:`InstallFailureFunction`. + +.. code:: cpp + + void YourFailureFunction() { + // Reports something... + exit(EXIT_FAILURE); + } + + int main(int argc, char* argv[]) { + google::InstallFailureFunction(&YourFailureFunction); + } + +By default, glog tries to dump stacktrace and makes the program exit +with status 1. The stacktrace is produced only when you run the program +on an architecture for which glog supports stack tracing (as of +September 2008, glog supports stack tracing for x86 and x86_64). + +Raw Logging +~~~~~~~~~~~ + +The header file ```` can be used for thread-safe logging, +which does not allocate any memory or acquire any locks. Therefore, the macros +defined in this header file can be used by low-level memory allocation and +synchronization code. Please check `src/glog/raw_logging.h.in +`__ for detail. + +Google Style ``perror()`` +~~~~~~~~~~~~~~~~~~~~~~~~~ + +``PLOG()`` and ``PLOG_IF()`` and ``PCHECK()`` behave exactly like their +``LOG*`` and ``CHECK`` equivalents with the addition that they append a +description of the current state of errno to their output lines. E.g. + +.. code:: cpp + + PCHECK(write(1, nullptr, 2) >= 0) << "Write nullptr failed"; + +This check fails with the following error message. + +:: + + F0825 185142 test.cc:22] Check failed: write(1, nullptr, 2) >= 0 Write nullptr failed: Bad address [14] + +Syslog +~~~~~~ + +``SYSLOG``, ``SYSLOG_IF``, and ``SYSLOG_EVERY_N`` macros are available. +These log to syslog in addition to the normal logs. Be aware that +logging to syslog can drastically impact performance, especially if +syslog is configured for remote logging! Make sure you understand the +implications of outputting to syslog before you use these macros. In +general, it’s wise to use these macros sparingly. + +Strip Logging Messages +~~~~~~~~~~~~~~~~~~~~~~ + +Strings used in log messages can increase the size of your binary and +present a privacy concern. You can therefore instruct glog to remove all +strings which fall below a certain severity level by using the +``GOOGLE_STRIP_LOG`` macro: + +If your application has code like this: + +.. code:: cpp + + #define GOOGLE_STRIP_LOG 1 // this must go before the #include! + #include + +The compiler will remove the log messages whose severities are less than +the specified integer value. Since ``VLOG`` logs at the severity level +``INFO`` (numeric value ``0``), setting ``GOOGLE_STRIP_LOG`` to 1 or +greater removes all log messages associated with ``VLOG``\ s as well as +``INFO`` log statements. + +Automatically Remove Old Logs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To enable the log cleaner: + +.. code:: cpp + + google::EnableLogCleaner(3); // keep your logs for 3 days + +And then glog will check if there are overdue logs whenever a flush is +performed. In this example, any log file from your project whose last +modified time is greater than 3 days will be unlink()ed. + +This feature can be disabled at any time (if it has been enabled) + +.. code:: cpp + + google::DisableLogCleaner(); + +Notes for Windows Users +~~~~~~~~~~~~~~~~~~~~~~~ + +glog defines a severity level ``ERROR``, which is also defined in +``windows.h`` . You can make glog not define ``INFO``, ``WARNING``, +``ERROR``, and ``FATAL`` by defining ``GLOG_NO_ABBREVIATED_SEVERITIES`` +before including ``glog/logging.h`` . Even with this macro, you can +still use the iostream like logging facilities: + +.. code:: cpp + + #define GLOG_NO_ABBREVIATED_SEVERITIES + #include + #include + + // ... + + LOG(ERROR) << "This should work"; + LOG_IF(ERROR, x > y) << "This should be also OK"; + +However, you cannot use ``INFO``, ``WARNING``, ``ERROR``, and ``FATAL`` +anymore for functions defined in ``glog/logging.h`` . + +.. code:: cpp + + #define GLOG_NO_ABBREVIATED_SEVERITIES + #include + #include + + // ... + + // This won’t work. + // google::FlushLogFiles(google::ERROR); + + // Use this instead. + google::FlushLogFiles(google::GLOG_ERROR); + +If you don’t need ``ERROR`` defined by ``windows.h``, there are a couple +of more workarounds which sometimes don’t work: + +- ``#define WIN32_LEAN_AND_MEAN`` or ``NOGDI`` **before** you + ``#include windows.h``. +- ``#undef ERROR`` **after** you ``#include windows.h`` . + +See `this +issue `__ for +more detail. + + +Installation Notes for 64-bit Linux Systems +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The glibc built-in stack-unwinder on 64-bit systems has some problems with glog. +(In particular, if you are using :cpp:`InstallFailureSignalHandler()`, the +signal may be raised in the middle of malloc, holding some malloc-related locks +when they invoke the stack unwinder. The built-in stack unwinder may call malloc +recursively, which may require the thread to acquire a lock it already holds: +deadlock.) + +For that reason, if you use a 64-bit system and you need +:cpp:`InstallFailureSignalHandler()`, we strongly recommend you install +``libunwind`` before trying to configure or install google glog. +libunwind can be found +`here `__. + +Even if you already have ``libunwind`` installed, you will probably +still need to install from the snapshot to get the latest version. + +Caution: if you install libunwind from the URL above, be aware that you +may have trouble if you try to statically link your binary with glog: +that is, if you link with ``gcc -static -lgcc_eh ...``. This is because +both ``libunwind`` and ``libgcc`` implement the same C++ exception +handling APIs, but they implement them differently on some platforms. +This is not likely to be a problem on ia64, but may be on x86-64. + +Also, if you link binaries statically, make sure that you add +:cmd:`-Wl,--eh-frame-hdr` to your linker options. This is required so that +``libunwind`` can find the information generated by the compiler required for +stack unwinding. + +Using :cmd:`-static` is rare, though, so unless you know this will affect you it +probably won’t. + +If you cannot or do not wish to install libunwind, you can still try to +use two kinds of stack-unwinder: 1. glibc built-in stack-unwinder and 2. +frame pointer based stack-unwinder. + +1. As we already mentioned, glibc’s unwinder has a deadlock issue. + However, if you don’t use :cpp:`InstallFailureSignalHandler()` or you + don’t worry about the rare possibilities of deadlocks, you can use + this stack-unwinder. If you specify no options and ``libunwind`` + isn’t detected on your system, the configure script chooses this + unwinder by default. + +2. The frame pointer based stack unwinder requires that your + application, the glog library, and system libraries like libc, all be + compiled with a frame pointer. This is *not* the default for x86-64. + + +How to Contribute +----------------- + +We’d love to accept your patches and contributions to this project. +There are a just a few small guidelines you need to follow. + +Contributor License Agreement (CLA) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Contributions to any Google project must be accompanied by a Contributor +License Agreement. This is not a copyright **assignment**, it simply +gives Google permission to use and redistribute your contributions as +part of the project. + +* If you are an individual writing original source code and you’re sure + you own the intellectual property, then you’ll need to sign an + `individual + CLA `__. +* If you work for a company that wants to allow you to contribute your + work, then you’ll need to sign a `corporate + CLA `__. + +You generally only need to submit a CLA once, so if you’ve already +submitted one (even if it was for a different project), you probably +don’t need to do it again. + +Once your CLA is submitted (or if you already submitted one for another +Google project), make a commit adding yourself to the +`AUTHORS <./AUTHORS>`__ and `CONTRIBUTORS <./CONTRIBUTORS>`__ files. This +commit can be part of your first `pull +request `__. + +Submitting a Patch +~~~~~~~~~~~~~~~~~~ + +1. It’s generally best to start by opening a new issue describing the + bug or feature you’re intending to fix. Even if you think it’s + relatively minor, it’s helpful to know what people are working on. + Mention in the initial issue that you are planning to work on that + bug or feature so that it can be assigned to you. +2. Follow the normal process of + `forking `__ the + project, and setup a new branch to work in. It’s important that each + group of changes be done in separate branches in order to ensure that + a pull request only includes the commits related to that bug or + feature. +3. Do your best to have `well-formed commit + messages `__ + for each change. This provides consistency throughout the project, + and ensures that commit messages are able to be formatted properly by + various git tools. +4. Finally, push the commits to your fork and submit a `pull + request `__. + + +.. |Linux Github actions| image:: https://github.com/google/glog/actions/workflows/linux.yml/badge.svg + :target: https://github.com/google/glog/actions +.. |Windows Github actions| image:: https://github.com/google/glog/actions/workflows/windows.yml/badge.svg + :target: https://github.com/google/glog/actions +.. |macOS Github actions| image:: https://github.com/google/glog/actions/workflows/macos.yml/badge.svg + :target: https://github.com/google/glog/actions +.. |Codecov| image:: https://codecov.io/gh/google/glog/branch/master/graph/badge.svg?token=8an420vNju + :target: https://codecov.io/gh/google/glog diff --git a/funasr/runtime/onnxruntime/third_party/glog/WORKSPACE b/funasr/runtime/onnxruntime/third_party/glog/WORKSPACE new file mode 100644 index 000000000..6f8714baa --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/WORKSPACE @@ -0,0 +1,18 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "com_github_gflags_gflags", + sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", + strip_prefix = "gflags-2.2.2", + urls = [ + "https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz", + "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz", + ], +) + +http_archive( + name = "com_github_google_googletest", + sha256 = "258f33ab1a8ee17adf48ec65e821d0ea9eafcbedeff6110f9eaed78472e73dde", + strip_prefix = "googletest-15460959cbbfa20e66ef0b5ab497367e47fc0a04", + urls = ["https://github.com/google/googletest/archive/15460959cbbfa20e66ef0b5ab497367e47fc0a04.tar.gz"], +) diff --git a/funasr/runtime/onnxruntime/third_party/glog/bazel/example/BUILD.bazel b/funasr/runtime/onnxruntime/third_party/glog/bazel/example/BUILD.bazel new file mode 100644 index 000000000..05ab0f3e7 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/bazel/example/BUILD.bazel @@ -0,0 +1,9 @@ +cc_test( + name = "main", + size = "small", + srcs = ["main.cc"], + deps = [ + "//:glog", + "@com_github_gflags_gflags//:gflags", + ], +) diff --git a/funasr/runtime/onnxruntime/third_party/glog/bazel/example/main.cc b/funasr/runtime/onnxruntime/third_party/glog/bazel/example/main.cc new file mode 100644 index 000000000..fef01dc15 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/bazel/example/main.cc @@ -0,0 +1,22 @@ +#include +#include +#include + +int main(int argc, char* argv[]) { + // Initialize Google's logging library. + google::InitGoogleLogging(argv[0]); + + // Optional: parse command line flags + gflags::ParseCommandLineFlags(&argc, &argv, true); + + LOG(INFO) << "Hello, world!"; + + // glog/stl_logging.h allows logging STL containers. + std::vector x; + x.push_back(1); + x.push_back(2); + x.push_back(3); + LOG(INFO) << "ABC, it's easy as " << x; + + return 0; +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/bazel/glog.bzl b/funasr/runtime/onnxruntime/third_party/glog/bazel/glog.bzl new file mode 100644 index 000000000..c25a786f8 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/bazel/glog.bzl @@ -0,0 +1,307 @@ +# Implement a macro glog_library() that the BUILD.bazel file can load. + +# By default, glog is built with gflags support. You can change this behavior +# by using glog_library(with_gflags=0) +# +# This file is inspired by the following sample BUILD files: +# https://github.com/google/glog/issues/61 +# https://github.com/google/glog/files/393474/BUILD.txt +# +# Known issue: the namespace parameter is not supported on Win32. + +def expand_template_impl(ctx): + ctx.actions.expand_template( + template = ctx.file.template, + output = ctx.outputs.out, + substitutions = ctx.attr.substitutions, + ) + +expand_template = rule( + implementation = expand_template_impl, + attrs = { + "template": attr.label(mandatory = True, allow_single_file = True), + "substitutions": attr.string_dict(mandatory = True), + "out": attr.output(mandatory = True), + }, +) + +def dict_union(x, y): + z = {} + z.update(x) + z.update(y) + return z + +def glog_library(namespace = "google", with_gflags = 1, **kwargs): + if native.repository_name() != "@": + repo_name = native.repository_name()[1:] # Strip the first leading @ + gendir = "$(GENDIR)/external/" + repo_name + src_windows = "external/%s/src/windows" % repo_name + else: + gendir = "$(GENDIR)" + src_windows = "src/windows" + + # Config setting for WebAssembly target. + native.config_setting( + name = "wasm", + values = {"cpu": "wasm"}, + ) + + # Detect when building with clang-cl on Windows. + native.config_setting( + name = "clang-cl", + values = {"compiler": "clang-cl"}, + ) + + common_copts = [ + "-std=c++14", + "-DGLOG_BAZEL_BUILD", + # Inject a C++ namespace. + "-DGOOGLE_NAMESPACE='%s'" % namespace, + "-DHAVE_STRING_H", + "-I%s/glog_internal" % gendir, + ] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else []) + + wasm_copts = [ + # Disable warnings that exists in glog. + "-Wno-sign-compare", + "-Wno-unused-function", + "-Wno-unused-local-typedefs", + "-Wno-unused-variable", + # Allows src/base/mutex.h to include pthread.h. + "-DHAVE_PTHREAD", + # Allows src/logging.cc to determine the host name. + "-DHAVE_SYS_UTSNAME_H", + # For src/utilities.cc. + "-DHAVE_SYS_TIME_H", + "-DHAVE__UNWIND_BACKTRACE", + "-DHAVE__UNWIND_GETIP", + # Enable dumping stacktrace upon sigaction. + "-DHAVE_SIGACTION", + # For logging.cc. + "-DHAVE_PREAD", + "-DHAVE___ATTRIBUTE__", + ] + + linux_or_darwin_copts = wasm_copts + [ + "-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))", + # For src/utilities.cc. + "-DHAVE_SYS_SYSCALL_H", + # For src/logging.cc to create symlinks. + "-DHAVE_UNISTD_H", + "-fvisibility-inlines-hidden", + "-fvisibility=hidden", + ] + + freebsd_only_copts = [ + # Enable declaration of _Unwind_Backtrace + "-D_GNU_SOURCE", + ] + + linux_only_copts = [ + # For utilities.h. + "-DHAVE_EXECINFO_H", + ] + + darwin_only_copts = [ + # For stacktrace. + "-DHAVE_DLADDR", + # Avoid deprecated syscall(). + "-DHAVE_PTHREAD_THREADID_NP", + ] + + windows_only_copts = [ + # Override -DGLOG_EXPORT= from the cc_library's defines. + "-DGLOG_EXPORT=__declspec(dllexport)", + "-DGLOG_NO_ABBREVIATED_SEVERITIES", + "-DHAVE_SNPRINTF", + "-I" + src_windows, + ] + + clang_cl_only_copts = [ + # Allow the override of -DGLOG_EXPORT. + "-Wno-macro-redefined", + ] + + windows_only_srcs = [ + "src/glog/log_severity.h", + "src/windows/dirent.h", + "src/windows/port.cc", + "src/windows/port.h", + ] + + gflags_deps = ["@com_github_gflags_gflags//:gflags"] if with_gflags else [] + + final_lib_defines = select({ + # GLOG_EXPORT is normally set by export.h, but that's not + # generated for Bazel. + "@bazel_tools//src/conditions:windows": [ + "GLOG_EXPORT=", + "GLOG_DEPRECATED=__declspec(deprecated)", + "GLOG_NO_ABBREVIATED_SEVERITIES", + ], + "//conditions:default": [ + "GLOG_DEPRECATED=__attribute__((deprecated))", + "GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))", + ], + }) + + final_lib_copts = select({ + "@bazel_tools//src/conditions:windows": common_copts + windows_only_copts, + "@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts, + "@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts, + ":wasm": common_copts + wasm_copts, + "//conditions:default": common_copts + linux_or_darwin_copts + linux_only_copts, + }) + select({ + ":clang-cl": clang_cl_only_copts, + "//conditions:default": [], + }) + + native.cc_library( + name = "glog", + visibility = ["//visibility:public"], + srcs = [ + ":config_h", + "src/base/commandlineflags.h", + "src/base/googleinit.h", + "src/base/mutex.h", + "src/demangle.cc", + "src/demangle.h", + "src/logging.cc", + "src/raw_logging.cc", + "src/signalhandler.cc", + "src/stacktrace.h", + "src/stacktrace_generic-inl.h", + "src/stacktrace_libunwind-inl.h", + "src/stacktrace_powerpc-inl.h", + "src/stacktrace_unwind-inl.h", + "src/stacktrace_windows-inl.h", + "src/stacktrace_x86-inl.h", + "src/symbolize.cc", + "src/symbolize.h", + "src/utilities.cc", + "src/utilities.h", + "src/vlog_is_on.cc", + ] + select({ + "@bazel_tools//src/conditions:windows": windows_only_srcs, + "//conditions:default": [], + }), + hdrs = [ + "src/glog/log_severity.h", + "src/glog/platform.h", + ":logging_h", + ":raw_logging_h", + ":stl_logging_h", + ":vlog_is_on_h", + ], + strip_include_prefix = "src", + defines = final_lib_defines, + copts = final_lib_copts, + deps = gflags_deps + select({ + "@bazel_tools//src/conditions:windows": [":strip_include_prefix_hack"], + "//conditions:default": [], + }), + **kwargs + ) + + test_list = [ + "cleanup_immediately", + "cleanup_with_absolute_prefix", + "cleanup_with_relative_prefix", + # "demangle", # Broken + # "logging", # Broken + # "mock-log", # Broken + # "signalhandler", # Pointless + "stacktrace", + "stl_logging", + # "symbolize", # Broken + "utilities", + ] + + test_only_copts = [ + "-DTEST_SRC_DIR=\\\"%s/tests\\\"" % gendir, + ] + + for test_name in test_list: + native.cc_test( + name = test_name + "_test", + visibility = ["//visibility:public"], + srcs = [ + "src/googletest.h", + "src/" + test_name + "_unittest.cc", + ], + defines = final_lib_defines, + copts = final_lib_copts + test_only_copts, + deps = [ + ":glog", + "@com_github_google_googletest//:gtest", + ], + **kwargs + ) + + # Workaround https://github.com/bazelbuild/bazel/issues/6337 by declaring + # the dependencies without strip_include_prefix. + native.cc_library( + name = "strip_include_prefix_hack", + hdrs = [ + "src/glog/log_severity.h", + ":logging_h", + ":raw_logging_h", + ":stl_logging_h", + ":vlog_is_on_h", + ], + ) + + expand_template( + name = "config_h", + template = "src/config.h.cmake.in", + out = "glog_internal/config.h", + substitutions = {"#cmakedefine": "//cmakedefine"}, + ) + + common_config = { + "@ac_cv_have_u_int16_t@": "0", + "@ac_cv_have_glog_export@": "0", + "@ac_google_start_namespace@": "namespace google {", + "@ac_google_end_namespace@": "}", + "@ac_google_namespace@": "google", + } + + posix_config = dict_union(common_config, { + "@ac_cv___attribute___noinline@": "__attribute__((noinline))", + "@ac_cv___attribute___printf_4_5@": "__attribute__((__format__(__printf__, 4, 5)))", + "@ac_cv_have___builtin_expect@": "1", + "@ac_cv_have_libgflags@": "1" if with_gflags else "0", + "@ac_cv_have_mode_t@": "1", + "@ac_cv_have_ssize_t@": "1", + "@ac_cv_have_systypes_h@": "1", + "@ac_cv_have_unistd_h@": "1", + }) + + windows_config = dict_union(common_config, { + "@ac_cv___attribute___noinline@": "", + "@ac_cv___attribute___printf_4_5@": "", + "@ac_cv_have___builtin_expect@": "0", + "@ac_cv_have_libgflags@": "0", + "@ac_cv_have_mode_t@": "0", + "@ac_cv_have_ssize_t@": "0", + "@ac_cv_have_systypes_h@": "0", + "@ac_cv_have_unistd_h@": "0", + }) + + [ + expand_template( + name = "%s_h" % f, + template = "src/glog/%s.h.in" % f, + out = "src/glog/%s.h" % f, + substitutions = select({ + "@bazel_tools//src/conditions:windows": windows_config, + "//conditions:default": posix_config, + }), + ) + for f in [ + "vlog_is_on", + "stl_logging", + "raw_logging", + "logging", + ] + ] diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/DetermineGflagsNamespace.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/DetermineGflagsNamespace.cmake new file mode 100644 index 000000000..3dde42b4b --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/DetermineGflagsNamespace.cmake @@ -0,0 +1,69 @@ +macro(determine_gflags_namespace VARIABLE) + if (NOT DEFINED "${VARIABLE}") + if (CMAKE_REQUIRED_INCLUDES) + set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}") + else () + set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS) + endif () + + set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) + + set(_NAMESPACES gflags google) + set(_check_code +" +#include + +int main(int argc, char**argv) +{ + GLOG_GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true); +} +") + if (NOT CMAKE_REQUIRED_QUIET) + message (STATUS "Looking for gflags namespace") + endif () + if (${ARGC} EQUAL 3) + set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}") + endif () + + set (_check_file + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx) + + foreach (_namespace ${_NAMESPACES}) + file (WRITE "${_check_file}" "${_check_code}") + try_compile (${VARIABLE} + "${CMAKE_BINARY_DIR}" "${_check_file}" + COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGLOG_GFLAGS_NAMESPACE=${_namespace} + LINK_LIBRARIES gflags + CMAKE_FLAGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + OUTPUT_VARIABLE OUTPUT) + + if (${VARIABLE}) + set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE) + break () + else () + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining the gflags namespace ${_namespace} failed with the following output:\n" + "${OUTPUT}\n\n") + endif () + endforeach (_namespace) + + if (${ARGC} EQUAL 3) + set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE}) + endif () + + if (${VARIABLE}) + if (NOT CMAKE_REQUIRED_QUIET) + message (STATUS "Looking for gflags namespace - ${${VARIABLE}}") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining the gflags namespace passed with the following output:\n" + "${OUTPUT}\n\n") + else () + if (NOT CMAKE_REQUIRED_QUIET) + message (STATUS "Looking for gflags namespace - failed") + endif () + set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace") + endif () + endif () +endmacro () diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/FindUnwind.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/FindUnwind.cmake new file mode 100644 index 000000000..a7a976bfd --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/FindUnwind.cmake @@ -0,0 +1,61 @@ +# - Try to find libunwind +# Once done this will define +# +# Unwind_FOUND - system has libunwind +# unwind::unwind - cmake target for libunwind + +include (FindPackageHandleStandardArgs) + +find_path (Unwind_INCLUDE_DIR NAMES unwind.h libunwind.h DOC "unwind include directory") +find_library (Unwind_LIBRARY NAMES unwind DOC "unwind library") + +mark_as_advanced (Unwind_INCLUDE_DIR Unwind_LIBRARY) + +# Extract version information +if (Unwind_LIBRARY) + set (_Unwind_VERSION_HEADER ${Unwind_INCLUDE_DIR}/libunwind-common.h) + + if (EXISTS ${_Unwind_VERSION_HEADER}) + file (READ ${_Unwind_VERSION_HEADER} _Unwind_VERSION_CONTENTS) + + string (REGEX REPLACE ".*#define UNW_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" + Unwind_VERSION_MAJOR "${_Unwind_VERSION_CONTENTS}") + string (REGEX REPLACE ".*#define UNW_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" + Unwind_VERSION_MINOR "${_Unwind_VERSION_CONTENTS}") + string (REGEX REPLACE ".*#define UNW_VERSION_EXTRA[ \t]+([0-9]+).*" "\\1" + Unwind_VERSION_PATCH "${_Unwind_VERSION_CONTENTS}") + + set (Unwind_VERSION ${Unwind_VERSION_MAJOR}.${Unwind_VERSION_MINOR}) + + if (CMAKE_MATCH_0) + # Third version component may be empty + set (Unwind_VERSION ${Unwind_VERSION}.${Unwind_VERSION_PATCH}) + set (Unwind_VERSION_COMPONENTS 3) + else (CMAKE_MATCH_0) + set (Unwind_VERSION_COMPONENTS 2) + endif (CMAKE_MATCH_0) + endif (EXISTS ${_Unwind_VERSION_HEADER}) +endif (Unwind_LIBRARY) + +# handle the QUIETLY and REQUIRED arguments and set Unwind_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args (Unwind + REQUIRED_VARS Unwind_INCLUDE_DIR Unwind_LIBRARY + VERSION_VAR Unwind_VERSION +) + +if (Unwind_FOUND) + if (NOT TARGET unwind::unwind) + add_library (unwind::unwind INTERFACE IMPORTED) + + set_property (TARGET unwind::unwind PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Unwind_INCLUDE_DIR} + ) + set_property (TARGET unwind::unwind PROPERTY + INTERFACE_LINK_LIBRARIES ${Unwind_LIBRARY} + ) + set_property (TARGET unwind::unwind PROPERTY + IMPORTED_CONFIGURATIONS RELEASE + ) + endif (NOT TARGET unwind::unwind) +endif (Unwind_FOUND) diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/GetCacheVariables.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/GetCacheVariables.cmake new file mode 100644 index 000000000..ead35895a --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/GetCacheVariables.cmake @@ -0,0 +1,70 @@ +cmake_policy (PUSH) +cmake_policy (VERSION 3.3) + +include (CMakeParseArguments) + +function (get_cache_variables _CACHEVARS) + set (_SINGLE) + set (_MULTI EXCLUDE) + set (_OPTIONS) + + cmake_parse_arguments (_ARGS "${_OPTIONS}" "${_SINGLE}" "${_MULTI}" ${ARGS} ${ARGN}) + + get_cmake_property (_VARIABLES VARIABLES) + + set (CACHEVARS) + + foreach (_VAR ${_VARIABLES}) + if (DEFINED _ARGS_EXCLUDE) + if ("${_VAR}" IN_LIST _ARGS_EXCLUDE) + continue () + endif ("${_VAR}" IN_LIST _ARGS_EXCLUDE) + endif (DEFINED _ARGS_EXCLUDE) + + get_property (_CACHEVARTYPE CACHE ${_VAR} PROPERTY TYPE) + + if ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR + "${_CACHEVARTYPE}" STREQUAL STATIC OR + "${_CACHEVARTYPE}" STREQUAL UNINITIALIZED) + continue () + endif ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR + "${_CACHEVARTYPE}" STREQUAL STATIC OR + "${_CACHEVARTYPE}" STREQUAL UNINITIALIZED) + + get_property (_CACHEVARVAL CACHE ${_VAR} PROPERTY VALUE) + + if ("${_CACHEVARVAL}" STREQUAL "") + continue () + endif ("${_CACHEVARVAL}" STREQUAL "") + + get_property (_CACHEVARDOC CACHE ${_VAR} PROPERTY HELPSTRING) + + # Escape " in values + string (REPLACE "\"" "\\\"" _CACHEVARVAL "${_CACHEVARVAL}") + # Escape " in help strings + string (REPLACE "\"" "\\\"" _CACHEVARDOC "${_CACHEVARDOC}") + # Escape ; in values + string (REPLACE ";" "\\\;" _CACHEVARVAL "${_CACHEVARVAL}") + # Escape ; in help strings + string (REPLACE ";" "\\\;" _CACHEVARDOC "${_CACHEVARDOC}") + # Escape backslashes in values except those that are followed by a + # quote. + string (REGEX REPLACE "\\\\([^\"])" "\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}") + # Escape backslashes in values that are followed by a letter to avoid + # invalid escape sequence errors. + string (REGEX REPLACE "\\\\([a-zA-Z])" "\\\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}") + string (REPLACE "\\\\" "\\\\\\\\" _CACHEVARDOC "${_CACHEVARDOC}") + + if (NOT "${_CACHEVARTYPE}" STREQUAL BOOL) + set (_CACHEVARVAL "\"${_CACHEVARVAL}\"") + endif (NOT "${_CACHEVARTYPE}" STREQUAL BOOL) + + if (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "") + set (CACHEVARS "${CACHEVARS}set (${_VAR} ${_CACHEVARVAL} CACHE ${_CACHEVARTYPE} \"${_CACHEVARDOC}\")\n") + endif (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "") + endforeach (_VAR) + + set (${_CACHEVARS} ${CACHEVARS} PARENT_SCOPE) +endfunction (get_cache_variables) + +cmake_policy (POP) diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest1.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest1.cmake new file mode 100644 index 000000000..7fbf46336 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest1.cmake @@ -0,0 +1,22 @@ +set (RUNS 3) + +foreach (iter RANGE 1 ${RUNS}) + set (ENV{GOOGLE_LOG_DIR} ${TEST_DIR}) + execute_process (COMMAND ${LOGCLEANUP} RESULT_VARIABLE _RESULT) + + if (NOT _RESULT EQUAL 0) + message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})") + endif (NOT _RESULT EQUAL 0) + + # Ensure the log files to have different modification timestamps such that + # exactly one log file remains at the end. Otherwise all log files will be + # retained. + execute_process (COMMAND ${CMAKE_COMMAND} -E sleep 1) +endforeach (iter) + +file (GLOB LOG_FILES ${TEST_DIR}/*.foobar) +list (LENGTH LOG_FILES NUM_FILES) + +if (NOT NUM_FILES EQUAL 1) + message (SEND_ERROR "Expected 1 log file in log directory but found ${NUM_FILES}") +endif (NOT NUM_FILES EQUAL 1) diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest2.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest2.cmake new file mode 100644 index 000000000..d3b51e355 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest2.cmake @@ -0,0 +1,22 @@ +set (RUNS 3) + +foreach (iter RANGE 1 ${RUNS}) + execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR} + RESULT_VARIABLE _RESULT) + + if (NOT _RESULT EQUAL 0) + message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})") + endif (NOT _RESULT EQUAL 0) + + # Ensure the log files to have different modification timestamps such that + # exactly one log file remains at the end. Otherwise all log files will be + # retained. + execute_process (COMMAND ${CMAKE_COMMAND} -E sleep 1) +endforeach (iter) + +file (GLOB LOG_FILES ${TEST_DIR}/test_cleanup_*.barfoo) +list (LENGTH LOG_FILES NUM_FILES) + +if (NOT NUM_FILES EQUAL 1) + message (SEND_ERROR "Expected 1 log file in build directory ${TEST_DIR} but found ${NUM_FILES}") +endif (NOT NUM_FILES EQUAL 1) diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest3.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest3.cmake new file mode 100644 index 000000000..e8105d111 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/RunCleanerTest3.cmake @@ -0,0 +1,28 @@ +set (RUNS 3) + +# Create the subdirectory required by this unit test. +file (MAKE_DIRECTORY ${TEST_DIR}/${TEST_SUBDIR}) + +foreach (iter RANGE 1 ${RUNS}) + execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR} + RESULT_VARIABLE _RESULT) + + if (NOT _RESULT EQUAL 0) + message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})") + endif (NOT _RESULT EQUAL 0) + + # Ensure the log files to have different modification timestamps such that + # exactly one log file remains at the end. Otherwise all log files will be + # retained. + execute_process (COMMAND ${CMAKE_COMMAND} -E sleep 2) +endforeach (iter) + +file (GLOB LOG_FILES ${TEST_DIR}/${TEST_SUBDIR}/test_cleanup_*.relativefoo) +list (LENGTH LOG_FILES NUM_FILES) + +if (NOT NUM_FILES EQUAL 1) + message (SEND_ERROR "Expected 1 log file in build directory ${TEST_DIR}${TEST_SUBDIR} but found ${NUM_FILES}") +endif (NOT NUM_FILES EQUAL 1) + +# Remove the subdirectory required by this unit test. +file (REMOVE_RECURSE ${TEST_DIR}/${TEST_SUBDIR}) diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/TestInitPackageConfig.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/TestInitPackageConfig.cmake new file mode 100644 index 000000000..01d3a4021 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/TestInitPackageConfig.cmake @@ -0,0 +1,11 @@ +# Create the build directory +execute_process ( + COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR} + RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED +) + +if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) + message (FATAL_ERROR "Failed to create build directory") +endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) + +file (WRITE ${INITIAL_CACHE} "${CACHEVARS}") diff --git a/funasr/runtime/onnxruntime/third_party/glog/cmake/TestPackageConfig.cmake b/funasr/runtime/onnxruntime/third_party/glog/cmake/TestPackageConfig.cmake new file mode 100644 index 000000000..97244ab79 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/cmake/TestPackageConfig.cmake @@ -0,0 +1,40 @@ +# Create the build directory +execute_process ( + COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR} + RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED +) + +if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) + message (FATAL_ERROR "Failed to create build directory") +endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0) + +if (GENERATOR_TOOLSET) + list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET}) +endif (GENERATOR_TOOLSET) + +if (GENERATOR_PLATFORM) + list (APPEND _ADDITIONAL_ARGS -A ${GENERATOR_PLATFORM}) +endif (GENERATOR_PLATFORM) + +# Run CMake +execute_process ( + # Capture the PATH environment variable content set during project generation + # stage. This is required because later during the build stage the PATH is + # modified again (e.g., for MinGW AppVeyor CI builds) by adding back the + # directory containing git.exe. Incidently, the Git installation directory + # also contains sh.exe which causes MinGW Makefile generation to fail. + COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH} + ${CMAKE_COMMAND} -C ${INITIAL_CACHE} + -G ${GENERATOR} + ${_ADDITIONAL_ARGS} + -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON + -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON + -DCMAKE_PREFIX_PATH=${PACKAGE_DIR} + ${SOURCE_DIR} + WORKING_DIRECTORY ${TEST_BINARY_DIR} + RESULT_VARIABLE _GENERATE_SUCCEEDED +) + +if (NOT _GENERATE_SUCCEEDED EQUAL 0) + message (FATAL_ERROR "Failed to generate project files using CMake") +endif (NOT _GENERATE_SUCCEEDED EQUAL 0) diff --git a/funasr/runtime/onnxruntime/third_party/glog/glog-config.cmake.in b/funasr/runtime/onnxruntime/third_party/glog/glog-config.cmake.in new file mode 100644 index 000000000..5c5c9c0da --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/glog-config.cmake.in @@ -0,0 +1,13 @@ +if (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@) + message (FATAL_ERROR "CMake >= @glog_CMake_VERSION@ required") +endif (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@) + +@PACKAGE_INIT@ + +include (CMakeFindDependencyMacro) +include (${CMAKE_CURRENT_LIST_DIR}/glog-modules.cmake) + +@gflags_DEPENDENCY@ +@Unwind_DEPENDENCY@ + +include (${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake) diff --git a/funasr/runtime/onnxruntime/third_party/glog/glog-modules.cmake.in b/funasr/runtime/onnxruntime/third_party/glog/glog-modules.cmake.in new file mode 100644 index 000000000..71c516078 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/glog-modules.cmake.in @@ -0,0 +1,18 @@ +cmake_policy (PUSH) +cmake_policy (SET CMP0057 NEW) + +if (CMAKE_VERSION VERSION_LESS 3.3) + message (FATAL_ERROR "glog-modules.cmake requires the consumer " + "to use CMake 3.3 (or newer)") +endif (CMAKE_VERSION VERSION_LESS 3.3) + +set (glog_MODULE_PATH "@glog_FULL_CMake_DATADIR@") +list (APPEND CMAKE_MODULE_PATH ${glog_MODULE_PATH}) + +if (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH) + message (FATAL_ERROR "Cannot add '${glog_MODULE_PATH}' to " + "CMAKE_MODULE_PATH. This will cause glog-config.cmake to fail at " + "locating required find modules. Make sure CMAKE_MODULE_PATH is not a cache variable.") +endif (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH) + +cmake_policy (POP) diff --git a/funasr/runtime/onnxruntime/third_party/glog/libglog.pc.in b/funasr/runtime/onnxruntime/third_party/glog/libglog.pc.in new file mode 100644 index 000000000..2303e2e51 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/libglog.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libglog +Description: Google Log (glog) C++ logging framework +Version: @VERSION@ +Libs: -L${libdir} -lglog +Libs.private: @glog_libraries_options_for_static_linking@ +Cflags: -I${includedir} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/base/commandlineflags.h b/funasr/runtime/onnxruntime/third_party/glog/src/base/commandlineflags.h new file mode 100644 index 000000000..c011df411 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/base/commandlineflags.h @@ -0,0 +1,148 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// This file is a compatibility layer that defines Google's version of +// command line flags that are used for configuration. +// +// We put flags into their own namespace. It is purposefully +// named in an opaque way that people should have trouble typing +// directly. The idea is that DEFINE puts the flag in the weird +// namespace, and DECLARE imports the flag from there into the +// current namespace. The net result is to force people to use +// DECLARE to get access to a flag, rather than saying +// extern bool FLAGS_logtostderr; +// or some such instead. We want this so we can put extra +// functionality (like sanity-checking) in DECLARE if we want, +// and make sure it is picked up everywhere. +// +// We also put the type of the variable in the namespace, so that +// people can't DECLARE_int32 something that they DEFINE_bool'd +// elsewhere. +#ifndef BASE_COMMANDLINEFLAGS_H__ +#define BASE_COMMANDLINEFLAGS_H__ + +#include "config.h" +#include // for getenv +#include // for memchr +#include + +#ifdef HAVE_LIB_GFLAGS + +#include + +#else + +#include + +#define DECLARE_VARIABLE(type, shorttype, name, tn) \ + namespace fL##shorttype { \ + extern GLOG_EXPORT type FLAGS_##name; \ + } \ + using fL##shorttype::FLAGS_##name +#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \ + namespace fL##shorttype { \ + GLOG_EXPORT type FLAGS_##name(value); \ + char FLAGS_no##name; \ + } \ + using fL##shorttype::FLAGS_##name + +// bool specialization +#define DECLARE_bool(name) \ + DECLARE_VARIABLE(bool, B, name, bool) +#define DEFINE_bool(name, value, meaning) \ + DEFINE_VARIABLE(bool, B, name, value, meaning, bool) + +// int32 specialization +#define DECLARE_int32(name) \ + DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, int32) +#define DEFINE_int32(name, value, meaning) \ + DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, value, meaning, int32) + +// uint32 specialization +#ifndef DECLARE_uint32 +#define DECLARE_uint32(name) \ + DECLARE_VARIABLE(GOOGLE_NAMESPACE::uint32, U, name, uint32) +#endif // DECLARE_uint64 +#define DEFINE_uint32(name, value, meaning) \ + DEFINE_VARIABLE(GOOGLE_NAMESPACE::uint32, U, name, value, meaning, uint32) + +// Special case for string, because we have to specify the namespace +// std::string, which doesn't play nicely with our FLAG__namespace hackery. +#define DECLARE_string(name) \ + namespace fLS { \ + extern GLOG_EXPORT std::string& FLAGS_##name; \ + } \ + using fLS::FLAGS_##name +#define DEFINE_string(name, value, meaning) \ + namespace fLS { \ + std::string FLAGS_##name##_buf(value); \ + GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \ + char FLAGS_no##name; \ + } \ + using fLS::FLAGS_##name + +#endif // HAVE_LIB_GFLAGS + +// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we +// have GLOG_* environ variables even if we have gflags installed. +// +// If both an environment variable and a flag are specified, the value +// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the +// verbosity will be 1, not 0. + +#define GLOG_DEFINE_bool(name, value, meaning) \ + DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning) + +#define GLOG_DEFINE_int32(name, value, meaning) \ + DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning) + +#define GLOG_DEFINE_uint32(name, value, meaning) \ + DEFINE_uint32(name, EnvToUInt("GLOG_" #name, value), meaning) + +#define GLOG_DEFINE_string(name, value, meaning) \ + DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning) + +// These macros (could be functions, but I don't want to bother with a .cc +// file), make it easier to initialize flags from the environment. + +#define EnvToString(envname, dflt) \ + (!getenv(envname) ? (dflt) : getenv(envname)) + +#define EnvToBool(envname, dflt) \ + (!getenv(envname) ? (dflt) \ + : memchr("tTyY1\0", getenv(envname)[0], 6) != nullptr) + +#define EnvToInt(envname, dflt) \ + (!getenv(envname) ? (dflt) : strtol(getenv(envname), nullptr, 10)) + +#define EnvToUInt(envname, dflt) \ + (!getenv(envname) ? (dflt) : strtoul(getenv(envname), nullptr, 10)) + +#endif // BASE_COMMANDLINEFLAGS_H__ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/base/googleinit.h b/funasr/runtime/onnxruntime/third_party/glog/src/base/googleinit.h new file mode 100644 index 000000000..b5f4436a5 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/base/googleinit.h @@ -0,0 +1,51 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// Author: Jacob Hoffman-Andrews + +#ifndef _GOOGLEINIT_H +#define _GOOGLEINIT_H + +class GoogleInitializer { + public: + using void_function = void (*)(); + GoogleInitializer(const char*, void_function f) { + f(); + } +}; + +#define REGISTER_MODULE_INITIALIZER(name, body) \ + namespace { \ + static void google_init_module_##name () { body; } \ + GoogleInitializer google_initializer_module_##name(#name, \ + google_init_module_##name); \ + } + +#endif /* _GOOGLEINIT_H */ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/base/mutex.h b/funasr/runtime/onnxruntime/third_party/glog/src/base/mutex.h new file mode 100644 index 000000000..6d10df1f4 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/base/mutex.h @@ -0,0 +1,333 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --- +// Author: Craig Silverstein. +// +// A simple mutex wrapper, supporting locks and read-write locks. +// You should assume the locks are *not* re-entrant. +// +// To use: you should define the following macros in your configure.ac: +// ACX_PTHREAD +// AC_RWLOCK +// The latter is defined in ../autoconf. +// +// This class is meant to be internal-only and should be wrapped by an +// internal namespace. Before you use this module, please give the +// name of your internal namespace for this module. Or, if you want +// to expose it, you'll want to move it to the Google namespace. We +// cannot put this class in global namespace because there can be some +// problems when we have multiple versions of Mutex in each shared object. +// +// NOTE: by default, we have #ifdef'ed out the TryLock() method. +// This is for two reasons: +// 1) TryLock() under Windows is a bit annoying (it requires a +// #define to be defined very early). +// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG +// mode. +// If you need TryLock(), and either these two caveats are not a +// problem for you, or you're willing to work around them, then +// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs +// in the code below. +// +// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy: +// http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html +// Because of that, we might as well use windows locks for +// cygwin. They seem to be more reliable than the cygwin pthreads layer. +// +// TRICKY IMPLEMENTATION NOTE: +// This class is designed to be safe to use during +// dynamic-initialization -- that is, by global constructors that are +// run before main() starts. The issue in this case is that +// dynamic-initialization happens in an unpredictable order, and it +// could be that someone else's dynamic initializer could call a +// function that tries to acquire this mutex -- but that all happens +// before this mutex's constructor has run. (This can happen even if +// the mutex and the function that uses the mutex are in the same .cc +// file.) Basically, because Mutex does non-trivial work in its +// constructor, it's not, in the naive implementation, safe to use +// before dynamic initialization has run on it. +// +// The solution used here is to pair the actual mutex primitive with a +// bool that is set to true when the mutex is dynamically initialized. +// (Before that it's false.) Then we modify all mutex routines to +// look at the bool, and not try to lock/unlock until the bool makes +// it to true (which happens after the Mutex constructor has run.) +// +// This works because before main() starts -- particularly, during +// dynamic initialization -- there are no threads, so a) it's ok that +// the mutex operations are a no-op, since we don't need locking then +// anyway; and b) we can be quite confident our bool won't change +// state between a call to Lock() and a call to Unlock() (that would +// require a global constructor in one translation unit to call Lock() +// and another global constructor in another translation unit to call +// Unlock() later, which is pretty perverse). +// +// That said, it's tricky, and can conceivably fail; it's safest to +// avoid trying to acquire a mutex in a global constructor, if you +// can. One way it can fail is that a really smart compiler might +// initialize the bool to true at static-initialization time (too +// early) rather than at dynamic-initialization time. To discourage +// that, we set is_safe_ to true in code (not the constructor +// colon-initializer) and set it to true via a function that always +// evaluates to true, but that the compiler can't know always +// evaluates to true. This should be good enough. + +#ifndef GOOGLE_MUTEX_H_ +#define GOOGLE_MUTEX_H_ + +#include "config.h" // to figure out pthreads support + +#if defined(NO_THREADS) + typedef int MutexType; // to keep a lock-count +#elif defined(_WIN32) || defined(__CYGWIN__) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN // We only need minimal includes +# endif +# ifdef GMUTEX_TRYLOCK + // We need Windows NT or later for TryEnterCriticalSection(). If you + // don't need that functionality, you can remove these _WIN32_WINNT + // lines, and change TryLock() to assert(0) or something. +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0400 +# endif +# endif +// To avoid macro definition of ERROR. +# ifndef NOGDI +# define NOGDI +# endif +// To avoid macro definition of min/max. +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include + typedef CRITICAL_SECTION MutexType; +#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK) + // Needed for pthread_rwlock_*. If it causes problems, you could take it + // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it + // *does* cause problems for FreeBSD, or MacOSX, but isn't needed + // for locking there.) +# ifdef __linux__ +# ifndef _XOPEN_SOURCE // Some other header might have already set it for us. +# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls +# endif +# endif +# include +using MutexType = pthread_rwlock_t; +#elif defined(HAVE_PTHREAD) +# include + typedef pthread_mutex_t MutexType; +#else +# error Need to implement mutex.h for your architecture, or #define NO_THREADS +#endif + +// We need to include these header files after defining _XOPEN_SOURCE +// as they may define the _XOPEN_SOURCE macro. +#include +#include // for abort() + +#define MUTEX_NAMESPACE glog_internal_namespace_ + +namespace MUTEX_NAMESPACE { + +class Mutex { + public: + // Create a Mutex that is not held by anybody. This constructor is + // typically used for Mutexes allocated on the heap or the stack. + // See below for a recommendation for constructing global Mutex + // objects. + inline Mutex(); + + // Destructor + inline ~Mutex(); + + inline void Lock(); // Block if needed until free then acquire exclusively + inline void Unlock(); // Release a lock acquired via Lock() +#ifdef GMUTEX_TRYLOCK + inline bool TryLock(); // If free, Lock() and return true, else return false +#endif + // Note that on systems that don't support read-write locks, these may + // be implemented as synonyms to Lock() and Unlock(). So you can use + // these for efficiency, but don't use them anyplace where being able + // to do shared reads is necessary to avoid deadlock. + inline void ReaderLock(); // Block until free or shared then acquire a share + inline void ReaderUnlock(); // Release a read share of this Mutex + inline void WriterLock() { Lock(); } // Acquire an exclusive lock + inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock() + + // TODO(hamaji): Do nothing, implement correctly. + inline void AssertHeld() {} + + private: + MutexType mutex_; + // We want to make sure that the compiler sets is_safe_ to true only + // when we tell it to, and never makes assumptions is_safe_ is + // always true. volatile is the most reliable way to do that. + volatile bool is_safe_; + + inline void SetIsSafe() { is_safe_ = true; } + + // Catch the error of writing Mutex when intending MutexLock. + explicit Mutex(Mutex * /*ignored*/) {} + // Disallow "evil" constructors + Mutex(const Mutex &) = delete; + void operator=(const Mutex &) = delete; +}; + +// Now the implementation of Mutex for various systems +#if defined(NO_THREADS) + +// When we don't have threads, we can be either reading or writing, +// but not both. We can have lots of readers at once (in no-threads +// mode, that's most likely to happen in recursive function calls), +// but only one writer. We represent this by having mutex_ be -1 when +// writing and a number > 0 when reading (and 0 when no lock is held). +// +// In debug mode, we assert these invariants, while in non-debug mode +// we do nothing, for efficiency. That's why everything is in an +// assert. + +Mutex::Mutex() : mutex_(0) { } +Mutex::~Mutex() { assert(mutex_ == 0); } +void Mutex::Lock() { assert(--mutex_ == -1); } +void Mutex::Unlock() { assert(mutex_++ == -1); } +#ifdef GMUTEX_TRYLOCK +bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; } +#endif +void Mutex::ReaderLock() { assert(++mutex_ > 0); } +void Mutex::ReaderUnlock() { assert(mutex_-- > 0); } + +#elif defined(_WIN32) || defined(__CYGWIN__) + +Mutex::Mutex() { InitializeCriticalSection(&mutex_); SetIsSafe(); } +Mutex::~Mutex() { DeleteCriticalSection(&mutex_); } +void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); } +void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); } +#ifdef GMUTEX_TRYLOCK +bool Mutex::TryLock() { return is_safe_ ? + TryEnterCriticalSection(&mutex_) != 0 : true; } +#endif +void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks +void Mutex::ReaderUnlock() { Unlock(); } + +#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK) + +#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \ + if (is_safe_ && fncall(&mutex_) != 0) abort(); \ +} while (0) + +Mutex::Mutex() { + SetIsSafe(); + if (is_safe_ && pthread_rwlock_init(&mutex_, nullptr) != 0) abort(); +} +Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy); } +void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock); } +void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock); } +#ifdef GMUTEX_TRYLOCK +bool Mutex::TryLock() { return is_safe_ ? + pthread_rwlock_trywrlock(&mutex_) == 0 : + true; } +#endif +void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); } +void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); } +#undef SAFE_PTHREAD + +#elif defined(HAVE_PTHREAD) + +#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \ + if (is_safe_ && fncall(&mutex_) != 0) abort(); \ +} while (0) + +Mutex::Mutex() { + SetIsSafe(); + if (is_safe_ && pthread_mutex_init(&mutex_, nullptr) != 0) abort(); +} +Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy); } +void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); } +void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); } +#ifdef GMUTEX_TRYLOCK +bool Mutex::TryLock() { return is_safe_ ? + pthread_mutex_trylock(&mutex_) == 0 : true; } +#endif +void Mutex::ReaderLock() { Lock(); } +void Mutex::ReaderUnlock() { Unlock(); } +#undef SAFE_PTHREAD + +#endif + +// -------------------------------------------------------------------------- +// Some helper classes + +// MutexLock(mu) acquires mu when constructed and releases it when destroyed. +class MutexLock { + public: + explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); } + ~MutexLock() { mu_->Unlock(); } + private: + Mutex * const mu_; + // Disallow "evil" constructors + MutexLock(const MutexLock &) = delete; + void operator=(const MutexLock &) = delete; +}; + +// ReaderMutexLock and WriterMutexLock do the same, for rwlocks +class ReaderMutexLock { + public: + explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); } + ~ReaderMutexLock() { mu_->ReaderUnlock(); } + private: + Mutex * const mu_; + // Disallow "evil" constructors + ReaderMutexLock(const ReaderMutexLock &) = delete; + void operator=(const ReaderMutexLock &) = delete; +}; + +class WriterMutexLock { + public: + explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); } + ~WriterMutexLock() { mu_->WriterUnlock(); } + private: + Mutex * const mu_; + // Disallow "evil" constructors + WriterMutexLock(const WriterMutexLock &) = delete; + void operator=(const WriterMutexLock &) = delete; +}; + +// Catch bug where variable name is omitted, e.g. MutexLock (&mu); +#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name) +#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name) +#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name) + +} // namespace MUTEX_NAMESPACE + +using namespace MUTEX_NAMESPACE; + +#undef MUTEX_NAMESPACE + +#endif /* #define GOOGLE_MUTEX_H__ */ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_immediately_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_immediately_unittest.cc new file mode 100644 index 000000000..686d19386 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_immediately_unittest.cc @@ -0,0 +1,96 @@ +// Copyright (c) 2021, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +#include "base/commandlineflags.h" +#include "googletest.h" + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +#ifdef HAVE_LIB_GMOCK +#include + +#include "mock-log.h" +// Introduce several symbols from gmock. +using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog; +using testing::_; +using testing::AllOf; +using testing::AnyNumber; +using testing::HasSubstr; +using testing::InitGoogleMock; +using testing::StrictMock; +using testing::StrNe; +#endif + +using namespace GOOGLE_NAMESPACE; + +TEST(CleanImmediately, logging) { + google::SetLogFilenameExtension(".foobar"); + google::EnableLogCleaner(0); + + for (unsigned i = 0; i < 1000; ++i) { + LOG(INFO) << "cleanup test"; + } + + google::DisableLogCleaner(); +} + +int main(int argc, char **argv) { + FLAGS_colorlogtostderr = false; + FLAGS_timestamp_in_logfile_name = true; +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + // Make sure stderr is not buffered as stderr seems to be buffered + // on recent windows. + setbuf(stderr, nullptr); + + // Test some basics before InitGoogleLogging: + CaptureTestStderr(); + const string early_stderr = GetCapturedTestStderr(); + + EXPECT_FALSE(IsGoogleLoggingInitialized()); + + InitGoogleLogging(argv[0]); + + EXPECT_TRUE(IsGoogleLoggingInitialized()); + + InitGoogleTest(&argc, argv); +#ifdef HAVE_LIB_GMOCK + InitGoogleMock(&argc, argv); +#endif + + // so that death tests run before we use threads + CHECK_EQ(RUN_ALL_TESTS(), 0); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_absolute_prefix_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_absolute_prefix_unittest.cc new file mode 100644 index 000000000..95c4baf09 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_absolute_prefix_unittest.cc @@ -0,0 +1,101 @@ +// Copyright (c) 2021, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +#include "base/commandlineflags.h" +#include "googletest.h" + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +#ifdef HAVE_LIB_GMOCK +#include + +#include "mock-log.h" +// Introduce several symbols from gmock. +using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog; +using testing::_; +using testing::AllOf; +using testing::AnyNumber; +using testing::HasSubstr; +using testing::InitGoogleMock; +using testing::StrictMock; +using testing::StrNe; +#endif + +using namespace GOOGLE_NAMESPACE; + +TEST(CleanImmediatelyWithAbsolutePrefix, logging) { + google::EnableLogCleaner(0); + google::SetLogFilenameExtension(".barfoo"); + google::SetLogDestination(GLOG_INFO, "test_cleanup_"); + + for (unsigned i = 0; i < 1000; ++i) { + LOG(INFO) << "cleanup test"; + } + + for (unsigned i = 0; i < 10; ++i) { + LOG(ERROR) << "cleanup test"; + } + + google::DisableLogCleaner(); +} + +int main(int argc, char **argv) { + FLAGS_colorlogtostderr = false; + FLAGS_timestamp_in_logfile_name = true; +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + // Make sure stderr is not buffered as stderr seems to be buffered + // on recent windows. + setbuf(stderr, nullptr); + + // Test some basics before InitGoogleLogging: + CaptureTestStderr(); + const string early_stderr = GetCapturedTestStderr(); + + EXPECT_FALSE(IsGoogleLoggingInitialized()); + + InitGoogleLogging(argv[0]); + + EXPECT_TRUE(IsGoogleLoggingInitialized()); + + InitGoogleTest(&argc, argv); +#ifdef HAVE_LIB_GMOCK + InitGoogleMock(&argc, argv); +#endif + + // so that death tests run before we use threads + CHECK_EQ(RUN_ALL_TESTS(), 0); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_relative_prefix_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_relative_prefix_unittest.cc new file mode 100644 index 000000000..0cee085e5 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/cleanup_with_relative_prefix_unittest.cc @@ -0,0 +1,97 @@ +// Copyright (c) 2021, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +#include "base/commandlineflags.h" +#include "googletest.h" + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +#ifdef HAVE_LIB_GMOCK +#include + +#include "mock-log.h" +// Introduce several symbols from gmock. +using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog; +using testing::_; +using testing::AllOf; +using testing::AnyNumber; +using testing::HasSubstr; +using testing::InitGoogleMock; +using testing::StrictMock; +using testing::StrNe; +#endif + +using namespace GOOGLE_NAMESPACE; + +TEST(CleanImmediatelyWithRelativePrefix, logging) { + google::EnableLogCleaner(0); + google::SetLogFilenameExtension(".relativefoo"); + google::SetLogDestination(GLOG_INFO, "test_subdir/test_cleanup_"); + + for (unsigned i = 0; i < 1000; ++i) { + LOG(INFO) << "cleanup test"; + } + + google::DisableLogCleaner(); +} + +int main(int argc, char **argv) { + FLAGS_colorlogtostderr = false; + FLAGS_timestamp_in_logfile_name = true; +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + // Make sure stderr is not buffered as stderr seems to be buffered + // on recent windows. + setbuf(stderr, nullptr); + + // Test some basics before InitGoogleLogging: + CaptureTestStderr(); + const string early_stderr = GetCapturedTestStderr(); + + EXPECT_FALSE(IsGoogleLoggingInitialized()); + + InitGoogleLogging(argv[0]); + + EXPECT_TRUE(IsGoogleLoggingInitialized()); + + InitGoogleTest(&argc, argv); +#ifdef HAVE_LIB_GMOCK + InitGoogleMock(&argc, argv); +#endif + + // so that death tests run before we use threads + CHECK_EQ(RUN_ALL_TESTS(), 0); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/config.h.cmake.in b/funasr/runtime/onnxruntime/third_party/glog/src/config.h.cmake.in new file mode 100644 index 000000000..9d6101013 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/config.h.cmake.in @@ -0,0 +1,177 @@ +#ifndef GLOG_CONFIG_H +#define GLOG_CONFIG_H + +/* Namespace for Google classes */ +#cmakedefine GOOGLE_NAMESPACE ${GOOGLE_NAMESPACE} + +/* Define if you have the `dladdr' function */ +#cmakedefine HAVE_DLADDR + +/* Define if you have the `snprintf' function */ +#cmakedefine HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define if you have the `backtrace' function in */ +#cmakedefine HAVE_EXECINFO_BACKTRACE + +/* Define if you have the `backtrace_symbols' function in */ +#cmakedefine HAVE_EXECINFO_BACKTRACE_SYMBOLS + +/* Define if you have the `fcntl' function */ +#cmakedefine HAVE_FCNTL + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GLOB_H + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#cmakedefine HAVE_LIBPTHREAD + +/* define if you have google gflags library */ +#cmakedefine HAVE_LIB_GFLAGS + +/* define if you have google gmock library */ +#cmakedefine HAVE_LIB_GMOCK + +/* define if you have google gtest library */ +#cmakedefine HAVE_LIB_GTEST + +/* define if you have dbghelp library */ +#cmakedefine HAVE_DBGHELP + +/* define if you have libunwind */ +#cmakedefine HAVE_LIB_UNWIND + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H + +/* define to disable multithreading support. */ +#cmakedefine NO_THREADS + +/* Define if you have the 'pread' function */ +#cmakedefine HAVE_PREAD + +/* Define if you have POSIX threads libraries and header files. */ +#cmakedefine HAVE_PTHREAD + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PWD_H + +/* Define if you have the 'pwrite' function */ +#cmakedefine HAVE_PWRITE + +/* define if the compiler implements pthread_rwlock_* */ +#cmakedefine HAVE_RWLOCK + +/* Define if you have the 'sigaction' function */ +#cmakedefine HAVE_SIGACTION + +/* Define if you have the `sigaltstack' function */ +#cmakedefine HAVE_SIGALTSTACK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSCALL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSLOG_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SYSCALL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UCONTEXT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UTSNAME_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UCONTEXT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} + +/* Define if you linking to _Unwind_Backtrace is possible. */ +#cmakedefine HAVE__UNWIND_BACKTRACE + +/* Define if you linking to _Unwind_GetIP is possible. */ +#cmakedefine HAVE__UNWIND_GETIP + +/* define if your compiler has __attribute__ */ +#cmakedefine HAVE___ATTRIBUTE__ + +/* define if your compiler has __builtin_expect */ +#cmakedefine HAVE___BUILTIN_EXPECT ${HAVE___BUILTIN_EXPECT} + +/* define if your compiler has __sync_val_compare_and_swap */ +#cmakedefine HAVE___SYNC_VAL_COMPARE_AND_SWAP + +/* define if symbolize support is available */ +#cmakedefine HAVE_SYMBOLIZE + +/* define if localtime_r is available in time.h */ +#cmakedefine HAVE_LOCALTIME_R + +/* define if gmtime_r is available in time.h */ +#cmakedefine HAVE_GMTIME_R + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#cmakedefine LT_OBJDIR + +/* How to access the PC from a struct ucontext */ +#cmakedefine PC_FROM_UCONTEXT + +/* define if we should print file offsets in traces instead of symbolizing. */ +#cmakedefine PRINT_UNSYMBOLIZED_STACK_TRACES + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#cmakedefine PTHREAD_CREATE_JOINABLE + +/* The size of `void *', as computed by sizeof. */ +#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P} + +/* location of source code */ +#cmakedefine TEST_SRC_DIR ${TEST_SRC_DIR} + +/* Define if thread-local storage is enabled. */ +#cmakedefine GLOG_THREAD_LOCAL_STORAGE + +#ifdef GLOG_BAZEL_BUILD + +/* TODO(rodrigoq): remove this workaround once bazel#3979 is resolved: + * https://github.com/bazelbuild/bazel/issues/3979 */ +#define _START_GOOGLE_NAMESPACE_ namespace GOOGLE_NAMESPACE { + +#define _END_GOOGLE_NAMESPACE_ } + +#else + +/* Stops putting the code inside the Google namespace */ +#cmakedefine _END_GOOGLE_NAMESPACE_ ${_END_GOOGLE_NAMESPACE_} + +/* Puts following code inside the Google namespace */ +#cmakedefine _START_GOOGLE_NAMESPACE_ ${_START_GOOGLE_NAMESPACE_} + +#endif + +/* Replacement for deprecated syscall(SYS_gettid) on macOS. */ +#cmakedefine HAVE_PTHREAD_THREADID_NP ${HAVE_PTHREAD_THREADID_NP} + +#endif // GLOG_CONFIG_H diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/demangle.cc b/funasr/runtime/onnxruntime/third_party/glog/src/demangle.cc new file mode 100644 index 000000000..b19d446c8 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/demangle.cc @@ -0,0 +1,1310 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// For reference check out: +// http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling +// +// Note that we only have partial C++0x support yet. + +#include "demangle.h" + +#include // for nullptr + +#include "utilities.h" + +#if defined(GLOG_OS_WINDOWS) +#include +#endif + +_START_GOOGLE_NAMESPACE_ + +#if !defined(GLOG_OS_WINDOWS) +struct AbbrevPair { + const char *abbrev; + const char *real_name; +}; + +// List of operators from Itanium C++ ABI. +static const AbbrevPair kOperatorList[] = { + {"nw", "new"}, {"na", "new[]"}, {"dl", "delete"}, {"da", "delete[]"}, + {"ps", "+"}, {"ng", "-"}, {"ad", "&"}, {"de", "*"}, + {"co", "~"}, {"pl", "+"}, {"mi", "-"}, {"ml", "*"}, + {"dv", "/"}, {"rm", "%"}, {"an", "&"}, {"or", "|"}, + {"eo", "^"}, {"aS", "="}, {"pL", "+="}, {"mI", "-="}, + {"mL", "*="}, {"dV", "/="}, {"rM", "%="}, {"aN", "&="}, + {"oR", "|="}, {"eO", "^="}, {"ls", "<<"}, {"rs", ">>"}, + {"lS", "<<="}, {"rS", ">>="}, {"eq", "=="}, {"ne", "!="}, + {"lt", "<"}, {"gt", ">"}, {"le", "<="}, {"ge", ">="}, + {"nt", "!"}, {"aa", "&&"}, {"oo", "||"}, {"pp", "++"}, + {"mm", "--"}, {"cm", ","}, {"pm", "->*"}, {"pt", "->"}, + {"cl", "()"}, {"ix", "[]"}, {"qu", "?"}, {"st", "sizeof"}, + {"sz", "sizeof"}, {nullptr, nullptr}, +}; + +// List of builtin types from Itanium C++ ABI. +static const AbbrevPair kBuiltinTypeList[] = { + {"v", "void"}, {"w", "wchar_t"}, + {"b", "bool"}, {"c", "char"}, + {"a", "signed char"}, {"h", "unsigned char"}, + {"s", "short"}, {"t", "unsigned short"}, + {"i", "int"}, {"j", "unsigned int"}, + {"l", "long"}, {"m", "unsigned long"}, + {"x", "long long"}, {"y", "unsigned long long"}, + {"n", "__int128"}, {"o", "unsigned __int128"}, + {"f", "float"}, {"d", "double"}, + {"e", "long double"}, {"g", "__float128"}, + {"z", "ellipsis"}, {nullptr, nullptr}}; + +// List of substitutions Itanium C++ ABI. +static const AbbrevPair kSubstitutionList[] = { + {"St", ""}, + {"Sa", "allocator"}, + {"Sb", "basic_string"}, + // std::basic_string,std::allocator > + {"Ss", "string"}, + // std::basic_istream > + {"Si", "istream"}, + // std::basic_ostream > + {"So", "ostream"}, + // std::basic_iostream > + {"Sd", "iostream"}, + {nullptr, nullptr}}; + +// State needed for demangling. +struct State { + const char *mangled_cur; // Cursor of mangled name. + char *out_cur; // Cursor of output string. + const char *out_begin; // Beginning of output string. + const char *out_end; // End of output string. + const char *prev_name; // For constructors/destructors. + ssize_t prev_name_length; // For constructors/destructors. + short nest_level; // For nested names. + bool append; // Append flag. + bool overflowed; // True if output gets overflowed. +}; + +// We don't use strlen() in libc since it's not guaranteed to be async +// signal safe. +static size_t StrLen(const char *str) { + size_t len = 0; + while (*str != '\0') { + ++str; + ++len; + } + return len; +} + +// Returns true if "str" has at least "n" characters remaining. +static bool AtLeastNumCharsRemaining(const char *str, ssize_t n) { + for (ssize_t i = 0; i < n; ++i) { + if (str[i] == '\0') { + return false; + } + } + return true; +} + +// Returns true if "str" has "prefix" as a prefix. +static bool StrPrefix(const char *str, const char *prefix) { + size_t i = 0; + while (str[i] != '\0' && prefix[i] != '\0' && + str[i] == prefix[i]) { + ++i; + } + return prefix[i] == '\0'; // Consumed everything in "prefix". +} + +static void InitState(State *state, const char *mangled, + char *out, size_t out_size) { + state->mangled_cur = mangled; + state->out_cur = out; + state->out_begin = out; + state->out_end = out + out_size; + state->prev_name = nullptr; + state->prev_name_length = -1; + state->nest_level = -1; + state->append = true; + state->overflowed = false; +} + +// Returns true and advances "mangled_cur" if we find "one_char_token" +// at "mangled_cur" position. It is assumed that "one_char_token" does +// not contain '\0'. +static bool ParseOneCharToken(State *state, const char one_char_token) { + if (state->mangled_cur[0] == one_char_token) { + ++state->mangled_cur; + return true; + } + return false; +} + +// Returns true and advances "mangled_cur" if we find "two_char_token" +// at "mangled_cur" position. It is assumed that "two_char_token" does +// not contain '\0'. +static bool ParseTwoCharToken(State *state, const char *two_char_token) { + if (state->mangled_cur[0] == two_char_token[0] && + state->mangled_cur[1] == two_char_token[1]) { + state->mangled_cur += 2; + return true; + } + return false; +} + +// Returns true and advances "mangled_cur" if we find any character in +// "char_class" at "mangled_cur" position. +static bool ParseCharClass(State *state, const char *char_class) { + const char *p = char_class; + for (; *p != '\0'; ++p) { + if (state->mangled_cur[0] == *p) { + ++state->mangled_cur; + return true; + } + } + return false; +} + +// This function is used for handling an optional non-terminal. +static bool Optional(bool) { + return true; +} + +// This function is used for handling + syntax. +using ParseFunc = bool (*)(State *); +static bool OneOrMore(ParseFunc parse_func, State *state) { + if (parse_func(state)) { + while (parse_func(state)) { + } + return true; + } + return false; +} + +// This function is used for handling * syntax. The function +// always returns true and must be followed by a termination token or a +// terminating sequence not handled by parse_func (e.g. +// ParseOneCharToken(state, 'E')). +static bool ZeroOrMore(ParseFunc parse_func, State *state) { + while (parse_func(state)) { + } + return true; +} + +// Append "str" at "out_cur". If there is an overflow, "overflowed" +// is set to true for later use. The output string is ensured to +// always terminate with '\0' as long as there is no overflow. +static void Append(State *state, const char * const str, ssize_t length) { + for (ssize_t i = 0; i < length; ++i) { + if (state->out_cur + 1 < state->out_end) { // +1 for '\0' + *state->out_cur = str[i]; + ++state->out_cur; + } else { + state->overflowed = true; + break; + } + } + if (!state->overflowed) { + *state->out_cur = '\0'; // Terminate it with '\0' + } +} + +// We don't use equivalents in libc to avoid locale issues. +static bool IsLower(char c) { + return c >= 'a' && c <= 'z'; +} + +static bool IsAlpha(char c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +static bool IsDigit(char c) { + return c >= '0' && c <= '9'; +} + +// Returns true if "str" is a function clone suffix. These suffixes are used +// by GCC 4.5.x and later versions to indicate functions which have been +// cloned during optimization. We treat any sequence (.+.+)+ as +// a function clone suffix. +static bool IsFunctionCloneSuffix(const char *str) { + size_t i = 0; + while (str[i] != '\0') { + // Consume a single .+.+ sequence. + if (str[i] != '.' || !IsAlpha(str[i + 1])) { + return false; + } + i += 2; + while (IsAlpha(str[i])) { + ++i; + } + if (str[i] != '.' || !IsDigit(str[i + 1])) { + return false; + } + i += 2; + while (IsDigit(str[i])) { + ++i; + } + } + return true; // Consumed everything in "str". +} + +// Append "str" with some tweaks, iff "append" state is true. +// Returns true so that it can be placed in "if" conditions. +static void MaybeAppendWithLength(State *state, const char * const str, + ssize_t length) { + if (state->append && length > 0) { + // Append a space if the output buffer ends with '<' and "str" + // starts with '<' to avoid <<<. + if (str[0] == '<' && state->out_begin < state->out_cur && + state->out_cur[-1] == '<') { + Append(state, " ", 1); + } + // Remember the last identifier name for ctors/dtors. + if (IsAlpha(str[0]) || str[0] == '_') { + state->prev_name = state->out_cur; + state->prev_name_length = length; + } + Append(state, str, length); + } +} + +// A convenient wrapper arount MaybeAppendWithLength(). +static bool MaybeAppend(State *state, const char * const str) { + if (state->append) { + size_t length = StrLen(str); + MaybeAppendWithLength(state, str, static_cast(length)); + } + return true; +} + +// This function is used for handling nested names. +static bool EnterNestedName(State *state) { + state->nest_level = 0; + return true; +} + +// This function is used for handling nested names. +static bool LeaveNestedName(State *state, short prev_value) { + state->nest_level = prev_value; + return true; +} + +// Disable the append mode not to print function parameters, etc. +static bool DisableAppend(State *state) { + state->append = false; + return true; +} + +// Restore the append mode to the previous state. +static bool RestoreAppend(State *state, bool prev_value) { + state->append = prev_value; + return true; +} + +// Increase the nest level for nested names. +static void MaybeIncreaseNestLevel(State *state) { + if (state->nest_level > -1) { + ++state->nest_level; + } +} + +// Appends :: for nested names if necessary. +static void MaybeAppendSeparator(State *state) { + if (state->nest_level >= 1) { + MaybeAppend(state, "::"); + } +} + +// Cancel the last separator if necessary. +static void MaybeCancelLastSeparator(State *state) { + if (state->nest_level >= 1 && state->append && + state->out_begin <= state->out_cur - 2) { + state->out_cur -= 2; + *state->out_cur = '\0'; + } +} + +// Returns true if the identifier of the given length pointed to by +// "mangled_cur" is anonymous namespace. +static bool IdentifierIsAnonymousNamespace(State *state, ssize_t length) { + static const char anon_prefix[] = "_GLOBAL__N_"; + return (length > static_cast(sizeof(anon_prefix)) - + 1 && // Should be longer. + StrPrefix(state->mangled_cur, anon_prefix)); +} + +// Forward declarations of our parsing functions. +static bool ParseMangledName(State *state); +static bool ParseEncoding(State *state); +static bool ParseName(State *state); +static bool ParseUnscopedName(State *state); +static bool ParseUnscopedTemplateName(State *state); +static bool ParseNestedName(State *state); +static bool ParsePrefix(State *state); +static bool ParseUnqualifiedName(State *state); +static bool ParseSourceName(State *state); +static bool ParseLocalSourceName(State *state); +static bool ParseNumber(State *state, int *number_out); +static bool ParseFloatNumber(State *state); +static bool ParseSeqId(State *state); +static bool ParseIdentifier(State *state, ssize_t length); +static bool ParseAbiTags(State *state); +static bool ParseAbiTag(State *state); +static bool ParseOperatorName(State *state); +static bool ParseSpecialName(State *state); +static bool ParseCallOffset(State *state); +static bool ParseNVOffset(State *state); +static bool ParseVOffset(State *state); +static bool ParseCtorDtorName(State *state); +static bool ParseType(State *state); +static bool ParseCVQualifiers(State *state); +static bool ParseBuiltinType(State *state); +static bool ParseFunctionType(State *state); +static bool ParseBareFunctionType(State *state); +static bool ParseClassEnumType(State *state); +static bool ParseArrayType(State *state); +static bool ParsePointerToMemberType(State *state); +static bool ParseTemplateParam(State *state); +static bool ParseTemplateTemplateParam(State *state); +static bool ParseTemplateArgs(State *state); +static bool ParseTemplateArg(State *state); +static bool ParseExpression(State *state); +static bool ParseExprPrimary(State *state); +static bool ParseLocalName(State *state); +static bool ParseDiscriminator(State *state); +static bool ParseSubstitution(State *state); + +// Implementation note: the following code is a straightforward +// translation of the Itanium C++ ABI defined in BNF with a couple of +// exceptions. +// +// - Support GNU extensions not defined in the Itanium C++ ABI +// - and are combined to avoid infinite loop +// - Reorder patterns to shorten the code +// - Reorder patterns to give greedier functions precedence +// We'll mark "Less greedy than" for these cases in the code +// +// Each parsing function changes the state and returns true on +// success. Otherwise, don't change the state and returns false. To +// ensure that the state isn't changed in the latter case, we save the +// original state before we call more than one parsing functions +// consecutively with &&, and restore the state if unsuccessful. See +// ParseEncoding() as an example of this convention. We follow the +// convention throughout the code. +// +// Originally we tried to do demangling without following the full ABI +// syntax but it turned out we needed to follow the full syntax to +// parse complicated cases like nested template arguments. Note that +// implementing a full-fledged demangler isn't trivial (libiberty's +// cp-demangle.c has +4300 lines). +// +// Note that (foo) in <(foo) ...> is a modifier to be ignored. +// +// Reference: +// - Itanium C++ ABI +// + +// ::= _Z +static bool ParseMangledName(State *state) { + return ParseTwoCharToken(state, "_Z") && ParseEncoding(state); +} + +// ::= <(function) name> +// ::= <(data) name> +// ::= +static bool ParseEncoding(State *state) { + State copy = *state; + if (ParseName(state) && ParseBareFunctionType(state)) { + return true; + } + *state = copy; + + if (ParseName(state) || ParseSpecialName(state)) { + return true; + } + return false; +} + +// ::= +// ::= +// ::= +// ::= +static bool ParseName(State *state) { + if (ParseNestedName(state) || ParseLocalName(state)) { + return true; + } + + State copy = *state; + if (ParseUnscopedTemplateName(state) && + ParseTemplateArgs(state)) { + return true; + } + *state = copy; + + // Less greedy than . + if (ParseUnscopedName(state)) { + return true; + } + return false; +} + +// ::= +// ::= St +static bool ParseUnscopedName(State *state) { + if (ParseUnqualifiedName(state)) { + return true; + } + + State copy = *state; + if (ParseTwoCharToken(state, "St") && + MaybeAppend(state, "std::") && + ParseUnqualifiedName(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= +// ::= +static bool ParseUnscopedTemplateName(State *state) { + return ParseUnscopedName(state) || ParseSubstitution(state); +} + +// ::= N [] E +// ::= N [] E +static bool ParseNestedName(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'N') && + EnterNestedName(state) && + Optional(ParseCVQualifiers(state)) && + ParsePrefix(state) && + LeaveNestedName(state, copy.nest_level) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + return false; +} + +// This part is tricky. If we literally translate them to code, we'll +// end up infinite loop. Hence we merge them to avoid the case. +// +// ::= +// ::= +// ::= +// ::= +// ::= # empty +// ::= <(template) unqualified-name> +// ::= +// ::= +static bool ParsePrefix(State *state) { + bool has_something = false; + while (true) { + MaybeAppendSeparator(state); + if (ParseTemplateParam(state) || + ParseSubstitution(state) || + ParseUnscopedName(state)) { + has_something = true; + MaybeIncreaseNestLevel(state); + continue; + } + MaybeCancelLastSeparator(state); + if (has_something && ParseTemplateArgs(state)) { + return ParsePrefix(state); + } else { + break; + } + } + return true; +} + +// ::= +// ::= +// ::= [] +// ::= [] +static bool ParseUnqualifiedName(State *state) { + return (ParseOperatorName(state) || + ParseCtorDtorName(state) || + (ParseSourceName(state) && Optional(ParseAbiTags(state))) || + (ParseLocalSourceName(state) && Optional(ParseAbiTags(state)))); +} + +// ::= +static bool ParseSourceName(State *state) { + State copy = *state; + int length = -1; + if (ParseNumber(state, &length) && ParseIdentifier(state, length)) { + return true; + } + *state = copy; + return false; +} + +// ::= L [] +// +// References: +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775 +// http://gcc.gnu.org/viewcvs?view=rev&revision=124467 +static bool ParseLocalSourceName(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'L') && ParseSourceName(state) && + Optional(ParseDiscriminator(state))) { + return true; + } + *state = copy; + return false; +} + +// ::= [n] +// If "number_out" is non-null, then *number_out is set to the value of the +// parsed number on success. +static bool ParseNumber(State *state, int *number_out) { + int sign = 1; + if (ParseOneCharToken(state, 'n')) { + sign = -1; + } + const char *p = state->mangled_cur; + int number = 0; + for (;*p != '\0'; ++p) { + if (IsDigit(*p)) { + number = number * 10 + (*p - '0'); + } else { + break; + } + } + if (p != state->mangled_cur) { // Conversion succeeded. + state->mangled_cur = p; + if (number_out != nullptr) { + *number_out = number * sign; + } + return true; + } + return false; +} + +// Floating-point literals are encoded using a fixed-length lowercase +// hexadecimal string. +static bool ParseFloatNumber(State *state) { + const char *p = state->mangled_cur; + for (;*p != '\0'; ++p) { + if (!IsDigit(*p) && !(*p >= 'a' && *p <= 'f')) { + break; + } + } + if (p != state->mangled_cur) { // Conversion succeeded. + state->mangled_cur = p; + return true; + } + return false; +} + +// The is a sequence number in base 36, +// using digits and upper case letters +static bool ParseSeqId(State *state) { + const char *p = state->mangled_cur; + for (;*p != '\0'; ++p) { + if (!IsDigit(*p) && !(*p >= 'A' && *p <= 'Z')) { + break; + } + } + if (p != state->mangled_cur) { // Conversion succeeded. + state->mangled_cur = p; + return true; + } + return false; +} + +// ::= (of given length) +static bool ParseIdentifier(State *state, ssize_t length) { + if (length == -1 || + !AtLeastNumCharsRemaining(state->mangled_cur, length)) { + return false; + } + if (IdentifierIsAnonymousNamespace(state, length)) { + MaybeAppend(state, "(anonymous namespace)"); + } else { + MaybeAppendWithLength(state, state->mangled_cur, length); + } + state->mangled_cur += length; + return true; +} + +// ::= [] +static bool ParseAbiTags(State *state) { + State copy = *state; + DisableAppend(state); + if (OneOrMore(ParseAbiTag, state)) { + RestoreAppend(state, copy.append); + return true; + } + *state = copy; + return false; +} + +// ::= B +static bool ParseAbiTag(State *state) { + return ParseOneCharToken(state, 'B') && ParseSourceName(state); +} + +// ::= nw, and other two letters cases +// ::= cv # (cast) +// ::= v # vendor extended operator +static bool ParseOperatorName(State *state) { + if (!AtLeastNumCharsRemaining(state->mangled_cur, 2)) { + return false; + } + // First check with "cv" (cast) case. + State copy = *state; + if (ParseTwoCharToken(state, "cv") && + MaybeAppend(state, "operator ") && + EnterNestedName(state) && + ParseType(state) && + LeaveNestedName(state, copy.nest_level)) { + return true; + } + *state = copy; + + // Then vendor extended operators. + if (ParseOneCharToken(state, 'v') && ParseCharClass(state, "0123456789") && + ParseSourceName(state)) { + return true; + } + *state = copy; + + // Other operator names should start with a lower alphabet followed + // by a lower/upper alphabet. + if (!(IsLower(state->mangled_cur[0]) && + IsAlpha(state->mangled_cur[1]))) { + return false; + } + // We may want to perform a binary search if we really need speed. + const AbbrevPair *p; + for (p = kOperatorList; p->abbrev != nullptr; ++p) { + if (state->mangled_cur[0] == p->abbrev[0] && + state->mangled_cur[1] == p->abbrev[1]) { + MaybeAppend(state, "operator"); + if (IsLower(*p->real_name)) { // new, delete, etc. + MaybeAppend(state, " "); + } + MaybeAppend(state, p->real_name); + state->mangled_cur += 2; + return true; + } + } + return false; +} + +// ::= TV +// ::= TT +// ::= TI +// ::= TS +// ::= Tc <(base) encoding> +// ::= GV <(object) name> +// ::= T <(base) encoding> +// G++ extensions: +// ::= TC <(offset) number> _ <(base) type> +// ::= TF +// ::= TJ +// ::= GR +// ::= GA +// ::= Th <(base) encoding> +// ::= Tv <(base) encoding> +// +// Note: we don't care much about them since they don't appear in +// stack traces. The are special data. +static bool ParseSpecialName(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'T') && + ParseCharClass(state, "VTIS") && + ParseType(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "Tc") && ParseCallOffset(state) && + ParseCallOffset(state) && ParseEncoding(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "GV") && + ParseName(state)) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'T') && ParseCallOffset(state) && + ParseEncoding(state)) { + return true; + } + *state = copy; + + // G++ extensions + if (ParseTwoCharToken(state, "TC") && ParseType(state) && + ParseNumber(state, nullptr) && ParseOneCharToken(state, '_') && + DisableAppend(state) && ParseType(state)) { + RestoreAppend(state, copy.append); + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "FJ") && + ParseType(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "GR") && ParseName(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "hv") && + ParseCallOffset(state) && ParseEncoding(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= h _ +// ::= v _ +static bool ParseCallOffset(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'h') && + ParseNVOffset(state) && ParseOneCharToken(state, '_')) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'v') && + ParseVOffset(state) && ParseOneCharToken(state, '_')) { + return true; + } + *state = copy; + + return false; +} + +// ::= <(offset) number> +static bool ParseNVOffset(State *state) { return ParseNumber(state, nullptr); } + +// ::= <(offset) number> _ <(virtual offset) number> +static bool ParseVOffset(State *state) { + State copy = *state; + if (ParseNumber(state, nullptr) && ParseOneCharToken(state, '_') && + ParseNumber(state, nullptr)) { + return true; + } + *state = copy; + return false; +} + +// ::= C1 | C2 | C3 +// ::= D0 | D1 | D2 +static bool ParseCtorDtorName(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'C') && + ParseCharClass(state, "123")) { + const char * const prev_name = state->prev_name; + const ssize_t prev_name_length = state->prev_name_length; + MaybeAppendWithLength(state, prev_name, prev_name_length); + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'D') && + ParseCharClass(state, "012")) { + const char * const prev_name = state->prev_name; + const ssize_t prev_name_length = state->prev_name_length; + MaybeAppend(state, "~"); + MaybeAppendWithLength(state, prev_name, prev_name_length); + return true; + } + *state = copy; + return false; +} + +// ::= +// ::= P # pointer-to +// ::= R # reference-to +// ::= O # rvalue reference-to (C++0x) +// ::= C # complex pair (C 2000) +// ::= G # imaginary (C 2000) +// ::= U # vendor extended type qualifier +// ::= +// ::= +// ::= +// ::= +// ::= +// ::= +// ::= +// ::= +// ::= Dp # pack expansion of (C++0x) +// ::= Dt E # decltype of an id-expression or class +// # member access (C++0x) +// ::= DT E # decltype of an expression (C++0x) +// +static bool ParseType(State *state) { + // We should check CV-qualifers, and PRGC things first. + State copy = *state; + if (ParseCVQualifiers(state) && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseCharClass(state, "OPRCG") && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "Dp") && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'D') && ParseCharClass(state, "tT") && + ParseExpression(state) && ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'U') && ParseSourceName(state) && + ParseType(state)) { + return true; + } + *state = copy; + + if (ParseBuiltinType(state) || + ParseFunctionType(state) || + ParseClassEnumType(state) || + ParseArrayType(state) || + ParsePointerToMemberType(state) || + ParseSubstitution(state)) { + return true; + } + + if (ParseTemplateTemplateParam(state) && + ParseTemplateArgs(state)) { + return true; + } + *state = copy; + + // Less greedy than . + if (ParseTemplateParam(state)) { + return true; + } + + return false; +} + +// ::= [r] [V] [K] +// We don't allow empty to avoid infinite loop in +// ParseType(). +static bool ParseCVQualifiers(State *state) { + int num_cv_qualifiers = 0; + num_cv_qualifiers += ParseOneCharToken(state, 'r'); + num_cv_qualifiers += ParseOneCharToken(state, 'V'); + num_cv_qualifiers += ParseOneCharToken(state, 'K'); + return num_cv_qualifiers > 0; +} + +// ::= v, etc. +// ::= u +static bool ParseBuiltinType(State *state) { + const AbbrevPair *p; + for (p = kBuiltinTypeList; p->abbrev != nullptr; ++p) { + if (state->mangled_cur[0] == p->abbrev[0]) { + MaybeAppend(state, p->real_name); + ++state->mangled_cur; + return true; + } + } + + State copy = *state; + if (ParseOneCharToken(state, 'u') && ParseSourceName(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= F [Y] E +static bool ParseFunctionType(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'F') && + Optional(ParseOneCharToken(state, 'Y')) && + ParseBareFunctionType(state) && ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + return false; +} + +// ::= <(signature) type>+ +static bool ParseBareFunctionType(State *state) { + State copy = *state; + DisableAppend(state); + if (OneOrMore(ParseType, state)) { + RestoreAppend(state, copy.append); + MaybeAppend(state, "()"); + return true; + } + *state = copy; + return false; +} + +// ::= +static bool ParseClassEnumType(State *state) { + return ParseName(state); +} + +// ::= A <(positive dimension) number> _ <(element) type> +// ::= A [<(dimension) expression>] _ <(element) type> +static bool ParseArrayType(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'A') && ParseNumber(state, nullptr) && + ParseOneCharToken(state, '_') && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'A') && Optional(ParseExpression(state)) && + ParseOneCharToken(state, '_') && ParseType(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= M <(class) type> <(member) type> +static bool ParsePointerToMemberType(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'M') && ParseType(state) && + ParseType(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= T_ +// ::= T _ +static bool ParseTemplateParam(State *state) { + if (ParseTwoCharToken(state, "T_")) { + MaybeAppend(state, "?"); // We don't support template substitutions. + return true; + } + + State copy = *state; + if (ParseOneCharToken(state, 'T') && ParseNumber(state, nullptr) && + ParseOneCharToken(state, '_')) { + MaybeAppend(state, "?"); // We don't support template substitutions. + return true; + } + *state = copy; + return false; +} + + +// ::= +// ::= +static bool ParseTemplateTemplateParam(State *state) { + return (ParseTemplateParam(state) || + ParseSubstitution(state)); +} + +// ::= I + E +static bool ParseTemplateArgs(State *state) { + State copy = *state; + DisableAppend(state); + if (ParseOneCharToken(state, 'I') && + OneOrMore(ParseTemplateArg, state) && + ParseOneCharToken(state, 'E')) { + RestoreAppend(state, copy.append); + MaybeAppend(state, "<>"); + return true; + } + *state = copy; + return false; +} + +// ::= +// ::= +// ::= I * E # argument pack +// ::= J * E # argument pack +// ::= X E +static bool ParseTemplateArg(State *state) { + State copy = *state; + if ((ParseOneCharToken(state, 'I') || ParseOneCharToken(state, 'J')) && + ZeroOrMore(ParseTemplateArg, state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseType(state) || + ParseExprPrimary(state)) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'X') && ParseExpression(state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + return false; +} + +// ::= +// ::= +// ::= +// ::= +// ::= +// +// ::= st +// ::= sr +// ::= sr +static bool ParseExpression(State *state) { + if (ParseTemplateParam(state) || ParseExprPrimary(state)) { + return true; + } + + State copy = *state; + if (ParseOperatorName(state) && + ParseExpression(state) && + ParseExpression(state) && + ParseExpression(state)) { + return true; + } + *state = copy; + + if (ParseOperatorName(state) && + ParseExpression(state) && + ParseExpression(state)) { + return true; + } + *state = copy; + + if (ParseOperatorName(state) && + ParseExpression(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "st") && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "sr") && ParseType(state) && + ParseUnqualifiedName(state) && + ParseTemplateArgs(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "sr") && ParseType(state) && + ParseUnqualifiedName(state)) { + return true; + } + *state = copy; + return false; +} + +// ::= L <(value) number> E +// ::= L <(value) float> E +// ::= L E +// // A bug in g++'s C++ ABI version 2 (-fabi-version=2). +// ::= LZ E +static bool ParseExprPrimary(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'L') && ParseType(state) && + ParseNumber(state, nullptr) && ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'L') && ParseType(state) && + ParseFloatNumber(state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'L') && ParseMangledName(state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "LZ") && ParseEncoding(state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + return false; +} + +// := Z <(function) encoding> E <(entity) name> +// [] +// := Z <(function) encoding> E s [] +static bool ParseLocalName(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && + ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") && + ParseName(state) && Optional(ParseDiscriminator(state))) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && + ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) { + return true; + } + *state = copy; + return false; +} + +// := _ <(non-negative) number> +static bool ParseDiscriminator(State *state) { + State copy = *state; + if (ParseOneCharToken(state, '_') && ParseNumber(state, nullptr)) { + return true; + } + *state = copy; + return false; +} + +// ::= S_ +// ::= S _ +// ::= St, etc. +static bool ParseSubstitution(State *state) { + if (ParseTwoCharToken(state, "S_")) { + MaybeAppend(state, "?"); // We don't support substitutions. + return true; + } + + State copy = *state; + if (ParseOneCharToken(state, 'S') && ParseSeqId(state) && + ParseOneCharToken(state, '_')) { + MaybeAppend(state, "?"); // We don't support substitutions. + return true; + } + *state = copy; + + // Expand abbreviations like "St" => "std". + if (ParseOneCharToken(state, 'S')) { + const AbbrevPair *p; + for (p = kSubstitutionList; p->abbrev != nullptr; ++p) { + if (state->mangled_cur[0] == p->abbrev[1]) { + MaybeAppend(state, "std"); + if (p->real_name[0] != '\0') { + MaybeAppend(state, "::"); + MaybeAppend(state, p->real_name); + } + ++state->mangled_cur; + return true; + } + } + } + *state = copy; + return false; +} + +// Parse , optionally followed by either a function-clone suffix +// or version suffix. Returns true only if all of "mangled_cur" was consumed. +static bool ParseTopLevelMangledName(State *state) { + if (ParseMangledName(state)) { + if (state->mangled_cur[0] != '\0') { + // Drop trailing function clone suffix, if any. + if (IsFunctionCloneSuffix(state->mangled_cur)) { + return true; + } + // Append trailing version suffix if any. + // ex. _Z3foo@@GLIBCXX_3.4 + if (state->mangled_cur[0] == '@') { + MaybeAppend(state, state->mangled_cur); + return true; + } + return false; // Unconsumed suffix. + } + return true; + } + return false; +} +#endif + +// The demangler entry point. +bool Demangle(const char *mangled, char *out, size_t out_size) { +#if defined(GLOG_OS_WINDOWS) +#if defined(HAVE_DBGHELP) + // When built with incremental linking, the Windows debugger + // library provides a more complicated `Symbol->Name` with the + // Incremental Linking Table offset, which looks like + // `@ILT+1105(?func@Foo@@SAXH@Z)`. However, the demangler expects + // only the mangled symbol, `?func@Foo@@SAXH@Z`. Fortunately, the + // mangled symbol is guaranteed not to have parentheses, + // so we search for `(` and extract up to `)`. + // + // Since we may be in a signal handler here, we cannot use `std::string`. + char buffer[1024]; // Big enough for a sane symbol. + const char *lparen = strchr(mangled, '('); + if (lparen) { + // Extract the string `(?...)` + const char *rparen = strchr(lparen, ')'); + size_t length = static_cast(rparen - lparen) - 1; + strncpy(buffer, lparen + 1, length); + buffer[length] = '\0'; + mangled = buffer; + } // Else the symbol wasn't inside a set of parentheses + // We use the ANSI version to ensure the string type is always `char *`. + return UnDecorateSymbolName(mangled, out, out_size, UNDNAME_COMPLETE); +#else + (void)mangled; + (void)out; + (void)out_size; + return false; +#endif +#else + State state; + InitState(&state, mangled, out, out_size); + return ParseTopLevelMangledName(&state) && !state.overflowed; +#endif +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/demangle.h b/funasr/runtime/onnxruntime/third_party/glog/src/demangle.h new file mode 100644 index 000000000..f347b9814 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/demangle.h @@ -0,0 +1,85 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// An async-signal-safe and thread-safe demangler for Itanium C++ ABI +// (aka G++ V3 ABI). + +// The demangler is implemented to be used in async signal handlers to +// symbolize stack traces. We cannot use libstdc++'s +// abi::__cxa_demangle() in such signal handlers since it's not async +// signal safe (it uses malloc() internally). +// +// Note that this demangler doesn't support full demangling. More +// specifically, it doesn't print types of function parameters and +// types of template arguments. It just skips them. However, it's +// still very useful to extract basic information such as class, +// function, constructor, destructor, and operator names. +// +// See the implementation note in demangle.cc if you are interested. +// +// Example: +// +// | Mangled Name | The Demangler | abi::__cxa_demangle() +// |---------------|---------------|----------------------- +// | _Z1fv | f() | f() +// | _Z1fi | f() | f(int) +// | _Z3foo3bar | foo() | foo(bar) +// | _Z1fIiEvi | f<>() | void f(int) +// | _ZN1N1fE | N::f | N::f +// | _ZN3Foo3BarEv | Foo::Bar() | Foo::Bar() +// | _Zrm1XS_" | operator%() | operator%(X, X) +// | _ZN3FooC1Ev | Foo::Foo() | Foo::Foo() +// | _Z1fSs | f() | f(std::basic_string, +// | | | std::allocator >) +// +// See the unit test for more examples. +// +// Note: we might want to write demanglers for ABIs other than Itanium +// C++ ABI in the future. +// + +#ifndef BASE_DEMANGLE_H_ +#define BASE_DEMANGLE_H_ + +#include "config.h" +#include + +_START_GOOGLE_NAMESPACE_ + +// Demangle "mangled". On success, return true and write the +// demangled symbol name to "out". Otherwise, return false. +// "out" is modified even if demangling is unsuccessful. +bool GLOG_EXPORT Demangle(const char *mangled, char *out, size_t out_size); + +_END_GOOGLE_NAMESPACE_ + +#endif // BASE_DEMANGLE_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.cc new file mode 100644 index 000000000..144781c33 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.cc @@ -0,0 +1,170 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// Unit tests for functions in demangle.c. + +#include "utilities.h" + +#include +#include +#include +#include +#include "demangle.h" +#include "googletest.h" +#include "config.h" + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +GLOG_DEFINE_bool(demangle_filter, false, + "Run demangle_unittest in filter mode"); + +using namespace std; +using namespace GOOGLE_NAMESPACE; + +// A wrapper function for Demangle() to make the unit test simple. +static const char *DemangleIt(const char * const mangled) { + static char demangled[4096]; + if (Demangle(mangled, demangled, sizeof(demangled))) { + return demangled; + } else { + return mangled; + } +} + +#if defined(GLOG_OS_WINDOWS) + +#if defined(HAVE_DBGHELP) && !defined(NDEBUG) +TEST(Demangle, Windows) { + EXPECT_STREQ( + "public: static void __cdecl Foo::func(int)", + DemangleIt("?func@Foo@@SAXH@Z")); + EXPECT_STREQ( + "public: static void __cdecl Foo::func(int)", + DemangleIt("@ILT+1105(?func@Foo@@SAXH@Z)")); + EXPECT_STREQ( + "int __cdecl foobarArray(int * const)", + DemangleIt("?foobarArray@@YAHQAH@Z")); +} +#endif + +#else + +// Test corner cases of bounary conditions. +TEST(Demangle, CornerCases) { + const size_t size = 10; + char tmp[size] = { 0 }; + const char *demangled = "foobar()"; + const char *mangled = "_Z6foobarv"; + EXPECT_TRUE(Demangle(mangled, tmp, sizeof(tmp))); + // sizeof("foobar()") == size - 1 + EXPECT_STREQ(demangled, tmp); + EXPECT_TRUE(Demangle(mangled, tmp, size - 1)); + EXPECT_STREQ(demangled, tmp); + EXPECT_FALSE(Demangle(mangled, tmp, size - 2)); // Not enough. + EXPECT_FALSE(Demangle(mangled, tmp, 1)); + EXPECT_FALSE(Demangle(mangled, tmp, 0)); + EXPECT_FALSE(Demangle(mangled, nullptr, 0)); // Should not cause SEGV. +} + +// Test handling of functions suffixed with .clone.N, which is used by GCC +// 4.5.x, and .constprop.N and .isra.N, which are used by GCC 4.6.x. These +// suffixes are used to indicate functions which have been cloned during +// optimization. We ignore these suffixes. +TEST(Demangle, Clones) { + char tmp[20]; + EXPECT_TRUE(Demangle("_ZL3Foov", tmp, sizeof(tmp))); + EXPECT_STREQ("Foo()", tmp); + EXPECT_TRUE(Demangle("_ZL3Foov.clone.3", tmp, sizeof(tmp))); + EXPECT_STREQ("Foo()", tmp); + EXPECT_TRUE(Demangle("_ZL3Foov.constprop.80", tmp, sizeof(tmp))); + EXPECT_STREQ("Foo()", tmp); + EXPECT_TRUE(Demangle("_ZL3Foov.isra.18", tmp, sizeof(tmp))); + EXPECT_STREQ("Foo()", tmp); + EXPECT_TRUE(Demangle("_ZL3Foov.isra.2.constprop.18", tmp, sizeof(tmp))); + EXPECT_STREQ("Foo()", tmp); + // Invalid (truncated), should not demangle. + EXPECT_FALSE(Demangle("_ZL3Foov.clo", tmp, sizeof(tmp))); + // Invalid (.clone. not followed by number), should not demangle. + EXPECT_FALSE(Demangle("_ZL3Foov.clone.", tmp, sizeof(tmp))); + // Invalid (.clone. followed by non-number), should not demangle. + EXPECT_FALSE(Demangle("_ZL3Foov.clone.foo", tmp, sizeof(tmp))); + // Invalid (.constprop. not followed by number), should not demangle. + EXPECT_FALSE(Demangle("_ZL3Foov.isra.2.constprop.", tmp, sizeof(tmp))); +} + +TEST(Demangle, FromFile) { + string test_file = FLAGS_test_srcdir + "/src/demangle_unittest.txt"; + ifstream f(test_file.c_str()); // The file should exist. + EXPECT_FALSE(f.fail()); + + string line; + while (getline(f, line)) { + // Lines start with '#' are considered as comments. + if (line.empty() || line[0] == '#') { + continue; + } + // Each line should contain a mangled name and a demangled name + // separated by '\t'. Example: "_Z3foo\tfoo" + string::size_type tab_pos = line.find('\t'); + EXPECT_NE(string::npos, tab_pos); + string mangled = line.substr(0, tab_pos); + string demangled = line.substr(tab_pos + 1); + EXPECT_EQ(demangled, DemangleIt(mangled.c_str())); + } +} + +#endif + +int main(int argc, char **argv) { +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + InitGoogleTest(&argc, argv); + + FLAGS_logtostderr = true; + InitGoogleLogging(argv[0]); + if (FLAGS_demangle_filter) { + // Read from cin and write to cout. + string line; + while (getline(cin, line, '\n')) { + cout << DemangleIt(line.c_str()) << endl; + } + return 0; + } else if (argc > 1) { + cout << DemangleIt(argv[1]) << endl; + return 0; + } else { + return RUN_ALL_TESTS(); + } +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.sh b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.sh new file mode 100755 index 000000000..91deee219 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.sh @@ -0,0 +1,95 @@ +#! /bin/sh +# +# Copyright (c) 2006, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Author: Satoru Takabayashi +# +# Unit tests for demangle.c with a real binary. + +set -e + +die () { + echo $1 + exit 1 +} + +BINDIR=".libs" +LIBGLOG="$BINDIR/libglog.so" + +DEMANGLER="$BINDIR/demangle_unittest" + +if test -e "$DEMANGLER"; then + # We need shared object. + export LD_LIBRARY_PATH=$BINDIR + export DYLD_LIBRARY_PATH=$BINDIR +else + # For windows + DEMANGLER="./demangle_unittest.exe" + if ! test -e "$DEMANGLER"; then + echo "We coundn't find demangle_unittest binary." + exit 1 + fi +fi + +# Extract C++ mangled symbols from libbase.so. +NM_OUTPUT="demangle.nm" +nm "$LIBGLOG" | perl -nle 'print $1 if /\s(_Z\S+$)/' > "$NM_OUTPUT" + +# Check if mangled symbols exist. If there are none, we quit. +# The binary is more likely compiled with GCC 2.95 or something old. +if ! grep --quiet '^_Z' "$NM_OUTPUT"; then + echo "PASS" + exit 0 +fi + +# Demangle the symbols using our demangler. +DM_OUTPUT="demangle.dm" +GLOG_demangle_filter=1 "$DEMANGLER" --demangle_filter < "$NM_OUTPUT" > "$DM_OUTPUT" + +# Calculate the numbers of lines. +NM_LINES=`wc -l "$NM_OUTPUT" | awk '{ print $1 }'` +DM_LINES=`wc -l "$DM_OUTPUT" | awk '{ print $1 }'` + +# Compare the numbers of lines. They must be the same. +if test "$NM_LINES" != "$DM_LINES"; then + die "$NM_OUTPUT and $DM_OUTPUT don't have the same numbers of lines" +fi + +# Check if mangled symbols exist. They must not exist. +if grep --quiet '^_Z' "$DM_OUTPUT"; then + MANGLED=`grep '^_Z' "$DM_OUTPUT" | wc -l | awk '{ print \$1 }'` + echo "Mangled symbols ($MANGLED out of $NM_LINES) found in $DM_OUTPUT:" + grep '^_Z' "$DM_OUTPUT" + die "Mangled symbols ($MANGLED out of $NM_LINES) found in $DM_OUTPUT" +fi + +# All C++ symbols are demangled successfully. +echo "PASS" +exit 0 diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.txt b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.txt new file mode 100644 index 000000000..07e28bce2 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/demangle_unittest.txt @@ -0,0 +1,145 @@ +# Test caces for demangle_unittest. Each line consists of a +# tab-separated pair of mangled and demangled symbol names. + +# Constructors and destructors. +_ZN3FooC1Ev Foo::Foo() +_ZN3FooD1Ev Foo::~Foo() +_ZNSoD0Ev std::ostream::~ostream() + +# G++ extensions. +_ZTCN10LogMessage9LogStreamE0_So LogMessage::LogStream +_ZTv0_n12_N10LogMessage9LogStreamD0Ev LogMessage::LogStream::~LogStream() +_ZThn4_N7icu_3_410UnicodeSetD0Ev icu_3_4::UnicodeSet::~UnicodeSet() + +# A bug in g++'s C++ ABI version 2 (-fabi-version=2). +_ZN7NSSInfoI5groupjjXadL_Z10getgrgid_rEELZ19nss_getgrgid_r_nameEEC1Ei NSSInfo<>::NSSInfo() + +# C linkage symbol names. Should keep them untouched. +main main +Demangle Demangle +_ZERO _ZERO + +# Cast operator. +_Zcviv operator int() +_ZN3foocviEv foo::operator int() + +# Versioned symbols. +_Z3Foo@GLIBCXX_3.4 Foo@GLIBCXX_3.4 +_Z3Foo@@GLIBCXX_3.4 Foo@@GLIBCXX_3.4 + +# Abbreviations. +_ZNSaE std::allocator +_ZNSbE std::basic_string +_ZNSdE std::iostream +_ZNSiE std::istream +_ZNSoE std::ostream +_ZNSsE std::string + +# Substitutions. We just replace them with ?. +_ZN3fooS_E foo::? +_ZN3foo3barS0_E foo::bar::? +_ZNcvT_IiEEv operator ?<>() + +# "<< <" case. +_ZlsI3fooE operator<< <> + +# ABI tags. +_Z1AB3barB3foo A +_ZN3fooL3barB5cxx11E foo::bar + +# Random things we found interesting. +_ZN3FooISt6vectorISsSaISsEEEclEv Foo<>::operator()() +_ZTI9Callback1IiE Callback1<> +_ZN7icu_3_47UMemorynwEj icu_3_4::UMemory::operator new() +_ZNSt6vectorIbE9push_backE std::vector<>::push_back +_ZNSt6vectorIbSaIbEE9push_backEb std::vector<>::push_back() +_ZlsRSoRK15PRIVATE_Counter operator<<() +_ZSt6fill_nIPPN9__gnu_cxx15_Hashtable_nodeISt4pairIKPKcjEEEjS8_ET_SA_T0_RKT1_ std::fill_n<>() +_ZZ3FoovE3Bar Foo()::Bar +_ZGVZ7UpTimervE8up_timer UpTimer()::up_timer + +# Test cases from gcc-4.1.0/libstdc++-v3/testsuite/demangle. +# Collected by: +# % grep verify_demangle **/*.cc | perl -nle 'print $1 if /"(_Z.*?)"/' | +# sort | uniq +# +# Note that the following symbols are invalid. +# That's why they are not demangled. +# - _ZNZN1N1fEiE1X1gE +# - _ZNZN1N1fEiE1X1gEv +# - _Z1xINiEE +_Z1fA37_iPS_ f() +_Z1fAszL_ZZNK1N1A1fEvE3foo_0E_i f() +_Z1fI1APS0_PKS0_EvT_T0_T1_PA4_S3_M1CS8_ f<>() +_Z1fI1XENT_1tES2_ f<>() +_Z1fI1XEvPVN1AIT_E1TE f<>() +_Z1fILi1ELc120EEv1AIXplT_cviLd4028ae147ae147aeEEE f<>() +_Z1fILi1ELc120EEv1AIXplT_cviLf3f800000EEE f<>() +_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE f<>() +_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE f<>() +_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE f<>() +_Z1fIiEvi f<>() +_Z1fKPFiiE f() +_Z1fM1AFivEPS0_ f() +_Z1fM1AKFivE f() +_Z1fM1AKFvvE f() +_Z1fPFPA1_ivE f() +_Z1fPFYPFiiEiE f() +_Z1fPFvvEM1SFvvE f() +_Z1fPKM1AFivE f() +_Z1fi f() +_Z1fv f() +_Z1jM1AFivEPS1_ j() +_Z1rM1GFivEMS_KFivES_M1HFivES1_4whatIKS_E5what2IS8_ES3_ r() +_Z1sPA37_iPS0_ s() +_Z1xINiEE _Z1xINiEE +_Z3absILi11EEvv abs<>() +_Z3foo3bar foo() +_Z3foo5Hello5WorldS0_S_ foo() +_Z3fooA30_A_i foo() +_Z3fooIA6_KiEvA9_KT_rVPrS4_ foo<>() +_Z3fooILi2EEvRAplT_Li1E_i foo<>() +_Z3fooIiFvdEiEvv foo<>() +_Z3fooPM2ABi foo() +_Z3fooc foo() +_Z3fooiPiPS_PS0_PS1_PS2_PS3_PS4_PS5_PS6_PS7_PS8_PS9_PSA_PSB_PSC_ foo() +_Z3kooPA28_A30_i koo() +_Z4makeI7FactoryiET_IT0_Ev make<>() +_Z5firstI3DuoEvS0_ first<>() +_Z5firstI3DuoEvT_ first<>() +_Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE hairyfunc() +_ZGVN5libcw24_GLOBAL__N_cbll.cc0ZhUKa23compiler_bug_workaroundISt6vectorINS_13omanip_id_tctINS_5debug32memblk_types_manipulator_data_ctEEESaIS6_EEE3idsE libcw::(anonymous namespace)::compiler_bug_workaround<>::ids +_ZN12libcw_app_ct10add_optionIS_EEvMT_FvPKcES3_cS3_S3_ libcw_app_ct::add_option<>() +_ZN1AIfEcvT_IiEEv A<>::operator ?<>() +_ZN1N1TIiiE2mfES0_IddE N::T<>::mf() +_ZN1N1fE N::f +_ZN1f1fE f::f +_ZN3FooIA4_iE3barE Foo<>::bar +_ZN5Arena5levelE Arena::level +_ZN5StackIiiE5levelE Stack<>::level +_ZN5libcw5debug13cwprint_usingINS_9_private_12GlobalObjectEEENS0_17cwprint_using_tctIT_EERKS5_MS5_KFvRSt7ostreamE libcw::debug::cwprint_using<>() +_ZN6System5Sound4beepEv System::Sound::beep() +_ZNKSt14priority_queueIP27timer_event_request_base_ctSt5dequeIS1_SaIS1_EE13timer_greaterE3topEv std::priority_queue<>::top() +_ZNKSt15_Deque_iteratorIP15memory_block_stRKS1_PS2_EeqERKS5_ std::_Deque_iterator<>::operator==() +_ZNKSt17__normal_iteratorIPK6optionSt6vectorIS0_SaIS0_EEEmiERKS6_ std::__normal_iterator<>::operator-() +_ZNSbIcSt11char_traitsIcEN5libcw5debug27no_alloc_checking_allocatorEE12_S_constructIPcEES6_T_S7_RKS3_ std::basic_string<>::_S_construct<>() +_ZNSt13_Alloc_traitsISbIcSt18string_char_traitsIcEN5libcw5debug9_private_17allocator_adaptorIcSt24__default_alloc_templateILb0ELi327664EELb1EEEENS5_IS9_S7_Lb1EEEE15_S_instancelessE std::_Alloc_traits<>::_S_instanceless +_ZNSt3_In4wardE std::_In::ward +_ZNZN1N1fEiE1X1gE _ZNZN1N1fEiE1X1gE +_ZNZN1N1fEiE1X1gEv _ZNZN1N1fEiE1X1gEv +_ZSt1BISt1DIP1ARKS2_PS3_ES0_IS2_RS2_PS2_ES2_ET0_T_SB_SA_PT1_ std::B<>() +_ZSt5state std::state +_ZTI7a_class a_class +_ZZN1N1fEiE1p N::f()::p +_ZZN1N1fEiEs N::f() +_ZlsRK1XS1_ operator<<() +_ZlsRKU3fooU4bart1XS0_ operator<<() +_ZlsRKU3fooU4bart1XS2_ operator<<() +_ZlsRSoRKSs operator<<() +_ZngILi42EEvN1AIXplT_Li2EEE1TE operator-<>() +_ZplR1XS0_ operator+() +_Zrm1XS_ operator%() + +# Template argument packs can start with I or J. +_Z3addIIiEEvDpT_ add<>() +_Z3addIJiEEvDpT_ add<>() diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/fuzz_demangle.cc b/funasr/runtime/onnxruntime/third_party/glog/src/fuzz_demangle.cc new file mode 100644 index 000000000..c6ee4b5c4 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/fuzz_demangle.cc @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#include "demangle.h" + +extern "C" int LLVMFuzzerTestOneInput(const unsigned char *Data, + unsigned Size) { + if (Size >= 4095) { + return 0; + } + char Buffer[Size + 1]; + std::memcpy(Buffer, Data, Size); + Buffer[Size] = 0; + char demangled[4096]; + google::Demangle(Buffer, demangled, Size); + return 0; +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/log_severity.h b/funasr/runtime/onnxruntime/third_party/glog/src/glog/log_severity.h new file mode 100644 index 000000000..d52989d72 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/log_severity.h @@ -0,0 +1,98 @@ +// Copyright (c) 2023, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef BASE_LOG_SEVERITY_H__ +#define BASE_LOG_SEVERITY_H__ + +// The recommended semantics of the log levels are as follows: +// +// INFO: +// Use for state changes or other major events, or to aid debugging. +// WARNING: +// Use for undesired but relatively expected events, which may indicate a +// problem +// ERROR: +// Use for undesired and unexpected events that the program can recover from. +// All ERRORs should be actionable - it should be appropriate to file a bug +// whenever an ERROR occurs in production. +// FATAL: +// Use for undesired and unexpected events that the program cannot recover +// from. + +// Variables of type LogSeverity are widely taken to lie in the range +// [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if +// you ever need to change their values or add a new severity. +using LogSeverity = int; + +const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3, + NUM_SEVERITIES = 4; +#ifndef GLOG_NO_ABBREVIATED_SEVERITIES +# ifdef ERROR +# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. +# endif +const int INFO = GLOG_INFO, WARNING = GLOG_WARNING, + ERROR = GLOG_ERROR, FATAL = GLOG_FATAL; +#endif + +// DFATAL is FATAL in debug mode, ERROR in normal mode +#ifdef NDEBUG +#define DFATAL_LEVEL ERROR +#else +#define DFATAL_LEVEL FATAL +#endif + +extern GLOG_EXPORT const char* const LogSeverityNames[NUM_SEVERITIES]; + +// NDEBUG usage helpers related to (RAW_)DCHECK: +// +// DEBUG_MODE is for small !NDEBUG uses like +// if (DEBUG_MODE) foo.CheckThatFoo(); +// instead of substantially more verbose +// #ifndef NDEBUG +// foo.CheckThatFoo(); +// #endif +// +// IF_DEBUG_MODE is for small !NDEBUG uses like +// IF_DEBUG_MODE( string error; ) +// DCHECK(Foo(&error)) << error; +// instead of substantially more verbose +// #ifndef NDEBUG +// string error; +// DCHECK(Foo(&error)) << error; +// #endif +// +#ifdef NDEBUG +enum { DEBUG_MODE = 0 }; +#define IF_DEBUG_MODE(x) +#else +enum { DEBUG_MODE = 1 }; +#define IF_DEBUG_MODE(x) x +#endif + +#endif // BASE_LOG_SEVERITY_H__ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/logging.h.in b/funasr/runtime/onnxruntime/third_party/glog/src/glog/logging.h.in new file mode 100644 index 000000000..e8e6c41b8 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/logging.h.in @@ -0,0 +1,1842 @@ +// Copyright (c) 2023, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Ray Sidney +// +// This file contains #include information about logging-related stuff. +// Pretty much everybody needs to #include this file so that they can +// log various happenings. +// +#ifndef GLOG_LOGGING_H +#define GLOG_LOGGING_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if @ac_cv_have_unistd_h@ +# include +#endif +#include + +#if defined(_MSC_VER) +#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ + __pragma(warning(disable:n)) +#define GLOG_MSVC_POP_WARNING() __pragma(warning(pop)) +#else +#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) +#define GLOG_MSVC_POP_WARNING() +#endif + +#include + +#if @ac_cv_have_glog_export@ +#include +#endif + +// We care a lot about number of bits things take up. Unfortunately, +// systems define their bit-specific ints in a lot of different ways. +// We use our own way, and have a typedef to get there. +// Note: these commands below may look like "#if 1" or "#if 0", but +// that's because they were constructed that way at ./configure time. +// Look at logging.h.in to see how they're calculated (based on your config). +#include // the normal place uint16_t is defined +#if @ac_cv_have_systypes_h@ +#include // the normal place u_int16_t is defined +#endif + +#if @ac_cv_have_libgflags@ +#include +#endif + +#include + +@ac_google_start_namespace@ + + typedef std::int32_t int32; +typedef std::uint32_t uint32; +typedef std::int64_t int64; +typedef std::uint64_t uint64; + +#if !(@ac_cv_have_ssize_t@) +typedef ptrdiff_t ssize_t; +#endif + +#if !(@ac_cv_have_mode_t@) +typedef int mode_t; +#endif + +typedef double WallTime; + +struct GLOG_EXPORT LogMessageTime { + LogMessageTime(); + LogMessageTime(std::tm t); + LogMessageTime(std::time_t timestamp, WallTime now); + + const time_t& timestamp() const { return timestamp_; } + const int& sec() const { return time_struct_.tm_sec; } + const int32_t& usec() const { return usecs_; } + const int&(min)() const { return time_struct_.tm_min; } + const int& hour() const { return time_struct_.tm_hour; } + const int& day() const { return time_struct_.tm_mday; } + const int& month() const { return time_struct_.tm_mon; } + const int& year() const { return time_struct_.tm_year; } + const int& dayOfWeek() const { return time_struct_.tm_wday; } + const int& dayInYear() const { return time_struct_.tm_yday; } + const int& dst() const { return time_struct_.tm_isdst; } + const long int& gmtoff() const { return gmtoffset_; } + const std::tm& tm() const { return time_struct_; } + + private: + void init(const std::tm& t, std::time_t timestamp, WallTime now); + std::tm time_struct_; // Time of creation of LogMessage + time_t timestamp_; // Time of creation of LogMessage in seconds + int32_t usecs_; // Time of creation of LogMessage - microseconds part + long int gmtoffset_; + + void CalcGmtOffset(); +}; + +struct LogMessageInfo { + explicit LogMessageInfo(const char* const severity_, + const char* const filename_, + const int& line_number_, + const int& thread_id_, + const LogMessageTime& time_): + severity(severity_), filename(filename_), line_number(line_number_), + thread_id(thread_id_), time(time_) + {} + + const char* const severity; + const char* const filename; + const int &line_number; + const int &thread_id; + const LogMessageTime& time; +}; + +typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, void* data); + +@ac_google_end_namespace@ + + +// The global value of GOOGLE_STRIP_LOG. All the messages logged to +// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed. +// If it can be determined at compile time that the message will not be +// printed, the statement will be compiled out. +// +// Example: to strip out all INFO and WARNING messages, use the value +// of 2 below. To make an exception for WARNING messages from a single +// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including +// base/logging.h +#ifndef GOOGLE_STRIP_LOG +#define GOOGLE_STRIP_LOG 0 +#endif + +// GCC can be told that a certain branch is not likely to be taken (for +// instance, a CHECK failure), and use that information in static analysis. +// Giving it this information can help it optimize for the common case in +// the absence of better information (ie. -fprofile-arcs). +// +#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN +#if @ac_cv_have___builtin_expect@ +#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0)) +#else +#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x +#endif +#endif + +#ifndef GOOGLE_PREDICT_FALSE +#if @ac_cv_have___builtin_expect@ +#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0)) +#else +#define GOOGLE_PREDICT_FALSE(x) x +#endif +#endif + +#ifndef GOOGLE_PREDICT_TRUE +#if @ac_cv_have___builtin_expect@ +#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +#else +#define GOOGLE_PREDICT_TRUE(x) x +#endif +#endif + + +// Make a bunch of macros for logging. The way to log things is to stream +// things to LOG(). E.g., +// +// LOG(INFO) << "Found " << num_cookies << " cookies"; +// +// You can capture log messages in a string, rather than reporting them +// immediately: +// +// vector errors; +// LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num; +// +// This pushes back the new error onto 'errors'; if given a NULL pointer, +// it reports the error via LOG(ERROR). +// +// You can also do conditional logging: +// +// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// You can also do occasional logging (log every n'th occurrence of an +// event): +// +// LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; +// +// The above will cause log messages to be output on the 1st, 11th, 21st, ... +// times it is executed. Note that the special google::COUNTER value is used +// to identify which repetition is happening. +// +// You can also do occasional conditional logging (log every n'th +// occurrence of an event, when condition is satisfied): +// +// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER +// << "th big cookie"; +// +// You can log messages the first N times your code executes a line. E.g. +// +// LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie"; +// +// Outputs log messages for the first 20 times it is executed. +// +// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available. +// These log to syslog as well as to the normal logs. If you use these at +// all, you need to be aware that syslog can drastically reduce performance, +// especially if it is configured for remote logging! Don't use these +// unless you fully understand this and have a concrete need to use them. +// Even then, try to minimize your use of them. +// +// There are also "debug mode" logging macros like the ones above: +// +// DLOG(INFO) << "Found cookies"; +// +// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; +// +// All "debug mode" logging is compiled away to nothing for non-debug mode +// compiles. +// +// We also have +// +// LOG_ASSERT(assertion); +// DLOG_ASSERT(assertion); +// +// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion; +// +// There are "verbose level" logging macros. They look like +// +// VLOG(1) << "I'm printed when you run the program with --v=1 or more"; +// VLOG(2) << "I'm printed when you run the program with --v=2 or more"; +// +// These always log at the INFO log level (when they log at all). +// The verbose logging can also be turned on module-by-module. For instance, +// --vmodule=mapreduce=2,file=1,gfs*=3 --v=0 +// will cause: +// a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc} +// b. VLOG(1) and lower messages to be printed from file.{h,cc} +// c. VLOG(3) and lower messages to be printed from files prefixed with "gfs" +// d. VLOG(0) and lower messages to be printed from elsewhere +// +// The wildcarding functionality shown by (c) supports both '*' (match +// 0 or more characters) and '?' (match any single character) wildcards. +// +// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as +// +// if (VLOG_IS_ON(2)) { +// // do some logging preparation and logging +// // that can't be accomplished with just VLOG(2) << ...; +// } +// +// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level" +// condition macros for sample cases, when some extra computation and +// preparation for logs is not needed. +// VLOG_IF(1, (size > 1024)) +// << "I'm printed when size is more than 1024 and when you run the " +// "program with --v=1 or more"; +// VLOG_EVERY_N(1, 10) +// << "I'm printed every 10th occurrence, and when you run the program " +// "with --v=1 or more. Present occurence is " << google::COUNTER; +// VLOG_IF_EVERY_N(1, (size > 1024), 10) +// << "I'm printed on every 10th occurence of case when size is more " +// " than 1024, when you run the program with --v=1 or more. "; +// "Present occurence is " << google::COUNTER; +// +// The supported severity levels for macros that allow you to specify one +// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. +// Note that messages of a given severity are logged not only in the +// logfile for that severity, but also in all logfiles of lower severity. +// E.g., a message of severity FATAL will be logged to the logfiles of +// severity FATAL, ERROR, WARNING, and INFO. +// +// There is also the special severity of DFATAL, which logs FATAL in +// debug mode, ERROR in normal mode. +// +// Very important: logging a message at the FATAL severity level causes +// the program to terminate (after the message is logged). +// +// Unless otherwise specified, logs will be written to the filename +// "...log..", followed +// by the date, time, and pid (you can't prevent the date, time, and pid +// from being in the filename). +// +// The logging code takes two flags: +// --v=# set the verbose level +// --logtostderr log all the messages to stderr instead of to logfiles + +// LOG LINE PREFIX FORMAT +// +// Log lines have this form: +// +// Lyyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg... +// +// where the fields are defined as follows: +// +// L A single character, representing the log level +// (eg 'I' for INFO) +// yyyy The year +// mm The month (zero padded; ie May is '05') +// dd The day (zero padded) +// hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds +// threadid The space-padded thread ID as returned by GetTID() +// (this matches the PID on Linux) +// file The file name +// line The line number +// msg The user-supplied message +// +// Example: +// +// I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog +// I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395 +// +// NOTE: although the microseconds are useful for comparing events on +// a single machine, clocks on different machines may not be well +// synchronized. Hence, use caution when comparing the low bits of +// timestamps from different machines. + +#pragma push_macro("DECLARE_VARIABLE") +#pragma push_macro("DECLARE_bool") +#pragma push_macro("DECLARE_string") +#pragma push_macro("DECLARE_int32") +#pragma push_macro("DECLARE_uint32") + +#ifdef DECLARE_VARIABLE +#undef DECLARE_VARIABLE +#endif + +#ifdef DECLARE_bool +#undef DECLARE_bool +#endif + +#ifdef DECLARE_string +#undef DECLARE_string +#endif + +#ifdef DECLARE_int32 +#undef DECLARE_int32 +#endif + +#ifdef DECLARE_uint32 +#undef DECLARE_uint32 +#endif + +#ifndef DECLARE_VARIABLE +#define DECLARE_VARIABLE(type, shorttype, name, tn) \ + namespace fL##shorttype { \ + extern GLOG_EXPORT type FLAGS_##name; \ + } \ + using fL##shorttype::FLAGS_##name + +// bool specialization +#define DECLARE_bool(name) \ + DECLARE_VARIABLE(bool, B, name, bool) + +// int32 specialization +#define DECLARE_int32(name) \ + DECLARE_VARIABLE(@ac_google_namespace@::int32, I, name, int32) + +#if !defined(DECLARE_uint32) +// uint32 specialization +#define DECLARE_uint32(name) \ + DECLARE_VARIABLE(@ac_google_namespace@::uint32, U, name, uint32) +#endif // !defined(DECLARE_uint32) && !(@ac_cv_have_libgflags@) + +// Special case for string, because we have to specify the namespace +// std::string, which doesn't play nicely with our FLAG__namespace hackery. +#define DECLARE_string(name) \ + namespace fLS { \ + extern GLOG_EXPORT std::string& FLAGS_##name; \ + } \ + using fLS::FLAGS_##name +#endif + +// Set whether appending a timestamp to the log file name +DECLARE_bool(timestamp_in_logfile_name); + +// Set whether log messages go to stdout instead of logfiles +DECLARE_bool(logtostdout); + +// Set color messages logged to stdout (if supported by terminal). +DECLARE_bool(colorlogtostdout); + +// Set whether log messages go to stderr instead of logfiles +DECLARE_bool(logtostderr); + +// Set whether log messages go to stderr in addition to logfiles. +DECLARE_bool(alsologtostderr); + +// Set color messages logged to stderr (if supported by terminal). +DECLARE_bool(colorlogtostderr); + +// Log messages at a level >= this flag are automatically sent to +// stderr in addition to log files. +DECLARE_int32(stderrthreshold); + +// Set whether the log file header should be written upon creating a file. +DECLARE_bool(log_file_header); + +// Set whether the log prefix should be prepended to each line of output. +DECLARE_bool(log_prefix); + +// Set whether the year should be included in the log prefix. +DECLARE_bool(log_year_in_prefix); + +// Log messages at a level <= this flag are buffered. +// Log messages at a higher level are flushed immediately. +DECLARE_int32(logbuflevel); + +// Sets the maximum number of seconds which logs may be buffered for. +DECLARE_int32(logbufsecs); + +// Log suppression level: messages logged at a lower level than this +// are suppressed. +DECLARE_int32(minloglevel); + +// If specified, logfiles are written into this directory instead of the +// default logging directory. +DECLARE_string(log_dir); + +// Set the log file mode. +DECLARE_int32(logfile_mode); + +// Sets the path of the directory into which to put additional links +// to the log files. +DECLARE_string(log_link); + +DECLARE_int32(v); // in vlog_is_on.cc + +DECLARE_string(vmodule); // also in vlog_is_on.cc + +// Sets the maximum log file size (in MB). +DECLARE_uint32(max_log_size); + +// Sets whether to avoid logging to the disk if the disk is full. +DECLARE_bool(stop_logging_if_full_disk); + +// Use UTC time for logging +DECLARE_bool(log_utc_time); + +// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for +// security reasons. See LOG(severtiy) below. + +// A few definitions of macros that don't generate much code. Since +// LOG(INFO) and its ilk are used all over our code, it's +// better to have compact code for these operations. + +#if GOOGLE_STRIP_LOG == 0 +#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__) +#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, message) +#else +#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::NullStream() +#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::NullStream() +#endif + +#if GOOGLE_STRIP_LOG <= 1 +#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING) +#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, message) +#else +#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::NullStream() +#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::NullStream() +#endif + +#if GOOGLE_STRIP_LOG <= 2 +#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR) +#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, message) +#else +#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::NullStream() +#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::NullStream() +#endif + +#if GOOGLE_STRIP_LOG <= 3 +#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::LogMessageFatal( \ + __FILE__, __LINE__) +#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, message) +#else +#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::NullStreamFatal() +#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::NullStreamFatal() +#endif + +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + +// For DFATAL, we want to use LogMessage (as opposed to +// LogMessageFatal), to be consistent with the original behavior. +#if !DCHECK_IS_ON() +#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR +#elif GOOGLE_STRIP_LOG <= 3 +#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL) +#else +#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::NullStreamFatal() +#endif + +#define GOOGLE_LOG_INFO(counter) @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, counter, &@ac_google_namespace@::LogMessage::SendToLog) +#define SYSLOG_INFO(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, counter, \ + &@ac_google_namespace@::LogMessage::SendToSyslogAndLog) +#define GOOGLE_LOG_WARNING(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, counter, \ + &@ac_google_namespace@::LogMessage::SendToLog) +#define SYSLOG_WARNING(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, counter, \ + &@ac_google_namespace@::LogMessage::SendToSyslogAndLog) +#define GOOGLE_LOG_ERROR(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, counter, \ + &@ac_google_namespace@::LogMessage::SendToLog) +#define SYSLOG_ERROR(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, counter, \ + &@ac_google_namespace@::LogMessage::SendToSyslogAndLog) +#define GOOGLE_LOG_FATAL(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, counter, \ + &@ac_google_namespace@::LogMessage::SendToLog) +#define SYSLOG_FATAL(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, counter, \ + &@ac_google_namespace@::LogMessage::SendToSyslogAndLog) +#define GOOGLE_LOG_DFATAL(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::DFATAL_LEVEL, counter, \ + &@ac_google_namespace@::LogMessage::SendToLog) +#define SYSLOG_DFATAL(counter) \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::DFATAL_LEVEL, counter, \ + &@ac_google_namespace@::LogMessage::SendToSyslogAndLog) + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__) +// A very useful logging macro to log windows errors: +#define LOG_SYSRESULT(result) \ + if (FAILED(HRESULT_FROM_WIN32(result))) { \ + LPSTR message = NULL; \ + LPSTR msg = reinterpret_cast(&message); \ + DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \ + FORMAT_MESSAGE_FROM_SYSTEM | \ + FORMAT_MESSAGE_IGNORE_INSERTS, \ + 0, result, 0, msg, 100, NULL); \ + if (message_length > 0) { \ + @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \ + &@ac_google_namespace@::LogMessage::SendToLog).stream() \ + << reinterpret_cast(message); \ + LocalFree(message); \ + } \ + } +#endif + +// We use the preprocessor's merging operator, "##", so that, e.g., +// LOG(INFO) becomes the token GOOGLE_LOG_INFO. There's some funny +// subtle difference between ostream member streaming functions (e.g., +// ostream::operator<<(int) and ostream non-member streaming functions +// (e.g., ::operator<<(ostream&, string&): it turns out that it's +// impossible to stream something like a string directly to an unnamed +// ostream. We employ a neat hack by calling the stream() member +// function of LogMessage which seems to avoid the problem. +#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream() +#define SYSLOG(severity) SYSLOG_ ## severity(0).stream() + +@ac_google_start_namespace@ + +// They need the definitions of integer types. +#include +#include + +// Initialize google's logging library. You will see the program name +// specified by argv0 in log outputs. +GLOG_EXPORT void InitGoogleLogging(const char* argv0); + +GLOG_EXPORT void InitGoogleLogging(const char* argv0, + CustomPrefixCallback prefix_callback, + void* prefix_callback_data = NULL); + +// Check if google's logging library has been initialized. +GLOG_EXPORT bool IsGoogleLoggingInitialized(); + +// Shutdown google's logging library. +GLOG_EXPORT void ShutdownGoogleLogging(); + +#if defined(__GNUC__) +typedef void (*logging_fail_func_t)() __attribute__((noreturn)); +#else +typedef void (*logging_fail_func_t)(); +#endif + +// Install a function which will be called after LOG(FATAL). +GLOG_EXPORT void InstallFailureFunction(logging_fail_func_t fail_func); + +// Enable/Disable old log cleaner. +GLOG_EXPORT void EnableLogCleaner(unsigned int overdue_days); +GLOG_EXPORT void DisableLogCleaner(); +GLOG_EXPORT void SetApplicationFingerprint(const std::string& fingerprint); + +class LogSink; // defined below + +// If a non-NULL sink pointer is given, we push this message to that sink. +// For LOG_TO_SINK we then do normal LOG(severity) logging as well. +// This is useful for capturing messages and passing/storing them +// somewhere more specific than the global log of the process. +// Argument types: +// LogSink* sink; +// LogSeverity severity; +// The cast is to disambiguate NULL arguments. +#define LOG_TO_SINK(sink, severity) \ + @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, \ + @ac_google_namespace@::GLOG_ ## severity, \ + static_cast<@ac_google_namespace@::LogSink*>(sink), true).stream() +#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \ + @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, \ + @ac_google_namespace@::GLOG_ ## severity, \ + static_cast<@ac_google_namespace@::LogSink*>(sink), false).stream() + +// If a non-NULL string pointer is given, we write this message to that string. +// We then do normal LOG(severity) logging as well. +// This is useful for capturing messages and storing them somewhere more +// specific than the global log of the process. +// Argument types: +// string* message; +// LogSeverity severity; +// The cast is to disambiguate NULL arguments. +// NOTE: LOG(severity) expands to LogMessage().stream() for the specified +// severity. +#define LOG_TO_STRING(severity, message) \ + LOG_TO_STRING_##severity(static_cast(message)).stream() + +// If a non-NULL pointer is given, we push the message onto the end +// of a vector of strings; otherwise, we report it with LOG(severity). +// This is handy for capturing messages and perhaps passing them back +// to the caller, rather than reporting them immediately. +// Argument types: +// LogSeverity severity; +// vector *outvec; +// The cast is to disambiguate NULL arguments. +#define LOG_STRING(severity, outvec) \ + LOG_TO_STRING_##severity(static_cast*>(outvec)).stream() + +#define LOG_IF(severity, condition) \ + static_cast(0), \ + !(condition) ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity) +#define SYSLOG_IF(severity, condition) \ + static_cast(0), \ + !(condition) ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & SYSLOG(severity) + +#define LOG_ASSERT(condition) \ + LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition +#define SYSLOG_ASSERT(condition) \ + SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition + +// CHECK dies with a fatal error if condition is not true. It is *not* +// controlled by DCHECK_IS_ON(), so the check will be executed regardless of +// compilation mode. Therefore, it is safe to do things like: +// CHECK(fp->Write(x) == 4) +#define CHECK(condition) \ + LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \ + << "Check failed: " #condition " " + +// A container for a string pointer which can be evaluated to a bool - +// true iff the pointer is NULL. +struct CheckOpString { + CheckOpString(std::string* str) : str_(str) { } + // No destructor: if str_ is non-NULL, we're about to LOG(FATAL), + // so there's no point in cleaning up str_. + operator bool() const { + return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL); + } + std::string* str_; +}; + +// Function is overloaded for integral types to allow static const +// integrals declared in classes and not defined to be used as arguments to +// CHECK* macros. It's not encouraged though. +template +inline const T& GetReferenceableValue(const T& t) { return t; } +inline char GetReferenceableValue(char t) { return t; } +inline unsigned char GetReferenceableValue(unsigned char t) { return t; } +inline signed char GetReferenceableValue(signed char t) { return t; } +inline short GetReferenceableValue(short t) { return t; } +inline unsigned short GetReferenceableValue(unsigned short t) { return t; } +inline int GetReferenceableValue(int t) { return t; } +inline unsigned int GetReferenceableValue(unsigned int t) { return t; } +inline long GetReferenceableValue(long t) { return t; } +inline unsigned long GetReferenceableValue(unsigned long t) { return t; } +inline long long GetReferenceableValue(long long t) { return t; } +inline unsigned long long GetReferenceableValue(unsigned long long t) { + return t; +} + +// This is a dummy class to define the following operator. +struct DummyClassToDefineOperator {}; + +@ac_google_end_namespace@ + +// Define global operator<< to declare using ::operator<<. +// This declaration will allow use to use CHECK macros for user +// defined classes which have operator<< (e.g., stl_logging.h). +inline std::ostream& operator<<( + std::ostream& out, const google::DummyClassToDefineOperator&) { + return out; +} + +@ac_google_start_namespace@ + +// This formats a value for a failing CHECK_XX statement. Ordinarily, +// it uses the definition for operator<<, with a few special cases below. +template +inline void MakeCheckOpValueString(std::ostream* os, const T& v) { + (*os) << v; +} + +// Overrides for char types provide readable values for unprintable +// characters. +template <> GLOG_EXPORT +void MakeCheckOpValueString(std::ostream* os, const char& v); +template <> GLOG_EXPORT +void MakeCheckOpValueString(std::ostream* os, const signed char& v); +template <> GLOG_EXPORT +void MakeCheckOpValueString(std::ostream* os, const unsigned char& v); + +// Provide printable value for nullptr_t +template <> +GLOG_EXPORT void MakeCheckOpValueString(std::ostream* os, + const std::nullptr_t& v); + +// Build the error message string. Specify no inlining for code size. +template +std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) + @ac_cv___attribute___noinline@; + +namespace base { +namespace internal { + +// If "s" is less than base_logging::INFO, returns base_logging::INFO. +// If "s" is greater than base_logging::FATAL, returns +// base_logging::ERROR. Otherwise, returns "s". +LogSeverity NormalizeSeverity(LogSeverity s); + +} // namespace internal + +// A helper class for formatting "expr (V1 vs. V2)" in a CHECK_XX +// statement. See MakeCheckOpString for sample usage. Other +// approaches were considered: use of a template method (e.g., +// base::BuildCheckOpString(exprtext, base::Print, &v1, +// base::Print, &v2), however this approach has complications +// related to volatile arguments and function-pointer arguments). +class GLOG_EXPORT CheckOpMessageBuilder { + public: + // Inserts "exprtext" and " (" to the stream. + explicit CheckOpMessageBuilder(const char *exprtext); + // Deletes "stream_". + ~CheckOpMessageBuilder(); + // For inserting the first variable. + std::ostream* ForVar1() { return stream_; } + // For inserting the second variable (adds an intermediate " vs. "). + std::ostream* ForVar2(); + // Get the result (inserts the closing ")"). + std::string* NewString(); + + private: + std::ostringstream *stream_; +}; + +} // namespace base + +template +std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) { + base::CheckOpMessageBuilder comb(exprtext); + MakeCheckOpValueString(comb.ForVar1(), v1); + MakeCheckOpValueString(comb.ForVar2(), v2); + return comb.NewString(); +} + +// Helper functions for CHECK_OP macro. +// The (int, int) specialization works around the issue that the compiler +// will not instantiate the template version of the function on values of +// unnamed enum type - see comment below. +#define DEFINE_CHECK_OP_IMPL(name, op) \ + template \ + inline std::string* name##Impl(const T1& v1, const T2& v2, \ + const char* exprtext) { \ + if (GOOGLE_PREDICT_TRUE(v1 op v2)) return NULL; \ + else return MakeCheckOpString(v1, v2, exprtext); \ + } \ + inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \ + return name##Impl(v1, v2, exprtext); \ + } + +// We use the full name Check_EQ, Check_NE, etc. in case the file including +// base/logging.h provides its own #defines for the simpler names EQ, NE, etc. +// This happens if, for example, those are used as token names in a +// yacc grammar. +DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(NULL, x)? +DEFINE_CHECK_OP_IMPL(Check_NE, !=) // Use CHECK(x == NULL) instead. +DEFINE_CHECK_OP_IMPL(Check_LE, <=) +DEFINE_CHECK_OP_IMPL(Check_LT, < ) +DEFINE_CHECK_OP_IMPL(Check_GE, >=) +DEFINE_CHECK_OP_IMPL(Check_GT, > ) +#undef DEFINE_CHECK_OP_IMPL + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use CHECK_EQ et al below. + +#if defined(STATIC_ANALYSIS) +// Only for static analysis tool to know that it is equivalent to assert +#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2)) +#elif DCHECK_IS_ON() +// In debug mode, avoid constructing CheckOpStrings if possible, +// to reduce the overhead of CHECK statments by 2x. +// Real DCHECK-heavy tests have seen 1.5x speedups. + +// The meaning of "string" might be different between now and +// when this macro gets invoked (e.g., if someone is experimenting +// with other string implementations that get defined after this +// file is included). Save the current meaning now and use it +// in the macro. +typedef std::string _Check_string; +#define CHECK_OP_LOG(name, op, val1, val2, log) \ + while (@ac_google_namespace@::_Check_string* _result = \ + @ac_google_namespace@::Check##name##Impl( \ + @ac_google_namespace@::GetReferenceableValue(val1), \ + @ac_google_namespace@::GetReferenceableValue(val2), \ + #val1 " " #op " " #val2)) \ + log(__FILE__, __LINE__, \ + @ac_google_namespace@::CheckOpString(_result)).stream() +#else +// In optimized mode, use CheckOpString to hint to compiler that +// the while condition is unlikely. +#define CHECK_OP_LOG(name, op, val1, val2, log) \ + while (@ac_google_namespace@::CheckOpString _result = \ + @ac_google_namespace@::Check##name##Impl( \ + @ac_google_namespace@::GetReferenceableValue(val1), \ + @ac_google_namespace@::GetReferenceableValue(val2), \ + #val1 " " #op " " #val2)) \ + log(__FILE__, __LINE__, _result).stream() +#endif // STATIC_ANALYSIS, DCHECK_IS_ON() + +#if GOOGLE_STRIP_LOG <= 3 +#define CHECK_OP(name, op, val1, val2) \ + CHECK_OP_LOG(name, op, val1, val2, @ac_google_namespace@::LogMessageFatal) +#else +#define CHECK_OP(name, op, val1, val2) \ + CHECK_OP_LOG(name, op, val1, val2, @ac_google_namespace@::NullStreamFatal) +#endif // STRIP_LOG <= 3 + +// Equality/Inequality checks - compare two values, and log a FATAL message +// including the two values when the result is not as expected. The values +// must have operator<<(ostream, ...) defined. +// +// You may append to the error message like so: +// CHECK_NE(1, 2) << ": The world must be ending!"; +// +// We are very careful to ensure that each argument is evaluated exactly +// once, and that anything which is legal to pass as a function argument is +// legal here. In particular, the arguments may be temporary expressions +// which will end up being destroyed at the end of the apparent statement, +// for example: +// CHECK_EQ(string("abc")[1], 'b'); +// +// WARNING: These don't compile correctly if one of the arguments is a pointer +// and the other is NULL. To work around this, simply static_cast NULL to the +// type of the desired pointer. + +#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2) +#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2) +#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2) +#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2) +#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2) +#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2) + +// Check that the input is non NULL. This very useful in constructor +// initializer lists. + +#define CHECK_NOTNULL(val) \ + @ac_google_namespace@::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) + +// Helper functions for string comparisons. +// To avoid bloat, the definitions are in logging.cc. +#define DECLARE_CHECK_STROP_IMPL(func, expected) \ + GLOG_EXPORT std::string* Check##func##expected##Impl( \ + const char* s1, const char* s2, const char* names); +DECLARE_CHECK_STROP_IMPL(strcmp, true) +DECLARE_CHECK_STROP_IMPL(strcmp, false) +DECLARE_CHECK_STROP_IMPL(strcasecmp, true) +DECLARE_CHECK_STROP_IMPL(strcasecmp, false) +#undef DECLARE_CHECK_STROP_IMPL + +// Helper macro for string comparisons. +// Don't use this macro directly in your code, use CHECK_STREQ et al below. +#define CHECK_STROP(func, op, expected, s1, s2) \ + while (@ac_google_namespace@::CheckOpString _result = \ + @ac_google_namespace@::Check##func##expected##Impl((s1), (s2), \ + #s1 " " #op " " #s2)) \ + LOG(FATAL) << *_result.str_ + + +// String (char*) equality/inequality checks. +// CASE versions are case-insensitive. +// +// Note that "s1" and "s2" may be temporary strings which are destroyed +// by the compiler at the end of the current "full expression" +// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())). + +#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2) +#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2) +#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2) +#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2) + +#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0]))) +#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0]))) + +#define CHECK_DOUBLE_EQ(val1, val2) \ + do { \ + CHECK_LE((val1), (val2)+0.000000000000001L); \ + CHECK_GE((val1), (val2)-0.000000000000001L); \ + } while (0) + +#define CHECK_NEAR(val1, val2, margin) \ + do { \ + CHECK_LE((val1), (val2)+(margin)); \ + CHECK_GE((val1), (val2)-(margin)); \ + } while (0) + +// perror()..googly style! +// +// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and +// CHECK equivalents with the addition that they postpend a description +// of the current state of errno to their output lines. + +#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream() + +#define GOOGLE_PLOG(severity, counter) \ + @ac_google_namespace@::ErrnoLogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, counter, \ + &@ac_google_namespace@::LogMessage::SendToLog) + +#define PLOG_IF(severity, condition) \ + static_cast(0), \ + !(condition) ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & PLOG(severity) + +// A CHECK() macro that postpends errno if the condition is false. E.g. +// +// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... } +#define PCHECK(condition) \ + PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \ + << "Check failed: " #condition " " + +// A CHECK() macro that lets you assert the success of a function that +// returns -1 and sets errno in case of an error. E.g. +// +// CHECK_ERR(mkdir(path, 0700)); +// +// or +// +// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename; +#define CHECK_ERR(invocation) \ +PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ + << #invocation + +// Use macro expansion to create, for each use of LOG_EVERY_N(), static +// variables with the __LINE__ expansion as part of the variable name. +#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line) +#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line + +#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__) +#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__) + +#define LOG_TIME_PERIOD LOG_EVERY_N_VARNAME(timePeriod_, __LINE__) +#define LOG_PREVIOUS_TIME_RAW LOG_EVERY_N_VARNAME(previousTimeRaw_, __LINE__) +#define LOG_TIME_DELTA LOG_EVERY_N_VARNAME(deltaTime_, __LINE__) +#define LOG_CURRENT_TIME LOG_EVERY_N_VARNAME(currentTime_, __LINE__) +#define LOG_PREVIOUS_TIME LOG_EVERY_N_VARNAME(previousTime_, __LINE__) + +#if defined(__has_feature) +# if __has_feature(thread_sanitizer) +# define GLOG_SANITIZE_THREAD 1 +# endif +#endif + +#if !defined(GLOG_SANITIZE_THREAD) && defined(__SANITIZE_THREAD__) && __SANITIZE_THREAD__ +# define GLOG_SANITIZE_THREAD 1 +#endif + +#if defined(GLOG_SANITIZE_THREAD) +#define GLOG_IFDEF_THREAD_SANITIZER(X) X +#else +#define GLOG_IFDEF_THREAD_SANITIZER(X) +#endif + +#if defined(GLOG_SANITIZE_THREAD) +} // namespace google + +// We need to identify the static variables as "benign" races +// to avoid noisy reports from TSAN. +extern "C" void AnnotateBenignRaceSized( + const char *file, + int line, + const volatile void *mem, + size_t size, + const char *description); + +namespace google { +#endif + +#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \ + constexpr std::chrono::nanoseconds LOG_TIME_PERIOD = \ + std::chrono::duration_cast( \ + std::chrono::duration(seconds)); \ + static std::atomic<@ac_google_namespace@ ::int64> LOG_PREVIOUS_TIME_RAW; \ + GLOG_IFDEF_THREAD_SANITIZER( \ + AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_TIME_PERIOD, \ + sizeof(@ac_google_namespace @ ::int64), "")); \ + GLOG_IFDEF_THREAD_SANITIZER( \ + AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_PREVIOUS_TIME_RAW, \ + sizeof(@ac_google_namespace @ ::int64), "")); \ + const auto LOG_CURRENT_TIME = \ + std::chrono::duration_cast( \ + std::chrono::steady_clock::now().time_since_epoch()); \ + const auto LOG_PREVIOUS_TIME = \ + LOG_PREVIOUS_TIME_RAW.load(std::memory_order_relaxed); \ + const auto LOG_TIME_DELTA = \ + LOG_CURRENT_TIME - std::chrono::nanoseconds(LOG_PREVIOUS_TIME); \ + if (LOG_TIME_DELTA > LOG_TIME_PERIOD) \ + LOG_PREVIOUS_TIME_RAW.store( \ + std::chrono::duration_cast(LOG_CURRENT_TIME) \ + .count(), \ + std::memory_order_relaxed); \ + if (LOG_TIME_DELTA > LOG_TIME_PERIOD) \ + @ac_google_namespace@ ::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@ ::GLOG_##severity) \ + .stream() + +#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \ + static std::atomic LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \ + ++LOG_OCCURRENCES; \ + if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ + if (LOG_OCCURRENCES_MOD_N == 1) \ + @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \ + &what_to_do).stream() + +#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \ + static std::atomic LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \ + ++LOG_OCCURRENCES; \ + if ((condition) && \ + ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \ + @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \ + &what_to_do).stream() + +#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \ + static std::atomic LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES_MOD_N, sizeof(int), "")); \ + ++LOG_OCCURRENCES; \ + if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ + if (LOG_OCCURRENCES_MOD_N == 1) \ + @ac_google_namespace@::ErrnoLogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \ + &what_to_do).stream() + +#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \ + static std::atomic LOG_OCCURRENCES(0); \ + GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \ + if (LOG_OCCURRENCES <= n) \ + ++LOG_OCCURRENCES; \ + if (LOG_OCCURRENCES <= n) \ + @ac_google_namespace@::LogMessage( \ + __FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \ + &what_to_do).stream() + +namespace glog_internal_namespace_ { +template +struct CompileAssert { +}; +struct CrashReason; + +// Returns true if FailureSignalHandler is installed. +// Needs to be exported since it's used by the signalhandler_unittest. +GLOG_EXPORT bool IsFailureSignalHandlerInstalled(); +} // namespace glog_internal_namespace_ + +#define LOG_EVERY_N(severity, n) \ + SOME_KIND_OF_LOG_EVERY_N(severity, (n), @ac_google_namespace@::LogMessage::SendToLog) + +#define LOG_EVERY_T(severity, T) SOME_KIND_OF_LOG_EVERY_T(severity, (T)) + +#define SYSLOG_EVERY_N(severity, n) \ + SOME_KIND_OF_LOG_EVERY_N(severity, (n), @ac_google_namespace@::LogMessage::SendToSyslogAndLog) + +#define PLOG_EVERY_N(severity, n) \ + SOME_KIND_OF_PLOG_EVERY_N(severity, (n), @ac_google_namespace@::LogMessage::SendToLog) + +#define LOG_FIRST_N(severity, n) \ + SOME_KIND_OF_LOG_FIRST_N(severity, (n), @ac_google_namespace@::LogMessage::SendToLog) + +#define LOG_IF_EVERY_N(severity, condition, n) \ + SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), @ac_google_namespace@::LogMessage::SendToLog) + +// We want the special COUNTER value available for LOG_EVERY_X()'ed messages +enum PRIVATE_Counter {COUNTER}; + +#ifdef GLOG_NO_ABBREVIATED_SEVERITIES +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR. +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +#define SYSLOG_0 SYSLOG_ERROR +#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity GLOG_0 = GLOG_ERROR; +#else +// Users may include windows.h after logging.h without +// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN. +// For this case, we cannot detect if ERROR is defined before users +// actually use ERROR. Let's make an undefined symbol to warn users. +# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail +# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG +# define SYSLOG_0 GLOG_ERROR_MSG +# define LOG_TO_STRING_0 GLOG_ERROR_MSG +# define GLOG_0 GLOG_ERROR_MSG +#endif + +// Plus some debug-logging macros that get compiled to nothing for production + +#if DCHECK_IS_ON() + +#define DLOG(severity) LOG(severity) +#define DVLOG(verboselevel) VLOG(verboselevel) +#define DLOG_IF(severity, condition) LOG_IF(severity, condition) +#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n) +#define DLOG_IF_EVERY_N(severity, condition, n) \ + LOG_IF_EVERY_N(severity, condition, n) +#define DLOG_ASSERT(condition) LOG_ASSERT(condition) + +// debug-only checking. executed if DCHECK_IS_ON(). +#define DCHECK(condition) CHECK(condition) +#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2) +#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2) +#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2) +#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2) +#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2) +#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2) +#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val) +#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2) +#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2) +#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2) +#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2) + +#else // !DCHECK_IS_ON() + +#define DLOG(severity) \ + static_cast(0), \ + true ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity) + +#define DVLOG(verboselevel) \ + static_cast(0), \ + (true || !VLOG_IS_ON(verboselevel)) ? \ + (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(INFO) + +#define DLOG_IF(severity, condition) \ + static_cast(0), \ + (true || !(condition)) ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity) + +#define DLOG_EVERY_N(severity, n) \ + static_cast(0), \ + true ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity) + +#define DLOG_IF_EVERY_N(severity, condition, n) \ + static_cast(0), \ + (true || !(condition))? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity) + +#define DLOG_ASSERT(condition) \ + static_cast(0), \ + true ? (void) 0 : LOG_ASSERT(condition) + +// MSVC warning C4127: conditional expression is constant +#define DCHECK(condition) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK(condition) + +#define DCHECK_EQ(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_EQ(val1, val2) + +#define DCHECK_NE(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_NE(val1, val2) + +#define DCHECK_LE(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_LE(val1, val2) + +#define DCHECK_LT(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_LT(val1, val2) + +#define DCHECK_GE(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_GE(val1, val2) + +#define DCHECK_GT(val1, val2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_GT(val1, val2) + +// You may see warnings in release mode if you don't use the return +// value of DCHECK_NOTNULL. Please just use DCHECK for such cases. +#define DCHECK_NOTNULL(val) (val) + +#define DCHECK_STREQ(str1, str2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_STREQ(str1, str2) + +#define DCHECK_STRCASEEQ(str1, str2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_STRCASEEQ(str1, str2) + +#define DCHECK_STRNE(str1, str2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_STRNE(str1, str2) + +#define DCHECK_STRCASENE(str1, str2) \ + GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \ + while (false) \ + GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2) + +#endif // DCHECK_IS_ON() + +// Log only in verbose mode. + +#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel)) + +#define VLOG_IF(verboselevel, condition) \ + LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel)) + +#define VLOG_EVERY_N(verboselevel, n) \ + LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n) + +#define VLOG_IF_EVERY_N(verboselevel, condition, n) \ + LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n) + +namespace base_logging { + +// LogMessage::LogStream is a std::ostream backed by this streambuf. +// This class ignores overflow and leaves two bytes at the end of the +// buffer to allow for a '\n' and '\0'. +class GLOG_EXPORT LogStreamBuf : public std::streambuf { + public: + // REQUIREMENTS: "len" must be >= 2 to account for the '\n' and '\0'. + LogStreamBuf(char *buf, int len) { + setp(buf, buf + len - 2); + } + + // This effectively ignores overflow. + int_type overflow(int_type ch) { + return ch; + } + + // Legacy public ostrstream method. + size_t pcount() const { return static_cast(pptr() - pbase()); } + char* pbase() const { return std::streambuf::pbase(); } +}; + +} // namespace base_logging + +// +// This class more or less represents a particular log message. You +// create an instance of LogMessage and then stream stuff to it. +// When you finish streaming to it, ~LogMessage is called and the +// full message gets streamed to the appropriate destination. +// +// You shouldn't actually use LogMessage's constructor to log things, +// though. You should use the LOG() macro (and variants thereof) +// above. +class GLOG_EXPORT LogMessage { +public: + enum { + // Passing kNoLogPrefix for the line number disables the + // log-message prefix. Useful for using the LogMessage + // infrastructure as a printing utility. See also the --log_prefix + // flag for controlling the log-message prefix on an + // application-wide basis. + kNoLogPrefix = -1 + }; + + // LogStream inherit from non-DLL-exported class (std::ostrstream) + // and VC++ produces a warning for this situation. + // However, MSDN says "C4275 can be ignored in Microsoft Visual C++ + // 2005 if you are deriving from a type in the Standard C++ Library" + // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx + // Let's just ignore the warning. +GLOG_MSVC_PUSH_DISABLE_WARNING(4275) + class GLOG_EXPORT LogStream : public std::ostream { +GLOG_MSVC_POP_WARNING() + public: + LogStream(char *buf, int len, int64 ctr) + : std::ostream(NULL), + streambuf_(buf, len), + ctr_(ctr), + self_(this) { + rdbuf(&streambuf_); + } + + int64 ctr() const { return ctr_; } + void set_ctr(int64 ctr) { ctr_ = ctr; } + LogStream* self() const { return self_; } + + // Legacy std::streambuf methods. + size_t pcount() const { return streambuf_.pcount(); } + char* pbase() const { return streambuf_.pbase(); } + char* str() const { return pbase(); } + + private: + LogStream(const LogStream&); + LogStream& operator=(const LogStream&); + base_logging::LogStreamBuf streambuf_; + int64 ctr_; // Counter hack (for the LOG_EVERY_X() macro) + LogStream *self_; // Consistency check hack + }; + +public: + // icc 8 requires this typedef to avoid an internal compiler error. + typedef void (LogMessage::*SendMethod)(); + + LogMessage(const char* file, int line, LogSeverity severity, int64 ctr, + SendMethod send_method); + + // Two special constructors that generate reduced amounts of code at + // LOG call sites for common cases. + + // Used for LOG(INFO): Implied are: + // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog. + // + // Using this constructor instead of the more complex constructor above + // saves 19 bytes per call site. + LogMessage(const char* file, int line); + + // Used for LOG(severity) where severity != INFO. Implied + // are: ctr = 0, send_method = &LogMessage::SendToLog + // + // Using this constructor instead of the more complex constructor above + // saves 17 bytes per call site. + LogMessage(const char* file, int line, LogSeverity severity); + + // Constructor to log this message to a specified sink (if not NULL). + // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if + // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise. + LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink, + bool also_send_to_log); + + // Constructor where we also give a vector pointer + // for storing the messages (if the pointer is not NULL). + // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog. + LogMessage(const char* file, int line, LogSeverity severity, + std::vector* outvec); + + // Constructor where we also give a string pointer for storing the + // message (if the pointer is not NULL). Implied are: ctr = 0, + // send_method = &LogMessage::WriteToStringAndLog. + LogMessage(const char* file, int line, LogSeverity severity, + std::string* message); + + // A special constructor used for check failures + LogMessage(const char* file, int line, const CheckOpString& result); + + ~LogMessage(); + + // Flush a buffered message to the sink set in the constructor. Always + // called by the destructor, it may also be called from elsewhere if + // needed. Only the first call is actioned; any later ones are ignored. + void Flush(); + + // An arbitrary limit on the length of a single log message. This + // is so that streaming can be done more efficiently. + static const size_t kMaxLogMessageLen; + + // Theses should not be called directly outside of logging.*, + // only passed as SendMethod arguments to other LogMessage methods: + void SendToLog(); // Actually dispatch to the logs + void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs + + // Call abort() or similar to perform LOG(FATAL) crash. + [[noreturn]] static void Fail(); + + std::ostream& stream(); + + int preserved_errno() const; + + // Must be called without the log_mutex held. (L < log_mutex) + static int64 num_messages(int severity); + + const LogMessageTime& getLogMessageTime() const; + + struct LogMessageData; + +private: + // Fully internal SendMethod cases: + void SendToSinkAndLog(); // Send to sink if provided and dispatch to the logs + void SendToSink(); // Send to sink if provided, do nothing otherwise. + + // Write to string if provided and dispatch to the logs. + void WriteToStringAndLog(); + + void SaveOrSendToLog(); // Save to stringvec if provided, else to logs + + void Init(const char* file, int line, LogSeverity severity, + void (LogMessage::*send_method)()); + + // Used to fill in crash information during LOG(FATAL) failures. + void RecordCrashReason(glog_internal_namespace_::CrashReason* reason); + + // Counts of messages sent at each priority: + static int64 num_messages_[NUM_SEVERITIES]; // under log_mutex + + // We keep the data in a separate struct so that each instance of + // LogMessage uses less stack space. + LogMessageData* allocated_; + LogMessageData* data_; + LogMessageTime logmsgtime_; + + friend class LogDestination; + + LogMessage(const LogMessage&); + void operator=(const LogMessage&); +}; + +// This class happens to be thread-hostile because all instances share +// a single data buffer, but since it can only be created just before +// the process dies, we don't worry so much. +class GLOG_EXPORT LogMessageFatal : public LogMessage { + public: + LogMessageFatal(const char* file, int line); + LogMessageFatal(const char* file, int line, const CheckOpString& result); + [[noreturn]] ~LogMessageFatal(); +}; + +// A non-macro interface to the log facility; (useful +// when the logging level is not a compile-time constant). +inline void LogAtLevel(int const severity, std::string const &msg) { + LogMessage(__FILE__, __LINE__, severity).stream() << msg; +} + +// A macro alternative of LogAtLevel. New code may want to use this +// version since there are two advantages: 1. this version outputs the +// file name and the line number where this macro is put like other +// LOG macros, 2. this macro can be used as C++ stream. +#define LOG_AT_LEVEL(severity) @ac_google_namespace@::LogMessage(__FILE__, __LINE__, severity).stream() + +// Helper for CHECK_NOTNULL(). +// +// In C++11, all cases can be handled by a single function. Since the value +// category of the argument is preserved (also for rvalue references), +// member initializer lists like the one below will compile correctly: +// +// Foo() +// : x_(CHECK_NOTNULL(MethodReturningUniquePtr())) {} +template +T CheckNotNull(const char* file, int line, const char* names, T&& t) { + if (t == nullptr) { + LogMessageFatal(file, line, new std::string(names)); + } + return std::forward(t); +} + +// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This +// only works if ostream is a LogStream. If the ostream is not a +// LogStream you'll get an assert saying as much at runtime. +GLOG_EXPORT std::ostream& operator<<(std::ostream &os, + const PRIVATE_Counter&); + + +// Derived class for PLOG*() above. +class GLOG_EXPORT ErrnoLogMessage : public LogMessage { + public: + ErrnoLogMessage(const char* file, int line, LogSeverity severity, int64 ctr, + void (LogMessage::*send_method)()); + + // Postpends ": strerror(errno) [errno]". + ~ErrnoLogMessage(); + + private: + ErrnoLogMessage(const ErrnoLogMessage&); + void operator=(const ErrnoLogMessage&); +}; + + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". + +class GLOG_EXPORT LogMessageVoidify { + public: + LogMessageVoidify() { } + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(std::ostream&) { } +}; + + +// Flushes all log files that contains messages that are at least of +// the specified severity level. Thread-safe. +GLOG_EXPORT void FlushLogFiles(LogSeverity min_severity); + +// Flushes all log files that contains messages that are at least of +// the specified severity level. Thread-hostile because it ignores +// locking -- used for catastrophic failures. +GLOG_EXPORT void FlushLogFilesUnsafe(LogSeverity min_severity); + +// +// Set the destination to which a particular severity level of log +// messages is sent. If base_filename is "", it means "don't log this +// severity". Thread-safe. +// +GLOG_EXPORT void SetLogDestination(LogSeverity severity, + const char* base_filename); + +// +// Set the basename of the symlink to the latest log file at a given +// severity. If symlink_basename is empty, do not make a symlink. If +// you don't call this function, the symlink basename is the +// invocation name of the program. Thread-safe. +// +GLOG_EXPORT void SetLogSymlink(LogSeverity severity, + const char* symlink_basename); + +// +// Used to send logs to some other kind of destination +// Users should subclass LogSink and override send to do whatever they want. +// Implementations must be thread-safe because a shared instance will +// be called from whichever thread ran the LOG(XXX) line. +class GLOG_EXPORT LogSink { + public: + virtual ~LogSink(); + + // Sink's logging logic (message_len is such as to exclude '\n' at the end). + // This method can't use LOG() or CHECK() as logging system mutex(s) are held + // during this call. + virtual void send(LogSeverity severity, const char* full_filename, + const char* base_filename, int line, + const LogMessageTime& logmsgtime, const char* message, + size_t message_len); + // Provide an overload for compatibility purposes + GLOG_DEPRECATED + virtual void send(LogSeverity severity, const char* full_filename, + const char* base_filename, int line, const std::tm* t, + const char* message, size_t message_len); + + // Redefine this to implement waiting for + // the sink's logging logic to complete. + // It will be called after each send() returns, + // but before that LogMessage exits or crashes. + // By default this function does nothing. + // Using this function one can implement complex logic for send() + // that itself involves logging; and do all this w/o causing deadlocks and + // inconsistent rearrangement of log messages. + // E.g. if a LogSink has thread-specific actions, the send() method + // can simply add the message to a queue and wake up another thread that + // handles real logging while itself making some LOG() calls; + // WaitTillSent() can be implemented to wait for that logic to complete. + // See our unittest for an example. + virtual void WaitTillSent(); + + // Returns the normal text output of the log message. + // Can be useful to implement send(). + static std::string ToString(LogSeverity severity, const char* file, int line, + const LogMessageTime &logmsgtime, + const char* message, size_t message_len); +}; + +// Add or remove a LogSink as a consumer of logging data. Thread-safe. +GLOG_EXPORT void AddLogSink(LogSink *destination); +GLOG_EXPORT void RemoveLogSink(LogSink *destination); + +// +// Specify an "extension" added to the filename specified via +// SetLogDestination. This applies to all severity levels. It's +// often used to append the port we're listening on to the logfile +// name. Thread-safe. +// +GLOG_EXPORT void SetLogFilenameExtension( + const char* filename_extension); + +// +// Make it so that all log messages of at least a particular severity +// are logged to stderr (in addition to logging to the usual log +// file(s)). Thread-safe. +// +GLOG_EXPORT void SetStderrLogging(LogSeverity min_severity); + +// +// Make it so that all log messages go only to stderr. Thread-safe. +// +GLOG_EXPORT void LogToStderr(); + +// +// Make it so that all log messages of at least a particular severity are +// logged via email to a list of addresses (in addition to logging to the +// usual log file(s)). The list of addresses is just a string containing +// the email addresses to send to (separated by spaces, say). Thread-safe. +// +GLOG_EXPORT void SetEmailLogging(LogSeverity min_severity, + const char* addresses); + +// A simple function that sends email. dest is a commma-separated +// list of addressess. Thread-safe. +GLOG_EXPORT bool SendEmail(const char* dest, const char* subject, + const char* body); + +GLOG_EXPORT const std::vector& GetLoggingDirectories(); + +// For tests only: Clear the internal [cached] list of logging directories to +// force a refresh the next time GetLoggingDirectories is called. +// Thread-hostile. +void TestOnly_ClearLoggingDirectoriesList(); + +// Returns a set of existing temporary directories, which will be a +// subset of the directories returned by GetLoggingDirectories(). +// Thread-safe. +GLOG_EXPORT void GetExistingTempDirectories( + std::vector* list); + +// Print any fatal message again -- useful to call from signal handler +// so that the last thing in the output is the fatal message. +// Thread-hostile, but a race is unlikely. +GLOG_EXPORT void ReprintFatalMessage(); + +// Truncate a log file that may be the append-only output of multiple +// processes and hence can't simply be renamed/reopened (typically a +// stdout/stderr). If the file "path" is > "limit" bytes, copy the +// last "keep" bytes to offset 0 and truncate the rest. Since we could +// be racing with other writers, this approach has the potential to +// lose very small amounts of data. For security, only follow symlinks +// if the path is /proc/self/fd/* +GLOG_EXPORT void TruncateLogFile(const char* path, uint64 limit, uint64 keep); + +// Truncate stdout and stderr if they are over the value specified by +// --max_log_size; keep the final 1MB. This function has the same +// race condition as TruncateLogFile. +GLOG_EXPORT void TruncateStdoutStderr(); + +// Return the string representation of the provided LogSeverity level. +// Thread-safe. +GLOG_EXPORT const char* GetLogSeverityName(LogSeverity severity); + +// --------------------------------------------------------------------- +// Implementation details that are not useful to most clients +// --------------------------------------------------------------------- + +// A Logger is the interface used by logging modules to emit entries +// to a log. A typical implementation will dump formatted data to a +// sequence of files. We also provide interfaces that will forward +// the data to another thread so that the invoker never blocks. +// Implementations should be thread-safe since the logging system +// will write to them from multiple threads. + +namespace base { + +class GLOG_EXPORT Logger { + public: + virtual ~Logger(); + + // Writes "message[0,message_len-1]" corresponding to an event that + // occurred at "timestamp". If "force_flush" is true, the log file + // is flushed immediately. + // + // The input message has already been formatted as deemed + // appropriate by the higher level logging facility. For example, + // textual log messages already contain timestamps, and the + // file:linenumber header. + virtual void Write(bool force_flush, + time_t timestamp, + const char* message, + size_t message_len) = 0; + + // Flush any buffered messages + virtual void Flush() = 0; + + // Get the current LOG file size. + // The returned value is approximate since some + // logged data may not have been flushed to disk yet. + virtual uint32 LogSize() = 0; +}; + +// Get the logger for the specified severity level. The logger +// remains the property of the logging module and should not be +// deleted by the caller. Thread-safe. +extern GLOG_EXPORT Logger* GetLogger(LogSeverity level); + +// Set the logger for the specified severity level. The logger +// becomes the property of the logging module and should not +// be deleted by the caller. Thread-safe. +extern GLOG_EXPORT void SetLogger(LogSeverity level, Logger* logger); + +} + +// glibc has traditionally implemented two incompatible versions of +// strerror_r(). There is a poorly defined convention for picking the +// version that we want, but it is not clear whether it even works with +// all versions of glibc. +// So, instead, we provide this wrapper that automatically detects the +// version that is in use, and then implements POSIX semantics. +// N.B. In addition to what POSIX says, we also guarantee that "buf" will +// be set to an empty string, if this function failed. This means, in most +// cases, you do not need to check the error code and you can directly +// use the value of "buf". It will never have an undefined value. +// DEPRECATED: Use StrError(int) instead. +GLOG_EXPORT int posix_strerror_r(int err, char *buf, size_t len); + +// A thread-safe replacement for strerror(). Returns a string describing the +// given POSIX error code. +GLOG_EXPORT std::string StrError(int err); + +// A class for which we define operator<<, which does nothing. +class GLOG_EXPORT NullStream : public LogMessage::LogStream { + public: + // Initialize the LogStream so the messages can be written somewhere + // (they'll never be actually displayed). This will be needed if a + // NullStream& is implicitly converted to LogStream&, in which case + // the overloaded NullStream::operator<< will not be invoked. + NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { } + NullStream(const char* /*file*/, int /*line*/, + const CheckOpString& /*result*/) : + LogMessage::LogStream(message_buffer_, 1, 0) { } + NullStream &stream() { return *this; } + private: + // A very short buffer for messages (which we discard anyway). This + // will be needed if NullStream& converted to LogStream& (e.g. as a + // result of a conditional expression). + char message_buffer_[2]; +}; + +// Do nothing. This operator is inline, allowing the message to be +// compiled away. The message will not be compiled away if we do +// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when +// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly +// converted to LogStream and the message will be computed and then +// quietly discarded. +template +inline NullStream& operator<<(NullStream &str, const T &) { return str; } + +// Similar to NullStream, but aborts the program (without stack +// trace), like LogMessageFatal. +class GLOG_EXPORT NullStreamFatal : public NullStream { + public: + NullStreamFatal() { } + NullStreamFatal(const char* file, int line, const CheckOpString& result) : + NullStream(file, line, result) { } +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4722) +#endif // _MSC_VER + [[noreturn]] ~NullStreamFatal() throw() { _exit(EXIT_FAILURE); } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif // _MSC_VER +}; + +// Install a signal handler that will dump signal information and a stack +// trace when the program crashes on certain signals. We'll install the +// signal handler for the following signals. +// +// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM. +// +// By default, the signal handler will write the failure dump to the +// standard error. You can customize the destination by installing your +// own writer function by InstallFailureWriter() below. +// +// Note on threading: +// +// The function should be called before threads are created, if you want +// to use the failure signal handler for all threads. The stack trace +// will be shown only for the thread that receives the signal. In other +// words, stack traces of other threads won't be shown. +GLOG_EXPORT void InstallFailureSignalHandler(); + +// Installs a function that is used for writing the failure dump. "data" +// is the pointer to the beginning of a message to be written, and "size" +// is the size of the message. You should not expect the data is +// terminated with '\0'. +GLOG_EXPORT void InstallFailureWriter( + void (*writer)(const char* data, size_t size)); + +@ac_google_end_namespace@ + +#pragma pop_macro("DECLARE_VARIABLE") +#pragma pop_macro("DECLARE_bool") +#pragma pop_macro("DECLARE_string") +#pragma pop_macro("DECLARE_int32") +#pragma pop_macro("DECLARE_uint32") + +#endif // GLOG_LOGGING_H diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/platform.h b/funasr/runtime/onnxruntime/third_party/glog/src/glog/platform.h new file mode 100644 index 000000000..7893c45d1 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/platform.h @@ -0,0 +1,60 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Shinichiro Hamaji +// +// Detect supported platforms. + +#ifndef GLOG_PLATFORM_H +#define GLOG_PLATFORM_H + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +#define GLOG_OS_WINDOWS +#elif defined(__CYGWIN__) || defined(__CYGWIN32__) +#define GLOG_OS_CYGWIN +#elif defined(linux) || defined(__linux) || defined(__linux__) +#ifndef GLOG_OS_LINUX +#define GLOG_OS_LINUX +#endif +#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) +#define GLOG_OS_MACOSX +#elif defined(__FreeBSD__) +#define GLOG_OS_FREEBSD +#elif defined(__NetBSD__) +#define GLOG_OS_NETBSD +#elif defined(__OpenBSD__) +#define GLOG_OS_OPENBSD +#elif defined(__EMSCRIPTEN__) +#define GLOG_OS_EMSCRIPTEN +#else +// TODO(hamaji): Add other platforms. +#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github. +#endif + +#endif // GLOG_PLATFORM_H diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/raw_logging.h.in b/funasr/runtime/onnxruntime/third_party/glog/src/glog/raw_logging.h.in new file mode 100644 index 000000000..66fec91e5 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/raw_logging.h.in @@ -0,0 +1,179 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Maxim Lifantsev +// +// Thread-safe logging routines that do not allocate any memory or +// acquire any locks, and can therefore be used by low-level memory +// allocation and synchronization code. + +#ifndef GLOG_RAW_LOGGING_H +#define GLOG_RAW_LOGGING_H + +#include + +@ac_google_start_namespace@ + +#include +#include +#include + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#endif + +// This is similar to LOG(severity) << format... and VLOG(level) << format.., +// but +// * it is to be used ONLY by low-level modules that can't use normal LOG() +// * it is desiged to be a low-level logger that does not allocate any +// memory and does not need any locks, hence: +// * it logs straight and ONLY to STDERR w/o buffering +// * it uses an explicit format and arguments list +// * it will silently chop off really long message strings +// Usage example: +// RAW_LOG(ERROR, "Failed foo with %i: %s", status, error); +// RAW_VLOG(3, "status is %i", status); +// These will print an almost standard log lines like this to stderr only: +// E20200821 211317 file.cc:123] RAW: Failed foo with 22: bad_file +// I20200821 211317 file.cc:142] RAW: status is 20 +#define RAW_LOG(severity, ...) \ + do { \ + switch (@ac_google_namespace@::GLOG_ ## severity) { \ + case 0: \ + RAW_LOG_INFO(__VA_ARGS__); \ + break; \ + case 1: \ + RAW_LOG_WARNING(__VA_ARGS__); \ + break; \ + case 2: \ + RAW_LOG_ERROR(__VA_ARGS__); \ + break; \ + case 3: \ + RAW_LOG_FATAL(__VA_ARGS__); \ + break; \ + default: \ + break; \ + } \ + } while (0) + +// The following STRIP_LOG testing is performed in the header file so that it's +// possible to completely compile out the logging code and the log messages. +#if !defined(STRIP_LOG) || STRIP_LOG == 0 +#define RAW_VLOG(verboselevel, ...) \ + do { \ + if (VLOG_IS_ON(verboselevel)) { \ + RAW_LOG_INFO(__VA_ARGS__); \ + } \ + } while (0) +#else +#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__) +#endif // STRIP_LOG == 0 + +#if !defined(STRIP_LOG) || STRIP_LOG == 0 +#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_INFO, \ + __FILE__, __LINE__, __VA_ARGS__) +#else +#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__) +#endif // STRIP_LOG == 0 + +#if !defined(STRIP_LOG) || STRIP_LOG <= 1 +#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_WARNING, \ + __FILE__, __LINE__, __VA_ARGS__) +#else +#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__) +#endif // STRIP_LOG <= 1 + +#if !defined(STRIP_LOG) || STRIP_LOG <= 2 +#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_ERROR, \ + __FILE__, __LINE__, __VA_ARGS__) +#else +#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__) +#endif // STRIP_LOG <= 2 + +#if !defined(STRIP_LOG) || STRIP_LOG <= 3 +#define RAW_LOG_FATAL(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_FATAL, \ + __FILE__, __LINE__, __VA_ARGS__) +#else +#define RAW_LOG_FATAL(...) \ + do { \ + @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__); \ + exit(EXIT_FAILURE); \ + } while (0) +#endif // STRIP_LOG <= 3 + +// Similar to CHECK(condition) << message, +// but for low-level modules: we use only RAW_LOG that does not allocate memory. +// We do not want to provide args list here to encourage this usage: +// if (!cond) RAW_LOG(FATAL, "foo ...", hard_to_compute_args); +// so that the args are not computed when not needed. +#define RAW_CHECK(condition, message) \ + do { \ + if (!(condition)) { \ + RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \ + } \ + } while (0) + +// Debug versions of RAW_LOG and RAW_CHECK +#ifndef NDEBUG + +#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__) +#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message) + +#else // NDEBUG + +#define RAW_DLOG(severity, ...) \ + while (false) \ + RAW_LOG(severity, __VA_ARGS__) +#define RAW_DCHECK(condition, message) \ + while (false) \ + RAW_CHECK(condition, message) + +#endif // NDEBUG + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +// Stub log function used to work around for unused variable warnings when +// building with STRIP_LOG > 0. +static inline void RawLogStub__(int /* ignored */, ...) { +} + +// Helper function to implement RAW_LOG and RAW_VLOG +// Logs format... at "severity" level, reporting it +// as called from file:line. +// This does not allocate memory or acquire locks. +GLOG_EXPORT void RawLog__(LogSeverity severity, const char* file, int line, + const char* format, ...) + @ac_cv___attribute___printf_4_5@; + +@ac_google_end_namespace@ + +#endif // GLOG_RAW_LOGGING_H diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/stl_logging.h.in b/funasr/runtime/onnxruntime/third_party/glog/src/glog/stl_logging.h.in new file mode 100644 index 000000000..49eec0397 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/stl_logging.h.in @@ -0,0 +1,177 @@ +// Copyright (c) 2003, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Stream output operators for STL containers; to be used for logging *only*. +// Inclusion of this file lets you do: +// +// list x; +// LOG(INFO) << "data: " << x; +// vector v1, v2; +// CHECK_EQ(v1, v2); +// +// If you want to use this header file with hash maps or slist, you +// need to define macros before including this file: +// +// - GLOG_STL_LOGGING_FOR_UNORDERED - and +// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - +// - GLOG_STL_LOGGING_FOR_EXT_HASH - +// - GLOG_STL_LOGGING_FOR_EXT_SLIST - +// + +#ifndef UTIL_GTL_STL_LOGGING_INL_H_ +#define UTIL_GTL_STL_LOGGING_INL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Forward declare these two, and define them after all the container streams +// operators so that we can recurse from pair -> container -> container -> pair +// properly. +template +std::ostream& operator<<(std::ostream& out, const std::pair& p); + +@ac_google_start_namespace@ + +template +void PrintSequence(std::ostream& out, Iter begin, Iter end); + +@ac_google_end_namespace@ +#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + + OUTPUT_TWO_ARG_CONTAINER(std::vector) OUTPUT_TWO_ARG_CONTAINER(std::deque) + OUTPUT_TWO_ARG_CONTAINER(std::list) + +#undef OUTPUT_TWO_ARG_CONTAINER + +#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + + OUTPUT_THREE_ARG_CONTAINER(std::set) OUTPUT_THREE_ARG_CONTAINER( + std::multiset) + +#undef OUTPUT_THREE_ARG_CONTAINER + +#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + + OUTPUT_FOUR_ARG_CONTAINER(std::map) OUTPUT_FOUR_ARG_CONTAINER( + std::multimap) OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) + OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) + +#undef OUTPUT_FOUR_ARG_CONTAINER + +#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \ +template \ +inline std::ostream& operator<<(std::ostream& out, \ + const Sequence& seq) { \ + @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \ + return out; \ +} + +#if defined(GLOG_STL_LOGGING_FOR_UNORDERED) && __cplusplus >= 201103L + OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) + OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) +#endif + +#undef OUTPUT_FIVE_ARG_CONTAINER + + template + inline std::ostream& operator<<( + std::ostream& out, + const std::pair& p) { + out << '(' << p.first << ", " << p.second << ')'; + return out; +} + +@ac_google_start_namespace@ + +template +inline void PrintSequence(std::ostream& out, Iter begin, Iter end) { + // Output at most 100 elements -- appropriate if used for logging. + for (int i = 0; begin != end && i < 100; ++i, ++begin) { + if (i > 0) out << ' '; + out << *begin; + } + if (begin != end) { + out << " ..."; + } +} + +@ac_google_end_namespace@ + +// Note that this is technically undefined behavior! We are adding things into +// the std namespace for a reason though -- we are providing new operations on +// types which are themselves defined with this namespace. Without this, these +// operator overloads cannot be found via ADL. If these definitions are not +// found via ADL, they must be #included before they're used, which requires +// this header to be included before apparently independent other headers. +// +// For example, base/logging.h defines various template functions to implement +// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails. +// It does so via the function template MakeCheckOpValueString: +// template +// void MakeCheckOpValueString(strstream* ss, const T& v) { +// (*ss) << v; +// } +// Because 'glog/logging.h' is included before 'glog/stl_logging.h', +// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only +// find these operator definitions via ADL. +// +// Even this solution has problems -- it may pull unintended operators into the +// namespace as well, allowing them to also be found via ADL, and creating code +// that only works with a particular order of includes. Long term, we need to +// move all of the *definitions* into namespace std, bet we need to ensure no +// one references them first. This lets us take that step. We cannot define them +// in both because that would create ambiguous overloads when both are found. +namespace std { using ::operator<<; } + +#endif // UTIL_GTL_STL_LOGGING_INL_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/glog/vlog_is_on.h.in b/funasr/runtime/onnxruntime/third_party/glog/src/glog/vlog_is_on.h.in new file mode 100644 index 000000000..ed37e0d35 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/glog/vlog_is_on.h.in @@ -0,0 +1,120 @@ +// Copyright (c) 2023, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Ray Sidney and many others +// +// Defines the VLOG_IS_ON macro that controls the variable-verbosity +// conditional logging. +// +// It's used by VLOG and VLOG_IF in logging.h +// and by RAW_VLOG in raw_logging.h to trigger the logging. +// +// It can also be used directly e.g. like this: +// if (VLOG_IS_ON(2)) { +// // do some logging preparation and logging +// // that can't be accomplished e.g. via just VLOG(2) << ...; +// } +// +// The truth value that VLOG_IS_ON(level) returns is determined by +// the three verbosity level flags: +// --v= Gives the default maximal active V-logging level; +// 0 is the default. +// Normally positive values are used for V-logging levels. +// --vmodule= Gives the per-module maximal V-logging levels to override +// the value given by --v. +// E.g. "my_module=2,foo*=3" would change the logging level +// for all code in source files "my_module.*" and "foo*.*" +// ("-inl" suffixes are also disregarded for this matching). +// +// SetVLOGLevel helper function is provided to do limited dynamic control over +// V-logging by overriding the per-module settings given via --vmodule flag. +// +// CAVEAT: --vmodule functionality is not available in non gcc compilers. +// + +#ifndef BASE_VLOG_IS_ON_H_ +#define BASE_VLOG_IS_ON_H_ + +#include + +#include + +#if defined(__GNUC__) +// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site. +// (Normally) the first time every VLOG_IS_ON(n) site is hit, +// we determine what variable will dynamically control logging at this site: +// it's either FLAGS_v or an appropriate internal variable +// matching the current source file that represents results of +// parsing of --vmodule flag and/or SetVLOGLevel calls. +#define VLOG_IS_ON(verboselevel) \ + __extension__ \ + ({ static @ac_google_namespace@::SiteFlag vlocal__ = {NULL, NULL, 0, NULL}; \ + @ac_google_namespace@::int32 verbose_level__ = (verboselevel); \ + (vlocal__.level == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \ + __FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \ + }) +#else +// GNU extensions not available, so we do not support --vmodule. +// Dynamic value of FLAGS_v always controls the logging level. +#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel)) +#endif + +// Set VLOG(_IS_ON) level for module_pattern to log_level. +// This lets us dynamically control what is normally set by the --vmodule flag. +// Returns the level that previously applied to module_pattern. +// NOTE: To change the log level for VLOG(_IS_ON) sites +// that have already executed after/during InitGoogleLogging, +// one needs to supply the exact --vmodule pattern that applied to them. +// (If no --vmodule pattern applied to them +// the value of FLAGS_v will continue to control them.) +extern GLOG_EXPORT int SetVLOGLevel(const char* module_pattern, int log_level); + +// Various declarations needed for VLOG_IS_ON above: ========================= + +struct SiteFlag { + @ac_google_namespace@::int32* level; + const char* base_name; + std::size_t base_len; + SiteFlag* next; +}; + +// Helper routine which determines the logging info for a particalur VLOG site. +// site_flag is the address of the site-local pointer to the controlling +// verbosity level +// site_default is the default to use for *site_flag +// fname is the current source file name +// verbose_level is the argument to VLOG_IS_ON +// We will return the return value for VLOG_IS_ON +// and if possible set *site_flag appropriately. +extern GLOG_EXPORT bool InitVLOG3__( + @ac_google_namespace@::SiteFlag* site_flag, + @ac_google_namespace@::int32* site_default, const char* fname, + @ac_google_namespace@::int32 verbose_level); + +#endif // BASE_VLOG_IS_ON_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/googletest.h b/funasr/runtime/onnxruntime/third_party/glog/src/googletest.h new file mode 100644 index 000000000..a12c38763 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/googletest.h @@ -0,0 +1,654 @@ +// Copyright (c) 2009, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Shinichiro Hamaji +// (based on googletest: http://code.google.com/p/googletest/) + +#ifdef GOOGLETEST_H__ +#error You must not include this file twice. +#endif +#define GOOGLETEST_H__ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "base/commandlineflags.h" + +#if __cplusplus < 201103L && !defined(_MSC_VER) +#define GOOGLE_GLOG_THROW_BAD_ALLOC throw (std::bad_alloc) +#else +#define GOOGLE_GLOG_THROW_BAD_ALLOC +#endif + +using std::map; +using std::string; +using std::vector; + +_START_GOOGLE_NAMESPACE_ + +extern GLOG_EXPORT void (*g_logging_fail_func)(); + +_END_GOOGLE_NAMESPACE_ + +#undef GLOG_EXPORT +#define GLOG_EXPORT + +static inline string GetTempDir() { + vector temp_directories_list; + google::GetExistingTempDirectories(&temp_directories_list); + + if (temp_directories_list.empty()) { + fprintf(stderr, "No temporary directory found\n"); + exit(EXIT_FAILURE); + } + + // Use first directory from list of existing temporary directories. + return temp_directories_list.front(); +} + +#if defined(GLOG_OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR) +// The test will run in glog/vsproject/ +// (e.g., glog/vsproject/logging_unittest). +static const char TEST_SRC_DIR[] = "../.."; +#elif !defined(TEST_SRC_DIR) +# warning TEST_SRC_DIR should be defined in config.h +static const char TEST_SRC_DIR[] = "."; +#endif + +static const uint32_t PTR_TEST_VALUE = 0x12345678; + +DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files"); +DEFINE_string(test_srcdir, TEST_SRC_DIR, + "Source-dir root, needed to find glog_unittest_flagfile"); +DEFINE_bool(run_benchmark, false, "If true, run benchmarks"); +#ifdef NDEBUG +DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark"); +#else +DEFINE_int32(benchmark_iters, 100000, "Number of iterations per benchmark"); +#endif + +#ifdef HAVE_LIB_GTEST +# include +// Use our ASSERT_DEATH implementation. +# undef ASSERT_DEATH +# undef ASSERT_DEBUG_DEATH +using testing::InitGoogleTest; +#else + +_START_GOOGLE_NAMESPACE_ + +void InitGoogleTest(int*, char**); + +void InitGoogleTest(int*, char**) {} + +// The following is some bare-bones testing infrastructure + +#define EXPECT_NEAR(val1, val2, abs_error) \ + do { \ + if (abs(val1 - val2) > abs_error) { \ + fprintf(stderr, "Check failed: %s within %s of %s\n", #val1, #abs_error, \ + #val2); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_TRUE(cond) \ + do { \ + if (!(cond)) { \ + fprintf(stderr, "Check failed: %s\n", #cond); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_FALSE(cond) EXPECT_TRUE(!(cond)) + +#define EXPECT_OP(op, val1, val2) \ + do { \ + if (!((val1) op (val2))) { \ + fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2) +#define EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2) +#define EXPECT_GT(val1, val2) EXPECT_OP(>, val1, val2) +#define EXPECT_LT(val1, val2) EXPECT_OP(<, val1, val2) + +#define EXPECT_NAN(arg) \ + do { \ + if (!isnan(arg)) { \ + fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_INF(arg) \ + do { \ + if (!isinf(arg)) { \ + fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_DOUBLE_EQ(val1, val2) \ + do { \ + if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \ + fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +#define EXPECT_STREQ(val1, val2) \ + do { \ + if (strcmp((val1), (val2)) != 0) { \ + fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) + +vector g_testlist; // the tests to run + +#define TEST(a, b) \ + struct Test_##a##_##b { \ + Test_##a##_##b() { g_testlist.push_back(&Run); } \ + static void Run() { FlagSaver fs; RunTest(); } \ + static void RunTest(); \ + }; \ + static Test_##a##_##b g_test_##a##_##b; \ + void Test_##a##_##b::RunTest() + + +static inline int RUN_ALL_TESTS() { + vector::const_iterator it; + for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { + (*it)(); + } + fprintf(stderr, "Passed %d tests\n\nPASS\n", + static_cast(g_testlist.size())); + return 0; +} + +_END_GOOGLE_NAMESPACE_ + +#endif // ! HAVE_LIB_GTEST + +_START_GOOGLE_NAMESPACE_ + +static bool g_called_abort; +static jmp_buf g_jmp_buf; +static inline void CalledAbort() { + g_called_abort = true; + longjmp(g_jmp_buf, 1); +} + +#ifdef GLOG_OS_WINDOWS +// TODO(hamaji): Death test somehow doesn't work in Windows. +#define ASSERT_DEATH(fn, msg) +#else +#define ASSERT_DEATH(fn, msg) \ + do { \ + g_called_abort = false; \ + /* in logging.cc */ \ + void (*original_logging_fail_func)() = g_logging_fail_func; \ + g_logging_fail_func = &CalledAbort; \ + if (!setjmp(g_jmp_buf)) fn; \ + /* set back to their default */ \ + g_logging_fail_func = original_logging_fail_func; \ + if (!g_called_abort) { \ + fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \ + exit(EXIT_FAILURE); \ + } \ + } while (0) +#endif + +#ifdef NDEBUG +#define ASSERT_DEBUG_DEATH(fn, msg) +#else +#define ASSERT_DEBUG_DEATH(fn, msg) ASSERT_DEATH(fn, msg) +#endif // NDEBUG + +// Benchmark tools. + +#define BENCHMARK(n) static BenchmarkRegisterer __benchmark_ ## n (#n, &n); + +map g_benchlist; // the benchmarks to run + +class BenchmarkRegisterer { + public: + BenchmarkRegisterer(const char* name, void (*function)(int iters)) { + EXPECT_TRUE(g_benchlist.insert(std::make_pair(name, function)).second); + } +}; + +static inline void RunSpecifiedBenchmarks() { + if (!FLAGS_run_benchmark) { + return; + } + + int iter_cnt = FLAGS_benchmark_iters; + puts("Benchmark\tTime(ns)\tIterations"); + for (auto& iter : g_benchlist) { + clock_t start = clock(); + iter.second(iter_cnt); + double elapsed_ns = (static_cast(clock()) - start) / + CLOCKS_PER_SEC * 1000 * 1000 * 1000; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat=" +#endif + printf("%s\t%8.2lf\t%10d\n", iter.first.c_str(), elapsed_ns / iter_cnt, + iter_cnt); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + } + puts(""); +} + +// ---------------------------------------------------------------------- +// Golden file functions +// ---------------------------------------------------------------------- + +class CapturedStream { + public: + CapturedStream(int fd, string filename) + : fd_(fd), + + filename_(std::move(filename)) { + Capture(); + } + + ~CapturedStream() { + if (uncaptured_fd_ != -1) { + CHECK(close(uncaptured_fd_) != -1); + } + } + + // Start redirecting output to a file + void Capture() { + // Keep original stream for later + CHECK(uncaptured_fd_ == -1) << ", Stream " << fd_ << " already captured!"; + uncaptured_fd_ = dup(fd_); + CHECK(uncaptured_fd_ != -1); + + // Open file to save stream to + int cap_fd = open(filename_.c_str(), + O_CREAT | O_TRUNC | O_WRONLY, + S_IRUSR | S_IWUSR); + CHECK(cap_fd != -1); + + // Send stdout/stderr to this file + fflush(nullptr); + CHECK(dup2(cap_fd, fd_) != -1); + CHECK(close(cap_fd) != -1); + } + + // Remove output redirection + void StopCapture() { + // Restore original stream + if (uncaptured_fd_ != -1) { + fflush(nullptr); + CHECK(dup2(uncaptured_fd_, fd_) != -1); + } + } + + const string & filename() const { return filename_; } + + private: + int fd_; // file descriptor being captured + int uncaptured_fd_{-1}; // where the stream was originally being sent to + string filename_; // file where stream is being saved +}; +static CapturedStream * s_captured_streams[STDERR_FILENO+1]; +// Redirect a file descriptor to a file. +// fd - Should be STDOUT_FILENO or STDERR_FILENO +// filename - File where output should be stored +static inline void CaptureTestOutput(int fd, const string & filename) { + CHECK((fd == STDOUT_FILENO) || (fd == STDERR_FILENO)); + CHECK(s_captured_streams[fd] == nullptr); + s_captured_streams[fd] = new CapturedStream(fd, filename); +} +static inline void CaptureTestStdout() { + CaptureTestOutput(STDOUT_FILENO, FLAGS_test_tmpdir + "/captured.out"); +} +static inline void CaptureTestStderr() { + CaptureTestOutput(STDERR_FILENO, FLAGS_test_tmpdir + "/captured.err"); +} +// Return the size (in bytes) of a file +static inline size_t GetFileSize(FILE * file) { + fseek(file, 0, SEEK_END); + return static_cast(ftell(file)); +} +// Read the entire content of a file as a string +static inline string ReadEntireFile(FILE * file) { + const size_t file_size = GetFileSize(file); + char * const buffer = new char[file_size]; + + size_t bytes_last_read = 0; // # of bytes read in the last fread() + size_t bytes_read = 0; // # of bytes read so far + + fseek(file, 0, SEEK_SET); + + // Keep reading the file until we cannot read further or the + // pre-determined file size is reached. + do { + bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); + bytes_read += bytes_last_read; + } while (bytes_last_read > 0 && bytes_read < file_size); + + const string content = string(buffer, buffer+bytes_read); + delete[] buffer; + + return content; +} +// Get the captured stdout (when fd is STDOUT_FILENO) or stderr (when +// fd is STDERR_FILENO) as a string +static inline string GetCapturedTestOutput(int fd) { + CHECK(fd == STDOUT_FILENO || fd == STDERR_FILENO); + CapturedStream * const cap = s_captured_streams[fd]; + CHECK(cap) + << ": did you forget CaptureTestStdout() or CaptureTestStderr()?"; + + // Make sure everything is flushed. + cap->StopCapture(); + + // Read the captured file. + FILE * const file = fopen(cap->filename().c_str(), "r"); + const string content = ReadEntireFile(file); + fclose(file); + + delete cap; + s_captured_streams[fd] = nullptr; + + return content; +} +// Get the captured stderr of a test as a string. +static inline string GetCapturedTestStderr() { + return GetCapturedTestOutput(STDERR_FILENO); +} + +static const std::size_t kLoggingPrefixLength = 9; + +// Check if the string is [IWEF](\d{8}|YEARDATE) +static inline bool IsLoggingPrefix(const string& s) { + if (s.size() != kLoggingPrefixLength) { + return false; + } + if (!strchr("IWEF", s[0])) return false; + for (size_t i = 1; i <= 8; ++i) { + if (!isdigit(s[i]) && s[i] != "YEARDATE"[i-1]) return false; + } + return true; +} + +// Convert log output into normalized form. +// +// Example: +// I20200102 030405 logging_unittest.cc:345] RAW: vlog -1 +// => IYEARDATE TIME__ logging_unittest.cc:LINE] RAW: vlog -1 +static inline string MungeLine(const string& line) { + string before, logcode_date, time, thread_lineinfo; + std::size_t begin_of_logging_prefix = 0; + for (; begin_of_logging_prefix + kLoggingPrefixLength < line.size(); + ++begin_of_logging_prefix) { + if (IsLoggingPrefix( + line.substr(begin_of_logging_prefix, kLoggingPrefixLength))) { + break; + } + } + if (begin_of_logging_prefix + kLoggingPrefixLength >= line.size()) { + return line; + } else if (begin_of_logging_prefix > 0) { + before = line.substr(0, begin_of_logging_prefix - 1); + } + std::istringstream iss(line.substr(begin_of_logging_prefix)); + iss >> logcode_date; + iss >> time; + iss >> thread_lineinfo; + CHECK(!thread_lineinfo.empty()); + if (thread_lineinfo[thread_lineinfo.size() - 1] != ']') { + // We found thread ID. + string tmp; + iss >> tmp; + CHECK(!tmp.empty()); + CHECK_EQ(']', tmp[tmp.size() - 1]); + thread_lineinfo = "THREADID " + tmp; + } + size_t index = thread_lineinfo.find(':'); + CHECK_NE(string::npos, index); + thread_lineinfo = thread_lineinfo.substr(0, index+1) + "LINE]"; + string rest; + std::getline(iss, rest); + return (before + logcode_date[0] + "YEARDATE TIME__ " + thread_lineinfo + + MungeLine(rest)); +} + +static inline void StringReplace(string* str, + const string& oldsub, + const string& newsub) { + size_t pos = str->find(oldsub); + if (pos != string::npos) { + str->replace(pos, oldsub.size(), newsub); + } +} + +static inline string Munge(const string& filename) { + FILE* fp = fopen(filename.c_str(), "rb"); + CHECK(fp != nullptr) << filename << ": couldn't open"; + char buf[4096]; + string result; + while (fgets(buf, 4095, fp)) { + string line = MungeLine(buf); + const size_t str_size = 256; + char null_str[str_size]; + char ptr_str[str_size]; + snprintf(null_str, str_size, "%p", static_cast(nullptr)); + snprintf(ptr_str, str_size, "%p", reinterpret_cast(PTR_TEST_VALUE)); + + StringReplace(&line, "__NULLP__", null_str); + StringReplace(&line, "__PTRTEST__", ptr_str); + + StringReplace(&line, "__SUCCESS__", StrError(0)); + StringReplace(&line, "__ENOENT__", StrError(ENOENT)); + StringReplace(&line, "__EINTR__", StrError(EINTR)); + StringReplace(&line, "__ENXIO__", StrError(ENXIO)); + StringReplace(&line, "__ENOEXEC__", StrError(ENOEXEC)); + result += line + "\n"; + } + fclose(fp); + return result; +} + +static inline void WriteToFile(const string& body, const string& file) { + FILE* fp = fopen(file.c_str(), "wb"); + fwrite(body.data(), 1, body.size(), fp); + fclose(fp); +} + +static inline bool MungeAndDiffTest(const string& golden_filename, + CapturedStream* cap) { + if (cap == s_captured_streams[STDOUT_FILENO]) { + CHECK(cap) << ": did you forget CaptureTestStdout()?"; + } else { + CHECK(cap) << ": did you forget CaptureTestStderr()?"; + } + + cap->StopCapture(); + + // Run munge + const string captured = Munge(cap->filename()); + const string golden = Munge(golden_filename); + if (captured != golden) { + fprintf(stderr, + "Test with golden file failed. We'll try to show the diff:\n"); + string munged_golden = golden_filename + ".munged"; + WriteToFile(golden, munged_golden); + string munged_captured = cap->filename() + ".munged"; + WriteToFile(captured, munged_captured); +#ifdef GLOG_OS_WINDOWS + string diffcmd("fc " + munged_golden + " " + munged_captured); +#else + string diffcmd("diff -u " + munged_golden + " " + munged_captured); +#endif + if (system(diffcmd.c_str()) != 0) { + fprintf(stderr, "diff command was failed.\n"); + } + unlink(munged_golden.c_str()); + unlink(munged_captured.c_str()); + return false; + } + LOG(INFO) << "Diff was successful"; + return true; +} + +static inline bool MungeAndDiffTestStderr(const string& golden_filename) { + return MungeAndDiffTest(golden_filename, s_captured_streams[STDERR_FILENO]); +} + +static inline bool MungeAndDiffTestStdout(const string& golden_filename) { + return MungeAndDiffTest(golden_filename, s_captured_streams[STDOUT_FILENO]); +} + +// Save flags used from logging_unittest.cc. +#ifndef HAVE_LIB_GFLAGS +struct FlagSaver { + FlagSaver() + : v_(FLAGS_v), + stderrthreshold_(FLAGS_stderrthreshold), + logtostderr_(FLAGS_logtostderr), + alsologtostderr_(FLAGS_alsologtostderr) {} + ~FlagSaver() { + FLAGS_v = v_; + FLAGS_stderrthreshold = stderrthreshold_; + FLAGS_logtostderr = logtostderr_; + FLAGS_alsologtostderr = alsologtostderr_; + } + int v_; + int stderrthreshold_; + bool logtostderr_; + bool alsologtostderr_; +}; +#endif + +class Thread { + public: + virtual ~Thread() = default; + + void SetJoinable(bool) {} +#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN) + void Start() { + handle_ = CreateThread(nullptr, 0, &Thread::InvokeThreadW, this, 0, &th_); + CHECK(handle_) << "CreateThread"; + } + void Join() { + WaitForSingleObject(handle_, INFINITE); + } +#elif defined(HAVE_PTHREAD) + void Start() { pthread_create(&th_, nullptr, &Thread::InvokeThread, this); } + void Join() { pthread_join(th_, nullptr); } +#else +# error No thread implementation. +#endif + + protected: + virtual void Run() = 0; + + private: + static void* InvokeThread(void* self) { + (static_cast(self))->Run(); + return nullptr; + } + +#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN) + static DWORD __stdcall InvokeThreadW(LPVOID self) { + InvokeThread(self); + return 0; + } + HANDLE handle_; + DWORD th_; +#else + pthread_t th_; +#endif +}; + +static inline void SleepForMilliseconds(unsigned t) { +#ifndef GLOG_OS_WINDOWS +# if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L + const struct timespec req = {0, t * 1000 * 1000}; + nanosleep(&req, nullptr); +# else + usleep(t * 1000); +# endif +#else + Sleep(t); +#endif +} + +// Add hook for operator new to ensure there are no memory allocation. + +void (*g_new_hook)() = nullptr; + +_END_GOOGLE_NAMESPACE_ + +void* operator new(size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC { + if (GOOGLE_NAMESPACE::g_new_hook) { + GOOGLE_NAMESPACE::g_new_hook(); + } + return malloc(size); +} + +void* operator new[](size_t size) GOOGLE_GLOG_THROW_BAD_ALLOC { + return ::operator new(size); +} + +void operator delete(void* p) noexcept { free(p); } + +void operator delete(void* p, size_t) noexcept { ::operator delete(p); } + +void operator delete[](void* p) noexcept { ::operator delete(p); } + +void operator delete[](void* p, size_t) noexcept { ::operator delete(p); } diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging.cc b/funasr/runtime/onnxruntime/third_party/glog/src/logging.cc new file mode 100644 index 000000000..53b485c0b --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging.cc @@ -0,0 +1,2678 @@ +// Copyright (c) 1999, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite() + +#include "utilities.h" + +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include // For _exit. +#endif +#include +#include +#include +#ifdef HAVE_SYS_UTSNAME_H +# include // For uname. +#endif +#include +#include +#include +#include +#include +#include +#ifdef HAVE_PWD_H +# include +#endif +#ifdef HAVE_SYSLOG_H +# include +#endif +#include +#include // for errno +#include +#ifdef GLOG_OS_WINDOWS +#include "windows/dirent.h" +#else +#include // for automatic removal of old logs +#endif +#include "base/commandlineflags.h" // to get the program name +#include +#include +#include "base/googleinit.h" + +#ifdef HAVE_STACKTRACE +# include "stacktrace.h" +#endif + +#ifdef __ANDROID__ +#include +#endif + +using std::string; +using std::vector; +using std::setw; +using std::setfill; +using std::hex; +using std::dec; +using std::min; +using std::ostream; +using std::ostringstream; + +using std::FILE; +using std::fwrite; +using std::fclose; +using std::fflush; +using std::fprintf; +using std::perror; + +#ifdef __QNX__ +using std::fdopen; +#endif + +#ifdef _WIN32 +#define fdopen _fdopen +#endif + +// There is no thread annotation support. +#define EXCLUSIVE_LOCKS_REQUIRED(mu) + +static bool BoolFromEnv(const char *varname, bool defval) { + const char* const valstr = getenv(varname); + if (!valstr) { + return defval; + } + return memchr("tTyY1\0", valstr[0], 6) != nullptr; +} + +GLOG_DEFINE_bool(timestamp_in_logfile_name, + BoolFromEnv("GOOGLE_TIMESTAMP_IN_LOGFILE_NAME", true), + "put a timestamp at the end of the log file name"); +GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false), + "log messages go to stderr instead of logfiles"); +GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false), + "log messages go to stderr in addition to logfiles"); +GLOG_DEFINE_bool(colorlogtostderr, false, + "color messages logged to stderr (if supported by terminal)"); +GLOG_DEFINE_bool(colorlogtostdout, false, + "color messages logged to stdout (if supported by terminal)"); +GLOG_DEFINE_bool(logtostdout, BoolFromEnv("GOOGLE_LOGTOSTDOUT", false), + "log messages go to stdout instead of logfiles"); +#ifdef GLOG_OS_LINUX +GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. " + "Logs can grow very quickly and they are rarely read before they " + "need to be evicted from memory. Instead, drop them from memory " + "as soon as they are flushed to disk."); +#endif + +// By default, errors (including fatal errors) get logged to stderr as +// well as the file. +// +// The default is ERROR instead of FATAL so that users can see problems +// when they run a program without having to look in another file. +DEFINE_int32(stderrthreshold, + GOOGLE_NAMESPACE::GLOG_ERROR, + "log messages at or above this level are copied to stderr in " + "addition to logfiles. This flag obsoletes --alsologtostderr."); + +GLOG_DEFINE_string(alsologtoemail, "", + "log messages go to these email addresses " + "in addition to logfiles"); +GLOG_DEFINE_bool(log_file_header, true, + "Write the file header at the start of each log file"); +GLOG_DEFINE_bool(log_prefix, true, + "Prepend the log prefix to the start of each log line"); +GLOG_DEFINE_bool(log_year_in_prefix, true, + "Include the year in the log prefix"); +GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't " + "actually get logged anywhere"); +GLOG_DEFINE_int32(logbuflevel, 0, + "Buffer log messages logged at this level or lower" + " (-1 means don't buffer; 0 means buffer INFO only;" + " ...)"); +GLOG_DEFINE_int32(logbufsecs, 30, + "Buffer log messages for at most this many seconds"); + +GLOG_DEFINE_int32(logcleansecs, 60 * 5, // every 5 minutes + "Clean overdue logs every this many seconds"); + +GLOG_DEFINE_int32(logemaillevel, 999, + "Email log messages logged at this level or higher" + " (0 means email all; 3 means email FATAL only;" + " ...)"); +GLOG_DEFINE_string(logmailer, "", + "Mailer used to send logging email"); + +// Compute the default value for --log_dir +static const char* DefaultLogDir() { + const char* env; + env = getenv("GOOGLE_LOG_DIR"); + if (env != nullptr && env[0] != '\0') { + return env; + } + env = getenv("TEST_TMPDIR"); + if (env != nullptr && env[0] != '\0') { + return env; + } + return ""; +} + +GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions."); + +GLOG_DEFINE_string(log_dir, DefaultLogDir(), + "If specified, logfiles are written into this directory instead " + "of the default logging directory."); +GLOG_DEFINE_string(log_link, "", "Put additional links to the log " + "files in this directory"); + +GLOG_DEFINE_uint32(max_log_size, 1800, + "approx. maximum log file size (in MB). A value of 0 will " + "be silently overridden to 1."); + +GLOG_DEFINE_bool(stop_logging_if_full_disk, false, + "Stop attempting to log to disk if the disk is full."); + +GLOG_DEFINE_string(log_backtrace_at, "", + "Emit a backtrace when logging at file:linenum."); + +GLOG_DEFINE_bool(log_utc_time, false, + "Use UTC time for logging."); + +// TODO(hamaji): consider windows +enum { PATH_SEPARATOR = '/' }; + +#ifndef HAVE_PREAD +#if defined(GLOG_OS_WINDOWS) +#include +#define ssize_t SSIZE_T +#endif +static ssize_t pread(int fd, void* buf, size_t count, off_t offset) { + off_t orig_offset = lseek(fd, 0, SEEK_CUR); + if (orig_offset == (off_t)-1) + return -1; + if (lseek(fd, offset, SEEK_CUR) == (off_t)-1) + return -1; + ssize_t len = read(fd, buf, count); + if (len < 0) + return len; + if (lseek(fd, orig_offset, SEEK_SET) == (off_t)-1) + return -1; + return len; +} +#endif // !HAVE_PREAD + +#ifndef HAVE_PWRITE +static ssize_t pwrite(int fd, void* buf, size_t count, off_t offset) { + off_t orig_offset = lseek(fd, 0, SEEK_CUR); + if (orig_offset == (off_t)-1) + return -1; + if (lseek(fd, offset, SEEK_CUR) == (off_t)-1) + return -1; + ssize_t len = write(fd, buf, count); + if (len < 0) + return len; + if (lseek(fd, orig_offset, SEEK_SET) == (off_t)-1) + return -1; + return len; +} +#endif // !HAVE_PWRITE + +static void GetHostName(string* hostname) { +#if defined(HAVE_SYS_UTSNAME_H) + struct utsname buf; + if (uname(&buf) < 0) { + // ensure null termination on failure + *buf.nodename = '\0'; + } + *hostname = buf.nodename; +#elif defined(GLOG_OS_WINDOWS) + char buf[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD len = MAX_COMPUTERNAME_LENGTH + 1; + if (GetComputerNameA(buf, &len)) { + *hostname = buf; + } else { + hostname->clear(); + } +#else +# warning There is no way to retrieve the host name. + *hostname = "(unknown)"; +#endif +} + +// Returns true iff terminal supports using colors in output. +static bool TerminalSupportsColor() { + bool term_supports_color = false; +#ifdef GLOG_OS_WINDOWS + // on Windows TERM variable is usually not set, but the console does + // support colors. + term_supports_color = true; +#else + // On non-Windows platforms, we rely on the TERM variable. + const char* const term = getenv("TERM"); + if (term != nullptr && term[0] != '\0') { + term_supports_color = + !strcmp(term, "xterm") || + !strcmp(term, "xterm-color") || + !strcmp(term, "xterm-256color") || + !strcmp(term, "screen-256color") || + !strcmp(term, "konsole") || + !strcmp(term, "konsole-16color") || + !strcmp(term, "konsole-256color") || + !strcmp(term, "screen") || + !strcmp(term, "linux") || + !strcmp(term, "cygwin"); + } +#endif + return term_supports_color; +} + +_START_GOOGLE_NAMESPACE_ + +enum GLogColor { + COLOR_DEFAULT, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW +}; + +static GLogColor SeverityToColor(LogSeverity severity) { + assert(severity >= 0 && severity < NUM_SEVERITIES); + GLogColor color = COLOR_DEFAULT; + switch (severity) { + case GLOG_INFO: + color = COLOR_DEFAULT; + break; + case GLOG_WARNING: + color = COLOR_YELLOW; + break; + case GLOG_ERROR: + case GLOG_FATAL: + color = COLOR_RED; + break; + default: + // should never get here. + assert(false); + } + return color; +} + +#ifdef GLOG_OS_WINDOWS + +// Returns the character attribute for the given color. +static WORD GetColorAttribute(GLogColor color) { + switch (color) { + case COLOR_RED: return FOREGROUND_RED; + case COLOR_GREEN: return FOREGROUND_GREEN; + case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN; + default: return 0; + } +} + +#else + +// Returns the ANSI color code for the given color. +static const char* GetAnsiColorCode(GLogColor color) { + switch (color) { + case COLOR_RED: return "1"; + case COLOR_GREEN: return "2"; + case COLOR_YELLOW: return "3"; + case COLOR_DEFAULT: return ""; + }; + return nullptr; // stop warning about return type. +} + +#endif // GLOG_OS_WINDOWS + +// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0 +static uint32 MaxLogSize() { + return (FLAGS_max_log_size > 0 && FLAGS_max_log_size < 4096 + ? FLAGS_max_log_size + : 1); +} + +// An arbitrary limit on the length of a single log message. This +// is so that streaming can be done more efficiently. +const size_t LogMessage::kMaxLogMessageLen = 30000; + +struct LogMessage::LogMessageData { + LogMessageData(); + + int preserved_errno_; // preserved errno + // Buffer space; contains complete message text. + char message_text_[LogMessage::kMaxLogMessageLen+1]; + LogStream stream_; + char severity_; // What level is this LogMessage logged at? + int line_; // line number where logging call is. + void (LogMessage::*send_method_)(); // Call this in destructor to send + union { // At most one of these is used: union to keep the size low. + LogSink* sink_; // nullptr or sink to send message to + std::vector* + outvec_; // nullptr or vector to push message onto + std::string* message_; // nullptr or string to write message into + }; + size_t num_prefix_chars_; // # of chars of prefix in this message + size_t num_chars_to_log_; // # of chars of msg to send to log + size_t num_chars_to_syslog_; // # of chars of msg to send to syslog + const char* basename_; // basename of file that called LOG + const char* fullname_; // fullname of file that called LOG + bool has_been_flushed_; // false => data has not been flushed + bool first_fatal_; // true => this was first fatal msg + + private: + LogMessageData(const LogMessageData&) = delete; + void operator=(const LogMessageData&) = delete; +}; + +// A mutex that allows only one thread to log at a time, to keep things from +// getting jumbled. Some other very uncommon logging operations (like +// changing the destination file for log messages of a given severity) also +// lock this mutex. Please be sure that anybody who might possibly need to +// lock it does so. +static Mutex log_mutex; + +// Number of messages sent at each severity. Under log_mutex. +int64 LogMessage::num_messages_[NUM_SEVERITIES] = {0, 0, 0, 0}; + +// Globally disable log writing (if disk is full) +static bool stop_writing = false; + +const char*const LogSeverityNames[NUM_SEVERITIES] = { + "INFO", "WARNING", "ERROR", "FATAL" +}; + +// Has the user called SetExitOnDFatal(true)? +static bool exit_on_dfatal = true; + +const char* GetLogSeverityName(LogSeverity severity) { + return LogSeverityNames[severity]; +} + +static bool SendEmailInternal(const char*dest, const char *subject, + const char*body, bool use_logging); + +base::Logger::~Logger() = default; + +namespace { + // Optional user-configured callback to print custom prefixes. +CustomPrefixCallback custom_prefix_callback = nullptr; +// User-provided data to pass to the callback: +void* custom_prefix_callback_data = nullptr; +} + +namespace { + +// Encapsulates all file-system related state +class LogFileObject : public base::Logger { + public: + LogFileObject(LogSeverity severity, const char* base_filename); + ~LogFileObject() override; + + void Write(bool force_flush, // Should we force a flush here? + time_t timestamp, // Timestamp for this entry + const char* message, size_t message_len) override; + + // Configuration options + void SetBasename(const char* basename); + void SetExtension(const char* ext); + void SetSymlinkBasename(const char* symlink_basename); + + // Normal flushing routine + void Flush() override; + + // It is the actual file length for the system loggers, + // i.e., INFO, ERROR, etc. + uint32 LogSize() override { + MutexLock l(&lock_); + return file_length_; + } + + // Internal flush routine. Exposed so that FlushLogFilesUnsafe() + // can avoid grabbing a lock. Usually Flush() calls it after + // acquiring lock_. + void FlushUnlocked(); + + private: + static const uint32 kRolloverAttemptFrequency = 0x20; + + Mutex lock_; + bool base_filename_selected_; + string base_filename_; + string symlink_basename_; + string filename_extension_; // option users can specify (eg to add port#) + FILE* file_{nullptr}; + LogSeverity severity_; + uint32 bytes_since_flush_{0}; + uint32 dropped_mem_length_{0}; + uint32 file_length_{0}; + unsigned int rollover_attempt_; + int64 next_flush_time_{0}; // cycle count at which to flush log + WallTime start_time_; + + // Actually create a logfile using the value of base_filename_ and the + // optional argument time_pid_string + // REQUIRES: lock_ is held + bool CreateLogfile(const string& time_pid_string); +}; + +// Encapsulate all log cleaner related states +class LogCleaner { + public: + LogCleaner(); + + // Setting overdue_days to 0 days will delete all logs. + void Enable(unsigned int overdue_days); + void Disable(); + + // update next_cleanup_time_ + void UpdateCleanUpTime(); + + void Run(bool base_filename_selected, + const string& base_filename, + const string& filename_extension); + + bool enabled() const { return enabled_; } + + private: + vector GetOverdueLogNames(string log_directory, unsigned int days, + const string& base_filename, + const string& filename_extension) const; + + bool IsLogFromCurrentProject(const string& filepath, + const string& base_filename, + const string& filename_extension) const; + + bool IsLogLastModifiedOver(const string& filepath, unsigned int days) const; + + bool enabled_{false}; + unsigned int overdue_days_{7}; + int64 next_cleanup_time_{0}; // cycle count at which to clean overdue log +}; + +LogCleaner log_cleaner; + +} // namespace + +class LogDestination { + public: + friend class LogMessage; + friend void ReprintFatalMessage(); + friend base::Logger* base::GetLogger(LogSeverity); + friend void base::SetLogger(LogSeverity, base::Logger*); + + // These methods are just forwarded to by their global versions. + static void SetLogDestination(LogSeverity severity, + const char* base_filename); + static void SetLogSymlink(LogSeverity severity, + const char* symlink_basename); + static void AddLogSink(LogSink *destination); + static void RemoveLogSink(LogSink *destination); + static void SetLogFilenameExtension(const char* filename_extension); + static void SetStderrLogging(LogSeverity min_severity); + static void SetEmailLogging(LogSeverity min_severity, const char* addresses); + static void LogToStderr(); + // Flush all log files that are at least at the given severity level + static void FlushLogFiles(int min_severity); + static void FlushLogFilesUnsafe(int min_severity); + + // we set the maximum size of our packet to be 1400, the logic being + // to prevent fragmentation. + // Really this number is arbitrary. + static const int kNetworkBytes = 1400; + + static const string& hostname(); + static const bool& terminal_supports_color() { + return terminal_supports_color_; + } + + static void DeleteLogDestinations(); + + private: + LogDestination(LogSeverity severity, const char* base_filename); + ~LogDestination(); + + // Take a log message of a particular severity and log it to stderr + // iff it's of a high enough severity to deserve it. + static void MaybeLogToStderr(LogSeverity severity, const char* message, + size_t message_len, size_t prefix_len); + + // Take a log message of a particular severity and log it to email + // iff it's of a high enough severity to deserve it. + static void MaybeLogToEmail(LogSeverity severity, const char* message, + size_t len); + // Take a log message of a particular severity and log it to a file + // iff the base filename is not "" (which means "don't log to me") + static void MaybeLogToLogfile(LogSeverity severity, + time_t timestamp, + const char* message, size_t len); + // Take a log message of a particular severity and log it to the file + // for that severity and also for all files with severity less than + // this severity. + static void LogToAllLogfiles(LogSeverity severity, + time_t timestamp, + const char* message, size_t len); + + // Send logging info to all registered sinks. + static void LogToSinks(LogSeverity severity, const char* full_filename, + const char* base_filename, int line, + const LogMessageTime& logmsgtime, const char* message, + size_t message_len); + + // Wait for all registered sinks via WaitTillSent + // including the optional one in "data". + static void WaitForSinks(LogMessage::LogMessageData* data); + + static LogDestination* log_destination(LogSeverity severity); + + base::Logger* GetLoggerImpl() const { return logger_; } + void SetLoggerImpl(base::Logger* logger); + void ResetLoggerImpl() { SetLoggerImpl(&fileobject_); } + + LogFileObject fileobject_; + base::Logger* logger_; // Either &fileobject_, or wrapper around it + + static LogDestination* log_destinations_[NUM_SEVERITIES]; + static LogSeverity email_logging_severity_; + static string addresses_; + static string hostname_; + static bool terminal_supports_color_; + + // arbitrary global logging destinations. + static vector* sinks_; + + // Protects the vector sinks_, + // but not the LogSink objects its elements reference. + static Mutex sink_mutex_; + + // Disallow + LogDestination(const LogDestination&) = delete; + LogDestination& operator=(const LogDestination&) = delete; +}; + +// Errors do not get logged to email by default. +LogSeverity LogDestination::email_logging_severity_ = 99999; + +string LogDestination::addresses_; +string LogDestination::hostname_; + +vector* LogDestination::sinks_ = nullptr; +Mutex LogDestination::sink_mutex_; +bool LogDestination::terminal_supports_color_ = TerminalSupportsColor(); + +/* static */ +const string& LogDestination::hostname() { + if (hostname_.empty()) { + GetHostName(&hostname_); + if (hostname_.empty()) { + hostname_ = "(unknown)"; + } + } + return hostname_; +} + +LogDestination::LogDestination(LogSeverity severity, + const char* base_filename) + : fileobject_(severity, base_filename), + logger_(&fileobject_) { +} + +LogDestination::~LogDestination() { + ResetLoggerImpl(); +} + +void LogDestination::SetLoggerImpl(base::Logger* logger) { + if (logger_ == logger) { + // Prevent releasing currently held sink on reset + return; + } + + if (logger_ && logger_ != &fileobject_) { + // Delete user-specified logger set via SetLogger(). + delete logger_; + } + logger_ = logger; +} + +inline void LogDestination::FlushLogFilesUnsafe(int min_severity) { + // assume we have the log_mutex or we simply don't care + // about it + for (int i = min_severity; i < NUM_SEVERITIES; i++) { + LogDestination* log = log_destinations_[i]; + if (log != nullptr) { + // Flush the base fileobject_ logger directly instead of going + // through any wrappers to reduce chance of deadlock. + log->fileobject_.FlushUnlocked(); + } + } +} + +inline void LogDestination::FlushLogFiles(int min_severity) { + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&log_mutex); + for (int i = min_severity; i < NUM_SEVERITIES; i++) { + LogDestination* log = log_destination(i); + if (log != nullptr) { + log->logger_->Flush(); + } + } +} + +inline void LogDestination::SetLogDestination(LogSeverity severity, + const char* base_filename) { + assert(severity >= 0 && severity < NUM_SEVERITIES); + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&log_mutex); + log_destination(severity)->fileobject_.SetBasename(base_filename); +} + +inline void LogDestination::SetLogSymlink(LogSeverity severity, + const char* symlink_basename) { + CHECK_GE(severity, 0); + CHECK_LT(severity, NUM_SEVERITIES); + MutexLock l(&log_mutex); + log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename); +} + +inline void LogDestination::AddLogSink(LogSink *destination) { + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&sink_mutex_); + if (!sinks_) sinks_ = new vector; + sinks_->push_back(destination); +} + +inline void LogDestination::RemoveLogSink(LogSink *destination) { + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&sink_mutex_); + // This doesn't keep the sinks in order, but who cares? + if (sinks_) { + sinks_->erase(std::remove(sinks_->begin(), sinks_->end(), destination), sinks_->end()); + } +} + +inline void LogDestination::SetLogFilenameExtension(const char* ext) { + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&log_mutex); + for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) { + log_destination(severity)->fileobject_.SetExtension(ext); + } +} + +inline void LogDestination::SetStderrLogging(LogSeverity min_severity) { + assert(min_severity >= 0 && min_severity < NUM_SEVERITIES); + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&log_mutex); + FLAGS_stderrthreshold = min_severity; +} + +inline void LogDestination::LogToStderr() { + // *Don't* put this stuff in a mutex lock, since SetStderrLogging & + // SetLogDestination already do the locking! + SetStderrLogging(0); // thus everything is "also" logged to stderr + for ( int i = 0; i < NUM_SEVERITIES; ++i ) { + SetLogDestination(i, ""); // "" turns off logging to a logfile + } +} + +inline void LogDestination::SetEmailLogging(LogSeverity min_severity, + const char* addresses) { + assert(min_severity >= 0 && min_severity < NUM_SEVERITIES); + // Prevent any subtle race conditions by wrapping a mutex lock around + // all this stuff. + MutexLock l(&log_mutex); + LogDestination::email_logging_severity_ = min_severity; + LogDestination::addresses_ = addresses; +} + +static void ColoredWriteToStderrOrStdout(FILE* output, LogSeverity severity, + const char* message, size_t len) { + bool is_stdout = (output == stdout); + const GLogColor color = (LogDestination::terminal_supports_color() && + ((!is_stdout && FLAGS_colorlogtostderr) || + (is_stdout && FLAGS_colorlogtostdout))) + ? SeverityToColor(severity) + : COLOR_DEFAULT; + + // Avoid using cerr from this module since we may get called during + // exit code, and cerr may be partially or fully destroyed by then. + if (COLOR_DEFAULT == color) { + fwrite(message, len, 1, output); + return; + } +#ifdef GLOG_OS_WINDOWS + const HANDLE output_handle = + GetStdHandle(is_stdout ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE); + + // Gets the current text color. + CONSOLE_SCREEN_BUFFER_INFO buffer_info; + GetConsoleScreenBufferInfo(output_handle, &buffer_info); + const WORD old_color_attrs = buffer_info.wAttributes; + + // We need to flush the stream buffers into the console before each + // SetConsoleTextAttribute call lest it affect the text that is already + // printed but has not yet reached the console. + fflush(output); + SetConsoleTextAttribute(output_handle, + GetColorAttribute(color) | FOREGROUND_INTENSITY); + fwrite(message, len, 1, output); + fflush(output); + // Restores the text color. + SetConsoleTextAttribute(output_handle, old_color_attrs); +#else + fprintf(output, "\033[0;3%sm", GetAnsiColorCode(color)); + fwrite(message, len, 1, output); + fprintf(output, "\033[m"); // Resets the terminal to default. +#endif // GLOG_OS_WINDOWS +} + +static void ColoredWriteToStdout(LogSeverity severity, const char* message, + size_t len) { + FILE* output = stdout; + // We also need to send logs to the stderr when the severity is + // higher or equal to the stderr threshold. + if (severity >= FLAGS_stderrthreshold) { + output = stderr; + } + ColoredWriteToStderrOrStdout(output, severity, message, len); +} + +static void ColoredWriteToStderr(LogSeverity severity, const char* message, + size_t len) { + ColoredWriteToStderrOrStdout(stderr, severity, message, len); +} + +static void WriteToStderr(const char* message, size_t len) { + // Avoid using cerr from this module since we may get called during + // exit code, and cerr may be partially or fully destroyed by then. + fwrite(message, len, 1, stderr); +} + +inline void LogDestination::MaybeLogToStderr(LogSeverity severity, + const char* message, size_t message_len, size_t prefix_len) { + if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) { + ColoredWriteToStderr(severity, message, message_len); +#ifdef GLOG_OS_WINDOWS + (void) prefix_len; + // On Windows, also output to the debugger + ::OutputDebugStringA(message); +#elif defined(__ANDROID__) + // On Android, also output to logcat + const int android_log_levels[NUM_SEVERITIES] = { + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL, + }; + __android_log_write(android_log_levels[severity], + glog_internal_namespace_::ProgramInvocationShortName(), + message + prefix_len); +#else + (void) prefix_len; +#endif + } +} + + +inline void LogDestination::MaybeLogToEmail(LogSeverity severity, + const char* message, size_t len) { + if (severity >= email_logging_severity_ || + severity >= FLAGS_logemaillevel) { + string to(FLAGS_alsologtoemail); + if (!addresses_.empty()) { + if (!to.empty()) { + to += ","; + } + to += addresses_; + } + const string subject(string("[LOG] ") + LogSeverityNames[severity] + ": " + + glog_internal_namespace_::ProgramInvocationShortName()); + string body(hostname()); + body += "\n\n"; + body.append(message, len); + + // should NOT use SendEmail(). The caller of this function holds the + // log_mutex and SendEmail() calls LOG/VLOG which will block trying to + // acquire the log_mutex object. Use SendEmailInternal() and set + // use_logging to false. + SendEmailInternal(to.c_str(), subject.c_str(), body.c_str(), false); + } +} + + +inline void LogDestination::MaybeLogToLogfile(LogSeverity severity, + time_t timestamp, + const char* message, + size_t len) { + const bool should_flush = severity > FLAGS_logbuflevel; + LogDestination* destination = log_destination(severity); + destination->logger_->Write(should_flush, timestamp, message, len); +} + +inline void LogDestination::LogToAllLogfiles(LogSeverity severity, + time_t timestamp, + const char* message, + size_t len) { + if (FLAGS_logtostdout) { // global flag: never log to file + ColoredWriteToStdout(severity, message, len); + } else if (FLAGS_logtostderr) { // global flag: never log to file + ColoredWriteToStderr(severity, message, len); + } else { + for (int i = severity; i >= 0; --i) { + LogDestination::MaybeLogToLogfile(i, timestamp, message, len); + } + } +} + +inline void LogDestination::LogToSinks(LogSeverity severity, + const char* full_filename, + const char* base_filename, int line, + const LogMessageTime& logmsgtime, + const char* message, + size_t message_len) { + ReaderMutexLock l(&sink_mutex_); + if (sinks_) { + for (size_t i = sinks_->size(); i-- > 0; ) { + (*sinks_)[i]->send(severity, full_filename, base_filename, + line, logmsgtime, message, message_len); + } + } +} + +inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) { + ReaderMutexLock l(&sink_mutex_); + if (sinks_) { + for (size_t i = sinks_->size(); i-- > 0; ) { + (*sinks_)[i]->WaitTillSent(); + } + } + const bool send_to_sink = + (data->send_method_ == &LogMessage::SendToSink) || + (data->send_method_ == &LogMessage::SendToSinkAndLog); + if (send_to_sink && data->sink_ != nullptr) { + data->sink_->WaitTillSent(); + } +} + +LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES]; + +inline LogDestination* LogDestination::log_destination(LogSeverity severity) { + assert(severity >=0 && severity < NUM_SEVERITIES); + if (!log_destinations_[severity]) { + log_destinations_[severity] = new LogDestination(severity, nullptr); + } + return log_destinations_[severity]; +} + +void LogDestination::DeleteLogDestinations() { + for (auto& log_destination : log_destinations_) { + delete log_destination; + log_destination = nullptr; + } + MutexLock l(&sink_mutex_); + delete sinks_; + sinks_ = nullptr; +} + +namespace { + +std::string g_application_fingerprint; + +} // namespace + +void SetApplicationFingerprint(const std::string& fingerprint) { + g_application_fingerprint = fingerprint; +} + +namespace { + +// Directory delimiter; Windows supports both forward slashes and backslashes +#ifdef GLOG_OS_WINDOWS +const char possible_dir_delim[] = {'\\', '/'}; +#else +const char possible_dir_delim[] = {'/'}; +#endif + +string PrettyDuration(int secs) { + std::stringstream result; + int mins = secs / 60; + int hours = mins / 60; + mins = mins % 60; + secs = secs % 60; + result.fill('0'); + result << hours << ':' << setw(2) << mins << ':' << setw(2) << secs; + return result.str(); +} + +LogFileObject::LogFileObject(LogSeverity severity, const char* base_filename) + : base_filename_selected_(base_filename != nullptr), + base_filename_((base_filename != nullptr) ? base_filename : ""), + symlink_basename_(glog_internal_namespace_::ProgramInvocationShortName()), + filename_extension_(), + + severity_(severity), + + rollover_attempt_(kRolloverAttemptFrequency - 1), + + start_time_(WallTime_Now()) { + assert(severity >= 0); + assert(severity < NUM_SEVERITIES); +} + +LogFileObject::~LogFileObject() { + MutexLock l(&lock_); + if (file_ != nullptr) { + fclose(file_); + file_ = nullptr; + } +} + +void LogFileObject::SetBasename(const char* basename) { + MutexLock l(&lock_); + base_filename_selected_ = true; + if (base_filename_ != basename) { + // Get rid of old log file since we are changing names + if (file_ != nullptr) { + fclose(file_); + file_ = nullptr; + rollover_attempt_ = kRolloverAttemptFrequency-1; + } + base_filename_ = basename; + } +} + +void LogFileObject::SetExtension(const char* ext) { + MutexLock l(&lock_); + if (filename_extension_ != ext) { + // Get rid of old log file since we are changing names + if (file_ != nullptr) { + fclose(file_); + file_ = nullptr; + rollover_attempt_ = kRolloverAttemptFrequency-1; + } + filename_extension_ = ext; + } +} + +void LogFileObject::SetSymlinkBasename(const char* symlink_basename) { + MutexLock l(&lock_); + symlink_basename_ = symlink_basename; +} + +void LogFileObject::Flush() { + MutexLock l(&lock_); + FlushUnlocked(); +} + +void LogFileObject::FlushUnlocked(){ + if (file_ != nullptr) { + fflush(file_); + bytes_since_flush_ = 0; + } + // Figure out when we are due for another flush. + const int64 next = (FLAGS_logbufsecs + * static_cast(1000000)); // in usec + next_flush_time_ = CycleClock_Now() + UsecToCycles(next); +} + +bool LogFileObject::CreateLogfile(const string& time_pid_string) { + string string_filename = base_filename_; + if (FLAGS_timestamp_in_logfile_name) { + string_filename += time_pid_string; + } + string_filename += filename_extension_; + const char* filename = string_filename.c_str(); + //only write to files, create if non-existant. + int flags = O_WRONLY | O_CREAT; + if (FLAGS_timestamp_in_logfile_name) { + //demand that the file is unique for our timestamp (fail if it exists). + flags = flags | O_EXCL; + } + int fd = open(filename, flags, static_cast(FLAGS_logfile_mode)); + if (fd == -1) return false; +#ifdef HAVE_FCNTL + // Mark the file close-on-exec. We don't really care if this fails + fcntl(fd, F_SETFD, FD_CLOEXEC); + + // Mark the file as exclusive write access to avoid two clients logging to the + // same file. This applies particularly when !FLAGS_timestamp_in_logfile_name + // (otherwise open would fail because the O_EXCL flag on similar filename). + // locks are released on unlock or close() automatically, only after log is + // released. + // This will work after a fork as it is not inherited (not stored in the fd). + // Lock will not be lost because the file is opened with exclusive lock + // (write) and we will never read from it inside the process. + // TODO: windows implementation of this (as flock is not available on + // mingw). + static struct flock w_lock; + + w_lock.l_type = F_WRLCK; + w_lock.l_start = 0; + w_lock.l_whence = SEEK_SET; + w_lock.l_len = 0; + + int wlock_ret = fcntl(fd, F_SETLK, &w_lock); + if (wlock_ret == -1) { + close(fd); //as we are failing already, do not check errors here + return false; + } +#endif + + //fdopen in append mode so if the file exists it will fseek to the end + file_ = fdopen(fd, "a"); // Make a FILE*. + if (file_ == nullptr) { // Man, we're screwed! + close(fd); + if (FLAGS_timestamp_in_logfile_name) { + unlink(filename); // Erase the half-baked evidence: an unusable log file, only if we just created it. + } + return false; + } +#ifdef GLOG_OS_WINDOWS + // https://github.com/golang/go/issues/27638 - make sure we seek to the end to append + // empirically replicated with wine over mingw build + if (!FLAGS_timestamp_in_logfile_name) { + if (fseek(file_, 0, SEEK_END) != 0) { + return false; + } + } +#endif + // We try to create a symlink called ., + // which is easier to use. (Every time we create a new logfile, + // we destroy the old symlink and create a new one, so it always + // points to the latest logfile.) If it fails, we're sad but it's + // no error. + if (!symlink_basename_.empty()) { + // take directory from filename + const char* slash = strrchr(filename, PATH_SEPARATOR); + const string linkname = + symlink_basename_ + '.' + LogSeverityNames[severity_]; + string linkpath; + if ( slash ) linkpath = string(filename, static_cast(slash-filename+1)); // get dirname + linkpath += linkname; + unlink(linkpath.c_str()); // delete old one if it exists + +#if defined(GLOG_OS_WINDOWS) + // TODO(hamaji): Create lnk file on Windows? +#elif defined(HAVE_UNISTD_H) + // We must have unistd.h. + // Make the symlink be relative (in the same dir) so that if the + // entire log directory gets relocated the link is still valid. + const char *linkdest = slash ? (slash + 1) : filename; + if (symlink(linkdest, linkpath.c_str()) != 0) { + // silently ignore failures + } + + // Make an additional link to the log file in a place specified by + // FLAGS_log_link, if indicated + if (!FLAGS_log_link.empty()) { + linkpath = FLAGS_log_link + "/" + linkname; + unlink(linkpath.c_str()); // delete old one if it exists + if (symlink(filename, linkpath.c_str()) != 0) { + // silently ignore failures + } + } +#endif + } + + return true; // Everything worked +} + +void LogFileObject::Write(bool force_flush, + time_t timestamp, + const char* message, + size_t message_len) { + MutexLock l(&lock_); + + // We don't log if the base_name_ is "" (which means "don't write") + if (base_filename_selected_ && base_filename_.empty()) { + return; + } + + if (file_length_ >> 20U >= MaxLogSize() || PidHasChanged()) { + if (file_ != nullptr) fclose(file_); + file_ = nullptr; + file_length_ = bytes_since_flush_ = dropped_mem_length_ = 0; + rollover_attempt_ = kRolloverAttemptFrequency - 1; + } + + // If there's no destination file, make one before outputting + if (file_ == nullptr) { + // Try to rollover the log file every 32 log messages. The only time + // this could matter would be when we have trouble creating the log + // file. If that happens, we'll lose lots of log messages, of course! + if (++rollover_attempt_ != kRolloverAttemptFrequency) return; + rollover_attempt_ = 0; + + struct ::tm tm_time; + if (FLAGS_log_utc_time) { + gmtime_r(×tamp, &tm_time); + } else { + localtime_r(×tamp, &tm_time); + } + + // The logfile's filename will have the date/time & pid in it + ostringstream time_pid_stream; + time_pid_stream.fill('0'); + time_pid_stream << 1900+tm_time.tm_year + << setw(2) << 1+tm_time.tm_mon + << setw(2) << tm_time.tm_mday + << '-' + << setw(2) << tm_time.tm_hour + << setw(2) << tm_time.tm_min + << setw(2) << tm_time.tm_sec + << '.' + << GetMainThreadPid(); + const string& time_pid_string = time_pid_stream.str(); + + if (base_filename_selected_) { + if (!CreateLogfile(time_pid_string)) { + perror("Could not create log file"); + fprintf(stderr, "COULD NOT CREATE LOGFILE '%s'!\n", + time_pid_string.c_str()); + return; + } + } else { + // If no base filename for logs of this severity has been set, use a + // default base filename of + // "...log..". So + // logfiles will have names like + // webserver.examplehost.root.log.INFO.19990817-150000.4354, where + // 19990817 is a date (1999 August 17), 150000 is a time (15:00:00), + // and 4354 is the pid of the logging process. The date & time reflect + // when the file was created for output. + // + // Where does the file get put? Successively try the directories + // "/tmp", and "." + string stripped_filename( + glog_internal_namespace_::ProgramInvocationShortName()); + string hostname; + GetHostName(&hostname); + + string uidname = MyUserName(); + // We should not call CHECK() here because this function can be + // called after holding on to log_mutex. We don't want to + // attempt to hold on to the same mutex, and get into a + // deadlock. Simply use a name like invalid-user. + if (uidname.empty()) uidname = "invalid-user"; + + stripped_filename = stripped_filename+'.'+hostname+'.' + +uidname+".log." + +LogSeverityNames[severity_]+'.'; + // We're going to (potentially) try to put logs in several different dirs + const vector & log_dirs = GetLoggingDirectories(); + + // Go through the list of dirs, and try to create the log file in each + // until we succeed or run out of options + bool success = false; + for (const auto& log_dir : log_dirs) { + base_filename_ = log_dir + "/" + stripped_filename; + if ( CreateLogfile(time_pid_string) ) { + success = true; + break; + } + } + // If we never succeeded, we have to give up + if ( success == false ) { + perror("Could not create logging file"); + fprintf(stderr, "COULD NOT CREATE A LOGGINGFILE %s!", + time_pid_string.c_str()); + return; + } + } + + // Write a header message into the log file + if (FLAGS_log_file_header) { + ostringstream file_header_stream; + file_header_stream.fill('0'); + file_header_stream << "Log file created at: " + << 1900+tm_time.tm_year << '/' + << setw(2) << 1+tm_time.tm_mon << '/' + << setw(2) << tm_time.tm_mday + << ' ' + << setw(2) << tm_time.tm_hour << ':' + << setw(2) << tm_time.tm_min << ':' + << setw(2) << tm_time.tm_sec << (FLAGS_log_utc_time ? " UTC\n" : "\n") + << "Running on machine: " + << LogDestination::hostname() << '\n'; + + if(!g_application_fingerprint.empty()) { + file_header_stream << "Application fingerprint: " << g_application_fingerprint << '\n'; + } + const char* const date_time_format = FLAGS_log_year_in_prefix + ? "yyyymmdd hh:mm:ss.uuuuuu" + : "mmdd hh:mm:ss.uuuuuu"; + file_header_stream << "Running duration (h:mm:ss): " + << PrettyDuration(static_cast(WallTime_Now() - start_time_)) << '\n' + << "Log line format: [IWEF]" << date_time_format << " " + << "threadid file:line] msg" << '\n'; + const string& file_header_string = file_header_stream.str(); + + const size_t header_len = file_header_string.size(); + fwrite(file_header_string.data(), 1, header_len, file_); + file_length_ += header_len; + bytes_since_flush_ += header_len; + } + } + + // Write to LOG file + if ( !stop_writing ) { + // fwrite() doesn't return an error when the disk is full, for + // messages that are less than 4096 bytes. When the disk is full, + // it returns the message length for messages that are less than + // 4096 bytes. fwrite() returns 4096 for message lengths that are + // greater than 4096, thereby indicating an error. + errno = 0; + fwrite(message, 1, message_len, file_); + if ( FLAGS_stop_logging_if_full_disk && + errno == ENOSPC ) { // disk full, stop writing to disk + stop_writing = true; // until the disk is + return; + } else { + file_length_ += message_len; + bytes_since_flush_ += message_len; + } + } else { + if (CycleClock_Now() >= next_flush_time_) { + stop_writing = false; // check to see if disk has free space. + } + return; // no need to flush + } + + // See important msgs *now*. Also, flush logs at least every 10^6 chars, + // or every "FLAGS_logbufsecs" seconds. + if ( force_flush || + (bytes_since_flush_ >= 1000000) || + (CycleClock_Now() >= next_flush_time_) ) { + FlushUnlocked(); +#ifdef GLOG_OS_LINUX + // Only consider files >= 3MiB + if (FLAGS_drop_log_memory && file_length_ >= (3U << 20U)) { + // Don't evict the most recent 1-2MiB so as not to impact a tailer + // of the log file and to avoid page rounding issue on linux < 4.7 + uint32 total_drop_length = + (file_length_ & ~((1U << 20U) - 1U)) - (1U << 20U); + uint32 this_drop_length = total_drop_length - dropped_mem_length_; + if (this_drop_length >= (2U << 20U)) { + // Only advise when >= 2MiB to drop +# if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21) + // 'posix_fadvise' introduced in API 21: + // * https://android.googlesource.com/platform/bionic/+/6880f936173081297be0dc12f687d341b86a4cfa/libc/libc.map.txt#732 +# else + posix_fadvise(fileno(file_), static_cast(dropped_mem_length_), + static_cast(this_drop_length), + POSIX_FADV_DONTNEED); +# endif + dropped_mem_length_ = total_drop_length; + } + } +#endif + + // Remove old logs + if (log_cleaner.enabled()) { + log_cleaner.Run(base_filename_selected_, + base_filename_, + filename_extension_); + } + } +} + +LogCleaner::LogCleaner() = default; + +void LogCleaner::Enable(unsigned int overdue_days) { + enabled_ = true; + overdue_days_ = overdue_days; +} + +void LogCleaner::Disable() { + enabled_ = false; +} + +void LogCleaner::UpdateCleanUpTime() { + const int64 next = (FLAGS_logcleansecs + * 1000000); // in usec + next_cleanup_time_ = CycleClock_Now() + UsecToCycles(next); +} + +void LogCleaner::Run(bool base_filename_selected, + const string& base_filename, + const string& filename_extension) { + assert(enabled_); + assert(!base_filename_selected || !base_filename.empty()); + + // avoid scanning logs too frequently + if (CycleClock_Now() < next_cleanup_time_) { + return; + } + UpdateCleanUpTime(); + + vector dirs; + + if (!base_filename_selected) { + dirs = GetLoggingDirectories(); + } else { + size_t pos = base_filename.find_last_of(possible_dir_delim, string::npos, + sizeof(possible_dir_delim)); + if (pos != string::npos) { + string dir = base_filename.substr(0, pos + 1); + dirs.push_back(dir); + } else { + dirs.emplace_back("."); + } + } + + for (auto& dir : dirs) { + vector logs = GetOverdueLogNames(dir, overdue_days_, base_filename, + filename_extension); + for (auto& log : logs) { + static_cast(unlink(log.c_str())); + } + } +} + +vector LogCleaner::GetOverdueLogNames( + string log_directory, unsigned int days, const string& base_filename, + const string& filename_extension) const { + // The names of overdue logs. + vector overdue_log_names; + + // Try to get all files within log_directory. + DIR *dir; + struct dirent *ent; + + if ((dir = opendir(log_directory.c_str()))) { + while ((ent = readdir(dir))) { + if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { + continue; + } + + string filepath = ent->d_name; + const char* const dir_delim_end = + possible_dir_delim + sizeof(possible_dir_delim); + + if (!log_directory.empty() && + std::find(possible_dir_delim, dir_delim_end, + log_directory[log_directory.size() - 1]) != dir_delim_end) { + filepath = log_directory + filepath; + } + + if (IsLogFromCurrentProject(filepath, base_filename, filename_extension) && + IsLogLastModifiedOver(filepath, days)) { + overdue_log_names.push_back(filepath); + } + } + closedir(dir); + } + + return overdue_log_names; +} + +bool LogCleaner::IsLogFromCurrentProject(const string& filepath, + const string& base_filename, + const string& filename_extension) const { + // We should remove duplicated delimiters from `base_filename`, e.g., + // before: "/tmp//.." + // after: "/tmp/.." + string cleaned_base_filename; + + const char* const dir_delim_end = + possible_dir_delim + sizeof(possible_dir_delim); + + size_t real_filepath_size = filepath.size(); + for (char c : base_filename) { + if (cleaned_base_filename.empty()) { + cleaned_base_filename += c; + } else if (std::find(possible_dir_delim, dir_delim_end, c) == + dir_delim_end || + (!cleaned_base_filename.empty() && + c != cleaned_base_filename[cleaned_base_filename.size() - 1])) { + cleaned_base_filename += c; + } + } + + // Return early if the filename doesn't start with `cleaned_base_filename`. + if (filepath.find(cleaned_base_filename) != 0) { + return false; + } + + // Check if in the string `filename_extension` is right next to + // `cleaned_base_filename` in `filepath` if the user + // has set a custom filename extension. + if (!filename_extension.empty()) { + if (cleaned_base_filename.size() >= real_filepath_size) { + return false; + } + // for origin version, `filename_extension` is middle of the `filepath`. + string ext = filepath.substr(cleaned_base_filename.size(), filename_extension.size()); + if (ext == filename_extension) { + cleaned_base_filename += filename_extension; + } + else { + // for new version, `filename_extension` is right of the `filepath`. + if (filename_extension.size() >= real_filepath_size) { + return false; + } + real_filepath_size = filepath.size() - filename_extension.size(); + if (filepath.substr(real_filepath_size) != filename_extension) { + return false; + } + } + } + + // The characters after `cleaned_base_filename` should match the format: + // YYYYMMDD-HHMMSS.pid + for (size_t i = cleaned_base_filename.size(); i < real_filepath_size; i++) { + const char& c = filepath[i]; + + if (i <= cleaned_base_filename.size() + 7) { // 0 ~ 7 : YYYYMMDD + if (c < '0' || c > '9') { return false; } + + } else if (i == cleaned_base_filename.size() + 8) { // 8: - + if (c != '-') { return false; } + + } else if (i <= cleaned_base_filename.size() + 14) { // 9 ~ 14: HHMMSS + if (c < '0' || c > '9') { return false; } + + } else if (i == cleaned_base_filename.size() + 15) { // 15: . + if (c != '.') { return false; } + + } else if (i >= cleaned_base_filename.size() + 16) { // 16+: pid + if (c < '0' || c > '9') { return false; } + } + } + + return true; +} + +bool LogCleaner::IsLogLastModifiedOver(const string& filepath, + unsigned int days) const { + // Try to get the last modified time of this file. + struct stat file_stat; + + if (stat(filepath.c_str(), &file_stat) == 0) { + const time_t seconds_in_a_day = 60 * 60 * 24; + time_t last_modified_time = file_stat.st_mtime; + time_t current_time = time(nullptr); + return difftime(current_time, last_modified_time) > days * seconds_in_a_day; + } + + // If failed to get file stat, don't return true! + return false; +} + +} // namespace + +// Static log data space to avoid alloc failures in a LOG(FATAL) +// +// Since multiple threads may call LOG(FATAL), and we want to preserve +// the data from the first call, we allocate two sets of space. One +// for exclusive use by the first thread, and one for shared use by +// all other threads. +static Mutex fatal_msg_lock; +static CrashReason crash_reason; +static bool fatal_msg_exclusive = true; +static LogMessage::LogMessageData fatal_msg_data_exclusive; +static LogMessage::LogMessageData fatal_msg_data_shared; + +#ifdef GLOG_THREAD_LOCAL_STORAGE +// Static thread-local log data space to use, because typically at most one +// LogMessageData object exists (in this case glog makes zero heap memory +// allocations). +static thread_local bool thread_data_available = true; + +static thread_local std::aligned_storage< + sizeof(LogMessage::LogMessageData), + alignof(LogMessage::LogMessageData)>::type thread_msg_data; +#endif // defined(GLOG_THREAD_LOCAL_STORAGE) + +LogMessage::LogMessageData::LogMessageData() + : stream_(message_text_, LogMessage::kMaxLogMessageLen, 0) { +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + int64 ctr, void (LogMessage::*send_method)()) + : allocated_(nullptr) { + Init(file, line, severity, send_method); + data_->stream_.set_ctr(ctr); +} + +LogMessage::LogMessage(const char* file, int line, const CheckOpString& result) + : allocated_(nullptr) { + Init(file, line, GLOG_FATAL, &LogMessage::SendToLog); + stream() << "Check failed: " << (*result.str_) << " "; +} + +LogMessage::LogMessage(const char* file, int line) : allocated_(nullptr) { + Init(file, line, GLOG_INFO, &LogMessage::SendToLog); +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity) + : allocated_(nullptr) { + Init(file, line, severity, &LogMessage::SendToLog); +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + LogSink* sink, bool also_send_to_log) + : allocated_(nullptr) { + Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog : + &LogMessage::SendToSink); + data_->sink_ = sink; // override Init()'s setting to nullptr +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + vector* outvec) + : allocated_(nullptr) { + Init(file, line, severity, &LogMessage::SaveOrSendToLog); + data_->outvec_ = outvec; // override Init()'s setting to nullptr +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + string* message) + : allocated_(nullptr) { + Init(file, line, severity, &LogMessage::WriteToStringAndLog); + data_->message_ = message; // override Init()'s setting to nullptr +} + +void LogMessage::Init(const char* file, + int line, + LogSeverity severity, + void (LogMessage::*send_method)()) { + allocated_ = nullptr; + if (severity != GLOG_FATAL || !exit_on_dfatal) { +#ifdef GLOG_THREAD_LOCAL_STORAGE + // No need for locking, because this is thread local. + if (thread_data_available) { + thread_data_available = false; + data_ = new (&thread_msg_data) LogMessageData; + } else { + allocated_ = new LogMessageData(); + data_ = allocated_; + } +#else // !defined(GLOG_THREAD_LOCAL_STORAGE) + allocated_ = new LogMessageData(); + data_ = allocated_; +#endif // defined(GLOG_THREAD_LOCAL_STORAGE) + data_->first_fatal_ = false; + } else { + MutexLock l(&fatal_msg_lock); + if (fatal_msg_exclusive) { + fatal_msg_exclusive = false; + data_ = &fatal_msg_data_exclusive; + data_->first_fatal_ = true; + } else { + data_ = &fatal_msg_data_shared; + data_->first_fatal_ = false; + } + } + + data_->preserved_errno_ = errno; + data_->severity_ = severity; + data_->line_ = line; + data_->send_method_ = send_method; + data_->sink_ = nullptr; + data_->outvec_ = nullptr; + WallTime now = WallTime_Now(); + auto timestamp_now = static_cast(now); + logmsgtime_ = LogMessageTime(timestamp_now, now); + + data_->num_chars_to_log_ = 0; + data_->num_chars_to_syslog_ = 0; + data_->basename_ = const_basename(file); + data_->fullname_ = file; + data_->has_been_flushed_ = false; + + // If specified, prepend a prefix to each line. For example: + // I20201018 160715 f5d4fbb0 logging.cc:1153] + // (log level, GMT year, month, date, time, thread_id, file basename, line) + // We exclude the thread_id for the default thread. + if (FLAGS_log_prefix && (line != kNoLogPrefix)) { + std::ios saved_fmt(nullptr); + saved_fmt.copyfmt(stream()); + stream().fill('0'); + if (custom_prefix_callback == nullptr) { + stream() << LogSeverityNames[severity][0]; + if (FLAGS_log_year_in_prefix) { + stream() << setw(4) << 1900 + logmsgtime_.year(); + } + stream() << setw(2) << 1 + logmsgtime_.month() << setw(2) + << logmsgtime_.day() << ' ' << setw(2) << logmsgtime_.hour() + << ':' << setw(2) << logmsgtime_.min() << ':' << setw(2) + << logmsgtime_.sec() << "." << setw(6) << logmsgtime_.usec() + << ' ' << setfill(' ') << setw(5) + << static_cast(GetTID()) << setfill('0') << ' ' + << data_->basename_ << ':' << data_->line_ << "] "; + } else { + custom_prefix_callback( + stream(), + LogMessageInfo(LogSeverityNames[severity], data_->basename_, + data_->line_, GetTID(), logmsgtime_), + custom_prefix_callback_data); + stream() << " "; + } + stream().copyfmt(saved_fmt); + } + data_->num_prefix_chars_ = data_->stream_.pcount(); + + if (!FLAGS_log_backtrace_at.empty()) { + char fileline[128]; + snprintf(fileline, sizeof(fileline), "%s:%d", data_->basename_, line); +#ifdef HAVE_STACKTRACE + if (FLAGS_log_backtrace_at == fileline) { + string stacktrace; + DumpStackTraceToString(&stacktrace); + stream() << " (stacktrace:\n" << stacktrace << ") "; + } +#endif + } +} + +const LogMessageTime& LogMessage::getLogMessageTime() const { + return logmsgtime_; +} + +LogMessage::~LogMessage() { + Flush(); +#ifdef GLOG_THREAD_LOCAL_STORAGE + if (data_ == static_cast(&thread_msg_data)) { + data_->~LogMessageData(); + thread_data_available = true; + } + else { + delete allocated_; + } +#else // !defined(GLOG_THREAD_LOCAL_STORAGE) + delete allocated_; +#endif // defined(GLOG_THREAD_LOCAL_STORAGE) +} + +int LogMessage::preserved_errno() const { + return data_->preserved_errno_; +} + +ostream& LogMessage::stream() { + return data_->stream_; +} + +// Flush buffered message, called by the destructor, or any other function +// that needs to synchronize the log. +void LogMessage::Flush() { + if (data_->has_been_flushed_ || data_->severity_ < FLAGS_minloglevel) { + return; + } + + data_->num_chars_to_log_ = data_->stream_.pcount(); + data_->num_chars_to_syslog_ = + data_->num_chars_to_log_ - data_->num_prefix_chars_; + + // Do we need to add a \n to the end of this message? + bool append_newline = + (data_->message_text_[data_->num_chars_to_log_-1] != '\n'); + char original_final_char = '\0'; + + // If we do need to add a \n, we'll do it by violating the memory of the + // ostrstream buffer. This is quick, and we'll make sure to undo our + // modification before anything else is done with the ostrstream. It + // would be preferable not to do things this way, but it seems to be + // the best way to deal with this. + if (append_newline) { + original_final_char = data_->message_text_[data_->num_chars_to_log_]; + data_->message_text_[data_->num_chars_to_log_++] = '\n'; + } + data_->message_text_[data_->num_chars_to_log_] = '\0'; + + // Prevent any subtle race conditions by wrapping a mutex lock around + // the actual logging action per se. + { + MutexLock l(&log_mutex); + (this->*(data_->send_method_))(); + ++num_messages_[static_cast(data_->severity_)]; + } + LogDestination::WaitForSinks(data_); + + if (append_newline) { + // Fix the ostrstream back how it was before we screwed with it. + // It's 99.44% certain that we don't need to worry about doing this. + data_->message_text_[data_->num_chars_to_log_-1] = original_final_char; + } + + // If errno was already set before we enter the logging call, we'll + // set it back to that value when we return from the logging call. + // It happens often that we log an error message after a syscall + // failure, which can potentially set the errno to some other + // values. We would like to preserve the original errno. + if (data_->preserved_errno_ != 0) { + errno = data_->preserved_errno_; + } + + // Note that this message is now safely logged. If we're asked to flush + // again, as a result of destruction, say, we'll do nothing on future calls. + data_->has_been_flushed_ = true; +} + +// Copy of first FATAL log message so that we can print it out again +// after all the stack traces. To preserve legacy behavior, we don't +// use fatal_msg_data_exclusive. +static time_t fatal_time; +static char fatal_message[256]; + +void ReprintFatalMessage() { + if (fatal_message[0]) { + const size_t n = strlen(fatal_message); + if (!FLAGS_logtostderr) { + // Also write to stderr (don't color to avoid terminal checks) + WriteToStderr(fatal_message, n); + } + LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n); + } +} + +// L >= log_mutex (callers must hold the log_mutex). +void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { + static bool already_warned_before_initgoogle = false; + + log_mutex.AssertHeld(); + + RAW_DCHECK(data_->num_chars_to_log_ > 0 && + data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); + + // Messages of a given severity get logged to lower severity logs, too + + if (!already_warned_before_initgoogle && !IsGoogleLoggingInitialized()) { + const char w[] = "WARNING: Logging before InitGoogleLogging() is " + "written to STDERR\n"; + WriteToStderr(w, strlen(w)); + already_warned_before_initgoogle = true; + } + + // global flag: never log to file if set. Also -- don't log to a + // file if we haven't parsed the command line flags to get the + // program name. + if (FLAGS_logtostderr || FLAGS_logtostdout || !IsGoogleLoggingInitialized()) { + if (FLAGS_logtostdout) { + ColoredWriteToStdout(data_->severity_, data_->message_text_, + data_->num_chars_to_log_); + } else { + ColoredWriteToStderr(data_->severity_, data_->message_text_, + data_->num_chars_to_log_); + } + + // this could be protected by a flag if necessary. + LogDestination::LogToSinks(data_->severity_, + data_->fullname_, data_->basename_, + data_->line_, logmsgtime_, + data_->message_text_ + data_->num_prefix_chars_, + (data_->num_chars_to_log_ - + data_->num_prefix_chars_ - 1) ); + } else { + // log this message to all log files of severity <= severity_ + LogDestination::LogToAllLogfiles(data_->severity_, logmsgtime_.timestamp(), + data_->message_text_, + data_->num_chars_to_log_); + + LogDestination::MaybeLogToStderr(data_->severity_, data_->message_text_, + data_->num_chars_to_log_, + data_->num_prefix_chars_); + LogDestination::MaybeLogToEmail(data_->severity_, data_->message_text_, + data_->num_chars_to_log_); + LogDestination::LogToSinks(data_->severity_, + data_->fullname_, data_->basename_, + data_->line_, logmsgtime_, + data_->message_text_ + data_->num_prefix_chars_, + (data_->num_chars_to_log_ + - data_->num_prefix_chars_ - 1) ); + // NOTE: -1 removes trailing \n + } + + // If we log a FATAL message, flush all the log destinations, then toss + // a signal for others to catch. We leave the logs in a state that + // someone else can use them (as long as they flush afterwards) + if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) { + if (data_->first_fatal_) { + // Store crash information so that it is accessible from within signal + // handlers that may be invoked later. + RecordCrashReason(&crash_reason); + SetCrashReason(&crash_reason); + + // Store shortened fatal message for other logs and GWQ status + const size_t copy = min(data_->num_chars_to_log_, + sizeof(fatal_message)-1); + memcpy(fatal_message, data_->message_text_, copy); + fatal_message[copy] = '\0'; + fatal_time = logmsgtime_.timestamp(); + } + + if (!FLAGS_logtostderr && !FLAGS_logtostdout) { + for (auto& log_destination : LogDestination::log_destinations_) { + if (log_destination) { + log_destination->logger_->Write(true, 0, "", 0); + } + } + } + + // release the lock that our caller (directly or indirectly) + // LogMessage::~LogMessage() grabbed so that signal handlers + // can use the logging facility. Alternately, we could add + // an entire unsafe logging interface to bypass locking + // for signal handlers but this seems simpler. + log_mutex.Unlock(); + LogDestination::WaitForSinks(data_); + + const char* message = "*** Check failure stack trace: ***\n"; + if (write(STDERR_FILENO, message, strlen(message)) < 0) { + // Ignore errors. + } +#if defined(__ANDROID__) + // ANDROID_LOG_FATAL as this message is of FATAL severity. + __android_log_write(ANDROID_LOG_FATAL, + glog_internal_namespace_::ProgramInvocationShortName(), + message); +#endif + Fail(); + } +} + +void LogMessage::RecordCrashReason( + glog_internal_namespace_::CrashReason* reason) { + reason->filename = fatal_msg_data_exclusive.fullname_; + reason->line_number = fatal_msg_data_exclusive.line_; + reason->message = fatal_msg_data_exclusive.message_text_ + + fatal_msg_data_exclusive.num_prefix_chars_; +#ifdef HAVE_STACKTRACE + // Retrieve the stack trace, omitting the logging frames that got us here. + reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4); +#else + reason->depth = 0; +#endif +} + +GLOG_EXPORT logging_fail_func_t g_logging_fail_func = + reinterpret_cast(&abort); + +void InstallFailureFunction(logging_fail_func_t fail_func) { + g_logging_fail_func = fail_func; +} + +void LogMessage::Fail() { + g_logging_fail_func(); +} + +// L >= log_mutex (callers must hold the log_mutex). +void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { + if (data_->sink_ != nullptr) { + RAW_DCHECK(data_->num_chars_to_log_ > 0 && + data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); + data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_, + data_->line_, logmsgtime_, + data_->message_text_ + data_->num_prefix_chars_, + (data_->num_chars_to_log_ - + data_->num_prefix_chars_ - 1) ); + } +} + +// L >= log_mutex (callers must hold the log_mutex). +void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { + SendToSink(); + SendToLog(); +} + +// L >= log_mutex (callers must hold the log_mutex). +void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { + if (data_->outvec_ != nullptr) { + RAW_DCHECK(data_->num_chars_to_log_ > 0 && + data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); + // Omit prefix of message and trailing newline when recording in outvec_. + const char *start = data_->message_text_ + data_->num_prefix_chars_; + size_t len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1; + data_->outvec_->push_back(string(start, len)); + } else { + SendToLog(); + } +} + +void LogMessage::WriteToStringAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { + if (data_->message_ != nullptr) { + RAW_DCHECK(data_->num_chars_to_log_ > 0 && + data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); + // Omit prefix of message and trailing newline when writing to message_. + const char *start = data_->message_text_ + data_->num_prefix_chars_; + size_t len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1; + data_->message_->assign(start, len); + } + SendToLog(); +} + +// L >= log_mutex (callers must hold the log_mutex). +void LogMessage::SendToSyslogAndLog() { +#ifdef HAVE_SYSLOG_H + // Before any calls to syslog(), make a single call to openlog() + static bool openlog_already_called = false; + if (!openlog_already_called) { + openlog(glog_internal_namespace_::ProgramInvocationShortName(), + LOG_CONS | LOG_NDELAY | LOG_PID, + LOG_USER); + openlog_already_called = true; + } + + // This array maps Google severity levels to syslog levels + const int SEVERITY_TO_LEVEL[] = { LOG_INFO, LOG_WARNING, LOG_ERR, LOG_EMERG }; + syslog(LOG_USER | SEVERITY_TO_LEVEL[static_cast(data_->severity_)], + "%.*s", static_cast(data_->num_chars_to_syslog_), + data_->message_text_ + data_->num_prefix_chars_); + SendToLog(); +#else + LOG(ERROR) << "No syslog support: message=" << data_->message_text_; +#endif +} + +base::Logger* base::GetLogger(LogSeverity severity) { + MutexLock l(&log_mutex); + return LogDestination::log_destination(severity)->GetLoggerImpl(); +} + +void base::SetLogger(LogSeverity severity, base::Logger* logger) { + MutexLock l(&log_mutex); + LogDestination::log_destination(severity)->SetLoggerImpl(logger); +} + +// L < log_mutex. Acquires and releases mutex_. +int64 LogMessage::num_messages(int severity) { + MutexLock l(&log_mutex); + return num_messages_[severity]; +} + +// Output the COUNTER value. This is only valid if ostream is a +// LogStream. +ostream& operator<<(ostream &os, const PRIVATE_Counter&) { +#ifdef DISABLE_RTTI + LogMessage::LogStream *log = static_cast(&os); +#else + auto* log = dynamic_cast(&os); +#endif + CHECK(log && log == log->self()) + << "You must not use COUNTER with non-glog ostream"; + os << log->ctr(); + return os; +} + +ErrnoLogMessage::ErrnoLogMessage(const char* file, int line, + LogSeverity severity, int64 ctr, + void (LogMessage::*send_method)()) + : LogMessage(file, line, severity, ctr, send_method) {} + +ErrnoLogMessage::~ErrnoLogMessage() { + // Don't access errno directly because it may have been altered + // while streaming the message. + stream() << ": " << StrError(preserved_errno()) << " [" + << preserved_errno() << "]"; +} + +void FlushLogFiles(LogSeverity min_severity) { + LogDestination::FlushLogFiles(min_severity); +} + +void FlushLogFilesUnsafe(LogSeverity min_severity) { + LogDestination::FlushLogFilesUnsafe(min_severity); +} + +void SetLogDestination(LogSeverity severity, const char* base_filename) { + LogDestination::SetLogDestination(severity, base_filename); +} + +void SetLogSymlink(LogSeverity severity, const char* symlink_basename) { + LogDestination::SetLogSymlink(severity, symlink_basename); +} + +LogSink::~LogSink() = default; + +void LogSink::send(LogSeverity severity, const char* full_filename, + const char* base_filename, int line, + const LogMessageTime& time, const char* message, + size_t message_len) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) +#endif // __GNUC__ + send(severity, full_filename, base_filename, line, &time.tm(), message, + message_len); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif // __GNUC__ +} + +void LogSink::send(LogSeverity severity, const char* full_filename, + const char* base_filename, int line, const std::tm* t, + const char* message, size_t message_len) { + (void)severity; + (void)full_filename; + (void)base_filename; + (void)line; + (void)t; + (void)message; + (void)message_len; +} + +void LogSink::WaitTillSent() { + // noop default +} + +string LogSink::ToString(LogSeverity severity, const char* file, int line, + const LogMessageTime& logmsgtime, const char* message, + size_t message_len) { + ostringstream stream; + stream.fill('0'); + + stream << LogSeverityNames[severity][0]; + if (FLAGS_log_year_in_prefix) { + stream << setw(4) << 1900 + logmsgtime.year(); + } + stream << setw(2) << 1 + logmsgtime.month() + << setw(2) << logmsgtime.day() + << ' ' + << setw(2) << logmsgtime.hour() << ':' + << setw(2) << logmsgtime.min() << ':' + << setw(2) << logmsgtime.sec() << '.' + << setw(6) << logmsgtime.usec() + << ' ' + << setfill(' ') << setw(5) << GetTID() << setfill('0') + << ' ' + << file << ':' << line << "] "; + + // A call to `write' is enclosed in parenthneses to prevent possible macro + // expansion. On Windows, `write' could be a macro defined for portability. + (stream.write)(message, static_cast(message_len)); + return stream.str(); +} + +void AddLogSink(LogSink *destination) { + LogDestination::AddLogSink(destination); +} + +void RemoveLogSink(LogSink *destination) { + LogDestination::RemoveLogSink(destination); +} + +void SetLogFilenameExtension(const char* ext) { + LogDestination::SetLogFilenameExtension(ext); +} + +void SetStderrLogging(LogSeverity min_severity) { + LogDestination::SetStderrLogging(min_severity); +} + +void SetEmailLogging(LogSeverity min_severity, const char* addresses) { + LogDestination::SetEmailLogging(min_severity, addresses); +} + +void LogToStderr() { + LogDestination::LogToStderr(); +} + +namespace base { +namespace internal { + +bool GetExitOnDFatal(); +bool GetExitOnDFatal() { + MutexLock l(&log_mutex); + return exit_on_dfatal; +} + +// Determines whether we exit the program for a LOG(DFATAL) message in +// debug mode. It does this by skipping the call to Fail/FailQuietly. +// This is intended for testing only. +// +// This can have some effects on LOG(FATAL) as well. Failure messages +// are always allocated (rather than sharing a buffer), the crash +// reason is not recorded, the "gwq" status message is not updated, +// and the stack trace is not recorded. The LOG(FATAL) *will* still +// exit the program. Since this function is used only in testing, +// these differences are acceptable. +void SetExitOnDFatal(bool value); +void SetExitOnDFatal(bool value) { + MutexLock l(&log_mutex); + exit_on_dfatal = value; +} + +} // namespace internal +} // namespace base + +#ifndef GLOG_OS_EMSCRIPTEN +// Shell-escaping as we need to shell out ot /bin/mail. +static const char kDontNeedShellEscapeChars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+-_.=/:,@"; + +static string ShellEscape(const string& src) { + string result; + if (!src.empty() && // empty string needs quotes + src.find_first_not_of(kDontNeedShellEscapeChars) == string::npos) { + // only contains chars that don't need quotes; it's fine + result.assign(src); + } else if (src.find_first_of('\'') == string::npos) { + // no single quotes; just wrap it in single quotes + result.assign("'"); + result.append(src); + result.append("'"); + } else { + // needs double quote escaping + result.assign("\""); + for (size_t i = 0; i < src.size(); ++i) { + switch (src[i]) { + case '\\': + case '$': + case '"': + case '`': + result.append("\\"); + } + result.append(src, i, 1); + } + result.append("\""); + } + return result; +} +#endif + +// use_logging controls whether the logging functions LOG/VLOG are used +// to log errors. It should be set to false when the caller holds the +// log_mutex. +static bool SendEmailInternal(const char*dest, const char *subject, + const char*body, bool use_logging) { +#ifndef GLOG_OS_EMSCRIPTEN + if (dest && *dest) { + if ( use_logging ) { + VLOG(1) << "Trying to send TITLE:" << subject + << " BODY:" << body << " to " << dest; + } else { + fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n", + subject, body, dest); + } + + string logmailer = FLAGS_logmailer; + if (logmailer.empty()) { + logmailer = "/bin/mail"; + } + string cmd = + logmailer + " -s" + + ShellEscape(subject) + " " + ShellEscape(dest); + if (use_logging) { + VLOG(4) << "Mailing command: " << cmd; + } + + FILE* pipe = popen(cmd.c_str(), "w"); + if (pipe != nullptr) { + // Add the body if we have one + if (body) { + fwrite(body, sizeof(char), strlen(body), pipe); + } + bool ok = pclose(pipe) != -1; + if ( !ok ) { + if ( use_logging ) { + LOG(ERROR) << "Problems sending mail to " << dest << ": " + << StrError(errno); + } else { + fprintf(stderr, "Problems sending mail to %s: %s\n", + dest, StrError(errno).c_str()); + } + } + return ok; + } else { + if ( use_logging ) { + LOG(ERROR) << "Unable to send mail to " << dest; + } else { + fprintf(stderr, "Unable to send mail to %s\n", dest); + } + } + } +#else + (void)dest; + (void)subject; + (void)body; + (void)use_logging; + LOG(WARNING) << "Email support not available; not sending message"; +#endif + return false; +} + +bool SendEmail(const char*dest, const char *subject, const char*body){ + return SendEmailInternal(dest, subject, body, true); +} + +static void GetTempDirectories(vector* list) { + list->clear(); +#ifdef GLOG_OS_WINDOWS + // On windows we'll try to find a directory in this order: + // C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is) + // C:/TMP/ + // C:/TEMP/ + // C:/WINDOWS/ or C:/WINNT/ + // . + char tmp[MAX_PATH]; + if (GetTempPathA(MAX_PATH, tmp)) + list->push_back(tmp); + list->push_back("C:\\tmp\\"); + list->push_back("C:\\temp\\"); +#else + // Directories, in order of preference. If we find a dir that + // exists, we stop adding other less-preferred dirs + const char * candidates[] = { + // Non-null only during unittest/regtest + getenv("TEST_TMPDIR"), + + // Explicitly-supplied temp dirs + getenv("TMPDIR"), getenv("TMP"), + + // If all else fails + "/tmp", + }; + + for (auto d : candidates) { + if (!d) continue; // Empty env var + + // Make sure we don't surprise anyone who's expecting a '/' + string dstr = d; + if (dstr[dstr.size() - 1] != '/') { + dstr += "/"; + } + list->push_back(dstr); + + struct stat statbuf; + if (!stat(d, &statbuf) && S_ISDIR(statbuf.st_mode)) { + // We found a dir that exists - we're done. + return; + } + } + +#endif +} + +static vector* logging_directories_list; + +const vector& GetLoggingDirectories() { + // Not strictly thread-safe but we're called early in InitGoogle(). + if (logging_directories_list == nullptr) { + logging_directories_list = new vector; + + if ( !FLAGS_log_dir.empty() ) { + // A dir was specified, we should use it + logging_directories_list->push_back(FLAGS_log_dir); + } else { + GetTempDirectories(logging_directories_list); +#ifdef GLOG_OS_WINDOWS + char tmp[MAX_PATH]; + if (GetWindowsDirectoryA(tmp, MAX_PATH)) + logging_directories_list->push_back(tmp); + logging_directories_list->push_back(".\\"); +#else + logging_directories_list->push_back("./"); +#endif + } + } + return *logging_directories_list; +} + +void TestOnly_ClearLoggingDirectoriesList() { + fprintf(stderr, "TestOnly_ClearLoggingDirectoriesList should only be " + "called from test code.\n"); + delete logging_directories_list; + logging_directories_list = nullptr; +} + +void GetExistingTempDirectories(vector* list) { + GetTempDirectories(list); + auto i_dir = list->begin(); + while( i_dir != list->end() ) { + // zero arg to access means test for existence; no constant + // defined on windows + if ( access(i_dir->c_str(), 0) ) { + i_dir = list->erase(i_dir); + } else { + ++i_dir; + } + } +} + +void TruncateLogFile(const char *path, uint64 limit, uint64 keep) { +#ifdef HAVE_UNISTD_H + struct stat statbuf; + const int kCopyBlockSize = 8 << 10; + char copybuf[kCopyBlockSize]; + off_t read_offset, write_offset; + // Don't follow symlinks unless they're our own fd symlinks in /proc + int flags = O_RDWR; + // TODO(hamaji): Support other environments. +#ifdef GLOG_OS_LINUX + const char *procfd_prefix = "/proc/self/fd/"; + if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW; +#endif + + int fd = open(path, flags); + if (fd == -1) { + if (errno == EFBIG) { + // The log file in question has got too big for us to open. The + // real fix for this would be to compile logging.cc (or probably + // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's + // rather scary. + // Instead just truncate the file to something we can manage + if (truncate(path, 0) == -1) { + PLOG(ERROR) << "Unable to truncate " << path; + } else { + LOG(ERROR) << "Truncated " << path << " due to EFBIG error"; + } + } else { + PLOG(ERROR) << "Unable to open " << path; + } + return; + } + + if (fstat(fd, &statbuf) == -1) { + PLOG(ERROR) << "Unable to fstat()"; + goto out_close_fd; + } + + // See if the path refers to a regular file bigger than the + // specified limit + if (!S_ISREG(statbuf.st_mode)) goto out_close_fd; + if (statbuf.st_size <= static_cast(limit)) goto out_close_fd; + if (statbuf.st_size <= static_cast(keep)) goto out_close_fd; + + // This log file is too large - we need to truncate it + LOG(INFO) << "Truncating " << path << " to " << keep << " bytes"; + + // Copy the last "keep" bytes of the file to the beginning of the file + read_offset = statbuf.st_size - static_cast(keep); + write_offset = 0; + ssize_t bytesin, bytesout; + while ((bytesin = pread(fd, copybuf, sizeof(copybuf), read_offset)) > 0) { + bytesout = pwrite(fd, copybuf, static_cast(bytesin), write_offset); + if (bytesout == -1) { + PLOG(ERROR) << "Unable to write to " << path; + break; + } else if (bytesout != bytesin) { + LOG(ERROR) << "Expected to write " << bytesin << ", wrote " << bytesout; + } + read_offset += bytesin; + write_offset += bytesout; + } + if (bytesin == -1) PLOG(ERROR) << "Unable to read from " << path; + + // Truncate the remainder of the file. If someone else writes to the + // end of the file after our last read() above, we lose their latest + // data. Too bad ... + if (ftruncate(fd, write_offset) == -1) { + PLOG(ERROR) << "Unable to truncate " << path; + } + + out_close_fd: + close(fd); +#else + LOG(ERROR) << "No log truncation support."; +#endif + } + +void TruncateStdoutStderr() { +#ifdef HAVE_UNISTD_H + uint64 limit = MaxLogSize() << 20U; + uint64 keep = 1U << 20U; + TruncateLogFile("/proc/self/fd/1", limit, keep); + TruncateLogFile("/proc/self/fd/2", limit, keep); +#else + LOG(ERROR) << "No log truncation support."; +#endif +} + + +// Helper functions for string comparisons. +#define DEFINE_CHECK_STROP_IMPL(name, func, expected) \ + string* Check##func##expected##Impl(const char* s1, const char* s2, \ + const char* names) { \ + bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \ + if (equal == expected) \ + return nullptr; \ + else { \ + ostringstream ss; \ + if (!s1) s1 = ""; \ + if (!s2) s2 = ""; \ + ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \ + return new string(ss.str()); \ + } \ + } +DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true) +DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false) +DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true) +DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false) +#undef DEFINE_CHECK_STROP_IMPL + +int posix_strerror_r(int err, char *buf, size_t len) { + // Sanity check input parameters + if (buf == nullptr || len <= 0) { + errno = EINVAL; + return -1; + } + + // Reset buf and errno, and try calling whatever version of strerror_r() + // is implemented by glibc + buf[0] = '\000'; + int old_errno = errno; + errno = 0; + char *rc = reinterpret_cast(strerror_r(err, buf, len)); + + // Both versions set errno on failure + if (errno) { + // Should already be there, but better safe than sorry + buf[0] = '\000'; + return -1; + } + errno = old_errno; + + // POSIX is vague about whether the string will be terminated, although + // is indirectly implies that typically ERANGE will be returned, instead + // of truncating the string. This is different from the GNU implementation. + // We play it safe by always terminating the string explicitly. + buf[len-1] = '\000'; + + // If the function succeeded, we can use its exit code to determine the + // semantics implemented by glibc + if (!rc) { + return 0; + } else { + // GNU semantics detected + if (rc == buf) { + return 0; + } else { + buf[0] = '\000'; +#if defined(GLOG_OS_MACOSX) || defined(GLOG_OS_FREEBSD) || defined(GLOG_OS_OPENBSD) + if (reinterpret_cast(rc) < sys_nerr) { + // This means an error on MacOSX or FreeBSD. + return -1; + } +#endif + strncat(buf, rc, len-1); + return 0; + } + } +} + +string StrError(int err) { + char buf[100]; + int rc = posix_strerror_r(err, buf, sizeof(buf)); + if ((rc < 0) || (buf[0] == '\000')) { + snprintf(buf, sizeof(buf), "Error number %d", err); + } + return buf; +} + +LogMessageFatal::LogMessageFatal(const char* file, int line) : + LogMessage(file, line, GLOG_FATAL) {} + +LogMessageFatal::LogMessageFatal(const char* file, int line, + const CheckOpString& result) : + LogMessage(file, line, result) {} + +LogMessageFatal::~LogMessageFatal() { + Flush(); + LogMessage::Fail(); +} + +namespace base { + +CheckOpMessageBuilder::CheckOpMessageBuilder(const char *exprtext) + : stream_(new ostringstream) { + *stream_ << exprtext << " ("; +} + +CheckOpMessageBuilder::~CheckOpMessageBuilder() { + delete stream_; +} + +ostream* CheckOpMessageBuilder::ForVar2() { + *stream_ << " vs. "; + return stream_; +} + +string* CheckOpMessageBuilder::NewString() { + *stream_ << ")"; + return new string(stream_->str()); +} + +} // namespace base + +template <> +void MakeCheckOpValueString(std::ostream* os, const char& v) { + if (v >= 32 && v <= 126) { + (*os) << "'" << v << "'"; + } else { + (*os) << "char value " << static_cast(v); + } +} + +template <> +void MakeCheckOpValueString(std::ostream* os, const signed char& v) { + if (v >= 32 && v <= 126) { + (*os) << "'" << v << "'"; + } else { + (*os) << "signed char value " << static_cast(v); + } +} + +template <> +void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) { + if (v >= 32 && v <= 126) { + (*os) << "'" << v << "'"; + } else { + (*os) << "unsigned char value " << static_cast(v); + } +} + +template <> +void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& /*v*/) { + (*os) << "nullptr"; +} + +void InitGoogleLogging(const char* argv0) { + glog_internal_namespace_::InitGoogleLoggingUtilities(argv0); +} + +void InitGoogleLogging(const char* argv0, + CustomPrefixCallback prefix_callback, + void* prefix_callback_data) { + custom_prefix_callback = prefix_callback; + custom_prefix_callback_data = prefix_callback_data; + InitGoogleLogging(argv0); +} + +void ShutdownGoogleLogging() { + glog_internal_namespace_::ShutdownGoogleLoggingUtilities(); + LogDestination::DeleteLogDestinations(); + delete logging_directories_list; + logging_directories_list = nullptr; +} + +void EnableLogCleaner(unsigned int overdue_days) { + log_cleaner.Enable(overdue_days); +} + +void DisableLogCleaner() { + log_cleaner.Disable(); +} + +LogMessageTime::LogMessageTime() + : time_struct_(), timestamp_(0), usecs_(0), gmtoffset_(0) {} + +LogMessageTime::LogMessageTime(std::tm t) { + std::time_t timestamp = std::mktime(&t); + init(t, timestamp, 0); +} + +LogMessageTime::LogMessageTime(std::time_t timestamp, WallTime now) { + std::tm t; + if (FLAGS_log_utc_time) { + gmtime_r(×tamp, &t); + } else { + localtime_r(×tamp, &t); + } + init(t, timestamp, now); +} + +void LogMessageTime::init(const std::tm& t, std::time_t timestamp, + WallTime now) { + time_struct_ = t; + timestamp_ = timestamp; + usecs_ = static_cast((now - timestamp) * 1000000); + + CalcGmtOffset(); +} + +void LogMessageTime::CalcGmtOffset() { + std::tm gmt_struct; + int isDst = 0; + if ( FLAGS_log_utc_time ) { + localtime_r(×tamp_, &gmt_struct); + isDst = gmt_struct.tm_isdst; + gmt_struct = time_struct_; + } else { + isDst = time_struct_.tm_isdst; + gmtime_r(×tamp_, &gmt_struct); + } + + time_t gmt_sec = mktime(&gmt_struct); + const long hour_secs = 3600; + // If the Daylight Saving Time(isDst) is active subtract an hour from the current timestamp. + gmtoffset_ = static_cast(timestamp_ - gmt_sec + (isDst ? hour_secs : 0) ) ; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_striplog_test.sh b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striplog_test.sh new file mode 100755 index 000000000..73492bda7 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striplog_test.sh @@ -0,0 +1,79 @@ +#! /bin/sh +# +# Copyright (c) 2007, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Author: Sergey Ioffe + +get_strings () { + if test -e ".libs/$1"; then + binary=".libs/$1" + elif test -e "$1.exe"; then + binary="$1.exe" + else + echo "We coundn't find $1 binary." + exit 1 + fi + + strings -n 10 $binary | sort | awk '/TESTMESSAGE/ {printf "%s ", $2}' +} + +# Die if "$1" != "$2", print $3 as death reason +check_eq () { + if [ "$1" != "$2" ]; then + echo "Check failed: '$1' == '$2' ${3:+ ($3)}" + exit 1 + fi +} + +die () { + echo $1 + exit 1 +} + +# Check that the string literals are appropriately stripped. This will +# not be the case in debug mode. + +mode=`GLOG_check_mode=1 ./logging_striptest0 2> /dev/null` +if [ "$mode" = "opt" ]; +then + echo "In OPT mode" + check_eq "`get_strings logging_striptest0`" "COND ERROR FATAL INFO USAGE WARNING " + check_eq "`get_strings logging_striptest2`" "COND ERROR FATAL USAGE " + check_eq "`get_strings logging_striptest10`" "" +else + echo "In DBG mode; not checking strings" +fi + +# Check that LOG(FATAL) aborts even for large STRIP_LOG + +./logging_striptest2 2>/dev/null && die "Did not abort for STRIP_LOG=2" +./logging_striptest10 2>/dev/null && die "Did not abort for STRIP_LOG=10" + +echo "PASS" diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest10.cc b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest10.cc new file mode 100644 index 000000000..f6e1078f3 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest10.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sergey Ioffe + +#define GOOGLE_STRIP_LOG 10 + +// Include the actual test. +#include "logging_striptest_main.cc" diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest2.cc b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest2.cc new file mode 100644 index 000000000..a64685c9e --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest2.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sergey Ioffe + +#define GOOGLE_STRIP_LOG 2 + +// Include the actual test. +#include "logging_striptest_main.cc" diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest_main.cc b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest_main.cc new file mode 100644 index 000000000..27e12544e --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_striptest_main.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Sergey Ioffe + +// The common part of the striplog tests. + +#include +#include +#include +#include +#include "base/commandlineflags.h" +#include "config.h" + +DECLARE_bool(logtostderr); +GLOG_DEFINE_bool(check_mode, false, "Prints 'opt' or 'dbg'"); + +using std::string; +using namespace GOOGLE_NAMESPACE; + +int CheckNoReturn(bool b) { + string s; + if (b) { + LOG(FATAL) << "Fatal"; + } else { + return 0; + } +} + +struct A { }; +std::ostream &operator<<(std::ostream &str, const A&) {return str;} + +int main(int, char* argv[]) { + FLAGS_logtostderr = true; + InitGoogleLogging(argv[0]); + if (FLAGS_check_mode) { + printf("%s\n", DEBUG_MODE ? "dbg" : "opt"); + return 0; + } + LOG(INFO) << "TESTMESSAGE INFO"; + LOG(WARNING) << 2 << "something" << "TESTMESSAGE WARNING" + << 1 << 'c' << A() << std::endl; + LOG(ERROR) << "TESTMESSAGE ERROR"; + bool flag = true; + (flag ? LOG(INFO) : LOG(ERROR)) << "TESTMESSAGE COND"; + LOG(FATAL) << "TESTMESSAGE FATAL"; +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.cc new file mode 100644 index 000000000..61039a36e --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.cc @@ -0,0 +1,1491 @@ +// Copyright (c) 2023, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Ray Sidney + +#include "config.h" +#include "utilities.h" + +#include +#ifdef HAVE_GLOB_H +# include +#endif +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "base/commandlineflags.h" +#include +#include +#include "googletest.h" + +DECLARE_string(log_backtrace_at); // logging.cc + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +#ifdef HAVE_LIB_GMOCK +#include +#include "mock-log.h" +// Introduce several symbols from gmock. +using testing::_; +using testing::AnyNumber; +using testing::HasSubstr; +using testing::AllOf; +using testing::StrNe; +using testing::StrictMock; +using testing::InitGoogleMock; +using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog; +#endif + +using namespace std; +using namespace GOOGLE_NAMESPACE; + +// Some non-advertised functions that we want to test or use. +_START_GOOGLE_NAMESPACE_ +namespace base { +namespace internal { +bool GetExitOnDFatal(); +void SetExitOnDFatal(bool value); +} // namespace internal +} // namespace base +_END_GOOGLE_NAMESPACE_ + +static void TestLogging(bool check_counts); +static void TestRawLogging(); +static void LogWithLevels(int v, int severity, bool err, bool alsoerr); +static void TestLoggingLevels(); +static void TestVLogModule(); +static void TestLogString(); +static void TestLogSink(); +static void TestLogToString(); +static void TestLogSinkWaitTillSent(); +static void TestCHECK(); +static void TestDCHECK(); +static void TestSTREQ(); +static void TestBasename(); +static void TestBasenameAppendWhenNoTimestamp(); +static void TestTwoProcessesWrite(); +static void TestSymlink(); +static void TestExtension(); +static void TestWrapper(); +static void TestErrno(); +static void TestTruncate(); +static void TestCustomLoggerDeletionOnShutdown(); +static void TestLogPeriodically(); + +static int x = -1; +static void BM_Check1(int n) { + while (n-- > 0) { + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + CHECK_GE(n, x); + } +} +BENCHMARK(BM_Check1) + +static void CheckFailure(int a, int b, const char* file, int line, const char* msg); +static void BM_Check3(int n) { + while (n-- > 0) { + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x"); + } +} +BENCHMARK(BM_Check3) + +static void BM_Check2(int n) { + if (n == 17) { + x = 5; + } + while (n-- > 0) { + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + CHECK(n >= x); + } +} +BENCHMARK(BM_Check2) + +static void CheckFailure(int, int, const char* /* file */, int /* line */, + const char* /* msg */) { +} + +static void BM_logspeed(int n) { + while (n-- > 0) { + LOG(INFO) << "test message"; + } +} +BENCHMARK(BM_logspeed) + +static void BM_vlog(int n) { + while (n-- > 0) { + VLOG(1) << "test message"; + } +} +BENCHMARK(BM_vlog) + +// Dynamically generate a prefix using the default format and write it to the stream. +void PrefixAttacher(std::ostream &s, const LogMessageInfo &l, void* data) { + // Assert that `data` contains the expected contents before producing the + // prefix (otherwise causing the tests to fail): + if (data == nullptr || *static_cast(data) != "good data") { + return; + } + + s << l.severity[0] + << setw(4) << 1900 + l.time.year() + << setw(2) << 1 + l.time.month() + << setw(2) << l.time.day() + << ' ' + << setw(2) << l.time.hour() << ':' + << setw(2) << l.time.min() << ':' + << setw(2) << l.time.sec() << "." + << setw(6) << l.time.usec() + << ' ' + << setfill(' ') << setw(5) + << l.thread_id << setfill('0') + << ' ' + << l.filename << ':' << l.line_number << "]"; +} + +int main(int argc, char **argv) { + FLAGS_colorlogtostderr = false; + FLAGS_timestamp_in_logfile_name = true; + + // Make sure stderr is not buffered as stderr seems to be buffered + // on recent windows. + setbuf(stderr, nullptr); + + // Test some basics before InitGoogleLogging: + CaptureTestStderr(); + LogWithLevels(FLAGS_v, FLAGS_stderrthreshold, + FLAGS_logtostderr, FLAGS_alsologtostderr); + LogWithLevels(0, 0, false, false); // simulate "before global c-tors" + const string early_stderr = GetCapturedTestStderr(); + + EXPECT_FALSE(IsGoogleLoggingInitialized()); + + // Setting a custom prefix generator (it will use the default format so that + // the golden outputs can be reused): + string prefix_attacher_data = "good data"; + InitGoogleLogging(argv[0], &PrefixAttacher, static_cast(&prefix_attacher_data)); + + EXPECT_TRUE(IsGoogleLoggingInitialized()); + + RunSpecifiedBenchmarks(); + + FLAGS_logtostderr = true; + + InitGoogleTest(&argc, argv); +#ifdef HAVE_LIB_GMOCK + InitGoogleMock(&argc, argv); +#endif + +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + + // so that death tests run before we use threads + CHECK_EQ(RUN_ALL_TESTS(), 0); + + CaptureTestStderr(); + + // re-emit early_stderr + LogMessage("dummy", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << early_stderr; + + TestLogging(true); + TestRawLogging(); + TestLoggingLevels(); + TestVLogModule(); + TestLogString(); + TestLogSink(); + TestLogToString(); + TestLogSinkWaitTillSent(); + TestCHECK(); + TestDCHECK(); + TestSTREQ(); + + // TODO: The golden test portion of this test is very flakey. + EXPECT_TRUE( + MungeAndDiffTestStderr(FLAGS_test_srcdir + "/src/logging_unittest.err")); + + FLAGS_logtostderr = false; + + FLAGS_logtostdout = true; + FLAGS_stderrthreshold = NUM_SEVERITIES; + CaptureTestStdout(); + TestRawLogging(); + TestLoggingLevels(); + TestLogString(); + TestLogSink(); + TestLogToString(); + TestLogSinkWaitTillSent(); + TestCHECK(); + TestDCHECK(); + TestSTREQ(); + EXPECT_TRUE( + MungeAndDiffTestStdout(FLAGS_test_srcdir + "/src/logging_unittest.out")); + FLAGS_logtostdout = false; + + TestBasename(); + TestBasenameAppendWhenNoTimestamp(); + TestTwoProcessesWrite(); + TestSymlink(); + TestExtension(); + TestWrapper(); + TestErrno(); + TestTruncate(); + TestCustomLoggerDeletionOnShutdown(); + TestLogPeriodically(); + + fprintf(stdout, "PASS\n"); + return 0; +} + +void TestLogging(bool check_counts) { + int64 base_num_infos = LogMessage::num_messages(GLOG_INFO); + int64 base_num_warning = LogMessage::num_messages(GLOG_WARNING); + int64 base_num_errors = LogMessage::num_messages(GLOG_ERROR); + + LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4; + for ( int i = 0; i < 10; ++i ) { + int old_errno = errno; + errno = i; + PLOG_EVERY_N(ERROR, 2) << "Plog every 2, iteration " << COUNTER; + errno = old_errno; + + LOG_EVERY_N(ERROR, 3) << "Log every 3, iteration " << COUNTER << endl; + LOG_EVERY_N(ERROR, 4) << "Log every 4, iteration " << COUNTER << endl; + + LOG_IF_EVERY_N(WARNING, true, 5) << "Log if every 5, iteration " << COUNTER; + LOG_IF_EVERY_N(WARNING, false, 3) + << "Log if every 3, iteration " << COUNTER; + LOG_IF_EVERY_N(INFO, true, 1) << "Log if every 1, iteration " << COUNTER; + LOG_IF_EVERY_N(ERROR, (i < 3), 2) + << "Log if less than 3 every 2, iteration " << COUNTER; + } + LOG_IF(WARNING, true) << "log_if this"; + LOG_IF(WARNING, false) << "don't log_if this"; + + char s[] = "array"; + LOG(INFO) << s; + const char const_s[] = "const array"; + LOG(INFO) << const_s; + int j = 1000; + LOG(ERROR) << string("foo") << ' '<< j << ' ' << setw(10) << j << " " + << setw(1) << hex << j; + LOG(INFO) << "foo " << std::setw(10) << 1.0; + + { + google::LogMessage outer(__FILE__, __LINE__, GLOG_ERROR); + outer.stream() << "outer"; + + LOG(ERROR) << "inner"; + } + + LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << "no prefix"; + + if (check_counts) { + CHECK_EQ(base_num_infos + 15, LogMessage::num_messages(GLOG_INFO)); + CHECK_EQ(base_num_warning + 3, LogMessage::num_messages(GLOG_WARNING)); + CHECK_EQ(base_num_errors + 17, LogMessage::num_messages(GLOG_ERROR)); + } +} + +static void NoAllocNewHook() { + LOG(FATAL) << "unexpected new"; +} + +struct NewHook { + NewHook() { + g_new_hook = &NoAllocNewHook; + } + ~NewHook() { g_new_hook = nullptr; } +}; + +TEST(DeathNoAllocNewHook, logging) { + // tests that NewHook used below works + NewHook new_hook; + ASSERT_DEATH({ + new int; + }, "unexpected new"); +} + +void TestRawLogging() { + auto* foo = new string("foo "); + string huge_str(50000, 'a'); + + FlagSaver saver; + + // Check that RAW loggging does not use mallocs. + NewHook new_hook; + + RAW_LOG(INFO, "%s%s%d%c%f", foo->c_str(), "bar ", 10, ' ', 3.4); + char s[] = "array"; + RAW_LOG(WARNING, "%s", s); + const char const_s[] = "const array"; + RAW_LOG(INFO, "%s", const_s); + void* p = reinterpret_cast(PTR_TEST_VALUE); + RAW_LOG(INFO, "ptr %p", p); + p = nullptr; + RAW_LOG(INFO, "ptr %p", p); + int j = 1000; + RAW_LOG(ERROR, "%s%d%c%010d%s%1x", foo->c_str(), j, ' ', j, " ", j); + RAW_VLOG(0, "foo %d", j); + +#if defined(NDEBUG) + RAW_LOG(INFO, "foo %d", j); // so that have same stderr to compare +#else + RAW_DLOG(INFO, "foo %d", j); // test RAW_DLOG in debug mode +#endif + + // test how long messages are chopped: + RAW_LOG(WARNING, "Huge string: %s", huge_str.c_str()); + RAW_VLOG(0, "Huge string: %s", huge_str.c_str()); + + FLAGS_v = 0; + RAW_LOG(INFO, "log"); + RAW_VLOG(0, "vlog 0 on"); + RAW_VLOG(1, "vlog 1 off"); + RAW_VLOG(2, "vlog 2 off"); + RAW_VLOG(3, "vlog 3 off"); + FLAGS_v = 2; + RAW_LOG(INFO, "log"); + RAW_VLOG(1, "vlog 1 on"); + RAW_VLOG(2, "vlog 2 on"); + RAW_VLOG(3, "vlog 3 off"); + +#if defined(NDEBUG) + RAW_DCHECK(1 == 2, " RAW_DCHECK's shouldn't be compiled in normal mode"); +#endif + + RAW_CHECK(1 == 1, "should be ok"); + RAW_DCHECK(true, "should be ok"); + + delete foo; +} + +void LogWithLevels(int v, int severity, bool err, bool alsoerr) { + RAW_LOG(INFO, + "Test: v=%d stderrthreshold=%d logtostderr=%d alsologtostderr=%d", + v, severity, err, alsoerr); + + FlagSaver saver; + + FLAGS_v = v; + FLAGS_stderrthreshold = severity; + FLAGS_logtostderr = err; + FLAGS_alsologtostderr = alsoerr; + + RAW_VLOG(-1, "vlog -1"); + RAW_VLOG(0, "vlog 0"); + RAW_VLOG(1, "vlog 1"); + RAW_LOG(INFO, "log info"); + RAW_LOG(WARNING, "log warning"); + RAW_LOG(ERROR, "log error"); + + VLOG(-1) << "vlog -1"; + VLOG(0) << "vlog 0"; + VLOG(1) << "vlog 1"; + LOG(INFO) << "log info"; + LOG(WARNING) << "log warning"; + LOG(ERROR) << "log error"; + + VLOG_IF(-1, true) << "vlog_if -1"; + VLOG_IF(-1, false) << "don't vlog_if -1"; + VLOG_IF(0, true) << "vlog_if 0"; + VLOG_IF(0, false) << "don't vlog_if 0"; + VLOG_IF(1, true) << "vlog_if 1"; + VLOG_IF(1, false) << "don't vlog_if 1"; + LOG_IF(INFO, true) << "log_if info"; + LOG_IF(INFO, false) << "don't log_if info"; + LOG_IF(WARNING, true) << "log_if warning"; + LOG_IF(WARNING, false) << "don't log_if warning"; + LOG_IF(ERROR, true) << "log_if error"; + LOG_IF(ERROR, false) << "don't log_if error"; + + int c; + c = 1; VLOG_IF(100, c -= 2) << "vlog_if 100 expr"; EXPECT_EQ(c, -1); + c = 1; VLOG_IF(0, c -= 2) << "vlog_if 0 expr"; EXPECT_EQ(c, -1); + c = 1; LOG_IF(INFO, c -= 2) << "log_if info expr"; EXPECT_EQ(c, -1); + c = 1; LOG_IF(ERROR, c -= 2) << "log_if error expr"; EXPECT_EQ(c, -1); + c = 2; VLOG_IF(0, c -= 2) << "don't vlog_if 0 expr"; EXPECT_EQ(c, 0); + c = 2; LOG_IF(ERROR, c -= 2) << "don't log_if error expr"; EXPECT_EQ(c, 0); + + c = 3; LOG_IF_EVERY_N(INFO, c -= 4, 1) << "log_if info every 1 expr"; + EXPECT_EQ(c, -1); + c = 3; LOG_IF_EVERY_N(ERROR, c -= 4, 1) << "log_if error every 1 expr"; + EXPECT_EQ(c, -1); + c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if info every 3 expr"; + EXPECT_EQ(c, 0); + c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if error every 3 expr"; + EXPECT_EQ(c, 0); + c = 5; VLOG_IF_EVERY_N(0, c -= 4, 1) << "vlog_if 0 every 1 expr"; + EXPECT_EQ(c, 1); + c = 5; VLOG_IF_EVERY_N(100, c -= 4, 3) << "vlog_if 100 every 3 expr"; + EXPECT_EQ(c, 1); + c = 6; VLOG_IF_EVERY_N(0, c -= 6, 1) << "don't vlog_if 0 every 1 expr"; + EXPECT_EQ(c, 0); + c = 6; VLOG_IF_EVERY_N(100, c -= 6, 3) << "don't vlog_if 100 every 1 expr"; + EXPECT_EQ(c, 0); +} + +void TestLoggingLevels() { + LogWithLevels(0, GLOG_INFO, false, false); + LogWithLevels(1, GLOG_INFO, false, false); + LogWithLevels(-1, GLOG_INFO, false, false); + LogWithLevels(0, GLOG_WARNING, false, false); + LogWithLevels(0, GLOG_ERROR, false, false); + LogWithLevels(0, GLOG_FATAL, false, false); + LogWithLevels(0, GLOG_FATAL, true, false); + LogWithLevels(0, GLOG_FATAL, false, true); + LogWithLevels(1, GLOG_WARNING, false, false); + LogWithLevels(1, GLOG_FATAL, false, true); +} + +int TestVlogHelper() { + if (VLOG_IS_ON(1)) { + return 1; + } + return 0; +} + +void TestVLogModule() { + int c = TestVlogHelper(); + EXPECT_EQ(0, c); + +#if defined(__GNUC__) + EXPECT_EQ(0, SetVLOGLevel("logging_unittest", 1)); + c = TestVlogHelper(); + EXPECT_EQ(1, c); +#endif +} + +TEST(DeathRawCHECK, logging) { + ASSERT_DEATH(RAW_CHECK(false, "failure 1"), + "RAW: Check false failed: failure 1"); + ASSERT_DEBUG_DEATH(RAW_DCHECK(1 == 2, "failure 2"), + "RAW: Check 1 == 2 failed: failure 2"); +} + +void TestLogString() { + vector errors; + vector* no_errors = nullptr; + + LOG_STRING(INFO, &errors) << "LOG_STRING: " << "collected info"; + LOG_STRING(WARNING, &errors) << "LOG_STRING: " << "collected warning"; + LOG_STRING(ERROR, &errors) << "LOG_STRING: " << "collected error"; + + LOG_STRING(INFO, no_errors) << "LOG_STRING: " << "reported info"; + LOG_STRING(WARNING, no_errors) << "LOG_STRING: " << "reported warning"; + LOG_STRING(ERROR, nullptr) << "LOG_STRING: " + << "reported error"; + + for (auto& error : errors) { + LOG(INFO) << "Captured by LOG_STRING: " << error; + } +} + +void TestLogToString() { + string error; + string* no_error = nullptr; + + LOG_TO_STRING(INFO, &error) << "LOG_TO_STRING: " << "collected info"; + LOG(INFO) << "Captured by LOG_TO_STRING: " << error; + LOG_TO_STRING(WARNING, &error) << "LOG_TO_STRING: " << "collected warning"; + LOG(INFO) << "Captured by LOG_TO_STRING: " << error; + LOG_TO_STRING(ERROR, &error) << "LOG_TO_STRING: " << "collected error"; + LOG(INFO) << "Captured by LOG_TO_STRING: " << error; + + LOG_TO_STRING(INFO, no_error) << "LOG_TO_STRING: " << "reported info"; + LOG_TO_STRING(WARNING, no_error) << "LOG_TO_STRING: " << "reported warning"; + LOG_TO_STRING(ERROR, nullptr) << "LOG_TO_STRING: " + << "reported error"; +} + +class TestLogSinkImpl : public LogSink { + public: + vector errors; + void send(LogSeverity severity, const char* /* full_filename */, + const char* base_filename, int line, + const LogMessageTime& logmsgtime, const char* message, + size_t message_len) override { + errors.push_back( + ToString(severity, base_filename, line, logmsgtime, message, message_len)); + } +}; + +void TestLogSink() { + TestLogSinkImpl sink; + LogSink* no_sink = nullptr; + + LOG_TO_SINK(&sink, INFO) << "LOG_TO_SINK: " << "collected info"; + LOG_TO_SINK(&sink, WARNING) << "LOG_TO_SINK: " << "collected warning"; + LOG_TO_SINK(&sink, ERROR) << "LOG_TO_SINK: " << "collected error"; + + LOG_TO_SINK(no_sink, INFO) << "LOG_TO_SINK: " << "reported info"; + LOG_TO_SINK(no_sink, WARNING) << "LOG_TO_SINK: " << "reported warning"; + LOG_TO_SINK(nullptr, ERROR) << "LOG_TO_SINK: " + << "reported error"; + + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, INFO) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected info"; + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, WARNING) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected warning"; + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, ERROR) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected error"; + + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, INFO) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed info"; + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, WARNING) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed warning"; + LOG_TO_SINK_BUT_NOT_TO_LOGFILE(nullptr, ERROR) + << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " + << "thrashed error"; + + LOG(INFO) << "Captured by LOG_TO_SINK:"; + for (auto& error : sink.errors) { + LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << error; + } +} + +// For testing using CHECK*() on anonymous enums. +enum { + CASE_A, + CASE_B +}; + +void TestCHECK() { + // Tests using CHECK*() on int values. + CHECK(1 == 1); + CHECK_EQ(1, 1); + CHECK_NE(1, 2); + CHECK_GE(1, 1); + CHECK_GE(2, 1); + CHECK_LE(1, 1); + CHECK_LE(1, 2); + CHECK_GT(2, 1); + CHECK_LT(1, 2); + + // Tests using CHECK*() on anonymous enums. + // Apple's GCC doesn't like this. +#if !defined(GLOG_OS_MACOSX) + CHECK_EQ(CASE_A, CASE_A); + CHECK_NE(CASE_A, CASE_B); + CHECK_GE(CASE_A, CASE_A); + CHECK_GE(CASE_B, CASE_A); + CHECK_LE(CASE_A, CASE_A); + CHECK_LE(CASE_A, CASE_B); + CHECK_GT(CASE_B, CASE_A); + CHECK_LT(CASE_A, CASE_B); +#endif +} + +void TestDCHECK() { +#if defined(NDEBUG) + DCHECK( 1 == 2 ) << " DCHECK's shouldn't be compiled in normal mode"; +#endif + DCHECK( 1 == 1 ); + DCHECK_EQ(1, 1); + DCHECK_NE(1, 2); + DCHECK_GE(1, 1); + DCHECK_GE(2, 1); + DCHECK_LE(1, 1); + DCHECK_LE(1, 2); + DCHECK_GT(2, 1); + DCHECK_LT(1, 2); + + auto* orig_ptr = new int64; + int64* ptr = DCHECK_NOTNULL(orig_ptr); + CHECK_EQ(ptr, orig_ptr); + delete orig_ptr; +} + +void TestSTREQ() { + CHECK_STREQ("this", "this"); + CHECK_STREQ(nullptr, nullptr); + CHECK_STRCASEEQ("this", "tHiS"); + CHECK_STRCASEEQ(nullptr, nullptr); + CHECK_STRNE("this", "tHiS"); + CHECK_STRNE("this", nullptr); + CHECK_STRCASENE("this", "that"); + CHECK_STRCASENE(nullptr, "that"); + CHECK_STREQ((string("a")+"b").c_str(), "ab"); + CHECK_STREQ(string("test").c_str(), + (string("te") + string("st")).c_str()); +} + +TEST(DeathSTREQ, logging) { + ASSERT_DEATH(CHECK_STREQ(nullptr, "this"), ""); + ASSERT_DEATH(CHECK_STREQ("this", "siht"), ""); + ASSERT_DEATH(CHECK_STRCASEEQ(nullptr, "siht"), ""); + ASSERT_DEATH(CHECK_STRCASEEQ("this", "siht"), ""); + ASSERT_DEATH(CHECK_STRNE(nullptr, nullptr), ""); + ASSERT_DEATH(CHECK_STRNE("this", "this"), ""); + ASSERT_DEATH(CHECK_STREQ((string("a")+"b").c_str(), "abc"), ""); +} + +TEST(CheckNOTNULL, Simple) { + int64 t; + void *ptr = static_cast(&t); + void *ref = CHECK_NOTNULL(ptr); + EXPECT_EQ(ptr, ref); + CHECK_NOTNULL(reinterpret_cast(ptr)); + CHECK_NOTNULL(reinterpret_cast(ptr)); + CHECK_NOTNULL(reinterpret_cast(ptr)); + CHECK_NOTNULL(reinterpret_cast(ptr)); +} + +TEST(DeathCheckNN, Simple) { + ASSERT_DEATH(CHECK_NOTNULL(static_cast(nullptr)), ""); +} + +// Get list of file names that match pattern +static void GetFiles(const string& pattern, vector* files) { + files->clear(); +#if defined(HAVE_GLOB_H) + glob_t g; + const int r = glob(pattern.c_str(), 0, nullptr, &g); + CHECK((r == 0) || (r == GLOB_NOMATCH)) << ": error matching " << pattern; + for (size_t i = 0; i < g.gl_pathc; i++) { + files->push_back(string(g.gl_pathv[i])); + } + globfree(&g); +#elif defined(GLOG_OS_WINDOWS) + WIN32_FIND_DATAA data; + HANDLE handle = FindFirstFileA(pattern.c_str(), &data); + size_t index = pattern.rfind('\\'); + if (index == string::npos) { + LOG(FATAL) << "No directory separator."; + } + const string dirname = pattern.substr(0, index + 1); + if (handle == INVALID_HANDLE_VALUE) { + // Finding no files is OK. + return; + } + do { + files->push_back(dirname + data.cFileName); + } while (FindNextFileA(handle, &data)); + BOOL result = FindClose(handle); + LOG_SYSRESULT(result != 0); +#else +# error There is no way to do glob. +#endif +} + +// Delete files patching pattern +static void DeleteFiles(const string& pattern) { + vector files; + GetFiles(pattern, &files); + for (auto& file : files) { + CHECK(unlink(file.c_str()) == 0) << ": " << strerror(errno); + } +} + +//check string is in file (or is *NOT*, depending on optional checkInFileOrNot) +static void CheckFile(const string& name, const string& expected_string, const bool checkInFileOrNot = true) { + vector files; + GetFiles(name + "*", &files); + CHECK_EQ(files.size(), 1UL); + + FILE* file = fopen(files[0].c_str(), "r"); + CHECK(file != nullptr) << ": could not open " << files[0]; + char buf[1000]; + while (fgets(buf, sizeof(buf), file) != nullptr) { + char* first = strstr(buf, expected_string.c_str()); + // if first == nullptr, not found. + // Terser than if (checkInFileOrNot && first != nullptr || !check... + if (checkInFileOrNot != (first == nullptr)) { + fclose(file); + return; + } + } + fclose(file); + LOG(FATAL) << "Did " << (checkInFileOrNot? "not " : "") << "find " << expected_string << " in " << files[0]; +} + +static void TestBasename() { + fprintf(stderr, "==== Test setting log file basename\n"); + const string dest = FLAGS_test_tmpdir + "/logging_test_basename"; + DeleteFiles(dest + "*"); + + SetLogDestination(GLOG_INFO, dest.c_str()); + LOG(INFO) << "message to new base"; + FlushLogFiles(GLOG_INFO); + + CheckFile(dest, "message to new base"); + + // Release file handle for the destination file to unlock the file in Windows. + LogToStderr(); + DeleteFiles(dest + "*"); +} + +static void TestBasenameAppendWhenNoTimestamp() { + fprintf(stderr, "==== Test setting log file basename without timestamp and appending properly\n"); + const string dest = FLAGS_test_tmpdir + "/logging_test_basename_append_when_no_timestamp"; + DeleteFiles(dest + "*"); + + ofstream out(dest.c_str()); + out << "test preexisting content" << endl; + out.close(); + + CheckFile(dest, "test preexisting content"); + + FLAGS_timestamp_in_logfile_name=false; + SetLogDestination(GLOG_INFO, dest.c_str()); + LOG(INFO) << "message to new base, appending to preexisting file"; + FlushLogFiles(GLOG_INFO); + FLAGS_timestamp_in_logfile_name=true; + + //if the logging overwrites the file instead of appending it will fail. + CheckFile(dest, "test preexisting content"); + CheckFile(dest, "message to new base, appending to preexisting file"); + + // Release file handle for the destination file to unlock the file in Windows. + LogToStderr(); + DeleteFiles(dest + "*"); +} + +static void TestTwoProcessesWrite() { +// test only implemented for platforms with fork & wait; the actual implementation relies on flock +#if defined(HAVE_SYS_WAIT_H) && defined(HAVE_UNISTD_H) && defined(HAVE_FCNTL) + fprintf(stderr, "==== Test setting log file basename and two processes writing - second should fail\n"); + const string dest = FLAGS_test_tmpdir + "/logging_test_basename_two_processes_writing"; + DeleteFiles(dest + "*"); + + //make both processes write into the same file (easier test) + FLAGS_timestamp_in_logfile_name=false; + SetLogDestination(GLOG_INFO, dest.c_str()); + LOG(INFO) << "message to new base, parent"; + FlushLogFiles(GLOG_INFO); + + pid_t pid = fork(); + CHECK_ERR(pid); + if (pid == 0) { + LOG(INFO) << "message to new base, child - should only appear on STDERR not on the file"; + ShutdownGoogleLogging(); //for children proc + exit(EXIT_SUCCESS); + } else if (pid > 0) { + wait(nullptr); + } + FLAGS_timestamp_in_logfile_name=true; + + CheckFile(dest, "message to new base, parent"); + CheckFile(dest, "message to new base, child - should only appear on STDERR not on the file", false); + + // Release + LogToStderr(); + DeleteFiles(dest + "*"); +#endif +} + +static void TestSymlink() { +#ifndef GLOG_OS_WINDOWS + fprintf(stderr, "==== Test setting log file symlink\n"); + string dest = FLAGS_test_tmpdir + "/logging_test_symlink"; + string sym = FLAGS_test_tmpdir + "/symlinkbase"; + DeleteFiles(dest + "*"); + DeleteFiles(sym + "*"); + + SetLogSymlink(GLOG_INFO, "symlinkbase"); + SetLogDestination(GLOG_INFO, dest.c_str()); + LOG(INFO) << "message to new symlink"; + FlushLogFiles(GLOG_INFO); + CheckFile(sym, "message to new symlink"); + + DeleteFiles(dest + "*"); + DeleteFiles(sym + "*"); +#endif +} + +static void TestExtension() { + fprintf(stderr, "==== Test setting log file extension\n"); + string dest = FLAGS_test_tmpdir + "/logging_test_extension"; + DeleteFiles(dest + "*"); + + SetLogDestination(GLOG_INFO, dest.c_str()); + SetLogFilenameExtension("specialextension"); + LOG(INFO) << "message to new extension"; + FlushLogFiles(GLOG_INFO); + CheckFile(dest, "message to new extension"); + + // Check that file name ends with extension + vector filenames; + GetFiles(dest + "*", &filenames); + CHECK_EQ(filenames.size(), 1UL); + CHECK(strstr(filenames[0].c_str(), "specialextension") != nullptr); + + // Release file handle for the destination file to unlock the file in Windows. + LogToStderr(); + DeleteFiles(dest + "*"); +} + +struct MyLogger : public base::Logger { + string data; + + explicit MyLogger(bool* set_on_destruction) + : set_on_destruction_(set_on_destruction) {} + + ~MyLogger() override { *set_on_destruction_ = true; } + + void Write(bool /* should_flush */, time_t /* timestamp */, + const char* message, size_t length) override { + data.append(message, length); + } + + void Flush() override {} + + uint32 LogSize() override { return data.length(); } + + private: + bool* set_on_destruction_; +}; + +static void TestWrapper() { + fprintf(stderr, "==== Test log wrapper\n"); + + bool custom_logger_deleted = false; + auto* my_logger = new MyLogger(&custom_logger_deleted); + base::Logger* old_logger = base::GetLogger(GLOG_INFO); + base::SetLogger(GLOG_INFO, my_logger); + LOG(INFO) << "Send to wrapped logger"; + CHECK(strstr(my_logger->data.c_str(), "Send to wrapped logger") != nullptr); + FlushLogFiles(GLOG_INFO); + + EXPECT_FALSE(custom_logger_deleted); + base::SetLogger(GLOG_INFO, old_logger); + EXPECT_TRUE(custom_logger_deleted); +} + +static void TestErrno() { + fprintf(stderr, "==== Test errno preservation\n"); + + errno = ENOENT; + TestLogging(false); + CHECK_EQ(errno, ENOENT); +} + +static void TestOneTruncate(const char *path, uint64 limit, uint64 keep, + size_t dsize, size_t ksize, size_t expect) { + int fd; + CHECK_ERR(fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600)); + + const char *discardstr = "DISCARDME!", *keepstr = "KEEPME!"; + const size_t discard_size = strlen(discardstr), keep_size = strlen(keepstr); + + // Fill the file with the requested data; first discard data, then kept data + size_t written = 0; + while (written < dsize) { + size_t bytes = min(dsize - written, discard_size); + CHECK_ERR(write(fd, discardstr, bytes)); + written += bytes; + } + written = 0; + while (written < ksize) { + size_t bytes = min(ksize - written, keep_size); + CHECK_ERR(write(fd, keepstr, bytes)); + written += bytes; + } + + TruncateLogFile(path, limit, keep); + + // File should now be shorter + struct stat statbuf; + CHECK_ERR(fstat(fd, &statbuf)); + CHECK_EQ(static_cast(statbuf.st_size), expect); + CHECK_ERR(lseek(fd, 0, SEEK_SET)); + + // File should contain the suffix of the original file + const size_t buf_size = static_cast(statbuf.st_size) + 1; + char* buf = new char[buf_size]; + memset(buf, 0, buf_size); + CHECK_ERR(read(fd, buf, buf_size)); + + const char* p = buf; + size_t checked = 0; + while (checked < expect) { + size_t bytes = min(expect - checked, keep_size); + CHECK(!memcmp(p, keepstr, bytes)); + checked += bytes; + } + close(fd); + delete[] buf; +} + +static void TestTruncate() { +#ifdef HAVE_UNISTD_H + fprintf(stderr, "==== Test log truncation\n"); + string path = FLAGS_test_tmpdir + "/truncatefile"; + + // Test on a small file + TestOneTruncate(path.c_str(), 10, 10, 10, 10, 10); + + // And a big file (multiple blocks to copy) + TestOneTruncate(path.c_str(), 2U << 20U, 4U << 10U, 3U << 20U, 4U << 10U, + 4U << 10U); + + // Check edge-case limits + TestOneTruncate(path.c_str(), 10, 20, 0, 20, 20); + TestOneTruncate(path.c_str(), 10, 0, 0, 0, 0); + TestOneTruncate(path.c_str(), 10, 50, 0, 10, 10); + TestOneTruncate(path.c_str(), 50, 100, 0, 30, 30); + + // MacOSX 10.4 doesn't fail in this case. + // Windows doesn't have symlink. + // Let's just ignore this test for these cases. +#if !defined(GLOG_OS_MACOSX) && !defined(GLOG_OS_WINDOWS) + // Through a symlink should fail to truncate + string linkname = path + ".link"; + unlink(linkname.c_str()); + CHECK_ERR(symlink(path.c_str(), linkname.c_str())); + TestOneTruncate(linkname.c_str(), 10, 10, 0, 30, 30); +#endif + + // The /proc/self path makes sense only for linux. +#if defined(GLOG_OS_LINUX) + // Through an open fd symlink should work + int fd; + CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY)); + char fdpath[64]; + snprintf(fdpath, sizeof(fdpath), "/proc/self/fd/%d", fd); + TestOneTruncate(fdpath, 10, 10, 10, 10, 10); +#endif + +#endif +} + +struct RecordDeletionLogger : public base::Logger { + RecordDeletionLogger(bool* set_on_destruction, + base::Logger* wrapped_logger) : + set_on_destruction_(set_on_destruction), + wrapped_logger_(wrapped_logger) + { + *set_on_destruction_ = false; + } + ~RecordDeletionLogger() override { *set_on_destruction_ = true; } + void Write(bool force_flush, time_t timestamp, const char* message, + size_t length) override { + wrapped_logger_->Write(force_flush, timestamp, message, length); + } + void Flush() override { wrapped_logger_->Flush(); } + uint32 LogSize() override { return wrapped_logger_->LogSize(); } + + private: + bool* set_on_destruction_; + base::Logger* wrapped_logger_; +}; + +static void TestCustomLoggerDeletionOnShutdown() { + bool custom_logger_deleted = false; + base::SetLogger(GLOG_INFO, + new RecordDeletionLogger(&custom_logger_deleted, + base::GetLogger(GLOG_INFO))); + EXPECT_TRUE(IsGoogleLoggingInitialized()); + ShutdownGoogleLogging(); + EXPECT_TRUE(custom_logger_deleted); + EXPECT_FALSE(IsGoogleLoggingInitialized()); +} + +namespace LogTimes { +// Log a "message" every 10ms, 10 times. These numbers are nice compromise +// between total running time of 100ms and the period of 10ms. The period is +// large enough such that any CPU and OS scheduling variation shouldn't affect +// the results from the ideal case by more than 5% (500us or 0.5ms) +constexpr int64_t LOG_PERIOD_NS = 10000000; // 10ms +constexpr int64_t LOG_PERIOD_TOL_NS = 500000; // 500us + +// Set an upper limit for the number of times the stream operator can be +// called. Make sure not to exceed this number of times the stream operator is +// called, since it is also the array size and will be indexed by the stream +// operator. +constexpr size_t MAX_CALLS = 10; +} // namespace LogTimes + +struct LogTimeRecorder { + LogTimeRecorder() = default; + size_t m_streamTimes{0}; + std::chrono::steady_clock::time_point m_callTimes[LogTimes::MAX_CALLS]; +}; +// The stream operator is called by LOG_EVERY_T every time a logging event +// occurs. Make sure to save the times for each call as they will be used later +// to verify the time delta between each call. +std::ostream& operator<<(std::ostream& stream, LogTimeRecorder& t) { + t.m_callTimes[t.m_streamTimes++] = std::chrono::steady_clock::now(); + return stream; +} +// get elapsed time in nanoseconds +int64 elapsedTime_ns(const std::chrono::steady_clock::time_point& begin, + const std::chrono::steady_clock::time_point& end) { + return std::chrono::duration_cast((end - begin)) + .count(); +} + +static void TestLogPeriodically() { + fprintf(stderr, "==== Test log periodically\n"); + + LogTimeRecorder timeLogger; + + constexpr double LOG_PERIOD_SEC = LogTimes::LOG_PERIOD_NS * 1e-9; + + while (timeLogger.m_streamTimes < LogTimes::MAX_CALLS) { + LOG_EVERY_T(INFO, LOG_PERIOD_SEC) + << timeLogger << "Timed Message #" << timeLogger.m_streamTimes; + } + + // Calculate time between each call in nanoseconds for higher resolution to + // minimize error. + int64 nsBetweenCalls[LogTimes::MAX_CALLS - 1]; + for (size_t i = 1; i < LogTimes::MAX_CALLS; ++i) { + nsBetweenCalls[i - 1] = elapsedTime_ns( + timeLogger.m_callTimes[i - 1], timeLogger.m_callTimes[i]); + } + + for (long time_ns : nsBetweenCalls) { + EXPECT_NEAR(time_ns, LogTimes::LOG_PERIOD_NS, LogTimes::LOG_PERIOD_TOL_NS); + } +} + +_START_GOOGLE_NAMESPACE_ +namespace glog_internal_namespace_ { +extern // in logging.cc +bool SafeFNMatch_(const char* pattern, size_t patt_len, + const char* str, size_t str_len); +} // namespace glog_internal_namespace_ +using glog_internal_namespace_::SafeFNMatch_; +_END_GOOGLE_NAMESPACE_ + +static bool WrapSafeFNMatch(string pattern, string str) { + pattern += "abc"; + str += "defgh"; + return SafeFNMatch_(pattern.data(), pattern.size() - 3, + str.data(), str.size() - 5); +} + +TEST(SafeFNMatch, logging) { + CHECK(WrapSafeFNMatch("foo", "foo")); + CHECK(!WrapSafeFNMatch("foo", "bar")); + CHECK(!WrapSafeFNMatch("foo", "fo")); + CHECK(!WrapSafeFNMatch("foo", "foo2")); + CHECK(WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext")); + CHECK(WrapSafeFNMatch("*ba*r/fo*o.ext*", "bar/foo.ext")); + CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/baz.ext")); + CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo")); + CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext.zip")); + CHECK(WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext")); + CHECK(WrapSafeFNMatch("ba?/*.ext", "baZ/FOO.ext")); + CHECK(!WrapSafeFNMatch("ba?/*.ext", "barr/foo.ext")); + CHECK(!WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext2")); + CHECK(WrapSafeFNMatch("ba?/*", "bar/foo.ext2")); + CHECK(WrapSafeFNMatch("ba?/*", "bar/")); + CHECK(!WrapSafeFNMatch("ba?/?", "bar/")); + CHECK(!WrapSafeFNMatch("ba?/*", "bar")); +} + +// TestWaitingLogSink will save messages here +// No lock: Accessed only by TestLogSinkWriter thread +// and after its demise by its creator. +static vector global_messages; + +// helper for TestWaitingLogSink below. +// Thread that does the logic of TestWaitingLogSink +// It's free to use LOG() itself. +class TestLogSinkWriter : public Thread { + public: + TestLogSinkWriter() { + SetJoinable(true); + Start(); + } + + // Just buffer it (can't use LOG() here). + void Buffer(const string& message) { + mutex_.Lock(); + RAW_LOG(INFO, "Buffering"); + messages_.push(message); + mutex_.Unlock(); + RAW_LOG(INFO, "Buffered"); + } + + // Wait for the buffer to clear (can't use LOG() here). + void Wait() { + RAW_LOG(INFO, "Waiting"); + mutex_.Lock(); + while (!NoWork()) { + mutex_.Unlock(); + SleepForMilliseconds(1); + mutex_.Lock(); + } + RAW_LOG(INFO, "Waited"); + mutex_.Unlock(); + } + + // Trigger thread exit. + void Stop() { + MutexLock l(&mutex_); + should_exit_ = true; + } + + private: + + // helpers --------------- + + // For creating a "Condition". + bool NoWork() { return messages_.empty(); } + bool HaveWork() { return !messages_.empty() || should_exit_; } + + // Thread body; CAN use LOG() here! + void Run() override { + while (true) { + mutex_.Lock(); + while (!HaveWork()) { + mutex_.Unlock(); + SleepForMilliseconds(1); + mutex_.Lock(); + } + if (should_exit_ && messages_.empty()) { + mutex_.Unlock(); + break; + } + // Give the main thread time to log its message, + // so that we get a reliable log capture to compare to golden file. + // Same for the other sleep below. + SleepForMilliseconds(20); + RAW_LOG(INFO, "Sink got a messages"); // only RAW_LOG under mutex_ here + string message = messages_.front(); + messages_.pop(); + // Normally this would be some more real/involved logging logic + // where LOG() usage can't be eliminated, + // e.g. pushing the message over with an RPC: + size_t messages_left = messages_.size(); + mutex_.Unlock(); + SleepForMilliseconds(20); + // May not use LOG while holding mutex_, because Buffer() + // acquires mutex_, and Buffer is called from LOG(), + // which has its own internal mutex: + // LOG()->LogToSinks()->TestWaitingLogSink::send()->Buffer() + LOG(INFO) << "Sink is sending out a message: " << message; + LOG(INFO) << "Have " << messages_left << " left"; + global_messages.push_back(message); + } + } + + // data --------------- + + Mutex mutex_; + bool should_exit_{false}; + queue messages_; // messages to be logged +}; + +// A log sink that exercises WaitTillSent: +// it pushes data to a buffer and wakes up another thread to do the logging +// (that other thread can than use LOG() itself), +class TestWaitingLogSink : public LogSink { + public: + + TestWaitingLogSink() { + tid_ = pthread_self(); // for thread-specific behavior + AddLogSink(this); + } + ~TestWaitingLogSink() override { + RemoveLogSink(this); + writer_.Stop(); + writer_.Join(); + } + + // (re)define LogSink interface + + void send(LogSeverity severity, const char* /* full_filename */, + const char* base_filename, int line, + const LogMessageTime& logmsgtime, const char* message, + size_t message_len) override { + // Push it to Writer thread if we are the original logging thread. + // Note: Something like ThreadLocalLogSink is a better choice + // to do thread-specific LogSink logic for real. + if (pthread_equal(tid_, pthread_self())) { + writer_.Buffer(ToString(severity, base_filename, line, + logmsgtime, message, message_len)); + } + } + + void WaitTillSent() override { + // Wait for Writer thread if we are the original logging thread. + if (pthread_equal(tid_, pthread_self())) writer_.Wait(); + } + + private: + + pthread_t tid_; + TestLogSinkWriter writer_; +}; + +// Check that LogSink::WaitTillSent can be used in the advertised way. +// We also do golden-stderr comparison. +static void TestLogSinkWaitTillSent() { + // Clear global_messages here to make sure that this test case can be + // reentered + global_messages.clear(); + { TestWaitingLogSink sink; + // Sleeps give the sink threads time to do all their work, + // so that we get a reliable log capture to compare to the golden file. + LOG(INFO) << "Message 1"; + SleepForMilliseconds(60); + LOG(ERROR) << "Message 2"; + SleepForMilliseconds(60); + LOG(WARNING) << "Message 3"; + SleepForMilliseconds(60); + } + for (auto& global_message : global_messages) { + LOG(INFO) << "Sink capture: " << global_message; + } + CHECK_EQ(global_messages.size(), 3UL); +} + +TEST(Strerror, logging) { + int errcode = EINTR; + char *msg = strdup(strerror(errcode)); + const size_t buf_size = strlen(msg) + 1; + char *buf = new char[buf_size]; + CHECK_EQ(posix_strerror_r(errcode, nullptr, 0), -1); + buf[0] = 'A'; + CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1); + CHECK_EQ(buf[0], 'A'); + CHECK_EQ(posix_strerror_r(errcode, nullptr, buf_size), -1); +#if defined(GLOG_OS_MACOSX) || defined(GLOG_OS_FREEBSD) || defined(GLOG_OS_OPENBSD) + // MacOSX or FreeBSD considers this case is an error since there is + // no enough space. + CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1); +#else + CHECK_EQ(posix_strerror_r(errcode, buf, 1), 0); +#endif + CHECK_STREQ(buf, ""); + CHECK_EQ(posix_strerror_r(errcode, buf, buf_size), 0); + CHECK_STREQ(buf, msg); + delete[] buf; + CHECK_EQ(msg, StrError(errcode)); + free(msg); +} + +// Simple routines to look at the sizes of generated code for LOG(FATAL) and +// CHECK(..) via objdump +/* +static void MyFatal() { + LOG(FATAL) << "Failed"; +} +static void MyCheck(bool a, bool b) { + CHECK_EQ(a, b); +} +*/ +#ifdef HAVE_LIB_GMOCK + +TEST(DVLog, Basic) { + ScopedMockLog log; + +#if defined(NDEBUG) + // We are expecting that nothing is logged. + EXPECT_CALL(log, Log(_, _, _)).Times(0); +#else + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "debug log")); +#endif + + FLAGS_v = 1; + DVLOG(1) << "debug log"; +} + +TEST(DVLog, V0) { + ScopedMockLog log; + + // We are expecting that nothing is logged. + EXPECT_CALL(log, Log(_, _, _)).Times(0); + + FLAGS_v = 0; + DVLOG(1) << "debug log"; +} + +TEST(LogAtLevel, Basic) { + ScopedMockLog log; + + // The function version outputs "logging.h" as a file name. + EXPECT_CALL(log, Log(GLOG_WARNING, StrNe(__FILE__), "function version")); + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "macro version")); + + int severity = GLOG_WARNING; + LogAtLevel(severity, "function version"); + + severity = GLOG_INFO; + // We can use the macro version as a C++ stream. + LOG_AT_LEVEL(severity) << "macro" << ' ' << "version"; +} + +TEST(TestExitOnDFatal, ToBeOrNotToBe) { + // Check the default setting... + EXPECT_TRUE(base::internal::GetExitOnDFatal()); + + // Turn off... + base::internal::SetExitOnDFatal(false); + EXPECT_FALSE(base::internal::GetExitOnDFatal()); + + // We don't die. + { + ScopedMockLog log; + //EXPECT_CALL(log, Log(_, _, _)).Times(AnyNumber()); + // LOG(DFATAL) has severity FATAL if debugging, but is + // downgraded to ERROR if not debugging. + const LogSeverity severity = +#if defined(NDEBUG) + GLOG_ERROR; +#else + GLOG_FATAL; +#endif + EXPECT_CALL(log, Log(severity, __FILE__, "This should not be fatal")); + LOG(DFATAL) << "This should not be fatal"; + } + + // Turn back on... + base::internal::SetExitOnDFatal(true); + EXPECT_TRUE(base::internal::GetExitOnDFatal()); + +#ifdef GTEST_HAS_DEATH_TEST + // Death comes on little cats' feet. + EXPECT_DEBUG_DEATH({ + LOG(DFATAL) << "This should be fatal in debug mode"; + }, "This should be fatal in debug mode"); +#endif +} + +#ifdef HAVE_STACKTRACE + +static void BacktraceAtHelper() { + LOG(INFO) << "Not me"; + +// The vertical spacing of the next 3 lines is significant. + LOG(INFO) << "Backtrace me"; +} +static int kBacktraceAtLine = __LINE__ - 2; // The line of the LOG(INFO) above + +TEST(LogBacktraceAt, DoesNotBacktraceWhenDisabled) { + StrictMock log; + + FLAGS_log_backtrace_at = ""; + + EXPECT_CALL(log, Log(_, _, "Backtrace me")); + EXPECT_CALL(log, Log(_, _, "Not me")); + + BacktraceAtHelper(); +} + +TEST(LogBacktraceAt, DoesBacktraceAtRightLineWhenEnabled) { + StrictMock log; + + char where[100]; + snprintf(where, 100, "%s:%d", const_basename(__FILE__), kBacktraceAtLine); + FLAGS_log_backtrace_at = where; + + // The LOG at the specified line should include a stacktrace which includes + // the name of the containing function, followed by the log message. + // We use HasSubstr()s instead of ContainsRegex() for environments + // which don't have regexp. + EXPECT_CALL(log, Log(_, _, AllOf(HasSubstr("stacktrace:"), + HasSubstr("BacktraceAtHelper"), + HasSubstr("main"), + HasSubstr("Backtrace me")))); + // Other LOGs should not include a backtrace. + EXPECT_CALL(log, Log(_, _, "Not me")); + + BacktraceAtHelper(); +} + +#endif // HAVE_STACKTRACE + +#endif // HAVE_LIB_GMOCK + +struct UserDefinedClass { + bool operator==(const UserDefinedClass&) const { return true; } +}; + +inline ostream& operator<<(ostream& out, const UserDefinedClass&) { + out << "OK"; + return out; +} + +TEST(UserDefinedClass, logging) { + UserDefinedClass u; + vector buf; + LOG_STRING(INFO, &buf) << u; + CHECK_EQ(1UL, buf.size()); + CHECK(buf[0].find("OK") != string::npos); + + // We must be able to compile this. + CHECK_EQ(u, u); +} + +TEST(LogMsgTime, gmtoff) { + /* + * Unit test for GMT offset API + * TODO: To properly test this API, we need a platform independent way to set time-zone. + * */ + google::LogMessage log_obj(__FILE__, __LINE__); + + long int nGmtOff = log_obj.getLogMessageTime().gmtoff(); + // GMT offset ranges from UTC-12:00 to UTC+14:00 + const long utc_min_offset = -43200; + const long utc_max_offset = 50400; + EXPECT_TRUE( (nGmtOff >= utc_min_offset) && (nGmtOff <= utc_max_offset) ); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.err b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.err new file mode 100644 index 000000000..21517cbf7 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.err @@ -0,0 +1,308 @@ +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=2 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +WARNING: Logging before InitGoogleLogging() is written to STDERR +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=0 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] foo bar 10 3.4 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 1: __SUCCESS__ [0] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 1 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 1 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 1 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 2 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 3: __ENOENT__ [2] +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 3 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 3 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 4 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 4 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 5: __EINTR__ [4] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 5 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 5 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 6 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 6 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 7: __ENXIO__ [6] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 7 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 7 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 8 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 9: __ENOEXEC__ [8] +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 9 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 9 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 10 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 10 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if this +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] array +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] const array +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] foo 1000 1000 3e8 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] foo 1 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] inner +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] outer +no prefix +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo bar 10 3.400000 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: array +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: const array +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __PTRTEST__ +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __NULLP__ +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 0000001000 3e8 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: RAW_LOG ERROR: The Message was too long! +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: RAW_LOG ERROR: The Message was too long! +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 on +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1 on +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 2 on +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=0 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=0 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=-1 stderrthreshold=0 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=1 logtostderr=0 alsologtostderr=0 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=2 logtostderr=0 alsologtostderr=0 +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=0 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=1 alsologtostderr=0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=0 alsologtostderr=1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=1 logtostderr=0 alsologtostderr=0 +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=3 logtostderr=0 alsologtostderr=1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_SINK: +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.out b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.out new file mode 100644 index 000000000..18795e196 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/logging_unittest.out @@ -0,0 +1,150 @@ +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING: LOG_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_SINK: +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected info +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected warning +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING: LOG_TO_STRING: collected error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported info +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported warning +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported error +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: EYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2 +IYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: WYEARDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3 diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/mock-log.h b/funasr/runtime/onnxruntime/third_party/glog/src/mock-log.h new file mode 100644 index 000000000..62999b249 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/mock-log.h @@ -0,0 +1,155 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Zhanyong Wan +// +// Defines the ScopedMockLog class (using Google C++ Mocking +// Framework), which is convenient for testing code that uses LOG(). + +#ifndef GLOG_SRC_MOCK_LOG_H_ +#define GLOG_SRC_MOCK_LOG_H_ + +// For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE. +#include "utilities.h" + +#include + +#include + +#include + +_START_GOOGLE_NAMESPACE_ +namespace glog_testing { + +// A ScopedMockLog object intercepts LOG() messages issued during its +// lifespan. Using this together with Google C++ Mocking Framework, +// it's very easy to test how a piece of code calls LOG(). The +// typical usage: +// +// TEST(FooTest, LogsCorrectly) { +// ScopedMockLog log; +// +// // We expect the WARNING "Something bad!" exactly twice. +// EXPECT_CALL(log, Log(WARNING, _, "Something bad!")) +// .Times(2); +// +// // We allow foo.cc to call LOG(INFO) any number of times. +// EXPECT_CALL(log, Log(INFO, HasSubstr("/foo.cc"), _)) +// .Times(AnyNumber()); +// +// Foo(); // Exercises the code under test. +// } +class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink { + public: + // When a ScopedMockLog object is constructed, it starts to + // intercept logs. + ScopedMockLog() { AddLogSink(this); } + + // When the object is destructed, it stops intercepting logs. + ~ScopedMockLog() override { RemoveLogSink(this); } + + // Implements the mock method: + // + // void Log(LogSeverity severity, const string& file_path, + // const string& message); + // + // The second argument to Send() is the full path of the source file + // in which the LOG() was issued. + // + // Note, that in a multi-threaded environment, all LOG() messages from a + // single thread will be handled in sequence, but that cannot be guaranteed + // for messages from different threads. In fact, if the same or multiple + // expectations are matched on two threads concurrently, their actions will + // be executed concurrently as well and may interleave. + MOCK_METHOD3(Log, void(GOOGLE_NAMESPACE::LogSeverity severity, + const std::string& file_path, + const std::string& message)); + + private: + // Implements the send() virtual function in class LogSink. + // Whenever a LOG() statement is executed, this function will be + // invoked with information presented in the LOG(). + // + // The method argument list is long and carries much information a + // test usually doesn't care about, so we trim the list before + // forwarding the call to Log(), which is much easier to use in + // tests. + // + // We still cannot call Log() directly, as it may invoke other LOG() + // messages, either due to Invoke, or due to an error logged in + // Google C++ Mocking Framework code, which would trigger a deadlock + // since a lock is held during send(). + // + // Hence, we save the message for WaitTillSent() which will be called after + // the lock on send() is released, and we'll call Log() inside + // WaitTillSent(). Since while a single send() call may be running at a + // time, multiple WaitTillSent() calls (along with the one send() call) may + // be running simultaneously, we ensure thread-safety of the exchange between + // send() and WaitTillSent(), and that for each message, LOG(), send(), + // WaitTillSent() and Log() are executed in the same thread. + void send(GOOGLE_NAMESPACE::LogSeverity severity, const char* full_filename, + const char* /*base_filename*/, int /*line*/, + const LogMessageTime& /*logmsgtime*/, const char* message, + size_t message_len) override { + // We are only interested in the log severity, full file name, and + // log message. + message_info_.severity = severity; + message_info_.file_path = full_filename; + message_info_.message = std::string(message, message_len); + } + + // Implements the WaitTillSent() virtual function in class LogSink. + // It will be executed after send() and after the global logging lock is + // released, so calls within it (or rather within the Log() method called + // within) may also issue LOG() statements. + // + // LOG(), send(), WaitTillSent() and Log() will occur in the same thread for + // a given log message. + void WaitTillSent() override { + // First, and very importantly, we save a copy of the message being + // processed before calling Log(), since Log() may indirectly call send() + // and WaitTillSent() in the same thread again. + MessageInfo message_info = message_info_; + Log(message_info.severity, message_info.file_path, message_info.message); + } + + // All relevant information about a logged message that needs to be passed + // from send() to WaitTillSent(). + struct MessageInfo { + GOOGLE_NAMESPACE::LogSeverity severity; + std::string file_path; + std::string message; + }; + MessageInfo message_info_; +}; + +} // namespace glog_testing +_END_GOOGLE_NAMESPACE_ + +#endif // GLOG_SRC_MOCK_LOG_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/mock-log_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/mock-log_unittest.cc new file mode 100644 index 000000000..b9bef4ea6 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/mock-log_unittest.cc @@ -0,0 +1,108 @@ +// Copyright (c) 2022, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Zhanyong Wan + +// Tests the ScopedMockLog class. + +#include "mock-log.h" + +#include + +#include +#include + +namespace { + +using GOOGLE_NAMESPACE::GLOG_ERROR; +using GOOGLE_NAMESPACE::GLOG_INFO; +using GOOGLE_NAMESPACE::GLOG_WARNING; +using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog; +using std::string; +using testing::_; +using testing::EndsWith; +using testing::InSequence; +using testing::InvokeWithoutArgs; + +// Tests that ScopedMockLog intercepts LOG()s when it's alive. +TEST(ScopedMockLogTest, InterceptsLog) { + ScopedMockLog log; + + InSequence s; + EXPECT_CALL(log, + Log(GLOG_WARNING, EndsWith("mock-log_unittest.cc"), "Fishy.")); + EXPECT_CALL(log, Log(GLOG_INFO, _, "Working...")) + .Times(2); + EXPECT_CALL(log, Log(GLOG_ERROR, _, "Bad!!")); + + LOG(WARNING) << "Fishy."; + LOG(INFO) << "Working..."; + LOG(INFO) << "Working..."; + LOG(ERROR) << "Bad!!"; +} + +void LogBranch() { + LOG(INFO) << "Logging a branch..."; +} + +void LogTree() { + LOG(INFO) << "Logging the whole tree..."; +} + +void LogForest() { + LOG(INFO) << "Logging the entire forest."; + LOG(INFO) << "Logging the entire forest.."; + LOG(INFO) << "Logging the entire forest..."; +} + +// The purpose of the following test is to verify that intercepting logging +// continues to work properly if a LOG statement is executed within the scope +// of a mocked call. +TEST(ScopedMockLogTest, LogDuringIntercept) { + ScopedMockLog log; + InSequence s; + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "Logging a branch...")) + .WillOnce(InvokeWithoutArgs(LogTree)); + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "Logging the whole tree...")) + .WillOnce(InvokeWithoutArgs(LogForest)); + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "Logging the entire forest.")); + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "Logging the entire forest..")); + EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "Logging the entire forest...")); + LogBranch(); +} + +} // namespace + +int main(int argc, char **argv) { + GOOGLE_NAMESPACE::InitGoogleLogging(argv[0]); + testing::InitGoogleTest(&argc, argv); + testing::InitGoogleMock(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/CMakeLists.txt b/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/CMakeLists.txt new file mode 100644 index 000000000..5fcfe7fd0 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required (VERSION 3.16) +project (glog_package_config LANGUAGES CXX) + +find_package (glog REQUIRED NO_MODULE) + +add_executable (glog_package_config glog_package_config.cc) + +target_link_libraries (glog_package_config PRIVATE glog::glog) diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/glog_package_config.cc b/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/glog_package_config.cc new file mode 100644 index 000000000..b7b5cf6c6 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/package_config_unittest/working_config/glog_package_config.cc @@ -0,0 +1,6 @@ +#include + +int main(int /*argc*/, char** argv) +{ + google::InitGoogleLogging(argv[0]); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/raw_logging.cc b/funasr/runtime/onnxruntime/third_party/glog/src/raw_logging.cc new file mode 100644 index 000000000..9e6cf1795 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/raw_logging.cc @@ -0,0 +1,179 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Maxim Lifantsev +// +// logging_unittest.cc covers the functionality herein + +#include +#include +#include + +#include "utilities.h" +#ifdef HAVE_UNISTD_H +# include // for close() and write() +#endif +#include // for open() +#include +#include "config.h" +#include // To pick up flag settings etc. +#include +#include "base/commandlineflags.h" + +#ifdef HAVE_STACKTRACE +# include "stacktrace.h" +#endif + +#if defined(HAVE_SYSCALL_H) +#include // for syscall() +#elif defined(HAVE_SYS_SYSCALL_H) +#include // for syscall() +#endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \ + (!(defined(GLOG_OS_MACOSX))) && !defined(GLOG_OS_EMSCRIPTEN) +#define safe_write(fd, s, len) syscall(SYS_write, fd, s, len) +#else +// Not so safe, but what can you do? +#define safe_write(fd, s, len) write(fd, s, len) +#endif + +_START_GOOGLE_NAMESPACE_ + +#if defined(__GNUC__) +#define GLOG_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) \ + __attribute__((format(archetype, stringIndex, firstToCheck))) +#define GLOG_ATTRIBUTE_FORMAT_ARG(stringIndex) \ + __attribute__((format_arg(stringIndex))) +#else +#define GLOG_ATTRIBUTE_FORMAT(archetype, stringIndex, firstToCheck) +#define GLOG_ATTRIBUTE_FORMAT_ARG(stringIndex) +#endif + +// CAVEAT: vsnprintf called from *DoRawLog below has some (exotic) code paths +// that invoke malloc() and getenv() that might acquire some locks. +// If this becomes a problem we should reimplement a subset of vsnprintf +// that does not need locks and malloc. + +// Helper for RawLog__ below. +// *DoRawLog writes to *buf of *size and move them past the written portion. +// It returns true iff there was no overflow or error. +GLOG_ATTRIBUTE_FORMAT(printf, 3, 4) +static bool DoRawLog(char** buf, size_t* size, const char* format, ...) { + va_list ap; + va_start(ap, format); + int n = vsnprintf(*buf, *size, format, ap); + va_end(ap); + if (n < 0 || static_cast(n) > *size) return false; + *size -= static_cast(n); + *buf += n; + return true; +} + +// Helper for RawLog__ below. +inline static bool VADoRawLog(char** buf, size_t* size, + const char* format, va_list ap) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif + int n = vsnprintf(*buf, *size, format, ap); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + if (n < 0 || static_cast(n) > *size) return false; + *size -= static_cast(n); + *buf += n; + return true; +} + +static const int kLogBufSize = 3000; +static bool crashed = false; +static CrashReason crash_reason; +static char crash_buf[kLogBufSize + 1] = { 0 }; // Will end in '\0' + +GLOG_ATTRIBUTE_FORMAT(printf, 4, 5) +void RawLog__(LogSeverity severity, const char* file, int line, + const char* format, ...) { + if (!(FLAGS_logtostdout || FLAGS_logtostderr || + severity >= FLAGS_stderrthreshold || FLAGS_alsologtostderr || + !IsGoogleLoggingInitialized())) { + return; // this stderr log message is suppressed + } + // can't call localtime_r here: it can allocate + char buffer[kLogBufSize]; + char* buf = buffer; + size_t size = sizeof(buffer); + + // NOTE: this format should match the specification in base/logging.h + DoRawLog(&buf, &size, "%c00000000 00:00:00.000000 %5u %s:%d] RAW: ", + LogSeverityNames[severity][0], + static_cast(GetTID()), + const_basename(const_cast(file)), line); + + // Record the position and size of the buffer after the prefix + const char* msg_start = buf; + const size_t msg_size = size; + + va_list ap; + va_start(ap, format); + bool no_chop = VADoRawLog(&buf, &size, format, ap); + va_end(ap); + if (no_chop) { + DoRawLog(&buf, &size, "\n"); + } else { + DoRawLog(&buf, &size, "RAW_LOG ERROR: The Message was too long!\n"); + } + // We make a raw syscall to write directly to the stderr file descriptor, + // avoiding FILE buffering (to avoid invoking malloc()), and bypassing + // libc (to side-step any libc interception). + // We write just once to avoid races with other invocations of RawLog__. + safe_write(STDERR_FILENO, buffer, strlen(buffer)); + if (severity == GLOG_FATAL) { + if (!sync_val_compare_and_swap(&crashed, false, true)) { + crash_reason.filename = file; + crash_reason.line_number = line; + memcpy(crash_buf, msg_start, msg_size); // Don't include prefix + crash_reason.message = crash_buf; +#ifdef HAVE_STACKTRACE + crash_reason.depth = + GetStackTrace(crash_reason.stack, ARRAYSIZE(crash_reason.stack), 1); +#else + crash_reason.depth = 0; +#endif + SetCrashReason(&crash_reason); + } + LogMessage::Fail(); // abort() + } +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler.cc b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler.cc new file mode 100644 index 000000000..657e15c08 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler.cc @@ -0,0 +1,412 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// Implementation of InstallFailureSignalHandler(). + +#include "utilities.h" +#include "stacktrace.h" +#include "symbolize.h" +#include + +#include +#include +#ifdef HAVE_UCONTEXT_H +# include +#endif +#ifdef HAVE_SYS_UCONTEXT_H +# include +#endif +#include + +_START_GOOGLE_NAMESPACE_ + +namespace { + +// We'll install the failure signal handler for these signals. We could +// use strsignal() to get signal names, but we don't use it to avoid +// introducing yet another #ifdef complication. +// +// The list should be synced with the comment in signalhandler.h. +const struct { + int number; + const char *name; +} kFailureSignals[] = { + { SIGSEGV, "SIGSEGV" }, + { SIGILL, "SIGILL" }, + { SIGFPE, "SIGFPE" }, + { SIGABRT, "SIGABRT" }, +#if !defined(GLOG_OS_WINDOWS) + { SIGBUS, "SIGBUS" }, +#endif + { SIGTERM, "SIGTERM" }, +}; + +static bool kFailureSignalHandlerInstalled = false; + +#if !defined(GLOG_OS_WINDOWS) +// Returns the program counter from signal context, nullptr if unknown. +void* GetPC(void* ucontext_in_void) { +#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT) + if (ucontext_in_void != nullptr) { + ucontext_t *context = reinterpret_cast(ucontext_in_void); + return (void*)context->PC_FROM_UCONTEXT; + } +#else + (void)ucontext_in_void; +#endif + return nullptr; +} +#endif + +// The class is used for formatting error messages. We don't use printf() +// as it's not async signal safe. +class MinimalFormatter { + public: + MinimalFormatter(char *buffer, size_t size) + : buffer_(buffer), + cursor_(buffer), + end_(buffer + size) { + } + + // Returns the number of bytes written in the buffer. + std::size_t num_bytes_written() const { return static_cast(cursor_ - buffer_); } + + // Appends string from "str" and updates the internal cursor. + void AppendString(const char* str) { + ptrdiff_t i = 0; + while (str[i] != '\0' && cursor_ + i < end_) { + cursor_[i] = str[i]; + ++i; + } + cursor_ += i; + } + + // Formats "number" in "radix" and updates the internal cursor. + // Lowercase letters are used for 'a' - 'z'. + void AppendUint64(uint64 number, unsigned radix) { + unsigned i = 0; + while (cursor_ + i < end_) { + const uint64 tmp = number % radix; + number /= radix; + cursor_[i] = static_cast(tmp < 10 ? '0' + tmp : 'a' + tmp - 10); + ++i; + if (number == 0) { + break; + } + } + // Reverse the bytes written. + std::reverse(cursor_, cursor_ + i); + cursor_ += i; + } + + // Formats "number" as hexadecimal number, and updates the internal + // cursor. Padding will be added in front if needed. + void AppendHexWithPadding(uint64 number, int width) { + char* start = cursor_; + AppendString("0x"); + AppendUint64(number, 16); + // Move to right and add padding in front if needed. + if (cursor_ < start + width) { + const int64 delta = start + width - cursor_; + std::copy(start, cursor_, start + delta); + std::fill(start, start + delta, ' '); + cursor_ = start + width; + } + } + + private: + char *buffer_; + char *cursor_; + const char * const end_; +}; + +// Writes the given data with the size to the standard error. +void WriteToStderr(const char* data, size_t size) { + if (write(STDERR_FILENO, data, size) < 0) { + // Ignore errors. + } +} + +// The writer function can be changed by InstallFailureWriter(). +void (*g_failure_writer)(const char* data, size_t size) = WriteToStderr; + +// Dumps time information. We don't dump human-readable time information +// as localtime() is not guaranteed to be async signal safe. +void DumpTimeInfo() { + time_t time_in_sec = time(nullptr); + char buf[256]; // Big enough for time info. + MinimalFormatter formatter(buf, sizeof(buf)); + formatter.AppendString("*** Aborted at "); + formatter.AppendUint64(static_cast(time_in_sec), 10); + formatter.AppendString(" (unix time)"); + formatter.AppendString(" try \"date -d @"); + formatter.AppendUint64(static_cast(time_in_sec), 10); + formatter.AppendString("\" if you are using GNU date ***\n"); + g_failure_writer(buf, formatter.num_bytes_written()); +} + +// TODO(hamaji): Use signal instead of sigaction? +#if defined(HAVE_STACKTRACE) && defined(HAVE_SIGACTION) + +// Dumps information about the signal to STDERR. +void DumpSignalInfo(int signal_number, siginfo_t *siginfo) { + // Get the signal name. + const char* signal_name = nullptr; + for (auto kFailureSignal : kFailureSignals) { + if (signal_number == kFailureSignal.number) { + signal_name = kFailureSignal.name; + } + } + + char buf[256]; // Big enough for signal info. + MinimalFormatter formatter(buf, sizeof(buf)); + + formatter.AppendString("*** "); + if (signal_name) { + formatter.AppendString(signal_name); + } else { + // Use the signal number if the name is unknown. The signal name + // should be known, but just in case. + formatter.AppendString("Signal "); + formatter.AppendUint64(static_cast(signal_number), 10); + } + formatter.AppendString(" (@0x"); + formatter.AppendUint64(reinterpret_cast(siginfo->si_addr), 16); + formatter.AppendString(")"); + formatter.AppendString(" received by PID "); + formatter.AppendUint64(static_cast(getpid()), 10); + formatter.AppendString(" (TID 0x"); + // We assume pthread_t is an integral number or a pointer, rather + // than a complex struct. In some environments, pthread_self() + // returns an uint64 but in some other environments pthread_self() + // returns a pointer. + pthread_t id = pthread_self(); + formatter.AppendUint64( + reinterpret_cast(reinterpret_cast(id)), 16); + formatter.AppendString(") "); + // Only linux has the PID of the signal sender in si_pid. +#ifdef GLOG_OS_LINUX + formatter.AppendString("from PID "); + formatter.AppendUint64(static_cast(siginfo->si_pid), 10); + formatter.AppendString("; "); +#endif + formatter.AppendString("stack trace: ***\n"); + g_failure_writer(buf, formatter.num_bytes_written()); +} + +#endif // HAVE_SIGACTION + +// Dumps information about the stack frame to STDERR. +void DumpStackFrameInfo(const char* prefix, void* pc) { + // Get the symbol name. + const char *symbol = "(unknown)"; + char symbolized[1024]; // Big enough for a sane symbol. + // Symbolizes the previous address of pc because pc may be in the + // next function. + if (Symbolize(reinterpret_cast(pc) - 1, + symbolized, sizeof(symbolized))) { + symbol = symbolized; + } + + char buf[1024]; // Big enough for stack frame info. + MinimalFormatter formatter(buf, sizeof(buf)); + + formatter.AppendString(prefix); + formatter.AppendString("@ "); + const int width = 2 * sizeof(void*) + 2; // + 2 for "0x". + formatter.AppendHexWithPadding(reinterpret_cast(pc), width); + formatter.AppendString(" "); + formatter.AppendString(symbol); + formatter.AppendString("\n"); + g_failure_writer(buf, formatter.num_bytes_written()); +} + +// Invoke the default signal handler. +void InvokeDefaultSignalHandler(int signal_number) { +#ifdef HAVE_SIGACTION + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); + sigemptyset(&sig_action.sa_mask); + sig_action.sa_handler = SIG_DFL; + sigaction(signal_number, &sig_action, nullptr); + kill(getpid(), signal_number); +#elif defined(GLOG_OS_WINDOWS) + signal(signal_number, SIG_DFL); + raise(signal_number); +#endif +} + +// This variable is used for protecting FailureSignalHandler() from +// dumping stuff while another thread is doing it. Our policy is to let +// the first thread dump stuff and let other threads wait. +// See also comments in FailureSignalHandler(). +static pthread_t* g_entered_thread_id_pointer = nullptr; + +// Dumps signal and stack frame information, and invokes the default +// signal handler once our job is done. +#if defined(GLOG_OS_WINDOWS) +void FailureSignalHandler(int signal_number) +#else +void FailureSignalHandler(int signal_number, + siginfo_t *signal_info, + void *ucontext) +#endif +{ + // First check if we've already entered the function. We use an atomic + // compare and swap operation for platforms that support it. For other + // platforms, we use a naive method that could lead to a subtle race. + + // We assume pthread_self() is async signal safe, though it's not + // officially guaranteed. + pthread_t my_thread_id = pthread_self(); + // NOTE: We could simply use pthread_t rather than pthread_t* for this, + // if pthread_self() is guaranteed to return non-zero value for thread + // ids, but there is no such guarantee. We need to distinguish if the + // old value (value returned from __sync_val_compare_and_swap) is + // different from the original value (in this case nullptr). + pthread_t* old_thread_id_pointer = + glog_internal_namespace_::sync_val_compare_and_swap( + &g_entered_thread_id_pointer, static_cast(nullptr), + &my_thread_id); + if (old_thread_id_pointer != nullptr) { + // We've already entered the signal handler. What should we do? + if (pthread_equal(my_thread_id, *g_entered_thread_id_pointer)) { + // It looks the current thread is reentering the signal handler. + // Something must be going wrong (maybe we are reentering by another + // type of signal?). Kill ourself by the default signal handler. + InvokeDefaultSignalHandler(signal_number); + } + // Another thread is dumping stuff. Let's wait until that thread + // finishes the job and kills the process. + while (true) { + sleep(1); + } + } + // This is the first time we enter the signal handler. We are going to + // do some interesting stuff from here. + // TODO(satorux): We might want to set timeout here using alarm(), but + // mixing alarm() and sleep() can be a bad idea. + + // First dump time info. + DumpTimeInfo(); + +#if !defined(GLOG_OS_WINDOWS) + // Get the program counter from ucontext. + void *pc = GetPC(ucontext); + DumpStackFrameInfo("PC: ", pc); +#endif + +#ifdef HAVE_STACKTRACE + // Get the stack traces. + void *stack[32]; + // +1 to exclude this function. + const int depth = GetStackTrace(stack, ARRAYSIZE(stack), 1); +# ifdef HAVE_SIGACTION + DumpSignalInfo(signal_number, signal_info); +#elif !defined(GLOG_OS_WINDOWS) + (void)signal_info; +# endif + // Dump the stack traces. + for (int i = 0; i < depth; ++i) { + DumpStackFrameInfo(" ", stack[i]); + } +#elif !defined(GLOG_OS_WINDOWS) + (void)signal_info; +#endif + + // *** TRANSITION *** + // + // BEFORE this point, all code must be async-termination-safe! + // (See WARNING above.) + // + // AFTER this point, we do unsafe things, like using LOG()! + // The process could be terminated or hung at any time. We try to + // do more useful things first and riskier things later. + + // Flush the logs before we do anything in case 'anything' + // causes problems. + FlushLogFilesUnsafe(0); + + // Kill ourself by the default signal handler. + InvokeDefaultSignalHandler(signal_number); +} + +} // namespace + +namespace glog_internal_namespace_ { + +bool IsFailureSignalHandlerInstalled() { +#ifdef HAVE_SIGACTION + // TODO(andschwa): Return kFailureSignalHandlerInstalled? + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); + sigemptyset(&sig_action.sa_mask); + sigaction(SIGABRT, nullptr, &sig_action); + if (sig_action.sa_sigaction == &FailureSignalHandler) { + return true; + } +#elif defined(GLOG_OS_WINDOWS) + return kFailureSignalHandlerInstalled; +#endif // HAVE_SIGACTION + return false; +} + +} // namespace glog_internal_namespace_ + +void InstallFailureSignalHandler() { +#ifdef HAVE_SIGACTION + // Build the sigaction struct. + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); + sigemptyset(&sig_action.sa_mask); + sig_action.sa_flags |= SA_SIGINFO; + sig_action.sa_sigaction = &FailureSignalHandler; + + for (auto kFailureSignal : kFailureSignals) { + CHECK_ERR(sigaction(kFailureSignal.number, &sig_action, nullptr)); + } + kFailureSignalHandlerInstalled = true; +#elif defined(GLOG_OS_WINDOWS) + for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { + CHECK_NE(signal(kFailureSignals[i].number, &FailureSignalHandler), + SIG_ERR); + } + kFailureSignalHandlerInstalled = true; +#endif // HAVE_SIGACTION +} + +void InstallFailureWriter(void (*writer)(const char* data, size_t size)) { +#if defined(HAVE_SIGACTION) || defined(GLOG_OS_WINDOWS) + g_failure_writer = writer; +#endif // HAVE_SIGACTION +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.cc new file mode 100644 index 000000000..c88598b4e --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.cc @@ -0,0 +1,113 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// This is a helper binary for testing signalhandler.cc. The actual test +// is done in signalhandler_unittest.sh. + +#include "utilities.h" + +#if defined(HAVE_PTHREAD) +# include +#endif +#include +#include +#include +#include +#include + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +using namespace GOOGLE_NAMESPACE; + +static void* DieInThread(void*) { + // We assume pthread_t is an integral number or a pointer, rather + // than a complex struct. In some environments, pthread_self() + // returns an uint64 but in some other environments pthread_self() + // returns a pointer. + fprintf( + stderr, "0x%px is dying\n", + static_cast(reinterpret_cast(pthread_self()))); + // Use volatile to prevent from these to be optimized away. + volatile int a = 0; + volatile int b = 1 / a; + fprintf(stderr, "We should have died: b=%d\n", b); + return nullptr; +} + +static void WriteToStdout(const char* data, size_t size) { + if (write(STDOUT_FILENO, data, size) < 0) { + // Ignore errors. + } +} + +int main(int argc, char **argv) { +#if defined(HAVE_STACKTRACE) && defined(HAVE_SYMBOLIZE) + InitGoogleLogging(argv[0]); +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + InstallFailureSignalHandler(); + const std::string command = argc > 1 ? argv[1] : "none"; + if (command == "segv") { + // We'll check if this is outputted. + LOG(INFO) << "create the log file"; + LOG(INFO) << "a message before segv"; + // We assume 0xDEAD is not writable. + int *a = (int*)0xDEAD; + *a = 0; + } else if (command == "loop") { + fprintf(stderr, "looping\n"); + while (true); + } else if (command == "die_in_thread") { +#if defined(HAVE_PTHREAD) + pthread_t thread; + pthread_create(&thread, nullptr, &DieInThread, nullptr); + pthread_join(thread, nullptr); +#else + fprintf(stderr, "no pthread\n"); + return 1; +#endif + } else if (command == "dump_to_stdout") { + InstallFailureWriter(WriteToStdout); + abort(); + } else if (command == "installed") { + fprintf(stderr, "signal handler installed: %s\n", + IsFailureSignalHandlerInstalled() ? "true" : "false"); + } else { + // Tell the shell script + puts("OK"); + } +#endif + return 0; +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.sh b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.sh new file mode 100755 index 000000000..265cd458c --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/signalhandler_unittest.sh @@ -0,0 +1,131 @@ +#! /bin/sh +# +# Copyright (c) 2008, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Author: Satoru Takabayashi +# +# Unit tests for signalhandler.cc. + +die () { + echo $1 + exit 1 +} + +BINDIR=".libs" +LIBGLOG="$BINDIR/libglog.so" + +BINARY="$BINDIR/signalhandler_unittest" +LOG_INFO="./signalhandler_unittest.INFO" + +# Remove temporary files. +rm -f signalhandler.out* + +if test -e "$BINARY"; then + # We need shared object. + export LD_LIBRARY_PATH=$BINDIR + export DYLD_LIBRARY_PATH=$BINDIR +else + # For windows + BINARY="./signalhandler_unittest.exe" + if ! test -e "$BINARY"; then + echo "We coundn't find demangle_unittest binary." + exit 1 + fi +fi + +if [ x`$BINARY` != 'xOK' ]; then + echo "PASS (No stacktrace support. We don't run this test.)" + exit 0 +fi + +# The PC cannot be obtained in signal handlers on PowerPC correctly. +# We just skip the test for PowerPC. +if [ x`uname -p` = x"powerpc" ]; then + echo "PASS (We don't test the signal handler on PowerPC.)" + exit 0 +fi + +# Test for a case the program kills itself by SIGSEGV. +GOOGLE_LOG_DIR=. $BINARY segv 2> signalhandler.out1 +for pattern in SIGSEGV 0xdead main "Aborted at [0-9]"; do + if ! grep --quiet "$pattern" signalhandler.out1; then + die "'$pattern' should appear in the output" + fi +done +if ! grep --quiet "a message before segv" $LOG_INFO; then + die "'a message before segv' should appear in the INFO log" +fi +rm -f $LOG_INFO + +# Test for a case the program is killed by this shell script. +# $! = the process id of the last command run in the background. +# $$ = the process id of this shell. +$BINARY loop 2> signalhandler.out2 & +# Wait until "looping" is written in the file. This indicates the program +# is ready to accept signals. +while true; do + if grep --quiet looping signalhandler.out2; then + break + fi +done +kill -TERM $! +wait $! + +from_pid='' +# Only linux has the process ID of the signal sender. +if [ x`uname` = "xLinux" ]; then + from_pid="from PID $$" +fi +for pattern in SIGTERM "by PID $!" "$from_pid" main "Aborted at [0-9]"; do + if ! grep --quiet "$pattern" signalhandler.out2; then + die "'$pattern' should appear in the output" + fi +done + +# Test for a case the program dies in a non-main thread. +$BINARY die_in_thread 2> signalhandler.out3 +EXPECTED_TID="`sed 's/ .*//; q' signalhandler.out3`" + +for pattern in SIGFPE DieInThread "TID $EXPECTED_TID" "Aborted at [0-9]"; do + if ! grep --quiet "$pattern" signalhandler.out3; then + die "'$pattern' should appear in the output" + fi +done + +# Test for a case the program installs a custom failure writer that writes +# stuff to stdout instead of stderr. +$BINARY dump_to_stdout 1> signalhandler.out4 +for pattern in SIGABRT main "Aborted at [0-9]"; do + if ! grep --quiet "$pattern" signalhandler.out4; then + die "'$pattern' should appear in the output" + fi +done + +echo PASS diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace.h new file mode 100644 index 000000000..bf23e193c --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace.h @@ -0,0 +1,61 @@ +// Copyright (c) 2000 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Routines to extract the current stack trace. These functions are +// thread-safe. + +#ifndef BASE_STACKTRACE_H_ +#define BASE_STACKTRACE_H_ + +#include "config.h" +#include + +_START_GOOGLE_NAMESPACE_ + +// This is similar to the GetStackFrames routine, except that it returns +// the stack trace only, and not the stack frame sizes as well. +// Example: +// main() { foo(); } +// foo() { bar(); } +// bar() { +// void* result[10]; +// int depth = GetStackFrames(result, 10, 1); +// } +// +// This produces: +// result[0] foo +// result[1] main +// .... ... +// +// "result" must not be nullptr. +GLOG_EXPORT int GetStackTrace(void** result, int max_depth, int skip_count); + +_END_GOOGLE_NAMESPACE_ + +#endif // BASE_STACKTRACE_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_generic-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_generic-inl.h new file mode 100644 index 000000000..0e473a9e8 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_generic-inl.h @@ -0,0 +1,64 @@ +// Copyright (c) 2000 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Portable implementation - just use glibc +// +// Note: The glibc implementation may cause a call to malloc. +// This can cause a deadlock in HeapProfiler. +#include + +#include + +#include "stacktrace.h" + +_START_GOOGLE_NAMESPACE_ + +// If you change this function, also change GetStackFrames below. +int GetStackTrace(void** result, int max_depth, int skip_count) { + static const int kStackLength = 64; + void * stack[kStackLength]; + int size; + + size = backtrace(stack, kStackLength); + skip_count++; // we want to skip the current frame as well + int result_count = size - skip_count; + if (result_count < 0) { + result_count = 0; + } + if (result_count > max_depth) { + result_count = max_depth; + } + for (int i = 0; i < result_count; i++) { + result[i] = stack[i + skip_count]; + } + + return result_count; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_libunwind-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_libunwind-inl.h new file mode 100644 index 000000000..0b20d2386 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_libunwind-inl.h @@ -0,0 +1,93 @@ +// Copyright (c) 2005 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Arun Sharma +// +// Produce stack trace using libunwind + +#include "utilities.h" + +extern "C" { +#define UNW_LOCAL_ONLY +#include +} +#include +#include "stacktrace.h" + +_START_GOOGLE_NAMESPACE_ + +// Sometimes, we can try to get a stack trace from within a stack +// trace, because libunwind can call mmap (maybe indirectly via an +// internal mmap based memory allocator), and that mmap gets trapped +// and causes a stack-trace request. If were to try to honor that +// recursive request, we'd end up with infinite recursion or deadlock. +// Luckily, it's safe to ignore those subsequent traces. In such +// cases, we return 0 to indicate the situation. +// We can use the GCC __thread syntax here since libunwind is not supported on +// Windows. +static __thread bool g_tl_entered; // Initialized to false. + +// If you change this function, also change GetStackFrames below. +int GetStackTrace(void** result, int max_depth, int skip_count) { + void *ip; + int n = 0; + unw_cursor_t cursor; + unw_context_t uc; + + if (g_tl_entered) { + return 0; + } + g_tl_entered = true; + + unw_getcontext(&uc); + RAW_CHECK(unw_init_local(&cursor, &uc) >= 0, "unw_init_local failed"); + skip_count++; // Do not include the "GetStackTrace" frame + + while (n < max_depth) { + int ret = + unw_get_reg(&cursor, UNW_REG_IP, reinterpret_cast(&ip)); + if (ret < 0) { + break; + } + if (skip_count > 0) { + skip_count--; + } else { + result[n++] = ip; + } + ret = unw_step(&cursor); + if (ret <= 0) { + break; + } + } + + g_tl_entered = false; + return n; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_powerpc-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_powerpc-inl.h new file mode 100644 index 000000000..30217dbaa --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_powerpc-inl.h @@ -0,0 +1,133 @@ +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Craig Silverstein +// +// Produce stack trace. I'm guessing (hoping!) the code is much like +// for x86. For apple machines, at least, it seems to be; see +// http://developer.apple.com/documentation/mac/runtimehtml/RTArch-59.html +// http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK +// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882 + +#include // for uintptr_t +#include + +#include "stacktrace.h" + +_START_GOOGLE_NAMESPACE_ + +// Given a pointer to a stack frame, locate and return the calling +// stackframe, or return nullptr if no stackframe can be found. Perform sanity +// checks (the strictness of which is controlled by the boolean parameter +// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned. +template +static void **NextStackFrame(void **old_sp) { + void **new_sp = static_cast(*old_sp); + + // Check that the transition from frame pointer old_sp to frame + // pointer new_sp isn't clearly bogus + if (STRICT_UNWINDING) { + // With the stack growing downwards, older stack frame must be + // at a greater address that the current one. + if (new_sp <= old_sp) return nullptr; + // Assume stack frames larger than 100,000 bytes are bogus. + if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000) return nullptr; + } else { + // In the non-strict mode, allow discontiguous stack frames. + // (alternate-signal-stacks for example). + if (new_sp == old_sp) return nullptr; + // And allow frames upto about 1MB. + if ((new_sp > old_sp) && + ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000)) { + return nullptr; + } + } + if ((uintptr_t)new_sp & (sizeof(void *) - 1)) return nullptr; + return new_sp; +} + +// This ensures that GetStackTrace stes up the Link Register properly. +void StacktracePowerPCDummyFunction() __attribute__((noinline)); +void StacktracePowerPCDummyFunction() { __asm__ volatile(""); } + +// If you change this function, also change GetStackFrames below. +int GetStackTrace(void** result, int max_depth, int skip_count) { + void **sp; + // Apple OS X uses an old version of gnu as -- both Darwin 7.9.0 (Panther) + // and Darwin 8.8.1 (Tiger) use as 1.38. This means we have to use a + // different asm syntax. I don't know quite the best way to discriminate + // systems using the old as from the new one; I've gone with __APPLE__. +#ifdef __APPLE__ + __asm__ volatile ("mr %0,r1" : "=r" (sp)); +#else + __asm__ volatile ("mr %0,1" : "=r" (sp)); +#endif + + // On PowerPC, the "Link Register" or "Link Record" (LR), is a stack + // entry that holds the return address of the subroutine call (what + // instruction we run after our function finishes). This is the + // same as the stack-pointer of our parent routine, which is what we + // want here. While the compiler will always(?) set up LR for + // subroutine calls, it may not for leaf functions (such as this one). + // This routine forces the compiler (at least gcc) to push it anyway. + StacktracePowerPCDummyFunction(); + + // The LR save area is used by the callee, so the top entry is bogus. + skip_count++; + + int n = 0; + while (sp && n < max_depth) { + if (skip_count > 0) { + skip_count--; + } else { + // PowerPC has 3 main ABIs, which say where in the stack the + // Link Register is. For DARWIN and AIX (used by apple and + // linux ppc64), it's in sp[2]. For SYSV (used by linux ppc), + // it's in sp[1]. +#if defined(_CALL_AIX) || defined(_CALL_DARWIN) + result[n++] = *(sp+2); +#elif defined(_CALL_SYSV) + result[n++] = *(sp+1); +#elif defined(__APPLE__) || ((defined(__linux) || defined(__linux__)) && defined(__PPC64__)) + // This check is in case the compiler doesn't define _CALL_AIX/etc. + result[n++] = *(sp+2); +#elif defined(__linux) || defined(__OpenBSD__) + // This check is in case the compiler doesn't define _CALL_SYSV. + result[n++] = *(sp+1); +#else +#error Need to specify the PPC ABI for your archiecture. +#endif + } + // Use strict unwinding rules. + sp = NextStackFrame(sp); + } + return n; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unittest.cc new file mode 100644 index 000000000..6d3c21aee --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unittest.cc @@ -0,0 +1,245 @@ +// Copyright (c) 2004, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "utilities.h" + +#include +#include +#include "config.h" +#include "base/commandlineflags.h" +#include +#include "stacktrace.h" + +#ifdef HAVE_EXECINFO_BACKTRACE_SYMBOLS +# include +#endif + +using namespace GOOGLE_NAMESPACE; + +#ifdef HAVE_STACKTRACE + +// Obtain a backtrace, verify that the expected callers are present in the +// backtrace, and maybe print the backtrace to stdout. + +// The sequence of functions whose return addresses we expect to see in the +// backtrace. +const int BACKTRACE_STEPS = 6; + +struct AddressRange { + const void *start, *end; +}; + +// Expected function [start,end] range. +AddressRange expected_range[BACKTRACE_STEPS]; + +#if __GNUC__ +// Using GCC extension: address of a label can be taken with '&&label'. +// Start should be a label somewhere before recursive call, end somewhere +// after it. +#define INIT_ADDRESS_RANGE(fn, start_label, end_label, prange) \ + do { \ + (prange)->start = &&start_label; \ + (prange)->end = &&end_label; \ + CHECK_LT((prange)->start, (prange)->end); \ + } while (0) +// This macro expands into "unmovable" code (opaque to GCC), and that +// prevents GCC from moving a_label up or down in the code. +// Without it, there is no code following the 'end' label, and GCC +// (4.3.1, 4.4.0) thinks it safe to assign &&end an address that is before +// the recursive call. +#define DECLARE_ADDRESS_LABEL(a_label) \ + a_label: do { __asm__ __volatile__(""); } while (0) +// Gcc 4.4.0 may split function into multiple chunks, and the chunk +// performing recursive call may end up later in the code then the return +// instruction (this actually happens with FDO). +// Adjust function range from __builtin_return_address. +#define ADJUST_ADDRESS_RANGE_FROM_RA(prange) \ + do { \ + void *ra = __builtin_return_address(0); \ + CHECK_LT((prange)->start, ra); \ + if (ra > (prange)->end) { \ + printf("Adjusting range from %p..%p to %p..%p\n", \ + (prange)->start, (prange)->end, \ + (prange)->start, ra); \ + (prange)->end = ra; \ + } \ + } while (0) +#else +// Assume the Check* functions below are not longer than 256 bytes. +#define INIT_ADDRESS_RANGE(fn, start_label, end_label, prange) \ + do { \ + (prange)->start = reinterpret_cast(&fn); \ + (prange)->end = reinterpret_cast(&fn) + 256; \ + } while (0) +#define DECLARE_ADDRESS_LABEL(a_label) do { } while (0) +#define ADJUST_ADDRESS_RANGE_FROM_RA(prange) do { } while (0) +#endif // __GNUC__ + +//-----------------------------------------------------------------------// + +static void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range) +{ + CHECK_GE(ret_addr, range.start); + CHECK_LE(ret_addr, range.end); +} + +//-----------------------------------------------------------------------// + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-label-as-value" +#endif + +void ATTRIBUTE_NOINLINE CheckStackTrace(int); +static void ATTRIBUTE_NOINLINE CheckStackTraceLeaf() { + const int STACK_LEN = 10; + void *stack[STACK_LEN]; + int size; + + ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[1]); + INIT_ADDRESS_RANGE(CheckStackTraceLeaf, start, end, &expected_range[0]); + DECLARE_ADDRESS_LABEL(start); + size = GetStackTrace(stack, STACK_LEN, 0); + printf("Obtained %d stack frames.\n", size); + CHECK_GE(size, 1); + CHECK_LE(size, STACK_LEN); + + if (true) { +#ifdef HAVE_EXECINFO_BACKTRACE_SYMBOLS + char **strings = backtrace_symbols(stack, size); + printf("Obtained %d stack frames.\n", size); + for (int i = 0; i < size; i++) { + printf("%s %p\n", strings[i], stack[i]); + } + + union { + void (*p1)(int); + void* p2; + } p = {&CheckStackTrace}; + + printf("CheckStackTrace() addr: %p\n", p.p2); + free(strings); +#endif + } + for (int i = 0; i < BACKTRACE_STEPS; i++) { + printf("Backtrace %d: expected: %p..%p actual: %p ... ", + i, expected_range[i].start, expected_range[i].end, stack[i]); + fflush(stdout); + CheckRetAddrIsInFunction(stack[i], expected_range[i]); + printf("OK\n"); + } + DECLARE_ADDRESS_LABEL(end); +} + +//-----------------------------------------------------------------------// + +/* Dummy functions to make the backtrace more interesting. */ +static void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) { + ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[2]); + INIT_ADDRESS_RANGE(CheckStackTrace4, start, end, &expected_range[1]); + DECLARE_ADDRESS_LABEL(start); + for (int j = i; j >= 0; j--) { + CheckStackTraceLeaf(); + } + DECLARE_ADDRESS_LABEL(end); +} +static void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) { + ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[3]); + INIT_ADDRESS_RANGE(CheckStackTrace3, start, end, &expected_range[2]); + DECLARE_ADDRESS_LABEL(start); + for (int j = i; j >= 0; j--) { + CheckStackTrace4(j); + } + DECLARE_ADDRESS_LABEL(end); +} +static void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) { + ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[4]); + INIT_ADDRESS_RANGE(CheckStackTrace2, start, end, &expected_range[3]); + DECLARE_ADDRESS_LABEL(start); + for (int j = i; j >= 0; j--) { + CheckStackTrace3(j); + } + DECLARE_ADDRESS_LABEL(end); +} +static void ATTRIBUTE_NOINLINE CheckStackTrace1(int i) { + ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[5]); + INIT_ADDRESS_RANGE(CheckStackTrace1, start, end, &expected_range[4]); + DECLARE_ADDRESS_LABEL(start); + for (int j = i; j >= 0; j--) { + CheckStackTrace2(j); + } + DECLARE_ADDRESS_LABEL(end); +} + +#ifndef __GNUC__ +// On non-GNU environment, we use the address of `CheckStackTrace` to +// guess the address range of this function. This guess is wrong for +// non-static function on Windows. This is probably because +// `&CheckStackTrace` returns the address of a trampoline like PLT, +// not the actual address of `CheckStackTrace`. +// See https://github.com/google/glog/issues/421 for the detail. +static +#endif +void ATTRIBUTE_NOINLINE CheckStackTrace(int i) { + INIT_ADDRESS_RANGE(CheckStackTrace, start, end, &expected_range[5]); + DECLARE_ADDRESS_LABEL(start); + for (int j = i; j >= 0; j--) { + CheckStackTrace1(j); + } + DECLARE_ADDRESS_LABEL(end); +} + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +//-----------------------------------------------------------------------// + +int main(int, char ** argv) { + FLAGS_logtostderr = true; + InitGoogleLogging(argv[0]); + + CheckStackTrace(0); + + printf("PASS\n"); + return 0; +} + +#else +int main() { + +#ifdef GLOG_BAZEL_BUILD + printf("HAVE_STACKTRACE is expected to be defined in Bazel tests\n"); + exit(EXIT_FAILURE); +#endif // GLOG_BAZEL_BUILD + + printf("PASS (no stacktrace support)\n"); + return 0; +} +#endif // HAVE_STACKTRACE diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unwind-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unwind-inl.h new file mode 100644 index 000000000..3a4b4c5bb --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_unwind-inl.h @@ -0,0 +1,106 @@ +// Copyright (c) 2005 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Arun Sharma +// +// Produce stack trace using libgcc + +#include // ABI defined unwinder + +#include // for nullptr + +#include "stacktrace.h" + +_START_GOOGLE_NAMESPACE_ + +struct trace_arg_t { + void **result; + int max_depth; + int skip_count; + int count; +}; + +// Workaround for the malloc() in _Unwind_Backtrace() issue. +static _Unwind_Reason_Code nop_backtrace(struct _Unwind_Context */*uc*/, void */*opq*/) { + return _URC_NO_REASON; +} + + +// This code is not considered ready to run until +// static initializers run so that we are guaranteed +// that any malloc-related initialization is done. +static bool ready_to_run = false; +class StackTraceInit { + public: + StackTraceInit() { + // Extra call to force initialization + _Unwind_Backtrace(nop_backtrace, nullptr); + ready_to_run = true; + } +}; + +static StackTraceInit module_initializer; // Force initialization + +static _Unwind_Reason_Code GetOneFrame(struct _Unwind_Context *uc, void *opq) { + auto *targ = static_cast(opq); + + if (targ->skip_count > 0) { + targ->skip_count--; + } else { + targ->result[targ->count++] = reinterpret_cast(_Unwind_GetIP(uc)); + } + + if (targ->count == targ->max_depth) { + return _URC_END_OF_STACK; + } + + return _URC_NO_REASON; +} + +// If you change this function, also change GetStackFrames below. +int GetStackTrace(void** result, int max_depth, int skip_count) { + if (!ready_to_run) { + return 0; + } + + trace_arg_t targ; + + skip_count += 1; // Do not include the "GetStackTrace" frame + + targ.result = result; + targ.max_depth = max_depth; + targ.skip_count = skip_count; + targ.count = 0; + + _Unwind_Backtrace(GetOneFrame, &targ); + + return targ.count; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_windows-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_windows-inl.h new file mode 100644 index 000000000..9c27664b7 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_windows-inl.h @@ -0,0 +1,51 @@ +// Copyright (c) 2000 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Andrew Schwartzmeyer +// +// Windows implementation - just use CaptureStackBackTrace + +#include "config.h" +#include "port.h" +#include "stacktrace.h" +#include + +_START_GOOGLE_NAMESPACE_ + +int GetStackTrace(void** result, int max_depth, int skip_count) { + if (max_depth > 64) { + max_depth = 64; + } + skip_count++; // we want to skip the current frame as well + // This API is thread-safe (moreover it walks only the current thread). + return CaptureStackBackTrace(static_cast(skip_count), + static_cast(max_depth), result, nullptr); +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_x86-inl.h b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_x86-inl.h new file mode 100644 index 000000000..f7afe8754 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stacktrace_x86-inl.h @@ -0,0 +1,159 @@ +// Copyright (c) 2000 - 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Produce stack trace + +#include // for uintptr_t + +#include "utilities.h" // for OS_* macros + +#if !defined(GLOG_OS_WINDOWS) +#include +#include +#endif + +#include // for nullptr + +#include "stacktrace.h" + +_START_GOOGLE_NAMESPACE_ + +// Given a pointer to a stack frame, locate and return the calling +// stackframe, or return nullptr if no stackframe can be found. Perform sanity +// checks (the strictness of which is controlled by the boolean parameter +// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned. +template +static void **NextStackFrame(void **old_sp) { + void **new_sp = static_cast(*old_sp); + + // Check that the transition from frame pointer old_sp to frame + // pointer new_sp isn't clearly bogus + if (STRICT_UNWINDING) { + // With the stack growing downwards, older stack frame must be + // at a greater address that the current one. + if (new_sp <= old_sp) return nullptr; + // Assume stack frames larger than 100,000 bytes are bogus. + if (reinterpret_cast(new_sp) - + reinterpret_cast(old_sp) > + 100000) { + return nullptr; + } + } else { + // In the non-strict mode, allow discontiguous stack frames. + // (alternate-signal-stacks for example). + if (new_sp == old_sp) return nullptr; + // And allow frames upto about 1MB. + if ((new_sp > old_sp) && (reinterpret_cast(new_sp) - + reinterpret_cast(old_sp) > + 1000000)) { + return nullptr; + } + } + if (reinterpret_cast(new_sp) & (sizeof(void *) - 1)) { + return nullptr; + } +#ifdef __i386__ + // On 64-bit machines, the stack pointer can be very close to + // 0xffffffff, so we explicitly check for a pointer into the + // last two pages in the address space + if ((uintptr_t)new_sp >= 0xffffe000) return nullptr; +#endif +#if !defined(GLOG_OS_WINDOWS) + if (!STRICT_UNWINDING) { + // Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test + // on AMD-based machines with VDSO-enabled kernels. + // Make an extra sanity check to insure new_sp is readable. + // Note: NextStackFrame() is only called while the program + // is already on its last leg, so it's ok to be slow here. + static int page_size = getpagesize(); + void *new_sp_aligned = + reinterpret_cast(reinterpret_cast(new_sp) & + static_cast(~(page_size - 1))); + if (msync(new_sp_aligned, static_cast(page_size), MS_ASYNC) == -1) { + return nullptr; + } + } +#endif + return new_sp; +} + +// If you change this function, also change GetStackFrames below. +int GetStackTrace(void** result, int max_depth, int skip_count) { + void **sp; + +#ifdef __GNUC__ +#if __GNUC__ * 100 + __GNUC_MINOR__ >= 402 +#define USE_BUILTIN_FRAME_ADDRESS +#endif +#endif + +#ifdef USE_BUILTIN_FRAME_ADDRESS + sp = reinterpret_cast(__builtin_frame_address(0)); +#elif defined(__i386__) + // Stack frame format: + // sp[0] pointer to previous frame + // sp[1] caller address + // sp[2] first argument + // ... + sp = (void **)&result - 2; +#elif defined(__x86_64__) + // __builtin_frame_address(0) can return the wrong address on gcc-4.1.0-k8 + unsigned long rbp; + // Move the value of the register %rbp into the local variable rbp. + // We need 'volatile' to prevent this instruction from getting moved + // around during optimization to before function prologue is done. + // An alternative way to achieve this + // would be (before this __asm__ instruction) to call Noop() defined as + // static void Noop() __attribute__ ((noinline)); // prevent inlining + // static void Noop() { asm(""); } // prevent optimizing-away + __asm__ volatile ("mov %%rbp, %0" : "=r" (rbp)); + // Arguments are passed in registers on x86-64, so we can't just + // offset from &result + sp = (void **) rbp; +#endif + + int n = 0; + while (sp && n < max_depth) { + if (*(sp + 1) == nullptr) { + // In 64-bit code, we often see a frame that + // points to itself and has a return address of 0. + break; + } + if (skip_count > 0) { + skip_count--; + } else { + result[n++] = *(sp+1); + } + // Use strict unwinding rules. + sp = NextStackFrame(sp); + } + return n; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/stl_logging_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/stl_logging_unittest.cc new file mode 100644 index 000000000..34daf8dd3 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/stl_logging_unittest.cc @@ -0,0 +1,114 @@ +// Copyright (c) 2003, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "googletest.h" + +using namespace std; + +struct user_hash { + size_t operator()(int x) const { return static_cast(x); } +}; + +static void TestSTLLogging() { + { + // Test a sequence. + vector v; + v.push_back(10); + v.push_back(20); + v.push_back(30); + ostringstream ss; + ss << v; + EXPECT_EQ(ss.str(), "10 20 30"); + vector copied_v(v); + CHECK_EQ(v, copied_v); // This must compile. + } + + { + // Test a sorted pair associative container. + map< int, string > m; + m[20] = "twenty"; + m[10] = "ten"; + m[30] = "thirty"; + ostringstream ss; + ss << m; + EXPECT_EQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)"); + map< int, string > copied_m(m); + CHECK_EQ(m, copied_m); // This must compile. + } + + { + // Test a long sequence. + vector v; + string expected; + for (int i = 0; i < 100; i++) { + v.push_back(i); + if (i > 0) expected += ' '; + const size_t buf_size = 256; + char buf[buf_size]; + snprintf(buf, buf_size, "%d", i); + expected += buf; + } + v.push_back(100); + expected += " ..."; + ostringstream ss; + ss << v; + CHECK_EQ(ss.str(), expected.c_str()); + } + + { + // Test a sorted pair associative container. + // Use a non-default comparison functor. + map > m; + m[20] = "twenty"; + m[10] = "ten"; + m[30] = "thirty"; + ostringstream ss; + ss << m; + EXPECT_EQ(ss.str(), "(30, thirty) (20, twenty) (10, ten)"); + map > copied_m(m); + CHECK_EQ(m, copied_m); // This must compile. + } +} + +int main(int, char**) { + TestSTLLogging(); + std::cout << "PASS\n"; + return 0; +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.cc b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.cc new file mode 100644 index 000000000..f95fccca4 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.cc @@ -0,0 +1,956 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// Stack-footprint reduction work done by Raksit Ashok +// +// Implementation note: +// +// We don't use heaps but only use stacks. We want to reduce the +// stack consumption so that the symbolizer can run on small stacks. +// +// Here are some numbers collected with GCC 4.1.0 on x86: +// - sizeof(Elf32_Sym) = 16 +// - sizeof(Elf32_Shdr) = 40 +// - sizeof(Elf64_Sym) = 24 +// - sizeof(Elf64_Shdr) = 64 +// +// This implementation is intended to be async-signal-safe but uses +// some functions which are not guaranteed to be so, such as memchr() +// and memmove(). We assume they are async-signal-safe. +// +// Additional header can be specified by the GLOG_BUILD_CONFIG_INCLUDE +// macro to add platform specific defines (e.g. GLOG_OS_OPENBSD). + +#ifdef GLOG_BUILD_CONFIG_INCLUDE +#include GLOG_BUILD_CONFIG_INCLUDE +#endif // GLOG_BUILD_CONFIG_INCLUDE + +#include "utilities.h" + +#if defined(HAVE_SYMBOLIZE) + +#include + +#include +#include + +#include "symbolize.h" +#include "demangle.h" + +_START_GOOGLE_NAMESPACE_ + +// We don't use assert() since it's not guaranteed to be +// async-signal-safe. Instead we define a minimal assertion +// macro. So far, we don't need pretty printing for __FILE__, etc. + +// A wrapper for abort() to make it callable in ? :. +static int AssertFail() { + abort(); + return 0; // Should not reach. +} + +#define SAFE_ASSERT(expr) ((expr) ? 0 : AssertFail()) + +static SymbolizeCallback g_symbolize_callback = nullptr; +void InstallSymbolizeCallback(SymbolizeCallback callback) { + g_symbolize_callback = callback; +} + +static SymbolizeOpenObjectFileCallback g_symbolize_open_object_file_callback = + nullptr; +void InstallSymbolizeOpenObjectFileCallback( + SymbolizeOpenObjectFileCallback callback) { + g_symbolize_open_object_file_callback = callback; +} + +// This function wraps the Demangle function to provide an interface +// where the input symbol is demangled in-place. +// To keep stack consumption low, we would like this function to not +// get inlined. +static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, size_t out_size) { + char demangled[256]; // Big enough for sane demangled symbols. + if (Demangle(out, demangled, sizeof(demangled))) { + // Demangling succeeded. Copy to out if the space allows. + size_t len = strlen(demangled); + if (len + 1 <= out_size) { // +1 for '\0'. + SAFE_ASSERT(len < sizeof(demangled)); + memmove(out, demangled, len + 1); + } + } +} + +_END_GOOGLE_NAMESPACE_ + +#if defined(__ELF__) + +#if defined(HAVE_DLFCN_H) +#include +#endif +#if defined(GLOG_OS_OPENBSD) +#include +#else +#include +#endif +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "symbolize.h" + +// Re-runs fn until it doesn't cause EINTR. +#define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR) + +_START_GOOGLE_NAMESPACE_ + +// Read up to "count" bytes from "offset" in the file pointed by file +// descriptor "fd" into the buffer starting at "buf" while handling short reads +// and EINTR. On success, return the number of bytes read. Otherwise, return +// -1. +static ssize_t ReadFromOffset(const int fd, void *buf, const size_t count, + const size_t offset) { + SAFE_ASSERT(fd >= 0); + SAFE_ASSERT(count <= static_cast(std::numeric_limits::max())); + char *buf0 = reinterpret_cast(buf); + size_t num_bytes = 0; + while (num_bytes < count) { + ssize_t len; + NO_INTR(len = pread(fd, buf0 + num_bytes, count - num_bytes, + static_cast(offset + num_bytes))); + if (len < 0) { // There was an error other than EINTR. + return -1; + } + if (len == 0) { // Reached EOF. + break; + } + num_bytes += static_cast(len); + } + SAFE_ASSERT(num_bytes <= count); + return static_cast(num_bytes); +} + +// Try reading exactly "count" bytes from "offset" bytes in a file +// pointed by "fd" into the buffer starting at "buf" while handling +// short reads and EINTR. On success, return true. Otherwise, return +// false. +static bool ReadFromOffsetExact(const int fd, void *buf, + const size_t count, const size_t offset) { + ssize_t len = ReadFromOffset(fd, buf, count, offset); + return static_cast(len) == count; +} + +// Returns elf_header.e_type if the file pointed by fd is an ELF binary. +static int FileGetElfType(const int fd) { + ElfW(Ehdr) elf_header; + if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) { + return -1; + } + if (memcmp(elf_header.e_ident, ELFMAG, SELFMAG) != 0) { + return -1; + } + return elf_header.e_type; +} + +// Read the section headers in the given ELF binary, and if a section +// of the specified type is found, set the output to this section header +// and return true. Otherwise, return false. +// To keep stack consumption low, we would like this function to not get +// inlined. +static ATTRIBUTE_NOINLINE bool +GetSectionHeaderByType(const int fd, ElfW(Half) sh_num, const size_t sh_offset, + ElfW(Word) type, ElfW(Shdr) *out) { + // Read at most 16 section headers at a time to save read calls. + ElfW(Shdr) buf[16]; + for (size_t i = 0; i < sh_num;) { + const size_t num_bytes_left = (sh_num - i) * sizeof(buf[0]); + const size_t num_bytes_to_read = + (sizeof(buf) > num_bytes_left) ? num_bytes_left : sizeof(buf); + const ssize_t len = ReadFromOffset(fd, buf, num_bytes_to_read, + sh_offset + i * sizeof(buf[0])); + if (len == -1) { + return false; + } + SAFE_ASSERT(static_cast(len) % sizeof(buf[0]) == 0); + const size_t num_headers_in_buf = static_cast(len) / sizeof(buf[0]); + SAFE_ASSERT(num_headers_in_buf <= sizeof(buf) / sizeof(buf[0])); + for (size_t j = 0; j < num_headers_in_buf; ++j) { + if (buf[j].sh_type == type) { + *out = buf[j]; + return true; + } + } + i += num_headers_in_buf; + } + return false; +} + +// There is no particular reason to limit section name to 63 characters, +// but there has (as yet) been no need for anything longer either. +const int kMaxSectionNameLen = 64; + +// name_len should include terminating '\0'. +bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, + ElfW(Shdr) *out) { + ElfW(Ehdr) elf_header; + if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) { + return false; + } + + ElfW(Shdr) shstrtab; + size_t shstrtab_offset = + (elf_header.e_shoff + static_cast(elf_header.e_shentsize) * + static_cast(elf_header.e_shstrndx)); + if (!ReadFromOffsetExact(fd, &shstrtab, sizeof(shstrtab), shstrtab_offset)) { + return false; + } + + for (size_t i = 0; i < elf_header.e_shnum; ++i) { + size_t section_header_offset = (elf_header.e_shoff + + elf_header.e_shentsize * i); + if (!ReadFromOffsetExact(fd, out, sizeof(*out), section_header_offset)) { + return false; + } + char header_name[kMaxSectionNameLen]; + if (sizeof(header_name) < name_len) { + RAW_LOG(WARNING, "Section name '%s' is too long (%" PRIuS "); " + "section will not be found (even if present).", name, name_len); + // No point in even trying. + return false; + } + size_t name_offset = shstrtab.sh_offset + out->sh_name; + ssize_t n_read = ReadFromOffset(fd, &header_name, name_len, name_offset); + if (n_read == -1) { + return false; + } else if (static_cast(n_read) != name_len) { + // Short read -- name could be at end of file. + continue; + } + if (memcmp(header_name, name, name_len) == 0) { + return true; + } + } + return false; +} + +// Read a symbol table and look for the symbol containing the +// pc. Iterate over symbols in a symbol table and look for the symbol +// containing "pc". On success, return true and write the symbol name +// to out. Otherwise, return false. +// To keep stack consumption low, we would like this function to not get +// inlined. +static ATTRIBUTE_NOINLINE bool +FindSymbol(uint64_t pc, const int fd, char *out, size_t out_size, + uint64_t symbol_offset, const ElfW(Shdr) *strtab, + const ElfW(Shdr) *symtab) { + if (symtab == nullptr) { + return false; + } + const size_t num_symbols = symtab->sh_size / symtab->sh_entsize; + for (unsigned i = 0; i < num_symbols;) { + size_t offset = symtab->sh_offset + i * symtab->sh_entsize; + + // If we are reading Elf64_Sym's, we want to limit this array to + // 32 elements (to keep stack consumption low), otherwise we can + // have a 64 element Elf32_Sym array. +#if defined(__WORDSIZE) && __WORDSIZE == 64 + const size_t NUM_SYMBOLS = 32U; +#else + const size_t NUM_SYMBOLS = 64U; +#endif + + // Read at most NUM_SYMBOLS symbols at once to save read() calls. + ElfW(Sym) buf[NUM_SYMBOLS]; + size_t num_symbols_to_read = std::min(NUM_SYMBOLS, num_symbols - i); + const ssize_t len = + ReadFromOffset(fd, &buf, sizeof(buf[0]) * num_symbols_to_read, offset); + SAFE_ASSERT(static_cast(len) % sizeof(buf[0]) == 0); + const size_t num_symbols_in_buf = static_cast(len) / sizeof(buf[0]); + SAFE_ASSERT(num_symbols_in_buf <= num_symbols_to_read); + for (unsigned j = 0; j < num_symbols_in_buf; ++j) { + const ElfW(Sym)& symbol = buf[j]; + uint64_t start_address = symbol.st_value; + start_address += symbol_offset; + uint64_t end_address = start_address + symbol.st_size; + if (symbol.st_value != 0 && // Skip null value symbols. + symbol.st_shndx != 0 && // Skip undefined symbols. + start_address <= pc && pc < end_address) { + ssize_t len1 = ReadFromOffset(fd, out, out_size, + strtab->sh_offset + symbol.st_name); + if (len1 <= 0 || memchr(out, '\0', out_size) == nullptr) { + memset(out, 0, out_size); + return false; + } + return true; // Obtained the symbol name. + } + } + i += num_symbols_in_buf; + } + return false; +} + +// Get the symbol name of "pc" from the file pointed by "fd". Process +// both regular and dynamic symbol tables if necessary. On success, +// write the symbol name to "out" and return true. Otherwise, return +// false. +static bool GetSymbolFromObjectFile(const int fd, + uint64_t pc, + char* out, + size_t out_size, + uint64_t base_address) { + // Read the ELF header. + ElfW(Ehdr) elf_header; + if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) { + return false; + } + + ElfW(Shdr) symtab, strtab; + + // Consult a regular symbol table first. + if (GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff, + SHT_SYMTAB, &symtab)) { + if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff + + symtab.sh_link * sizeof(symtab))) { + return false; + } + if (FindSymbol(pc, fd, out, out_size, base_address, &strtab, &symtab)) { + return true; // Found the symbol in a regular symbol table. + } + } + + // If the symbol is not found, then consult a dynamic symbol table. + if (GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff, + SHT_DYNSYM, &symtab)) { + if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff + + symtab.sh_link * sizeof(symtab))) { + return false; + } + if (FindSymbol(pc, fd, out, out_size, base_address, &strtab, &symtab)) { + return true; // Found the symbol in a dynamic symbol table. + } + } + + return false; +} + +namespace { +// Thin wrapper around a file descriptor so that the file descriptor +// gets closed for sure. +struct FileDescriptor { + const int fd_; + explicit FileDescriptor(int fd) : fd_(fd) {} + ~FileDescriptor() { + if (fd_ >= 0) { + close(fd_); + } + } + int get() { return fd_; } + + private: + FileDescriptor(const FileDescriptor &) = delete; + void operator=(const FileDescriptor &) = delete; +}; + +// Helper class for reading lines from file. +// +// Note: we don't use ProcMapsIterator since the object is big (it has +// a 5k array member) and uses async-unsafe functions such as sscanf() +// and snprintf(). +class LineReader { + public: + explicit LineReader(int fd, char *buf, size_t buf_len, size_t offset) + : fd_(fd), + buf_(buf), + buf_len_(buf_len), + offset_(offset), + bol_(buf), + eol_(buf), + eod_(buf) {} + + // Read '\n'-terminated line from file. On success, modify "bol" + // and "eol", then return true. Otherwise, return false. + // + // Note: if the last line doesn't end with '\n', the line will be + // dropped. It's an intentional behavior to make the code simple. + bool ReadLine(const char **bol, const char **eol) { + if (BufferIsEmpty()) { // First time. + const ssize_t num_bytes = ReadFromOffset(fd_, buf_, buf_len_, offset_); + if (num_bytes <= 0) { // EOF or error. + return false; + } + offset_ += static_cast(num_bytes); + eod_ = buf_ + num_bytes; + bol_ = buf_; + } else { + bol_ = eol_ + 1; // Advance to the next line in the buffer. + SAFE_ASSERT(bol_ <= eod_); // "bol_" can point to "eod_". + if (!HasCompleteLine()) { + const auto incomplete_line_length = static_cast(eod_ - bol_); + // Move the trailing incomplete line to the beginning. + memmove(buf_, bol_, incomplete_line_length); + // Read text from file and append it. + char * const append_pos = buf_ + incomplete_line_length; + const size_t capacity_left = buf_len_ - incomplete_line_length; + const ssize_t num_bytes = + ReadFromOffset(fd_, append_pos, capacity_left, offset_); + if (num_bytes <= 0) { // EOF or error. + return false; + } + offset_ += static_cast(num_bytes); + eod_ = append_pos + num_bytes; + bol_ = buf_; + } + } + eol_ = FindLineFeed(); + if (eol_ == nullptr) { // '\n' not found. Malformed line. + return false; + } + *eol_ = '\0'; // Replace '\n' with '\0'. + + *bol = bol_; + *eol = eol_; + return true; + } + + // Beginning of line. + const char *bol() { + return bol_; + } + + // End of line. + const char *eol() { + return eol_; + } + + private: + LineReader(const LineReader &) = delete; + void operator=(const LineReader &) = delete; + + char *FindLineFeed() { + return reinterpret_cast(memchr(bol_, '\n', static_cast(eod_ - bol_))); + } + + bool BufferIsEmpty() { + return buf_ == eod_; + } + + bool HasCompleteLine() { + return !BufferIsEmpty() && FindLineFeed() != nullptr; + } + + const int fd_; + char * const buf_; + const size_t buf_len_; + size_t offset_; + char *bol_; + char *eol_; + const char *eod_; // End of data in "buf_". +}; +} // namespace + +// Place the hex number read from "start" into "*hex". The pointer to +// the first non-hex character or "end" is returned. +static char *GetHex(const char *start, const char *end, uint64_t *hex) { + *hex = 0; + const char *p; + for (p = start; p < end; ++p) { + int ch = *p; + if ((ch >= '0' && ch <= '9') || + (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) { + *hex = (*hex << 4U) | (ch < 'A' ? static_cast(ch - '0') : (ch & 0xF) + 9U); + } else { // Encountered the first non-hex character. + break; + } + } + SAFE_ASSERT(p <= end); + return const_cast(p); +} + +// Searches for the object file (from /proc/self/maps) that contains +// the specified pc. If found, sets |start_address| to the start address +// of where this object file is mapped in memory, sets the module base +// address into |base_address|, copies the object file name into +// |out_file_name|, and attempts to open the object file. If the object +// file is opened successfully, returns the file descriptor. Otherwise, +// returns -1. |out_file_name_size| is the size of the file name buffer +// (including the null-terminator). +static ATTRIBUTE_NOINLINE int +OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc, + uint64_t &start_address, + uint64_t &base_address, + char *out_file_name, + size_t out_file_name_size) { + int object_fd; + + int maps_fd; + NO_INTR(maps_fd = open("/proc/self/maps", O_RDONLY)); + FileDescriptor wrapped_maps_fd(maps_fd); + if (wrapped_maps_fd.get() < 0) { + return -1; + } + + int mem_fd; + NO_INTR(mem_fd = open("/proc/self/mem", O_RDONLY)); + FileDescriptor wrapped_mem_fd(mem_fd); + if (wrapped_mem_fd.get() < 0) { + return -1; + } + + // Iterate over maps and look for the map containing the pc. Then + // look into the symbol tables inside. + char buf[1024]; // Big enough for line of sane /proc/self/maps + unsigned num_maps = 0; + LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf), 0); + while (true) { + num_maps++; + const char *cursor; + const char *eol; + if (!reader.ReadLine(&cursor, &eol)) { // EOF or malformed line. + return -1; + } + + // Start parsing line in /proc/self/maps. Here is an example: + // + // 08048000-0804c000 r-xp 00000000 08:01 2142121 /bin/cat + // + // We want start address (08048000), end address (0804c000), flags + // (r-xp) and file name (/bin/cat). + + // Read start address. + cursor = GetHex(cursor, eol, &start_address); + if (cursor == eol || *cursor != '-') { + return -1; // Malformed line. + } + ++cursor; // Skip '-'. + + // Read end address. + uint64_t end_address; + cursor = GetHex(cursor, eol, &end_address); + if (cursor == eol || *cursor != ' ') { + return -1; // Malformed line. + } + ++cursor; // Skip ' '. + + // Read flags. Skip flags until we encounter a space or eol. + const char * const flags_start = cursor; + while (cursor < eol && *cursor != ' ') { + ++cursor; + } + // We expect at least four letters for flags (ex. "r-xp"). + if (cursor == eol || cursor < flags_start + 4) { + return -1; // Malformed line. + } + + // Determine the base address by reading ELF headers in process memory. + ElfW(Ehdr) ehdr; + // Skip non-readable maps. + if (flags_start[0] == 'r' && + ReadFromOffsetExact(mem_fd, &ehdr, sizeof(ElfW(Ehdr)), start_address) && + memcmp(ehdr.e_ident, ELFMAG, SELFMAG) == 0) { + switch (ehdr.e_type) { + case ET_EXEC: + base_address = 0; + break; + case ET_DYN: + // Find the segment containing file offset 0. This will correspond + // to the ELF header that we just read. Normally this will have + // virtual address 0, but this is not guaranteed. We must subtract + // the virtual address from the address where the ELF header was + // mapped to get the base address. + // + // If we fail to find a segment for file offset 0, use the address + // of the ELF header as the base address. + base_address = start_address; + for (unsigned i = 0; i != ehdr.e_phnum; ++i) { + ElfW(Phdr) phdr; + if (ReadFromOffsetExact( + mem_fd, &phdr, sizeof(phdr), + start_address + ehdr.e_phoff + i * sizeof(phdr)) && + phdr.p_type == PT_LOAD && phdr.p_offset == 0) { + base_address = start_address - phdr.p_vaddr; + break; + } + } + break; + default: + // ET_REL or ET_CORE. These aren't directly executable, so they don't + // affect the base address. + break; + } + } + + // Check start and end addresses. + if (!(start_address <= pc && pc < end_address)) { + continue; // We skip this map. PC isn't in this map. + } + + // Check flags. We are only interested in "r*x" maps. + if (flags_start[0] != 'r' || flags_start[2] != 'x') { + continue; // We skip this map. + } + ++cursor; // Skip ' '. + + // Read file offset. + uint64_t file_offset; + cursor = GetHex(cursor, eol, &file_offset); + if (cursor == eol || *cursor != ' ') { + return -1; // Malformed line. + } + ++cursor; // Skip ' '. + + // Skip to file name. "cursor" now points to dev. We need to + // skip at least two spaces for dev and inode. + int num_spaces = 0; + while (cursor < eol) { + if (*cursor == ' ') { + ++num_spaces; + } else if (num_spaces >= 2) { + // The first non-space character after skipping two spaces + // is the beginning of the file name. + break; + } + ++cursor; + } + if (cursor == eol) { + return -1; // Malformed line. + } + + // Finally, "cursor" now points to file name of our interest. + NO_INTR(object_fd = open(cursor, O_RDONLY)); + if (object_fd < 0) { + // Failed to open object file. Copy the object file name to + // |out_file_name|. + strncpy(out_file_name, cursor, out_file_name_size); + // Making sure |out_file_name| is always null-terminated. + out_file_name[out_file_name_size - 1] = '\0'; + return -1; + } + return object_fd; + } +} + +// POSIX doesn't define any async-signal safe function for converting +// an integer to ASCII. We'll have to define our own version. +// itoa_r() converts an (unsigned) integer to ASCII. It returns "buf", if the +// conversion was successful or nullptr otherwise. It never writes more than +// "sz" bytes. Output will be truncated as needed, and a NUL character is always +// appended. +// NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. +static char *itoa_r(uintptr_t i, char *buf, size_t sz, unsigned base, size_t padding) { + // Make sure we can write at least one NUL byte. + size_t n = 1; + if (n > sz) { + return nullptr; + } + + if (base < 2 || base > 16) { + buf[0] = '\000'; + return nullptr; + } + + char *start = buf; + + // Loop until we have converted the entire number. Output at least one + // character (i.e. '0'). + char *ptr = start; + do { + // Make sure there is still enough space left in our output buffer. + if (++n > sz) { + buf[0] = '\000'; + return nullptr; + } + + // Output the next digit. + *ptr++ = "0123456789abcdef"[i % base]; + i /= base; + + if (padding > 0) { + padding--; + } + } while (i > 0 || padding > 0); + + // Terminate the output with a NUL character. + *ptr = '\000'; + + // Conversion to ASCII actually resulted in the digits being in reverse + // order. We can't easily generate them in forward order, as we can't tell + // the number of characters needed until we are done converting. + // So, now, we reverse the string (except for the possible "-" sign). + while (--ptr > start) { + char ch = *ptr; + *ptr = *start; + *start++ = ch; + } + return buf; +} + +// Safely appends string |source| to string |dest|. Never writes past the +// buffer size |dest_size| and guarantees that |dest| is null-terminated. +static void SafeAppendString(const char* source, char* dest, size_t dest_size) { + size_t dest_string_length = strlen(dest); + SAFE_ASSERT(dest_string_length < dest_size); + dest += dest_string_length; + dest_size -= dest_string_length; + strncpy(dest, source, dest_size); + // Making sure |dest| is always null-terminated. + dest[dest_size - 1] = '\0'; +} + +// Converts a 64-bit value into a hex string, and safely appends it to |dest|. +// Never writes past the buffer size |dest_size| and guarantees that |dest| is +// null-terminated. +static void SafeAppendHexNumber(uint64_t value, char* dest, size_t dest_size) { + // 64-bit numbers in hex can have up to 16 digits. + char buf[17] = {'\0'}; + SafeAppendString(itoa_r(value, buf, sizeof(buf), 16, 0), dest, dest_size); +} + +// The implementation of our symbolization routine. If it +// successfully finds the symbol containing "pc" and obtains the +// symbol name, returns true and write the symbol name to "out". +// Otherwise, returns false. If Callback function is installed via +// InstallSymbolizeCallback(), the function is also called in this function, +// and "out" is used as its output. +// To keep stack consumption low, we would like this function to not +// get inlined. +static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, + size_t out_size) { + auto pc0 = reinterpret_cast(pc); + uint64_t start_address = 0; + uint64_t base_address = 0; + int object_fd = -1; + + if (out_size < 1) { + return false; + } + out[0] = '\0'; + SafeAppendString("(", out, out_size); + + if (g_symbolize_open_object_file_callback) { + object_fd = g_symbolize_open_object_file_callback(pc0, start_address, + base_address, out + 1, + out_size - 1); + } else { + object_fd = OpenObjectFileContainingPcAndGetStartAddress(pc0, start_address, + base_address, + out + 1, + out_size - 1); + } + + FileDescriptor wrapped_object_fd(object_fd); + +#if defined(PRINT_UNSYMBOLIZED_STACK_TRACES) + { +#else + // Check whether a file name was returned. + if (object_fd < 0) { +#endif + if (out[1]) { + // The object file containing PC was determined successfully however the + // object file was not opened successfully. This is still considered + // success because the object file name and offset are known and tools + // like asan_symbolize.py can be used for the symbolization. + out[out_size - 1] = '\0'; // Making sure |out| is always null-terminated. + SafeAppendString("+0x", out, out_size); + SafeAppendHexNumber(pc0 - base_address, out, out_size); + SafeAppendString(")", out, out_size); + return true; + } + // Failed to determine the object file containing PC. Bail out. + return false; + } + int elf_type = FileGetElfType(wrapped_object_fd.get()); + if (elf_type == -1) { + return false; + } + if (g_symbolize_callback) { + // Run the call back if it's installed. + // Note: relocation (and much of the rest of this code) will be + // wrong for prelinked shared libraries and PIE executables. + uint64_t relocation = (elf_type == ET_DYN) ? start_address : 0; + int num_bytes_written = g_symbolize_callback(wrapped_object_fd.get(), + pc, out, out_size, + relocation); + if (num_bytes_written > 0) { + out += static_cast(num_bytes_written); + out_size -= static_cast(num_bytes_written); + } + } + if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0, + out, out_size, base_address)) { + if (out[1] && !g_symbolize_callback) { + // The object file containing PC was opened successfully however the + // symbol was not found. The object may have been stripped. This is still + // considered success because the object file name and offset are known + // and tools like asan_symbolize.py can be used for the symbolization. + out[out_size - 1] = '\0'; // Making sure |out| is always null-terminated. + SafeAppendString("+0x", out, out_size); + SafeAppendHexNumber(pc0 - base_address, out, out_size); + SafeAppendString(")", out, out_size); + return true; + } + return false; + } + + // Symbolization succeeded. Now we try to demangle the symbol. + DemangleInplace(out, out_size); + return true; +} + +_END_GOOGLE_NAMESPACE_ + +#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR) + +#include +#include + +_START_GOOGLE_NAMESPACE_ + +static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, + size_t out_size) { + Dl_info info; + if (dladdr(pc, &info)) { + if (info.dli_sname) { + if (strlen(info.dli_sname) < out_size) { + strcpy(out, info.dli_sname); + // Symbolization succeeded. Now we try to demangle the symbol. + DemangleInplace(out, out_size); + return true; + } + } + } + return false; +} + +_END_GOOGLE_NAMESPACE_ + +#elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN) + +#include +#include + +#ifdef _MSC_VER +#pragma comment(lib, "dbghelp") +#endif + +_START_GOOGLE_NAMESPACE_ + +class SymInitializer { +public: + HANDLE process; + bool ready; + SymInitializer() : process(nullptr), ready(false) { + // Initialize the symbol handler. + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680344(v=vs.85).aspx + process = GetCurrentProcess(); + // Defer symbol loading. + // We do not request undecorated symbols with SYMOPT_UNDNAME + // because the mangling library calls UnDecorateSymbolName. + SymSetOptions(SYMOPT_DEFERRED_LOADS); + if (SymInitialize(process, nullptr, true)) { + ready = true; + } + } + ~SymInitializer() { + SymCleanup(process); + // We do not need to close `HANDLE process` because it's a "pseudo handle." + } +private: + SymInitializer(const SymInitializer&); + SymInitializer& operator=(const SymInitializer&); +}; + +static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, + size_t out_size) { + const static SymInitializer symInitializer; + if (!symInitializer.ready) { + return false; + } + // Resolve symbol information from address. + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680578(v=vs.85).aspx + char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; + SYMBOL_INFO *symbol = reinterpret_cast(buf); + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + // We use the ANSI version to ensure the string type is always `char *`. + // This could break if a symbol has Unicode in it. + BOOL ret = SymFromAddr(symInitializer.process, + reinterpret_cast(pc), 0, symbol); + if (ret == 1 && static_cast(symbol->NameLen) < out_size) { + // `NameLen` does not include the null terminating character. + strncpy(out, symbol->Name, static_cast(symbol->NameLen) + 1); + out[static_cast(symbol->NameLen)] = '\0'; + // Symbolization succeeded. Now we try to demangle the symbol. + DemangleInplace(out, out_size); + return true; + } + return false; +} + +_END_GOOGLE_NAMESPACE_ + +#else +# error BUG: HAVE_SYMBOLIZE was wrongly set +#endif + +_START_GOOGLE_NAMESPACE_ + +bool Symbolize(void *pc, char *out, size_t out_size) { + return SymbolizeAndDemangle(pc, out, out_size); +} + +_END_GOOGLE_NAMESPACE_ + +#else /* HAVE_SYMBOLIZE */ + +#include + +#include "config.h" + +_START_GOOGLE_NAMESPACE_ + +// TODO: Support other environments. +bool Symbolize(void* /*pc*/, char* /*out*/, size_t /*out_size*/) { + assert(0); + return false; +} + +_END_GOOGLE_NAMESPACE_ + +#endif diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.h b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.h new file mode 100644 index 000000000..86c22e3ea --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize.h @@ -0,0 +1,152 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// This library provides Symbolize() function that symbolizes program +// counters to their corresponding symbol names on linux platforms. +// This library has a minimal implementation of an ELF symbol table +// reader (i.e. it doesn't depend on libelf, etc.). +// +// The algorithm used in Symbolize() is as follows. +// +// 1. Go through a list of maps in /proc/self/maps and find the map +// containing the program counter. +// +// 2. Open the mapped file and find a regular symbol table inside. +// Iterate over symbols in the symbol table and look for the symbol +// containing the program counter. If such a symbol is found, +// obtain the symbol name, and demangle the symbol if possible. +// If the symbol isn't found in the regular symbol table (binary is +// stripped), try the same thing with a dynamic symbol table. +// +// Note that Symbolize() is originally implemented to be used in +// FailureSignalHandler() in base/google.cc. Hence it doesn't use +// malloc() and other unsafe operations. It should be both +// thread-safe and async-signal-safe. + +#ifndef BASE_SYMBOLIZE_H_ +#define BASE_SYMBOLIZE_H_ + +#include "utilities.h" +#include "config.h" +#include + +#ifdef HAVE_SYMBOLIZE + +#if defined(__ELF__) // defined by gcc +#if defined(__OpenBSD__) +#include +#else +#include +#endif + +#if !defined(ANDROID) +#include // For ElfW() macro. +#endif + +// For systems where SIZEOF_VOID_P is not defined, determine it +// based on __LP64__ (defined by gcc on 64-bit systems) +#if !defined(SIZEOF_VOID_P) +# if defined(__LP64__) +# define SIZEOF_VOID_P 8 +# else +# define SIZEOF_VOID_P 4 +# endif +#endif + +// If there is no ElfW macro, let's define it by ourself. +#ifndef ElfW +# if SIZEOF_VOID_P == 4 +# define ElfW(type) Elf32_##type +# elif SIZEOF_VOID_P == 8 +# define ElfW(type) Elf64_##type +# else +# error "Unknown sizeof(void *)" +# endif +#endif + +_START_GOOGLE_NAMESPACE_ + +// Gets the section header for the given name, if it exists. Returns true on +// success. Otherwise, returns false. +bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, + ElfW(Shdr) *out); + +_END_GOOGLE_NAMESPACE_ + +#endif /* __ELF__ */ + +_START_GOOGLE_NAMESPACE_ + +// Restrictions on the callbacks that follow: +// - The callbacks must not use heaps but only use stacks. +// - The callbacks must be async-signal-safe. + +// Installs a callback function, which will be called right before a symbol name +// is printed. The callback is intended to be used for showing a file name and a +// line number preceding a symbol name. +// "fd" is a file descriptor of the object file containing the program +// counter "pc". The callback function should write output to "out" +// and return the size of the output written. On error, the callback +// function should return -1. +using SymbolizeCallback = int (*)(int, void *, char *, size_t, uint64_t); +GLOG_EXPORT +void InstallSymbolizeCallback(SymbolizeCallback callback); + +// Installs a callback function, which will be called instead of +// OpenObjectFileContainingPcAndGetStartAddress. The callback is expected +// to searches for the object file (from /proc/self/maps) that contains +// the specified pc. If found, sets |start_address| to the start address +// of where this object file is mapped in memory, sets the module base +// address into |base_address|, copies the object file name into +// |out_file_name|, and attempts to open the object file. If the object +// file is opened successfully, returns the file descriptor. Otherwise, +// returns -1. |out_file_name_size| is the size of the file name buffer +// (including the null-terminator). +using SymbolizeOpenObjectFileCallback = int (*)(uint64_t, uint64_t &, + uint64_t &, char *, size_t); +void InstallSymbolizeOpenObjectFileCallback( + SymbolizeOpenObjectFileCallback callback); + +_END_GOOGLE_NAMESPACE_ + +#endif + +_START_GOOGLE_NAMESPACE_ + +// Symbolizes a program counter. On success, returns true and write the +// symbol name to "out". The symbol name is demangled if possible +// (supports symbols generated by GCC 3.x or newer). Otherwise, +// returns false. +GLOG_EXPORT bool Symbolize(void* pc, char* out, size_t out_size); + +_END_GOOGLE_NAMESPACE_ + +#endif // BASE_SYMBOLIZE_H_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/symbolize_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize_unittest.cc new file mode 100644 index 000000000..2b4d8c29e --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/symbolize_unittest.cc @@ -0,0 +1,468 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Satoru Takabayashi +// +// Unit tests for functions in symbolize.cc. + +#include "symbolize.h" + +#include + +#include +#include + +#include "config.h" +#include "googletest.h" +#include "utilities.h" + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +using namespace std; +using namespace GOOGLE_NAMESPACE; + +// Avoid compile error due to "cast between pointer-to-function and +// pointer-to-object is an extension" warnings. +#if defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +#if defined(HAVE_STACKTRACE) + +#define always_inline + +#if defined(__ELF__) || defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN) +// A wrapper function for Symbolize() to make the unit test simple. +static const char *TrySymbolize(void *pc) { + static char symbol[4096]; + if (Symbolize(pc, symbol, sizeof(symbol))) { + return symbol; + } else { + return nullptr; + } +} +#endif + +# if defined(__ELF__) + +// This unit tests make sense only with GCC. +// Uses lots of GCC specific features. +#if defined(__GNUC__) && !defined(__OPENCC__) +# if __GNUC__ >= 4 +# define TEST_WITH_MODERN_GCC +# if defined(__i386__) && __i386__ // always_inline isn't supported for x86_64 with GCC 4.1.0. +# undef always_inline +# define always_inline __attribute__((always_inline)) +# define HAVE_ALWAYS_INLINE +# endif // __i386__ +# else +# endif // __GNUC__ >= 4 +# if defined(__i386__) || defined(__x86_64__) +# define TEST_X86_32_AND_64 1 +# endif // defined(__i386__) || defined(__x86_64__) +#endif + +// Make them C linkage to avoid mangled names. +extern "C" { +void nonstatic_func(); +void nonstatic_func() { + volatile int a = 0; + // NOTE: In C++20, increment of object of volatile-qualified type is + // deprecated. + a = a + 1; +} + +static void static_func() { + volatile int a = 0; + // NOTE: In C++20, increment of object of volatile-qualified type is + // deprecated. + a = a + 1; +} +} + +TEST(Symbolize, Symbolize) { + // We do C-style cast since GCC 2.95.3 doesn't allow + // reinterpret_cast(&func). + + // Compilers should give us pointers to them. + EXPECT_STREQ("nonstatic_func", TrySymbolize((void *)(&nonstatic_func))); + + // The name of an internal linkage symbol is not specified; allow either a + // mangled or an unmangled name here. + const char *static_func_symbol = + TrySymbolize(reinterpret_cast(&static_func)); + +#if !defined(_MSC_VER) || !defined(NDEBUG) + CHECK(nullptr != static_func_symbol); + EXPECT_TRUE(strcmp("static_func", static_func_symbol) == 0 || + strcmp("static_func()", static_func_symbol) == 0); +#endif + + EXPECT_TRUE(nullptr == TrySymbolize(nullptr)); +} + +struct Foo { + static void func(int x); +}; + +void ATTRIBUTE_NOINLINE Foo::func(int x) { + volatile int a = x; + // NOTE: In C++20, increment of object of volatile-qualified type is + // deprecated. + a = a + 1; +} + +// With a modern GCC, Symbolize() should return demangled symbol +// names. Function parameters should be omitted. +#ifdef TEST_WITH_MODERN_GCC +TEST(Symbolize, SymbolizeWithDemangling) { + Foo::func(100); +#if !defined(_MSC_VER) || !defined(NDEBUG) + EXPECT_STREQ("Foo::func()", TrySymbolize((void *)(&Foo::func))); +#endif +} +#endif + +// Tests that verify that Symbolize footprint is within some limit. + +// To measure the stack footprint of the Symbolize function, we create +// a signal handler (for SIGUSR1 say) that calls the Symbolize function +// on an alternate stack. This alternate stack is initialized to some +// known pattern (0x55, 0x55, 0x55, ...). We then self-send this signal, +// and after the signal handler returns, look at the alternate stack +// buffer to see what portion has been touched. +// +// This trick gives us the the stack footprint of the signal handler. +// But the signal handler, even before the call to Symbolize, consumes +// some stack already. We however only want the stack usage of the +// Symbolize function. To measure this accurately, we install two signal +// handlers: one that does nothing and just returns, and another that +// calls Symbolize. The difference between the stack consumption of these +// two signals handlers should give us the Symbolize stack foorprint. + +static void *g_pc_to_symbolize; +static char g_symbolize_buffer[4096]; +static char *g_symbolize_result; + +static void EmptySignalHandler(int /*signo*/) {} + +static void SymbolizeSignalHandler(int /*signo*/) { + if (Symbolize(g_pc_to_symbolize, g_symbolize_buffer, + sizeof(g_symbolize_buffer))) { + g_symbolize_result = g_symbolize_buffer; + } else { + g_symbolize_result = nullptr; + } +} + +const int kAlternateStackSize = 8096; +const char kAlternateStackFillValue = 0x55; + +// These helper functions look at the alternate stack buffer, and figure +// out what portion of this buffer has been touched - this is the stack +// consumption of the signal handler running on this alternate stack. +static ATTRIBUTE_NOINLINE bool StackGrowsDown(int *x) { + int y; + return &y < x; +} +static int GetStackConsumption(const char* alt_stack) { + int x; + if (StackGrowsDown(&x)) { + for (int i = 0; i < kAlternateStackSize; i++) { + if (alt_stack[i] != kAlternateStackFillValue) { + return (kAlternateStackSize - i); + } + } + } else { + for (int i = (kAlternateStackSize - 1); i >= 0; i--) { + if (alt_stack[i] != kAlternateStackFillValue) { + return i; + } + } + } + return -1; +} + +#ifdef HAVE_SIGALTSTACK + +// Call Symbolize and figure out the stack footprint of this call. +static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) { + + g_pc_to_symbolize = pc; + + // The alt-signal-stack cannot be heap allocated because there is a + // bug in glibc-2.2 where some signal handler setup code looks at the + // current stack pointer to figure out what thread is currently running. + // Therefore, the alternate stack must be allocated from the main stack + // itself. + char altstack[kAlternateStackSize]; + memset(altstack, kAlternateStackFillValue, kAlternateStackSize); + + // Set up the alt-signal-stack (and save the older one). + stack_t sigstk; + memset(&sigstk, 0, sizeof(stack_t)); + stack_t old_sigstk; + sigstk.ss_sp = altstack; + sigstk.ss_size = kAlternateStackSize; + sigstk.ss_flags = 0; + CHECK_ERR(sigaltstack(&sigstk, &old_sigstk)); + + // Set up SIGUSR1 and SIGUSR2 signal handlers (and save the older ones). + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + struct sigaction old_sa1, old_sa2; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_ONSTACK; + + // SIGUSR1 maps to EmptySignalHandler. + sa.sa_handler = EmptySignalHandler; + CHECK_ERR(sigaction(SIGUSR1, &sa, &old_sa1)); + + // SIGUSR2 maps to SymbolizeSignalHanlder. + sa.sa_handler = SymbolizeSignalHandler; + CHECK_ERR(sigaction(SIGUSR2, &sa, &old_sa2)); + + // Send SIGUSR1 signal and measure the stack consumption of the empty + // signal handler. + CHECK_ERR(kill(getpid(), SIGUSR1)); + int stack_consumption1 = GetStackConsumption(altstack); + + // Send SIGUSR2 signal and measure the stack consumption of the symbolize + // signal handler. + CHECK_ERR(kill(getpid(), SIGUSR2)); + int stack_consumption2 = GetStackConsumption(altstack); + + // The difference between the two stack consumption values is the + // stack footprint of the Symbolize function. + if (stack_consumption1 != -1 && stack_consumption2 != -1) { + *stack_consumed = stack_consumption2 - stack_consumption1; + } else { + *stack_consumed = -1; + } + + // Log the stack consumption values. + LOG(INFO) << "Stack consumption of empty signal handler: " + << stack_consumption1; + LOG(INFO) << "Stack consumption of symbolize signal handler: " + << stack_consumption2; + LOG(INFO) << "Stack consumption of Symbolize: " << *stack_consumed; + + // Now restore the old alt-signal-stack and signal handlers. + CHECK_ERR(sigaltstack(&old_sigstk, nullptr)); + CHECK_ERR(sigaction(SIGUSR1, &old_sa1, nullptr)); + CHECK_ERR(sigaction(SIGUSR2, &old_sa2, nullptr)); + + return g_symbolize_result; +} + +#ifdef __ppc64__ +// Symbolize stack consumption should be within 4kB. +const int kStackConsumptionUpperLimit = 4096; +#else +// Symbolize stack consumption should be within 2kB. +const int kStackConsumptionUpperLimit = 2048; +#endif + +TEST(Symbolize, SymbolizeStackConsumption) { + int stack_consumed; + const char* symbol; + + symbol = SymbolizeStackConsumption(reinterpret_cast(&nonstatic_func), + &stack_consumed); + EXPECT_STREQ("nonstatic_func", symbol); + EXPECT_GT(stack_consumed, 0); + EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit); + + // The name of an internal linkage symbol is not specified; allow either a + // mangled or an unmangled name here. + symbol = SymbolizeStackConsumption(reinterpret_cast(&static_func), + &stack_consumed); + CHECK(nullptr != symbol); + EXPECT_TRUE(strcmp("static_func", symbol) == 0 || + strcmp("static_func()", symbol) == 0); + EXPECT_GT(stack_consumed, 0); + EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit); +} + +#ifdef TEST_WITH_MODERN_GCC +TEST(Symbolize, SymbolizeWithDemanglingStackConsumption) { + Foo::func(100); + int stack_consumed; + const char* symbol; + + symbol = SymbolizeStackConsumption(reinterpret_cast(&Foo::func), + &stack_consumed); + + EXPECT_STREQ("Foo::func()", symbol); + EXPECT_GT(stack_consumed, 0); + EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit); +} +#endif + +#endif // HAVE_SIGALTSTACK + +// x86 specific tests. Uses some inline assembler. +extern "C" { +inline void* always_inline inline_func() { + void *pc = nullptr; +#ifdef TEST_X86_32_AND_64 + __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc)); +#endif + return pc; +} + +void* ATTRIBUTE_NOINLINE non_inline_func(); +void* ATTRIBUTE_NOINLINE non_inline_func() { + void *pc = nullptr; +#ifdef TEST_X86_32_AND_64 + __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc)); +#endif + return pc; +} + +static void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() { +#if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE) + void *pc = non_inline_func(); + const char *symbol = TrySymbolize(pc); + +#if !defined(_MSC_VER) || !defined(NDEBUG) + CHECK(symbol != nullptr); + CHECK_STREQ(symbol, "non_inline_func"); +#endif + cout << "Test case TestWithPCInsideNonInlineFunction passed." << endl; +#endif +} + +static void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() { +#if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE) + void *pc = inline_func(); // Must be inlined. + const char *symbol = TrySymbolize(pc); + +#if !defined(_MSC_VER) || !defined(NDEBUG) + CHECK(symbol != nullptr); + CHECK_STREQ(symbol, __FUNCTION__); +#endif + cout << "Test case TestWithPCInsideInlineFunction passed." << endl; +#endif +} +} + +// Test with a return address. +static void ATTRIBUTE_NOINLINE TestWithReturnAddress() { +#if defined(HAVE_ATTRIBUTE_NOINLINE) + void *return_address = __builtin_return_address(0); + const char *symbol = TrySymbolize(return_address); + +#if !defined(_MSC_VER) || !defined(NDEBUG) + CHECK(symbol != nullptr); + CHECK_STREQ(symbol, "main"); +#endif + cout << "Test case TestWithReturnAddress passed." << endl; +#endif +} + +# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN) + +#ifdef _MSC_VER +#include +#pragma intrinsic(_ReturnAddress) +#endif + +struct Foo { + static void func(int x); +}; + +__declspec(noinline) void Foo::func(int x) { + volatile int a = x; + // NOTE: In C++20, increment of object of volatile-qualified type is + // deprecated. + a = a + 1; +} + +TEST(Symbolize, SymbolizeWithDemangling) { + Foo::func(100); + const char* ret = TrySymbolize((void *)(&Foo::func)); + +#if defined(HAVE_DBGHELP) && !defined(NDEBUG) + EXPECT_STREQ("public: static void __cdecl Foo::func(int)", ret); +#endif +} + +__declspec(noinline) void TestWithReturnAddress() { + void *return_address = +#ifdef __GNUC__ // Cygwin and MinGW support + __builtin_return_address(0) +#else + _ReturnAddress() +#endif + ; + const char *symbol = TrySymbolize(return_address); +#if !defined(_MSC_VER) || !defined(NDEBUG) + CHECK(symbol != nullptr); + CHECK_STREQ(symbol, "main"); +#endif + cout << "Test case TestWithReturnAddress passed." << endl; +} +# endif // __ELF__ +#endif // HAVE_STACKTRACE + +int main(int argc, char **argv) { + FLAGS_logtostderr = true; + InitGoogleLogging(argv[0]); + InitGoogleTest(&argc, argv); +#if defined(HAVE_SYMBOLIZE) && defined(HAVE_STACKTRACE) +# if defined(__ELF__) + // We don't want to get affected by the callback interface, that may be + // used to install some callback function at InitGoogle() time. + InstallSymbolizeCallback(nullptr); + + TestWithPCInsideInlineFunction(); + TestWithPCInsideNonInlineFunction(); + TestWithReturnAddress(); + return RUN_ALL_TESTS(); +# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN) + TestWithReturnAddress(); + return RUN_ALL_TESTS(); +# else // GLOG_OS_WINDOWS + printf("PASS (no symbolize_unittest support)\n"); + return 0; +# endif // __ELF__ +#else + printf("PASS (no symbolize support)\n"); + return 0; +#endif // HAVE_SYMBOLIZE +} + +#if defined(__GNUG__) +#pragma GCC diagnostic pop +#endif diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/utilities.cc b/funasr/runtime/onnxruntime/third_party/glog/src/utilities.cc new file mode 100644 index 000000000..8b0a1ea0a --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/utilities.cc @@ -0,0 +1,400 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Shinichiro Hamaji + +#include "config.h" +#include "utilities.h" + +#include +#include + +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include +#if defined(HAVE_SYSCALL_H) +#include // for syscall() +#elif defined(HAVE_SYS_SYSCALL_H) +#include // for syscall() +#endif +#ifdef HAVE_SYSLOG_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include // For geteuid. +#endif +#ifdef HAVE_PWD_H +# include +#endif +#ifdef __ANDROID__ +#include +#endif + +#include "base/googleinit.h" + +using std::string; + +_START_GOOGLE_NAMESPACE_ + +static const char* g_program_invocation_short_name = nullptr; + +bool IsGoogleLoggingInitialized() { + return g_program_invocation_short_name != nullptr; +} + +_END_GOOGLE_NAMESPACE_ + +// The following APIs are all internal. +#ifdef HAVE_STACKTRACE + +#include "stacktrace.h" +#include "symbolize.h" +#include "base/commandlineflags.h" + +GLOG_DEFINE_bool(symbolize_stacktrace, true, + "Symbolize the stack trace in the tombstone"); + +_START_GOOGLE_NAMESPACE_ + +using DebugWriter = void(const char*, void*); + +// The %p field width for printf() functions is two characters per byte. +// For some environments, add two extra bytes for the leading "0x". +static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*); + +static void DebugWriteToStderr(const char* data, void *) { + // This one is signal-safe. + if (write(STDERR_FILENO, data, strlen(data)) < 0) { + // Ignore errors. + } +#if defined(__ANDROID__) + // ANDROID_LOG_FATAL as fatal error occurred and now is dumping call stack. + __android_log_write(ANDROID_LOG_FATAL, + glog_internal_namespace_::ProgramInvocationShortName(), + data); +#endif +} + +static void DebugWriteToString(const char* data, void *arg) { + reinterpret_cast(arg)->append(data); +} + +#ifdef HAVE_SYMBOLIZE +// Print a program counter and its symbol name. +static void DumpPCAndSymbol(DebugWriter *writerfn, void *arg, void *pc, + const char * const prefix) { + char tmp[1024]; + const char *symbol = "(unknown)"; + // Symbolizes the previous address of pc because pc may be in the + // next function. The overrun happens when the function ends with + // a call to a function annotated noreturn (e.g. CHECK). + if (Symbolize(reinterpret_cast(pc) - 1, tmp, sizeof(tmp))) { + symbol = tmp; + } + char buf[1024]; + snprintf(buf, sizeof(buf), "%s@ %*p %s\n", + prefix, kPrintfPointerFieldWidth, pc, symbol); + writerfn(buf, arg); +} +#endif + +static void DumpPC(DebugWriter *writerfn, void *arg, void *pc, + const char * const prefix) { + char buf[100]; + snprintf(buf, sizeof(buf), "%s@ %*p\n", + prefix, kPrintfPointerFieldWidth, pc); + writerfn(buf, arg); +} + +// Dump current stack trace as directed by writerfn +static void DumpStackTrace(int skip_count, DebugWriter *writerfn, void *arg) { + // Print stack trace + void* stack[32]; + int depth = GetStackTrace(stack, ARRAYSIZE(stack), skip_count+1); + for (int i = 0; i < depth; i++) { +#if defined(HAVE_SYMBOLIZE) + if (FLAGS_symbolize_stacktrace) { + DumpPCAndSymbol(writerfn, arg, stack[i], " "); + } else { + DumpPC(writerfn, arg, stack[i], " "); + } +#else + DumpPC(writerfn, arg, stack[i], " "); +#endif + } +} + +#ifdef __GNUC__ +__attribute__((noreturn)) +#endif +static void +DumpStackTraceAndExit() { + DumpStackTrace(1, DebugWriteToStderr, nullptr); + + // TODO(hamaji): Use signal instead of sigaction? + if (IsFailureSignalHandlerInstalled()) { + // Set the default signal handler for SIGABRT, to avoid invoking our + // own signal handler installed by InstallFailureSignalHandler(). +#ifdef HAVE_SIGACTION + struct sigaction sig_action; + memset(&sig_action, 0, sizeof(sig_action)); + sigemptyset(&sig_action.sa_mask); + sig_action.sa_handler = SIG_DFL; + sigaction(SIGABRT, &sig_action, nullptr); +#elif defined(GLOG_OS_WINDOWS) + signal(SIGABRT, SIG_DFL); +#endif // HAVE_SIGACTION + } + + abort(); +} + +_END_GOOGLE_NAMESPACE_ + +#endif // HAVE_STACKTRACE + +_START_GOOGLE_NAMESPACE_ + +namespace glog_internal_namespace_ { + +const char* ProgramInvocationShortName() { + if (g_program_invocation_short_name != nullptr) { + return g_program_invocation_short_name; + } else { + // TODO(hamaji): Use /proc/self/cmdline and so? + return "UNKNOWN"; + } +} + +#ifdef GLOG_OS_WINDOWS +struct timeval { + long tv_sec, tv_usec; +}; + +// Based on: http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/os_win32.c&q=GetSystemTimeAsFileTime%20license:bsd +// See COPYING for copyright information. +static int gettimeofday(struct timeval *tv, void* /*tz*/) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlong-long" +#endif +#define EPOCHFILETIME (116444736000000000ULL) + FILETIME ft; + ULARGE_INTEGER li; + uint64 tt; + + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + tt = (li.QuadPart - EPOCHFILETIME) / 10; + tv->tv_sec = tt / 1000000; + tv->tv_usec = tt % 1000000; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + + return 0; +} +#endif + +int64 CycleClock_Now() { + // TODO(hamaji): temporary impementation - it might be too slow. + struct timeval tv; + gettimeofday(&tv, nullptr); + return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; +} + +int64 UsecToCycles(int64 usec) { + return usec; +} + +WallTime WallTime_Now() { + // Now, cycle clock is retuning microseconds since the epoch. + return CycleClock_Now() * 0.000001; +} + +static int32 g_main_thread_pid = getpid(); +int32 GetMainThreadPid() { + return g_main_thread_pid; +} + +bool PidHasChanged() { + int32 pid = getpid(); + if (g_main_thread_pid == pid) { + return false; + } + g_main_thread_pid = pid; + return true; +} + +pid_t GetTID() { + // On Linux and MacOSX, we try to use gettid(). +#if defined GLOG_OS_LINUX || defined GLOG_OS_MACOSX +#ifndef __NR_gettid +#ifdef GLOG_OS_MACOSX +#define __NR_gettid SYS_gettid +#elif ! defined __i386__ +#error "Must define __NR_gettid for non-x86 platforms" +#else +#define __NR_gettid 224 +#endif +#endif + static bool lacks_gettid = false; + if (!lacks_gettid) { +#if (defined(GLOG_OS_MACOSX) && defined(HAVE_PTHREAD_THREADID_NP)) + uint64_t tid64; + const int error = pthread_threadid_np(nullptr, &tid64); + pid_t tid = error ? -1 : static_cast(tid64); +#else + auto tid = static_cast(syscall(__NR_gettid)); +#endif + if (tid != -1) { + return tid; + } + // Technically, this variable has to be volatile, but there is a small + // performance penalty in accessing volatile variables and there should + // not be any serious adverse effect if a thread does not immediately see + // the value change to "true". + lacks_gettid = true; + } +#endif // GLOG_OS_LINUX || GLOG_OS_MACOSX + + // If gettid() could not be used, we use one of the following. +#if defined GLOG_OS_LINUX + return getpid(); // Linux: getpid returns thread ID when gettid is absent +#elif defined GLOG_OS_WINDOWS && !defined GLOG_OS_CYGWIN + return static_cast(GetCurrentThreadId()); +#elif defined(HAVE_PTHREAD) + // If none of the techniques above worked, we use pthread_self(). + return (pid_t)(uintptr_t)pthread_self(); +#else + return -1; +#endif +} + +const char* const_basename(const char* filepath) { + const char* base = strrchr(filepath, '/'); +#ifdef GLOG_OS_WINDOWS // Look for either path separator in Windows + if (!base) + base = strrchr(filepath, '\\'); +#endif + return base ? (base+1) : filepath; +} + +static string g_my_user_name; +const string& MyUserName() { + return g_my_user_name; +} +static void MyUserNameInitializer() { + // TODO(hamaji): Probably this is not portable. +#if defined(GLOG_OS_WINDOWS) + const char* user = getenv("USERNAME"); +#else + const char* user = getenv("USER"); +#endif + if (user != nullptr) { + g_my_user_name = user; + } else { +#if defined(HAVE_PWD_H) && defined(HAVE_UNISTD_H) + struct passwd pwd; + struct passwd* result = nullptr; + char buffer[1024] = {'\0'}; + uid_t uid = geteuid(); + int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &result); + if (pwuid_res == 0 && result) { + g_my_user_name = pwd.pw_name; + } else { + snprintf(buffer, sizeof(buffer), "uid%d", uid); + g_my_user_name = buffer; + } +#endif + if (g_my_user_name.empty()) { + g_my_user_name = "invalid-user"; + } + } +} +REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer()) + +#ifdef HAVE_STACKTRACE +void DumpStackTraceToString(string* stacktrace) { + DumpStackTrace(1, DebugWriteToString, stacktrace); +} +#endif + +// We use an atomic operation to prevent problems with calling CrashReason +// from inside the Mutex implementation (potentially through RAW_CHECK). +static const CrashReason* g_reason = nullptr; + +void SetCrashReason(const CrashReason* r) { + sync_val_compare_and_swap(&g_reason, + reinterpret_cast(0), + r); +} + +void InitGoogleLoggingUtilities(const char* argv0) { + CHECK(!IsGoogleLoggingInitialized()) + << "You called InitGoogleLogging() twice!"; + const char* slash = strrchr(argv0, '/'); +#ifdef GLOG_OS_WINDOWS + if (!slash) slash = strrchr(argv0, '\\'); +#endif + g_program_invocation_short_name = slash ? slash + 1 : argv0; + +#ifdef HAVE_STACKTRACE + InstallFailureFunction(&DumpStackTraceAndExit); +#endif +} + +void ShutdownGoogleLoggingUtilities() { + CHECK(IsGoogleLoggingInitialized()) + << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; + g_program_invocation_short_name = nullptr; +#ifdef HAVE_SYSLOG_H + closelog(); +#endif +} + +} // namespace glog_internal_namespace_ + +_END_GOOGLE_NAMESPACE_ + +// Make an implementation of stacktrace compiled. +#ifdef STACKTRACE_H +# include STACKTRACE_H +# if 0 +// For include scanners which can't handle macro expansions. +# include "stacktrace_libunwind-inl.h" +# include "stacktrace_x86-inl.h" +# include "stacktrace_x86_64-inl.h" +# include "stacktrace_powerpc-inl.h" +# include "stacktrace_generic-inl.h" +# endif +#endif diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/utilities.h b/funasr/runtime/onnxruntime/third_party/glog/src/utilities.h new file mode 100644 index 000000000..45e555b27 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/utilities.h @@ -0,0 +1,217 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Shinichiro Hamaji +// +// Define utilties for glog internal usage. + +#ifndef UTILITIES_H__ +#define UTILITIES_H__ + +// printf macros for size_t, in the style of inttypes.h +#ifdef _LP64 +#define __PRIS_PREFIX "z" +#else +#define __PRIS_PREFIX +#endif + +// Use these macros after a % in a printf format string +// to get correct 32/64 bit behavior, like this: +// size_t size = records.size(); +// printf("%"PRIuS"\n", size); + +#define PRIdS __PRIS_PREFIX "d" +#define PRIxS __PRIS_PREFIX "x" +#define PRIuS __PRIS_PREFIX "u" +#define PRIXS __PRIS_PREFIX "X" +#define PRIoS __PRIS_PREFIX "o" + +#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE + +#include + +#include + +#if defined(GLOG_OS_WINDOWS) +# include "port.h" +#endif + +#include "config.h" + +// There are three different ways we can try to get the stack trace: +// +// 1) The libunwind library. This is still in development, and as a +// separate library adds a new dependency, but doesn't need a frame +// pointer. It also doesn't call malloc. +// +// 2) Our hand-coded stack-unwinder. This depends on a certain stack +// layout, which is used by gcc (and those systems using a +// gcc-compatible ABI) on x86 systems, at least since gcc 2.95. +// It uses the frame pointer to do its work. +// +// 3) The gdb unwinder -- also the one used by the c++ exception code. +// It's obviously well-tested, but has a fatal flaw: it can call +// malloc() from the unwinder. This is a problem because we're +// trying to use the unwinder to instrument malloc(). +// +// 4) The Windows API CaptureStackTrace. +// +// Note: if you add a new implementation here, make sure it works +// correctly when GetStackTrace() is called with max_depth == 0. +// Some code may do that. + +#if defined(HAVE_LIB_UNWIND) +# define STACKTRACE_H "stacktrace_libunwind-inl.h" +#elif defined(HAVE__UNWIND_BACKTRACE) && defined(HAVE__UNWIND_GETIP) +# define STACKTRACE_H "stacktrace_unwind-inl.h" +#elif !defined(NO_FRAME_POINTER) +# if defined(__i386__) && __GNUC__ >= 2 +# define STACKTRACE_H "stacktrace_x86-inl.h" +# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2 +# define STACKTRACE_H "stacktrace_powerpc-inl.h" +# elif defined(GLOG_OS_WINDOWS) +# define STACKTRACE_H "stacktrace_windows-inl.h" +# endif +#endif + +#if !defined(STACKTRACE_H) && defined(HAVE_EXECINFO_BACKTRACE) +# define STACKTRACE_H "stacktrace_generic-inl.h" +#endif + +#if defined(STACKTRACE_H) +# define HAVE_STACKTRACE +#endif + +#ifndef GLOG_NO_SYMBOLIZE_DETECTION +#ifndef HAVE_SYMBOLIZE +// defined by gcc +#if defined(__ELF__) && defined(GLOG_OS_LINUX) +# define HAVE_SYMBOLIZE +#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR) +// Use dladdr to symbolize. +# define HAVE_SYMBOLIZE +#elif defined(GLOG_OS_WINDOWS) +// Use DbgHelp to symbolize +# define HAVE_SYMBOLIZE +#endif +#endif // !defined(HAVE_SYMBOLIZE) +#endif // !defined(GLOG_NO_SYMBOLIZE_DETECTION) + +#ifndef ARRAYSIZE +// There is a better way, but this is good enough for our purpose. +# define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) +#endif + +_START_GOOGLE_NAMESPACE_ + +namespace glog_internal_namespace_ { + +#ifdef HAVE___ATTRIBUTE__ +# define ATTRIBUTE_NOINLINE __attribute__ ((noinline)) +# define HAVE_ATTRIBUTE_NOINLINE +#elif defined(GLOG_OS_WINDOWS) +# define ATTRIBUTE_NOINLINE __declspec(noinline) +# define HAVE_ATTRIBUTE_NOINLINE +#else +# define ATTRIBUTE_NOINLINE +#endif + +const char* ProgramInvocationShortName(); + +int64 CycleClock_Now(); + +int64 UsecToCycles(int64 usec); +WallTime WallTime_Now(); + +int32 GetMainThreadPid(); +bool PidHasChanged(); + +pid_t GetTID(); + +const std::string& MyUserName(); + +// Get the part of filepath after the last path separator. +// (Doesn't modify filepath, contrary to basename() in libgen.h.) +const char* const_basename(const char* filepath); + +// Wrapper of __sync_val_compare_and_swap. If the GCC extension isn't +// defined, we try the CPU specific logics (we only support x86 and +// x86_64 for now) first, then use a naive implementation, which has a +// race condition. +template +inline T sync_val_compare_and_swap(T* ptr, T oldval, T newval) { +#if defined(HAVE___SYNC_VAL_COMPARE_AND_SWAP) + return __sync_val_compare_and_swap(ptr, oldval, newval); +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + T ret; + __asm__ __volatile__("lock; cmpxchg %1, (%2);" + :"=a"(ret) + // GCC may produces %sil or %dil for + // constraint "r", but some of apple's gas + // dosn't know the 8 bit registers. + // We use "q" to avoid these registers. + :"q"(newval), "q"(ptr), "a"(oldval) + :"memory", "cc"); + return ret; +#else + T ret = *ptr; + if (ret == oldval) { + *ptr = newval; + } + return ret; +#endif +} + +void DumpStackTraceToString(std::string* stacktrace); + +struct CrashReason { + CrashReason() = default; + + const char* filename{nullptr}; + int line_number{0}; + const char* message{nullptr}; + + // We'll also store a bit of stack trace context at the time of crash as + // it may not be available later on. + void* stack[32]; + int depth{0}; +}; + +void SetCrashReason(const CrashReason* r); + +void InitGoogleLoggingUtilities(const char* argv0); +void ShutdownGoogleLoggingUtilities(); + +} // namespace glog_internal_namespace_ + +_END_GOOGLE_NAMESPACE_ + +using namespace GOOGLE_NAMESPACE::glog_internal_namespace_; + +#endif // UTILITIES_H__ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/utilities_unittest.cc b/funasr/runtime/onnxruntime/third_party/glog/src/utilities_unittest.cc new file mode 100644 index 000000000..93b1acdea --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/utilities_unittest.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Shinichiro Hamaji +#include "utilities.h" +#include "googletest.h" +#include + +#ifdef HAVE_LIB_GFLAGS +#include +using namespace GFLAGS_NAMESPACE; +#endif + +using namespace GOOGLE_NAMESPACE; + +TEST(utilities, sync_val_compare_and_swap) { + bool now_entering = false; + EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true)); + EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true)); + EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true)); +} + +TEST(utilities, InitGoogleLoggingDeathTest) { + ASSERT_DEATH(InitGoogleLogging("foobar"), ""); +} + +int main(int argc, char **argv) { + InitGoogleLogging(argv[0]); + InitGoogleTest(&argc, argv); + + CHECK_EQ(RUN_ALL_TESTS(), 0); +} diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/vlog_is_on.cc b/funasr/runtime/onnxruntime/third_party/glog/src/vlog_is_on.cc new file mode 100644 index 000000000..ac60d0293 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/vlog_is_on.cc @@ -0,0 +1,294 @@ +// Copyright (c) 1999, 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: Ray Sidney and many others +// +// Broken out from logging.cc by Soren Lassen +// logging_unittest.cc covers the functionality herein + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include "base/commandlineflags.h" +#include +#include +#include "base/googleinit.h" + +// glog doesn't have annotation +#define ANNOTATE_BENIGN_RACE(address, description) + +using std::string; + +GLOG_DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this." +" Overridable by --vmodule."); + +GLOG_DEFINE_string(vmodule, "", "per-module verbose level." +" Argument is a comma-separated list of =." +" is a glob pattern, matched against the filename base" +" (that is, name ignoring .cc/.h./-inl.h)." +" overrides any value given by --v."); + +_START_GOOGLE_NAMESPACE_ + +namespace glog_internal_namespace_ { + +// Used by logging_unittests.cc so can't make it static here. +GLOG_EXPORT bool SafeFNMatch_(const char* pattern, size_t patt_len, + const char* str, size_t str_len); + +// Implementation of fnmatch that does not need 0-termination +// of arguments and does not allocate any memory, +// but we only support "*" and "?" wildcards, not the "[...]" patterns. +// It's not a static function for the unittest. +GLOG_EXPORT bool SafeFNMatch_(const char* pattern, size_t patt_len, + const char* str, size_t str_len) { + size_t p = 0; + size_t s = 0; + while (true) { + if (p == patt_len && s == str_len) return true; + if (p == patt_len) return false; + if (s == str_len) return p+1 == patt_len && pattern[p] == '*'; + if (pattern[p] == str[s] || pattern[p] == '?') { + p += 1; + s += 1; + continue; + } + if (pattern[p] == '*') { + if (p+1 == patt_len) return true; + do { + if (SafeFNMatch_(pattern+(p+1), patt_len-(p+1), str+s, str_len-s)) { + return true; + } + s += 1; + } while (s != str_len); + return false; + } + return false; + } +} + +} // namespace glog_internal_namespace_ + +using glog_internal_namespace_::SafeFNMatch_; + +// List of per-module log levels from FLAGS_vmodule. +// Once created each element is never deleted/modified +// except for the vlog_level: other threads will read VModuleInfo blobs +// w/o locks and we'll store pointers to vlog_level at VLOG locations +// that will never go away. +// We can't use an STL struct here as we wouldn't know +// when it's safe to delete/update it: other threads need to use it w/o locks. +struct VModuleInfo { + string module_pattern; + mutable int32 vlog_level; // Conceptually this is an AtomicWord, but it's + // too much work to use AtomicWord type here + // w/o much actual benefit. + const VModuleInfo* next; +}; + +// This protects the following global variables. +static Mutex vmodule_lock; +// Pointer to head of the VModuleInfo list. +// It's a map from module pattern to logging level for those module(s). +static VModuleInfo* vmodule_list = nullptr; +static SiteFlag* cached_site_list = nullptr; + +// Boolean initialization flag. +static bool inited_vmodule = false; + +// L >= vmodule_lock. +static void VLOG2Initializer() { + vmodule_lock.AssertHeld(); + // Can now parse --vmodule flag and initialize mapping of module-specific + // logging levels. + inited_vmodule = false; + const char* vmodule = FLAGS_vmodule.c_str(); + const char* sep; + VModuleInfo* head = nullptr; + VModuleInfo* tail = nullptr; + while ((sep = strchr(vmodule, '=')) != nullptr) { + string pattern(vmodule, static_cast(sep - vmodule)); + int module_level; + if (sscanf(sep, "=%d", &module_level) == 1) { + auto* info = new VModuleInfo; + info->module_pattern = pattern; + info->vlog_level = module_level; + if (head) { + tail->next = info; + } else { + head = info; + } + tail = info; + } + // Skip past this entry + vmodule = strchr(sep, ','); + if (vmodule == nullptr) break; + vmodule++; // Skip past "," + } + if (head) { // Put them into the list at the head: + tail->next = vmodule_list; + vmodule_list = head; + } + inited_vmodule = true; +} + +// This can be called very early, so we use SpinLock and RAW_VLOG here. +int SetVLOGLevel(const char* module_pattern, int log_level) { + int result = FLAGS_v; + size_t const pattern_len = strlen(module_pattern); + bool found = false; + { + MutexLock l(&vmodule_lock); // protect whole read-modify-write + for (const VModuleInfo* info = vmodule_list; info != nullptr; + info = info->next) { + if (info->module_pattern == module_pattern) { + if (!found) { + result = info->vlog_level; + found = true; + } + info->vlog_level = log_level; + } else if (!found && + SafeFNMatch_(info->module_pattern.c_str(), + info->module_pattern.size(), + module_pattern, pattern_len)) { + result = info->vlog_level; + found = true; + } + } + if (!found) { + auto* info = new VModuleInfo; + info->module_pattern = module_pattern; + info->vlog_level = log_level; + info->next = vmodule_list; + vmodule_list = info; + + SiteFlag** item_ptr = &cached_site_list; + SiteFlag* item = cached_site_list; + + // We traverse the list fully because the pattern can match several items + // from the list. + while (item) { + if (SafeFNMatch_(module_pattern, pattern_len, item->base_name, + item->base_len)) { + // Redirect the cached value to its module override. + item->level = &info->vlog_level; + *item_ptr = item->next; // Remove the item from the list. + } else { + item_ptr = &item->next; + } + item = *item_ptr; + } + } + } + RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level); + return result; +} + +// NOTE: Individual VLOG statements cache the integer log level pointers. +// NOTE: This function must not allocate memory or require any locks. +bool InitVLOG3__(SiteFlag* site_flag, int32* level_default, + const char* fname, int32 verbose_level) { + MutexLock l(&vmodule_lock); + bool read_vmodule_flag = inited_vmodule; + if (!read_vmodule_flag) { + VLOG2Initializer(); + } + + // protect the errno global in case someone writes: + // VLOG(..) << "The last error was " << strerror(errno) + int old_errno = errno; + + // site_default normally points to FLAGS_v + int32* site_flag_value = level_default; + + // Get basename for file + const char* base = strrchr(fname, '/'); + +#ifdef _WIN32 + if (!base) { + base = strrchr(fname, '\\'); + } +#endif + + base = base ? (base+1) : fname; + const char* base_end = strchr(base, '.'); + size_t base_length = + base_end ? static_cast(base_end - base) : strlen(base); + + // Trim out trailing "-inl" if any + if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) { + base_length -= 4; + } + + // TODO: Trim out _unittest suffix? Perhaps it is better to have + // the extra control and just leave it there. + + // find target in vector of modules, replace site_flag_value with + // a module-specific verbose level, if any. + for (const VModuleInfo* info = vmodule_list; info != nullptr; + info = info->next) { + if (SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(), + base, base_length)) { + site_flag_value = &info->vlog_level; + // value at info->vlog_level is now what controls + // the VLOG at the caller site forever + break; + } + } + + // Cache the vlog value pointer if --vmodule flag has been parsed. + ANNOTATE_BENIGN_RACE(site_flag, + "*site_flag may be written by several threads," + " but the value will be the same"); + if (read_vmodule_flag) { + site_flag->level = site_flag_value; + // If VLOG flag has been cached to the default site pointer, + // we want to add to the cached list in order to invalidate in case + // SetVModule is called afterwards with new modules. + // The performance penalty here is neglible, because InitVLOG3__ is called + // once per site. + if (site_flag_value == level_default && !site_flag->base_name) { + site_flag->base_name = base; + site_flag->base_len = base_length; + site_flag->next = cached_site_list; + cached_site_list = site_flag; + } + } + + // restore the errno in case something recoverable went wrong during + // the initialization of the VLOG mechanism (see above note "protect the..") + errno = old_errno; + return *site_flag_value >= verbose_level; +} + +_END_GOOGLE_NAMESPACE_ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/windows/dirent.h b/funasr/runtime/onnxruntime/third_party/glog/src/windows/dirent.h new file mode 100644 index 000000000..097ad20a8 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/windows/dirent.h @@ -0,0 +1,1145 @@ +/* + * Dirent interface for Microsoft Visual Studio + * + * Copyright (C) 1998-2019 Toni Ronkko + * This file is part of dirent. Dirent may be freely distributed + * under the MIT license. For all details and documentation, see + * https://github.com/tronkko/dirent + */ +#ifndef DIRENT_H +#define DIRENT_H + +/* Hide warnings about unreferenced local functions */ +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunused-function" +#elif defined(_MSC_VER) +# pragma warning(disable:4505) +#elif defined(__GNUC__) +# pragma GCC diagnostic ignored "-Wunused-function" +#endif + +/* + * Include windows.h without Windows Sockets 1.1 to prevent conflicts with + * Windows Sockets 2.0. + */ +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Indicates that d_type field is available in dirent structure */ +#define _DIRENT_HAVE_D_TYPE + +/* Indicates that d_namlen field is available in dirent structure */ +#define _DIRENT_HAVE_D_NAMLEN + +/* Entries missing from MSVC 6.0 */ +#if !defined(FILE_ATTRIBUTE_DEVICE) +# define FILE_ATTRIBUTE_DEVICE 0x40 +#endif + +/* File type and permission flags for stat(), general mask */ +#if !defined(S_IFMT) +# define S_IFMT _S_IFMT +#endif + +/* Directory bit */ +#if !defined(S_IFDIR) +# define S_IFDIR _S_IFDIR +#endif + +/* Character device bit */ +#if !defined(S_IFCHR) +# define S_IFCHR _S_IFCHR +#endif + +/* Pipe bit */ +#if !defined(S_IFFIFO) +# define S_IFFIFO _S_IFFIFO +#endif + +/* Regular file bit */ +#if !defined(S_IFREG) +# define S_IFREG _S_IFREG +#endif + +/* Read permission */ +#if !defined(S_IREAD) +# define S_IREAD _S_IREAD +#endif + +/* Write permission */ +#if !defined(S_IWRITE) +# define S_IWRITE _S_IWRITE +#endif + +/* Execute permission */ +#if !defined(S_IEXEC) +# define S_IEXEC _S_IEXEC +#endif + +/* Pipe */ +#if !defined(S_IFIFO) +# define S_IFIFO _S_IFIFO +#endif + +/* Block device */ +#if !defined(S_IFBLK) +# define S_IFBLK 0 +#endif + +/* Link */ +#if !defined(S_IFLNK) +# define S_IFLNK 0 +#endif + +/* Socket */ +#if !defined(S_IFSOCK) +# define S_IFSOCK 0 +#endif + +/* Read user permission */ +#if !defined(S_IRUSR) +# define S_IRUSR S_IREAD +#endif + +/* Write user permission */ +#if !defined(S_IWUSR) +# define S_IWUSR S_IWRITE +#endif + +/* Execute user permission */ +#if !defined(S_IXUSR) +# define S_IXUSR 0 +#endif + +/* Read group permission */ +#if !defined(S_IRGRP) +# define S_IRGRP 0 +#endif + +/* Write group permission */ +#if !defined(S_IWGRP) +# define S_IWGRP 0 +#endif + +/* Execute group permission */ +#if !defined(S_IXGRP) +# define S_IXGRP 0 +#endif + +/* Read others permission */ +#if !defined(S_IROTH) +# define S_IROTH 0 +#endif + +/* Write others permission */ +#if !defined(S_IWOTH) +# define S_IWOTH 0 +#endif + +/* Execute others permission */ +#if !defined(S_IXOTH) +# define S_IXOTH 0 +#endif + +/* Maximum length of file name */ +#if !defined(PATH_MAX) +# define PATH_MAX MAX_PATH +#endif +#if !defined(FILENAME_MAX) +# define FILENAME_MAX MAX_PATH +#endif +#if !defined(NAME_MAX) +# define NAME_MAX FILENAME_MAX +#endif + +/* File type flags for d_type */ +#define DT_UNKNOWN 0 +#define DT_REG S_IFREG +#define DT_DIR S_IFDIR +#define DT_FIFO S_IFIFO +#define DT_SOCK S_IFSOCK +#define DT_CHR S_IFCHR +#define DT_BLK S_IFBLK +#define DT_LNK S_IFLNK + +/* Macros for converting between st_mode and d_type */ +#define IFTODT(mode) ((mode) & S_IFMT) +#define DTTOIF(type) (type) + +/* + * File type macros. Note that block devices, sockets and links cannot be + * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are + * only defined for compatibility. These macros should always return false + * on Windows. + */ +#if !defined(S_ISFIFO) +# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) +#endif +#if !defined(S_ISDIR) +# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif +#if !defined(S_ISREG) +# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#endif +#if !defined(S_ISLNK) +# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#endif +#if !defined(S_ISSOCK) +# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) +#endif +#if !defined(S_ISCHR) +# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) +#endif +#if !defined(S_ISBLK) +# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) +#endif + +/* Return the exact length of the file name without zero terminator */ +#define _D_EXACT_NAMLEN(p) ((p)->d_namlen) + +/* Return the maximum size of a file name */ +#define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1) + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Wide-character version */ +struct _wdirent { + /* Always zero */ + long d_ino; + + /* File position within stream */ + long d_off; + + /* Structure size */ + unsigned short d_reclen; + + /* Length of name without \0 */ + size_t d_namlen; + + /* File type */ + int d_type; + + /* File name */ + wchar_t d_name[PATH_MAX+1]; +}; + +struct _WDIR { + /* Current directory entry */ + _wdirent ent; + + /* Private file data */ + WIN32_FIND_DATAW data; + + /* True if data is valid */ + int cached; + + /* Win32 search handle */ + HANDLE handle; + + /* Initial directory name */ + wchar_t *patt; +}; + +/* Multi-byte character version */ +struct dirent { + /* Always zero */ + long d_ino; + + /* File position within stream */ + long d_off; + + /* Structure size */ + unsigned short d_reclen; + + /* Length of name without \0 */ + size_t d_namlen; + + /* File type */ + int d_type; + + /* File name */ + char d_name[PATH_MAX+1]; +}; + +struct DIR { + struct dirent ent; + struct _WDIR *wdirp; +}; + +/* Dirent functions */ +static DIR *opendir (const char *dirname); +static _WDIR *_wopendir (const wchar_t *dirname); + +static struct dirent *readdir (DIR *dirp); +static struct _wdirent *_wreaddir (_WDIR *dirp); + +static int readdir_r( + DIR *dirp, struct dirent *entry, struct dirent **result); +static int _wreaddir_r( + _WDIR *dirp, struct _wdirent *entry, struct _wdirent **result); + +static int closedir (DIR *dirp); +static int _wclosedir (_WDIR *dirp); + +static void rewinddir (DIR* dirp); +static void _wrewinddir (_WDIR* dirp); + +static int scandir (const char *dirname, struct dirent ***namelist, + int (*filter)(const struct dirent*), + int (*compare)(const struct dirent**, const struct dirent**)); + +static int alphasort (const struct dirent **a, const struct dirent **b); + +static int versionsort (const struct dirent **a, const struct dirent **b); + + +/* For compatibility with Symbian */ +#define wdirent _wdirent +#define WDIR _WDIR +#define wopendir _wopendir +#define wreaddir _wreaddir +#define wclosedir _wclosedir +#define wrewinddir _wrewinddir + + +/* Internal utility functions */ +static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp); +static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp); + +static int dirent_mbstowcs_s( + size_t *pReturnValue, + wchar_t *wcstr, + size_t sizeInWords, + const char *mbstr, + size_t count); + +static int dirent_wcstombs_s( + size_t *pReturnValue, + char *mbstr, + size_t sizeInBytes, + const wchar_t *wcstr, + size_t count); + +static void dirent_set_errno (int error); + + +/* + * Open directory stream DIRNAME for read and return a pointer to the + * internal working area that is used to retrieve individual directory + * entries. + */ +static _WDIR* +_wopendir( + const wchar_t *dirname) +{ + _WDIR *dirp; + DWORD n; + wchar_t *p; + + /* Must have directory name */ + if (dirname == nullptr || dirname[0] == '\0') { + dirent_set_errno(ENOENT); + return nullptr; + } + + /* Allocate new _WDIR structure */ + dirp = (_WDIR*) malloc (sizeof (struct _WDIR)); + if (!dirp) { + return nullptr; + } + + /* Reset _WDIR structure */ + dirp->handle = INVALID_HANDLE_VALUE; + dirp->patt = nullptr; + dirp->cached = 0; + + /* + * Compute the length of full path plus zero terminator + * + * Note that on WinRT there's no way to convert relative paths + * into absolute paths, so just assume it is an absolute path. + */ +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + /* Desktop */ + n = GetFullPathNameW(dirname, 0, nullptr, nullptr); +#else + /* WinRT */ + n = wcslen (dirname); +#endif + + /* Allocate room for absolute directory name and search pattern */ + dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16); + if (dirp->patt == nullptr) { + goto exit_closedir; + } + + /* + * Convert relative directory name to an absolute one. This + * allows rewinddir() to function correctly even when current + * working directory is changed between opendir() and rewinddir(). + * + * Note that on WinRT there's no way to convert relative paths + * into absolute paths, so just assume it is an absolute path. + */ +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + /* Desktop */ + n = GetFullPathNameW(dirname, n, dirp->patt, nullptr); + if (n <= 0) { + goto exit_closedir; + } +#else + /* WinRT */ + wcsncpy_s (dirp->patt, n+1, dirname, n); +#endif + + /* Append search pattern \* to the directory name */ + p = dirp->patt + n; + switch (p[-1]) { + case '\\': + case '/': + case ':': + /* Directory ends in path separator, e.g. c:\temp\ */ + /*NOP*/; + break; + + default: + /* Directory name doesn't end in path separator */ + *p++ = '\\'; + } + *p++ = '*'; + *p = '\0'; + + /* Open directory stream and retrieve the first entry */ + if (!dirent_first (dirp)) { + goto exit_closedir; + } + + /* Success */ + return dirp; + + /* Failure */ +exit_closedir: + _wclosedir (dirp); + return nullptr; +} + +/* + * Read next directory entry. + * + * Returns pointer to static directory entry which may be overwritten by + * subsequent calls to _wreaddir(). + */ +static struct _wdirent* +_wreaddir( + _WDIR *dirp) +{ + struct _wdirent *entry; + + /* + * Read directory entry to buffer. We can safely ignore the return value + * as entry will be set to nullptr in case of error. + */ + (void) _wreaddir_r (dirp, &dirp->ent, &entry); + + /* Return pointer to statically allocated directory entry */ + return entry; +} + +/* + * Read next directory entry. + * + * Returns zero on success. If end of directory stream is reached, then sets + * result to nullptr and returns zero. + */ +static int +_wreaddir_r( + _WDIR *dirp, + struct _wdirent *entry, + struct _wdirent **result) +{ + WIN32_FIND_DATAW *datap; + + /* Read next directory entry */ + datap = dirent_next (dirp); + if (datap) { + size_t n; + DWORD attr; + + /* + * Copy file name as wide-character string. If the file name is too + * long to fit in to the destination buffer, then truncate file name + * to PATH_MAX characters and zero-terminate the buffer. + */ + n = 0; + while (n < PATH_MAX && datap->cFileName[n] != 0) { + entry->d_name[n] = datap->cFileName[n]; + n++; + } + entry->d_name[n] = 0; + + /* Length of file name excluding zero terminator */ + entry->d_namlen = n; + + /* File type */ + attr = datap->dwFileAttributes; + if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { + entry->d_type = DT_CHR; + } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { + entry->d_type = DT_DIR; + } else { + entry->d_type = DT_REG; + } + + /* Reset dummy fields */ + entry->d_ino = 0; + entry->d_off = 0; + entry->d_reclen = sizeof (struct _wdirent); + + /* Set result address */ + *result = entry; + + } else { + /* Return nullptr to indicate end of directory */ + *result = nullptr; + } + + return /*OK*/0; +} + +/* + * Close directory stream opened by opendir() function. This invalidates the + * DIR structure as well as any directory entry read previously by + * _wreaddir(). + */ +static int +_wclosedir( + _WDIR *dirp) +{ + int ok; + if (dirp) { + + /* Release search handle */ + if (dirp->handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->handle); + } + + /* Release search pattern */ + free (dirp->patt); + + /* Release directory structure */ + free (dirp); + ok = /*success*/0; + + } else { + + /* Invalid directory stream */ + dirent_set_errno (EBADF); + ok = /*failure*/-1; + + } + return ok; +} + +/* + * Rewind directory stream such that _wreaddir() returns the very first + * file name again. + */ +static void +_wrewinddir( + _WDIR* dirp) +{ + if (dirp) { + /* Release existing search handle */ + if (dirp->handle != INVALID_HANDLE_VALUE) { + FindClose (dirp->handle); + } + + /* Open new search handle */ + dirent_first (dirp); + } +} + +/* Get first directory entry (internal) */ +static WIN32_FIND_DATAW* +dirent_first( + _WDIR *dirp) +{ + WIN32_FIND_DATAW *datap; + DWORD error; + + /* Open directory and retrieve the first entry */ + dirp->handle = FindFirstFileExW(dirp->patt, FindExInfoStandard, &dirp->data, + FindExSearchNameMatch, nullptr, 0); + if (dirp->handle != INVALID_HANDLE_VALUE) { + + /* a directory entry is now waiting in memory */ + datap = &dirp->data; + dirp->cached = 1; + + } else { + + /* Failed to open directory: no directory entry in memory */ + dirp->cached = 0; + datap = nullptr; + + /* Set error code */ + error = GetLastError (); + switch (error) { + case ERROR_ACCESS_DENIED: + /* No read access to directory */ + dirent_set_errno (EACCES); + break; + + case ERROR_DIRECTORY: + /* Directory name is invalid */ + dirent_set_errno (ENOTDIR); + break; + + case ERROR_PATH_NOT_FOUND: + default: + /* Cannot find the file */ + dirent_set_errno (ENOENT); + } + + } + return datap; +} + +/* + * Get next directory entry (internal). + * + * Returns + */ +static WIN32_FIND_DATAW* +dirent_next( + _WDIR *dirp) +{ + WIN32_FIND_DATAW *p; + + /* Get next directory entry */ + if (dirp->cached != 0) { + + /* A valid directory entry already in memory */ + p = &dirp->data; + dirp->cached = 0; + + } else if (dirp->handle != INVALID_HANDLE_VALUE) { + + /* Get the next directory entry from stream */ + if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) { + /* Got a file */ + p = &dirp->data; + } else { + /* The very last entry has been processed or an error occurred */ + FindClose (dirp->handle); + dirp->handle = INVALID_HANDLE_VALUE; + p = nullptr; + } + + } else { + + /* End of directory stream reached */ + p = nullptr; + } + + return p; +} + +/* + * Open directory stream using plain old C-string. + */ +static DIR* +opendir( + const char *dirname) +{ + struct DIR *dirp; + + /* Must have directory name */ + if (dirname == nullptr || dirname[0] == '\0') { + dirent_set_errno (ENOENT); + return nullptr; + } + + /* Allocate memory for DIR structure */ + dirp = (DIR*) malloc (sizeof (struct DIR)); + if (!dirp) { + return nullptr; + } + { + int error; + wchar_t wname[PATH_MAX + 1]; + size_t n; + + /* Convert directory name to wide-character string */ + error = dirent_mbstowcs_s( + &n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1); + if (error) { + /* + * Cannot convert file name to wide-character string. This + * occurs if the string contains invalid multi-byte sequences or + * the output buffer is too small to contain the resulting + * string. + */ + goto exit_free; + } + + + /* Open directory stream using wide-character name */ + dirp->wdirp = _wopendir (wname); + if (!dirp->wdirp) { + goto exit_free; + } + + } + + /* Success */ + return dirp; + + /* Failure */ +exit_free: + free (dirp); + return nullptr; +} + +/* + * Read next directory entry. + */ +static struct dirent* +readdir( + DIR *dirp) +{ + struct dirent *entry; + + /* + * Read directory entry to buffer. We can safely ignore the return value + * as entry will be set to nullptr in case of error. + */ + (void) readdir_r (dirp, &dirp->ent, &entry); + + /* Return pointer to statically allocated directory entry */ + return entry; +} + +/* + * Read next directory entry into called-allocated buffer. + * + * Returns zero on success. If the end of directory stream is reached, then + * sets result to nullptr and returns zero. + */ +static int +readdir_r( + DIR *dirp, + struct dirent *entry, + struct dirent **result) +{ + WIN32_FIND_DATAW *datap; + + /* Read next directory entry */ + datap = dirent_next (dirp->wdirp); + if (datap) { + size_t n; + int error; + + /* Attempt to convert file name to multi-byte string */ + error = dirent_wcstombs_s( + &n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1); + + /* + * If the file name cannot be represented by a multi-byte string, + * then attempt to use old 8+3 file name. This allows traditional + * Unix-code to access some file names despite of unicode + * characters, although file names may seem unfamiliar to the user. + * + * Be ware that the code below cannot come up with a short file + * name unless the file system provides one. At least + * VirtualBox shared folders fail to do this. + */ + if (error && datap->cAlternateFileName[0] != '\0') { + error = dirent_wcstombs_s( + &n, entry->d_name, PATH_MAX + 1, + datap->cAlternateFileName, PATH_MAX + 1); + } + + if (!error) { + DWORD attr; + + /* Length of file name excluding zero terminator */ + entry->d_namlen = n - 1; + + /* File attributes */ + attr = datap->dwFileAttributes; + if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { + entry->d_type = DT_CHR; + } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { + entry->d_type = DT_DIR; + } else { + entry->d_type = DT_REG; + } + + /* Reset dummy fields */ + entry->d_ino = 0; + entry->d_off = 0; + entry->d_reclen = sizeof (struct dirent); + + } else { + /* + * Cannot convert file name to multi-byte string so construct + * an erroneous directory entry and return that. Note that + * we cannot return nullptr as that would stop the processing + * of directory entries completely. + */ + entry->d_name[0] = '?'; + entry->d_name[1] = '\0'; + entry->d_namlen = 1; + entry->d_type = DT_UNKNOWN; + entry->d_ino = 0; + entry->d_off = -1; + entry->d_reclen = 0; + + } + + /* Return pointer to directory entry */ + *result = entry; + + } else { + + /* No more directory entries */ + *result = nullptr; + } + + return /*OK*/0; +} + +/* + * Close directory stream. + */ +static int +closedir( + DIR *dirp) +{ + int ok; + if (dirp) { + + /* Close wide-character directory stream */ + ok = _wclosedir (dirp->wdirp); + dirp->wdirp = nullptr; + + /* Release multi-byte character version */ + free (dirp); + + } else { + + /* Invalid directory stream */ + dirent_set_errno (EBADF); + ok = /*failure*/-1; + + } + return ok; +} + +/* + * Rewind directory stream to beginning. + */ +static void +rewinddir( + DIR* dirp) +{ + /* Rewind wide-character string directory stream */ + _wrewinddir (dirp->wdirp); +} + +/* + * Scan directory for entries. + */ +static int +scandir( + const char *dirname, + struct dirent ***namelist, + int (*filter)(const struct dirent*), + int (*compare)(const struct dirent**, const struct dirent**)) +{ + struct dirent **files = nullptr; + size_t size = 0; + size_t allocated = 0; + const size_t init_size = 1; + DIR *dir = nullptr; + struct dirent *entry; + struct dirent *tmp = nullptr; + size_t i; + int result = 0; + + /* Open directory stream */ + dir = opendir (dirname); + if (dir) { + + /* Read directory entries to memory */ + while (1) { + + /* Enlarge pointer table to make room for another pointer */ + if (size >= allocated) { + void *p; + size_t num_entries; + + /* Compute number of entries in the enlarged pointer table */ + if (size < init_size) { + /* Allocate initial pointer table */ + num_entries = init_size; + } else { + /* Double the size */ + num_entries = size * 2; + } + + /* Allocate first pointer table or enlarge existing table */ + p = realloc (files, sizeof (void*) * num_entries); + if (p != nullptr) { + /* Got the memory */ + files = (dirent**) p; + allocated = num_entries; + } else { + /* Out of memory */ + result = -1; + break; + } + } + + /* Allocate room for temporary directory entry */ + if (tmp == nullptr) { + tmp = (struct dirent*) malloc (sizeof (struct dirent)); + if (tmp == nullptr) { + /* Cannot allocate temporary directory entry */ + result = -1; + break; + } + } + + /* Read directory entry to temporary area */ + if (readdir_r (dir, tmp, &entry) == /*OK*/0) { + + /* Did we get an entry? */ + if (entry != nullptr) { + int pass; + + /* Determine whether to include the entry in result */ + if (filter) { + /* Let the filter function decide */ + pass = filter (tmp); + } else { + /* No filter function, include everything */ + pass = 1; + } + + if (pass) { + /* Store the temporary entry to pointer table */ + files[size++] = tmp; + tmp = nullptr; + + /* Keep up with the number of files */ + result++; + } + + } else { + /* + * End of directory stream reached => sort entries and + * exit. + */ + qsort (files, size, sizeof (void*), + (int (*) (const void*, const void*)) compare); + break; + } + + } else { + /* Error reading directory entry */ + result = /*Error*/ -1; + break; + } + + } + + } else { + /* Cannot open directory */ + result = /*Error*/ -1; + } + + /* Release temporary directory entry */ + free (tmp); + + /* Release allocated memory on error */ + if (result < 0) { + for (i = 0; i < size; i++) { + free (files[i]); + } + free (files); + files = nullptr; + } + + /* Close directory stream */ + if (dir) { + closedir (dir); + } + + /* Pass pointer table to caller */ + if (namelist) { + *namelist = files; + } + return result; +} + +/* Alphabetical sorting */ +static int +alphasort( + const struct dirent **a, const struct dirent **b) +{ + return strcoll ((*a)->d_name, (*b)->d_name); +} + +/* Sort versions */ +static int +versionsort( + const struct dirent **a, const struct dirent **b) +{ + /* FIXME: implement strverscmp and use that */ + return alphasort (a, b); +} + +/* Convert multi-byte string to wide character string */ +static int +dirent_mbstowcs_s( + size_t *pReturnValue, + wchar_t *wcstr, + size_t sizeInWords, + const char *mbstr, + size_t count) +{ + int error; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + + /* Microsoft Visual Studio 2005 or later */ + error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count); + +#else + + /* Older Visual Studio or non-Microsoft compiler */ + size_t n; + + /* Convert to wide-character string (or count characters) */ + n = mbstowcs (wcstr, mbstr, sizeInWords); + if (!wcstr || n < count) { + + /* Zero-terminate output buffer */ + if (wcstr && sizeInWords) { + if (n >= sizeInWords) { + n = sizeInWords - 1; + } + wcstr[n] = 0; + } + + /* Length of resulting multi-byte string WITH zero terminator */ + if (pReturnValue) { + *pReturnValue = n + 1; + } + + /* Success */ + error = 0; + + } else { + + /* Could not convert string */ + error = 1; + + } + +#endif + return error; +} + +/* Convert wide-character string to multi-byte string */ +static int +dirent_wcstombs_s( + size_t *pReturnValue, + char *mbstr, + size_t sizeInBytes, /* max size of mbstr */ + const wchar_t *wcstr, + size_t count) +{ + int error; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + + /* Microsoft Visual Studio 2005 or later */ + error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count); + +#else + + /* Older Visual Studio or non-Microsoft compiler */ + size_t n; + + /* Convert to multi-byte string (or count the number of bytes needed) */ + n = wcstombs (mbstr, wcstr, sizeInBytes); + if (!mbstr || n < count) { + + /* Zero-terminate output buffer */ + if (mbstr && sizeInBytes) { + if (n >= sizeInBytes) { + n = sizeInBytes - 1; + } + mbstr[n] = '\0'; + } + + /* Length of resulting multi-bytes string WITH zero-terminator */ + if (pReturnValue) { + *pReturnValue = n + 1; + } + + /* Success */ + error = 0; + + } else { + + /* Cannot convert string */ + error = 1; + + } + +#endif + return error; +} + +/* Set errno variable */ +static void +dirent_set_errno( + int error) +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + + /* Microsoft Visual Studio 2005 and later */ + _set_errno (error); + +#else + + /* Non-Microsoft compiler or older Microsoft compiler */ + errno = error; + +#endif +} + + +#ifdef __cplusplus +} +#endif +#endif /*DIRENT_H*/ diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.cc b/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.cc new file mode 100755 index 000000000..f80a54ae2 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.cc @@ -0,0 +1,75 @@ +/* Copyright (c) 2008, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Craig Silverstein + * Copied from google-perftools and modified by Shinichiro Hamaji + */ + +#ifndef _WIN32 +# error You should only be including windows/port.cc in a windows environment! +#endif + +#include "port.h" + +#include // for va_list, va_start, va_end +#include + +#include "config.h" + +// These call the windows _vsnprintf, but always NUL-terminate. +int safe_vsnprintf(char* str, std::size_t size, const char* format, + va_list ap) { + if (size == 0) // not even room for a \0? + return -1; // not what C99 says to do, but what windows does + str[size-1] = '\0'; + return _vsnprintf(str, size-1, format, ap); +} + +#ifndef HAVE_LOCALTIME_R +struct tm* localtime_r(const std::time_t* timep, std::tm* result) { + localtime_s(result, timep); + return result; +} +#endif // not HAVE_LOCALTIME_R +#ifndef HAVE_GMTIME_R +struct tm* gmtime_r(const std::time_t* timep, std::tm* result) { + gmtime_s(result, timep); + return result; +} +#endif // not HAVE_GMTIME_R +#ifndef HAVE_SNPRINTF +int snprintf(char *str, size_t size, const char *format, ...) { + va_list ap; + va_start(ap, format); + const int r = vsnprintf(str, size, format, ap); + va_end(ap); + return r; +} +#endif diff --git a/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.h b/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.h new file mode 100755 index 000000000..9611e1039 --- /dev/null +++ b/funasr/runtime/onnxruntime/third_party/glog/src/windows/port.h @@ -0,0 +1,181 @@ +/* Copyright (c) 2023, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Craig Silverstein + * Copied from google-perftools and modified by Shinichiro Hamaji + * + * These are some portability typedefs and defines to make it a bit + * easier to compile this code under VC++. + * + * Several of these are taken from glib: + * http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html + */ + +#ifndef CTEMPLATE_WINDOWS_PORT_H_ +#define CTEMPLATE_WINDOWS_PORT_H_ + +#include "config.h" + +#ifdef _WIN32 + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN /* We always want minimal includes */ +#endif + +#include +#include /* for gethostname */ +#include /* because we so often use open/close/etc */ +#include /* for _getcwd() */ +#include /* for _getpid() */ +#include /* template_dictionary.cc uses va_copy */ +#include /* read in vsnprintf decl. before redifining it */ +#include /* for _strnicmp(), strerror_s() */ +#include /* for localtime_s() */ +/* Note: the C++ #includes are all together at the bottom. This file is + * used by both C and C++ code, so we put all the C++ together. + */ + +#include + +#ifdef _MSC_VER + +/* 4244: otherwise we get problems when substracting two size_t's to an int + * 4251: it's complaining about a private struct I've chosen not to dllexport + * 4355: we use this in a constructor, but we do it safely + * 4715: for some reason VC++ stopped realizing you can't return after abort() + * 4800: we know we're casting ints/char*'s to bools, and we're ok with that + * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() + * 4312: Converting uint32_t to a pointer when testing %p + * 4267: also subtracting two size_t to int + * 4722: Destructor never returns due to abort() + */ +#pragma warning(disable:4244 4251 4355 4715 4800 4996 4267 4312 4722) + +/* file I/O */ +#define PATH_MAX 1024 +#define access _access +#define getcwd _getcwd +#define open _open +#define read _read +#define write(fd, p, n) _write(fd, p, n) +#define lseek _lseek +#define close _close +#define popen _popen +#define pclose _pclose +#define R_OK 04 /* read-only (for access()) */ +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) + +#define O_WRONLY _O_WRONLY +#define O_CREAT _O_CREAT +#define O_EXCL _O_EXCL + +#ifndef __MINGW32__ +enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 }; +#endif +#define S_IRUSR S_IREAD +#define S_IWUSR S_IWRITE + +/* Not quite as lightweight as a hard-link, but more than good enough for us. */ +#define link(oldpath, newpath) CopyFileA(oldpath, newpath, false) + +#define strcasecmp _stricmp +#define strncasecmp _strnicmp + +/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */ +/* VC11 provides std::hash */ +#if defined(_MSC_VER) && (_MSC_VER < 1700) +#define hash hash_compare +#endif + +/* Sleep is in ms, on windows */ +#define sleep(secs) Sleep((secs) * 1000) + +/* We can't just use _vsnprintf and _snprintf as drop-in-replacements, + * because they don't always NUL-terminate. :-( We also can't use the + * name vsnprintf, since windows defines that (but not snprintf (!)). + */ +#ifndef HAVE_SNPRINTF +extern int GLOG_EXPORT snprintf(char* str, size_t size, const char* format, + ...); +#endif +extern int GLOG_EXPORT safe_vsnprintf(char* str, size_t size, + const char* format, va_list ap); +#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) +#ifndef va_copy +#define va_copy(dst, src) (dst) = (src) +#endif + +/* Windows doesn't support specifying the number of buckets as a + * hash_map constructor arg, so we leave this blank. + */ +#define CTEMPLATE_SMALL_HASHTABLE + +#define DEFAULT_TEMPLATE_ROOTDIR ".." + +// ----------------------------------- SYSTEM/PROCESS +typedef int pid_t; +#define getpid _getpid + +#endif // _MSC_VER + +// ----------------------------------- THREADS +#if defined(HAVE_PTHREAD) +# include +#else // no PTHREAD +typedef DWORD pthread_t; +typedef DWORD pthread_key_t; +typedef LONG pthread_once_t; +enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock +#define pthread_self GetCurrentThreadId +#define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2)) +#endif // HAVE_PTHREAD + +#ifndef HAVE_LOCALTIME_R +extern GLOG_EXPORT std::tm* localtime_r(const std::time_t* timep, + std::tm* result); +#endif // not HAVE_LOCALTIME_R + +#ifndef HAVE_GMTIME_R +extern GLOG_EXPORT std::tm* gmtime_r(const std::time_t* timep, std::tm* result); +#endif // not HAVE_GMTIME_R + +inline char* strerror_r(int errnum, char* buf, std::size_t buflen) { + strerror_s(buf, buflen, errnum); + return buf; +} + +#ifndef __cplusplus +/* I don't see how to get inlining for C code in MSVC. Ah well. */ +#define inline +#endif + +#endif /* _WIN32 */ + +#endif /* CTEMPLATE_WINDOWS_PORT_H_ */ diff --git a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3-3.dll b/funasr/runtime/onnxruntime/win/bin/x64/libfftw3-3.dll deleted file mode 100644 index 75080e49f..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3f-3.dll b/funasr/runtime/onnxruntime/win/bin/x64/libfftw3f-3.dll deleted file mode 100644 index 32a3fcf1d..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3f-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3l-3.dll b/funasr/runtime/onnxruntime/win/bin/x64/libfftw3l-3.dll deleted file mode 100644 index 3e46d34db..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x64/libfftw3l-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x64/onnxruntime.dll b/funasr/runtime/onnxruntime/win/bin/x64/onnxruntime.dll deleted file mode 100644 index 087a1b439..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x64/onnxruntime.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3-3.dll b/funasr/runtime/onnxruntime/win/bin/x86/libfftw3-3.dll deleted file mode 100644 index f5a97b49d..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3f-3.dll b/funasr/runtime/onnxruntime/win/bin/x86/libfftw3f-3.dll deleted file mode 100644 index b0a053a82..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3f-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3l-3.dll b/funasr/runtime/onnxruntime/win/bin/x86/libfftw3l-3.dll deleted file mode 100644 index abc81ea87..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x86/libfftw3l-3.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/bin/x86/onnxruntime.dll b/funasr/runtime/onnxruntime/win/bin/x86/onnxruntime.dll deleted file mode 100644 index e284b45b0..000000000 Binary files a/funasr/runtime/onnxruntime/win/bin/x86/onnxruntime.dll and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/images/sample.png b/funasr/runtime/onnxruntime/win/images/sample.png deleted file mode 100644 index cbd7cd3c1..000000000 Binary files a/funasr/runtime/onnxruntime/win/images/sample.png and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/include/cpu_provider_factory.h b/funasr/runtime/onnxruntime/win/include/cpu_provider_factory.h deleted file mode 100644 index 292678692..000000000 --- a/funasr/runtime/onnxruntime/win/include/cpu_provider_factory.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "onnxruntime_c_api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \param use_arena zero: false. non-zero: true. - */ -ORT_EXPORT -ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CPU, _In_ OrtSessionOptions* options, int use_arena) -ORT_ALL_ARGS_NONNULL; - -#ifdef __cplusplus -} -#endif diff --git a/funasr/runtime/onnxruntime/win/include/fftw3.h b/funasr/runtime/onnxruntime/win/include/fftw3.h deleted file mode 100644 index 39661d226..000000000 --- a/funasr/runtime/onnxruntime/win/include/fftw3.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2003, 2007-14 Matteo Frigo - * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology - * - * The following statement of license applies *only* to this header file, - * and *not* to the other files distributed with FFTW or derived therefrom: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/***************************** NOTE TO USERS ********************************* - * - * THIS IS A HEADER FILE, NOT A MANUAL - * - * If you want to know how to use FFTW, please read the manual, - * online at http://www.fftw.org/doc/ and also included with FFTW. - * For a quick start, see the manual's tutorial section. - * - * (Reading header files to learn how to use a library is a habit - * stemming from code lacking a proper manual. Arguably, it's a - * *bad* habit in most cases, because header files can contain - * interfaces that are not part of the public, stable API.) - * - ****************************************************************************/ - -#ifndef FFTW3_H -#define FFTW3_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* If is included, use the C99 complex type. Otherwise - define a type bit-compatible with C99 complex */ -#if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I) -# define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C -#else -# define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2] -#endif - -#define FFTW_CONCAT(prefix, name) prefix ## name -#define FFTW_MANGLE_DOUBLE(name) FFTW_CONCAT(fftw_, name) -#define FFTW_MANGLE_FLOAT(name) FFTW_CONCAT(fftwf_, name) -#define FFTW_MANGLE_LONG_DOUBLE(name) FFTW_CONCAT(fftwl_, name) -#define FFTW_MANGLE_QUAD(name) FFTW_CONCAT(fftwq_, name) - -/* IMPORTANT: for Windows compilers, you should add a line -*/ -#define FFTW_DLL -/* - here and in kernel/ifftw.h if you are compiling/using FFTW as a - DLL, in order to do the proper importing/exporting, or - alternatively compile with -DFFTW_DLL or the equivalent - command-line flag. This is not necessary under MinGW/Cygwin, where - libtool does the imports/exports automatically. */ -#if defined(FFTW_DLL) && (defined(_WIN32) || defined(__WIN32__)) - /* annoying Windows syntax for shared-library declarations */ -# if defined(COMPILING_FFTW) /* defined in api.h when compiling FFTW */ -# define FFTW_EXTERN extern __declspec(dllexport) -# else /* user is calling FFTW; import symbol */ -# define FFTW_EXTERN extern __declspec(dllimport) -# endif -#else -# define FFTW_EXTERN extern -#endif - -enum fftw_r2r_kind_do_not_use_me { - FFTW_R2HC=0, FFTW_HC2R=1, FFTW_DHT=2, - FFTW_REDFT00=3, FFTW_REDFT01=4, FFTW_REDFT10=5, FFTW_REDFT11=6, - FFTW_RODFT00=7, FFTW_RODFT01=8, FFTW_RODFT10=9, FFTW_RODFT11=10 -}; - -struct fftw_iodim_do_not_use_me { - int n; /* dimension size */ - int is; /* input stride */ - int os; /* output stride */ -}; - -#include /* for ptrdiff_t */ -struct fftw_iodim64_do_not_use_me { - ptrdiff_t n; /* dimension size */ - ptrdiff_t is; /* input stride */ - ptrdiff_t os; /* output stride */ -}; - -typedef void (*fftw_write_char_func_do_not_use_me)(char c, void *); -typedef int (*fftw_read_char_func_do_not_use_me)(void *); - -/* - huge second-order macro that defines prototypes for all API - functions. We expand this macro for each supported precision - - X: name-mangling macro - R: real data type - C: complex data type -*/ - -#define FFTW_DEFINE_API(X, R, C) \ - \ -FFTW_DEFINE_COMPLEX(R, C); \ - \ -typedef struct X(plan_s) *X(plan); \ - \ -typedef struct fftw_iodim_do_not_use_me X(iodim); \ -typedef struct fftw_iodim64_do_not_use_me X(iodim64); \ - \ -typedef enum fftw_r2r_kind_do_not_use_me X(r2r_kind); \ - \ -typedef fftw_write_char_func_do_not_use_me X(write_char_func); \ -typedef fftw_read_char_func_do_not_use_me X(read_char_func); \ - \ -FFTW_EXTERN void X(execute)(const X(plan) p); \ - \ -FFTW_EXTERN X(plan) X(plan_dft)(int rank, const int *n, \ - C *in, C *out, int sign, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_2d)(int n0, int n1, \ - C *in, C *out, int sign, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_3d)(int n0, int n1, int n2, \ - C *in, C *out, int sign, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_many_dft)(int rank, const int *n, \ - int howmany, \ - C *in, const int *inembed, \ - int istride, int idist, \ - C *out, const int *onembed, \ - int ostride, int odist, \ - int sign, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - C *in, C *out, \ - int sign, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - R *ri, R *ii, R *ro, R *io, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru64_dft)(int rank, \ - const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - C *in, C *out, \ - int sign, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru64_split_dft)(int rank, \ - const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - R *ri, R *ii, R *ro, R *io, \ - unsigned flags); \ - \ -FFTW_EXTERN void X(execute_dft)(const X(plan) p, C *in, C *out); \ -FFTW_EXTERN void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, \ - R *ro, R *io); \ - \ -FFTW_EXTERN X(plan) X(plan_many_dft_r2c)(int rank, const int *n, \ - int howmany, \ - R *in, const int *inembed, \ - int istride, int idist, \ - C *out, const int *onembed, \ - int ostride, int odist, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_dft_r2c)(int rank, const int *n, \ - R *in, C *out, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_dft_r2c_1d)(int n,R *in,C *out,unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_r2c_2d)(int n0, int n1, \ - R *in, C *out, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_r2c_3d)(int n0, int n1, \ - int n2, \ - R *in, C *out, unsigned flags); \ - \ - \ -FFTW_EXTERN X(plan) X(plan_many_dft_c2r)(int rank, const int *n, \ - int howmany, \ - C *in, const int *inembed, \ - int istride, int idist, \ - R *out, const int *onembed, \ - int ostride, int odist, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_dft_c2r)(int rank, const int *n, \ - C *in, R *out, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_dft_c2r_1d)(int n,C *in,R *out,unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_c2r_2d)(int n0, int n1, \ - C *in, R *out, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_dft_c2r_3d)(int n0, int n1, \ - int n2, \ - C *in, R *out, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - R *in, C *out, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - C *in, R *out, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru_split_dft_r2c)( \ - int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - R *in, R *ro, R *io, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru_split_dft_c2r)( \ - int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - R *ri, R *ii, R *out, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru64_dft_r2c)(int rank, \ - const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - R *in, C *out, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru64_dft_c2r)(int rank, \ - const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - C *in, R *out, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru64_split_dft_r2c)( \ - int rank, const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - R *in, R *ro, R *io, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_guru64_split_dft_c2r)( \ - int rank, const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - R *ri, R *ii, R *out, \ - unsigned flags); \ - \ -FFTW_EXTERN void X(execute_dft_r2c)(const X(plan) p, R *in, C *out); \ -FFTW_EXTERN void X(execute_dft_c2r)(const X(plan) p, C *in, R *out); \ - \ -FFTW_EXTERN void X(execute_split_dft_r2c)(const X(plan) p, \ - R *in, R *ro, R *io); \ -FFTW_EXTERN void X(execute_split_dft_c2r)(const X(plan) p, \ - R *ri, R *ii, R *out); \ - \ -FFTW_EXTERN X(plan) X(plan_many_r2r)(int rank, const int *n, \ - int howmany, \ - R *in, const int *inembed, \ - int istride, int idist, \ - R *out, const int *onembed, \ - int ostride, int odist, \ - const X(r2r_kind) *kind, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_r2r)(int rank, const int *n, R *in, R *out, \ - const X(r2r_kind) *kind, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_r2r_1d)(int n, R *in, R *out, \ - X(r2r_kind) kind, unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_r2r_2d)(int n0, int n1, R *in, R *out, \ - X(r2r_kind) kind0, X(r2r_kind) kind1, \ - unsigned flags); \ -FFTW_EXTERN X(plan) X(plan_r2r_3d)(int n0, int n1, int n2, \ - R *in, R *out, X(r2r_kind) kind0, \ - X(r2r_kind) kind1, X(r2r_kind) kind2, \ - unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, \ - int howmany_rank, \ - const X(iodim) *howmany_dims, \ - R *in, R *out, \ - const X(r2r_kind) *kind, unsigned flags); \ - \ -FFTW_EXTERN X(plan) X(plan_guru64_r2r)(int rank, const X(iodim64) *dims, \ - int howmany_rank, \ - const X(iodim64) *howmany_dims, \ - R *in, R *out, \ - const X(r2r_kind) *kind, unsigned flags); \ - \ -FFTW_EXTERN void X(execute_r2r)(const X(plan) p, R *in, R *out); \ - \ -FFTW_EXTERN void X(destroy_plan)(X(plan) p); \ -FFTW_EXTERN void X(forget_wisdom)(void); \ -FFTW_EXTERN void X(cleanup)(void); \ - \ -FFTW_EXTERN void X(set_timelimit)(double t); \ - \ -FFTW_EXTERN void X(plan_with_nthreads)(int nthreads); \ -FFTW_EXTERN int X(init_threads)(void); \ -FFTW_EXTERN void X(cleanup_threads)(void); \ -FFTW_EXTERN void X(make_planner_thread_safe)(void); \ - \ -FFTW_EXTERN int X(export_wisdom_to_filename)(const char *filename); \ -FFTW_EXTERN void X(export_wisdom_to_file)(FILE *output_file); \ -FFTW_EXTERN char *X(export_wisdom_to_string)(void); \ -FFTW_EXTERN void X(export_wisdom)(X(write_char_func) write_char, \ - void *data); \ -FFTW_EXTERN int X(import_system_wisdom)(void); \ -FFTW_EXTERN int X(import_wisdom_from_filename)(const char *filename); \ -FFTW_EXTERN int X(import_wisdom_from_file)(FILE *input_file); \ -FFTW_EXTERN int X(import_wisdom_from_string)(const char *input_string); \ -FFTW_EXTERN int X(import_wisdom)(X(read_char_func) read_char, void *data); \ - \ -FFTW_EXTERN void X(fprint_plan)(const X(plan) p, FILE *output_file); \ -FFTW_EXTERN void X(print_plan)(const X(plan) p); \ -FFTW_EXTERN char *X(sprint_plan)(const X(plan) p); \ - \ -FFTW_EXTERN void *X(malloc)(size_t n); \ -FFTW_EXTERN R *X(alloc_real)(size_t n); \ -FFTW_EXTERN C *X(alloc_complex)(size_t n); \ -FFTW_EXTERN void X(free)(void *p); \ - \ -FFTW_EXTERN void X(flops)(const X(plan) p, \ - double *add, double *mul, double *fmas); \ -FFTW_EXTERN double X(estimate_cost)(const X(plan) p); \ -FFTW_EXTERN double X(cost)(const X(plan) p); \ - \ -FFTW_EXTERN int X(alignment_of)(R *p); \ -FFTW_EXTERN const char X(version)[]; \ -FFTW_EXTERN const char X(cc)[]; \ -FFTW_EXTERN const char X(codelet_optim)[]; - - -/* end of FFTW_DEFINE_API macro */ - -FFTW_DEFINE_API(FFTW_MANGLE_DOUBLE, double, fftw_complex) -FFTW_DEFINE_API(FFTW_MANGLE_FLOAT, float, fftwf_complex) -FFTW_DEFINE_API(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex) - -/* __float128 (quad precision) is a gcc extension on i386, x86_64, and ia64 - for gcc >= 4.6 (compiled in FFTW with --enable-quad-precision) */ -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) \ - && !(defined(__ICC) || defined(__INTEL_COMPILER) || defined(__CUDACC__) || defined(__PGI)) \ - && (defined(__i386__) || defined(__x86_64__) || defined(__ia64__)) -# if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I) -/* note: __float128 is a typedef, which is not supported with the _Complex - keyword in gcc, so instead we use this ugly __attribute__ version. - However, we can't simply pass the __attribute__ version to - FFTW_DEFINE_API because the __attribute__ confuses gcc in pointer - types. Hence redefining FFTW_DEFINE_COMPLEX. Ugh. */ -# undef FFTW_DEFINE_COMPLEX -# define FFTW_DEFINE_COMPLEX(R, C) typedef _Complex float __attribute__((mode(TC))) C -# endif -FFTW_DEFINE_API(FFTW_MANGLE_QUAD, __float128, fftwq_complex) -#endif - -#define FFTW_FORWARD (-1) -#define FFTW_BACKWARD (+1) - -#define FFTW_NO_TIMELIMIT (-1.0) - -/* documented flags */ -#define FFTW_MEASURE (0U) -#define FFTW_DESTROY_INPUT (1U << 0) -#define FFTW_UNALIGNED (1U << 1) -#define FFTW_CONSERVE_MEMORY (1U << 2) -#define FFTW_EXHAUSTIVE (1U << 3) /* NO_EXHAUSTIVE is default */ -#define FFTW_PRESERVE_INPUT (1U << 4) /* cancels FFTW_DESTROY_INPUT */ -#define FFTW_PATIENT (1U << 5) /* IMPATIENT is default */ -#define FFTW_ESTIMATE (1U << 6) -#define FFTW_WISDOM_ONLY (1U << 21) - -/* undocumented beyond-guru flags */ -#define FFTW_ESTIMATE_PATIENT (1U << 7) -#define FFTW_BELIEVE_PCOST (1U << 8) -#define FFTW_NO_DFT_R2HC (1U << 9) -#define FFTW_NO_NONTHREADED (1U << 10) -#define FFTW_NO_BUFFERING (1U << 11) -#define FFTW_NO_INDIRECT_OP (1U << 12) -#define FFTW_ALLOW_LARGE_GENERIC (1U << 13) /* NO_LARGE_GENERIC is default */ -#define FFTW_NO_RANK_SPLITS (1U << 14) -#define FFTW_NO_VRANK_SPLITS (1U << 15) -#define FFTW_NO_VRECURSE (1U << 16) -#define FFTW_NO_SIMD (1U << 17) -#define FFTW_NO_SLOW (1U << 18) -#define FFTW_NO_FIXED_RADIX_LARGE_N (1U << 19) -#define FFTW_ALLOW_PRUNING (1U << 20) - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* FFTW3_H */ diff --git a/funasr/runtime/onnxruntime/win/include/onnxruntime_c_api.h b/funasr/runtime/onnxruntime/win/include/onnxruntime_c_api.h deleted file mode 100644 index 44875b0f9..000000000 --- a/funasr/runtime/onnxruntime/win/include/onnxruntime_c_api.h +++ /dev/null @@ -1,3987 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// See docs\c_cxx\README.md on generating the Doxygen documentation from this file - -/** \mainpage C & C++ APIs - * - *

    C

    - * - * ::OrtApi - Click here to go to the structure with all C API functions. - * - *

    C++

    - * - * ::Ort - Click here to go to the namespace holding all of the C++ wrapper classes - * - * It is a set of header only wrapper classes around the C API. The goal is to turn the C style return value error codes into C++ exceptions, and to - * automate memory management through standard C++ RAII principles. - * - * \addtogroup Global - * ONNX Runtime C API - * @{ - */ - -#pragma once -#include -#include -#include - -/** \brief The API version defined in this header - * - * This value is used by some API functions to behave as this version of the header expects. - */ -#define ORT_API_VERSION 14 - -#ifdef __cplusplus -extern "C" { -#endif - -//! @} -// SAL2 Definitions -#ifndef _WIN32 -#define _In_ -#define _In_z_ -#define _In_opt_ -#define _In_opt_z_ -#define _Out_ -#define _Outptr_ -#define _Out_opt_ -#define _Inout_ -#define _Inout_opt_ -#define _Frees_ptr_opt_ -#define _Ret_maybenull_ -#define _Ret_notnull_ -#define _Check_return_ -#define _Outptr_result_maybenull_ -#define _In_reads_(X) -#define _Inout_updates_all_(X) -#define _Out_writes_bytes_all_(X) -#define _Out_writes_all_(X) -#define _Success_(X) -#define _Outptr_result_buffer_maybenull_(X) -#define ORT_ALL_ARGS_NONNULL __attribute__((nonnull)) -#else -#include -#define ORT_ALL_ARGS_NONNULL -#endif - -#ifdef _WIN32 -// Define ORT_DLL_IMPORT if your program is dynamically linked to Ort. -// dllexport is not used, we use a .def file. -#ifdef ORT_DLL_IMPORT -#define ORT_EXPORT __declspec(dllimport) -#else -#define ORT_EXPORT -#endif -#define ORT_API_CALL _stdcall -#define ORT_MUST_USE_RESULT -#define ORTCHAR_T wchar_t -#else -// To make symbols visible on macOS/iOS -#ifdef __APPLE__ -#define ORT_EXPORT __attribute__((visibility("default"))) -#else -#define ORT_EXPORT -#endif -#define ORT_API_CALL -#define ORT_MUST_USE_RESULT __attribute__((warn_unused_result)) -#define ORTCHAR_T char -#endif - -#ifndef ORT_TSTR -#ifdef _WIN32 -#define ORT_TSTR(X) L##X -#else -#define ORT_TSTR(X) X -#endif -#endif - -// Any pointer marked with _In_ or _Out_, cannot be NULL. - -// Windows users should use unicode paths when possible to bypass the MAX_PATH limitation -// Every pointer marked with _In_ or _Out_, cannot be NULL. Caller should ensure that. -// for ReleaseXXX(...) functions, they can accept NULL pointer. - -#ifdef __cplusplus -// For any compiler with C++11 support, MSVC 2015 and greater, or Clang version supporting noexcept. -// Such complex condition is needed because compilers set __cplusplus value differently. -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || (defined(__has_feature) && __has_feature(cxx_noexcept))) -#define NO_EXCEPTION noexcept -#else -#define NO_EXCEPTION throw() -#endif -#else -#define NO_EXCEPTION -#endif - -// __VA_ARGS__ on Windows and Linux are different -#define ORT_API(RETURN_TYPE, NAME, ...) RETURN_TYPE ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION - -#define ORT_API_STATUS(NAME, ...) \ - _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) \ - NO_EXCEPTION ORT_MUST_USE_RESULT - -// XXX: Unfortunately, SAL annotations are known to not work with function pointers -#define ORT_API2_STATUS(NAME, ...) \ - _Check_return_ _Ret_maybenull_ OrtStatusPtr(ORT_API_CALL* NAME)(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT - -// Used in *.cc files. Almost as same as ORT_API_STATUS, except without ORT_MUST_USE_RESULT and ORT_EXPORT -#define ORT_API_STATUS_IMPL(NAME, ...) \ - _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION - -#define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input) - -#ifdef __DOXYGEN__ -#undef ORT_API_STATUS -#define ORT_API_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__) -#undef ORT_API2_STATUS -#define ORT_API2_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__) -#undef ORT_CLASS_RELEASE -#define ORT_CLASS_RELEASE(X) void Release##X(Ort##X* input) -#undef NO_EXCEPTION -#define NO_EXCEPTION -#endif -/** \addtogroup Global - * ONNX Runtime C API - * @{ - */ - -/** Copied from TensorProto::DataType - * Currently, Ort doesn't support complex64, complex128 - */ -typedef enum ONNXTensorElementDataType { - ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED, - ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, // maps to c type float - ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8, // maps to c type uint8_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8, // maps to c type int8_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16, // maps to c type uint16_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16, // maps to c type int16_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32, // maps to c type int32_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64, // maps to c type int64_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING, // maps to c++ type std::string - ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL, - ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16, - ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE, // maps to c type double - ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32, // maps to c type uint32_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64, // maps to c type uint64_t - ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64, // complex with float32 real and imaginary components - ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128, // complex with float64 real and imaginary components - ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16 // Non-IEEE floating-point format based on IEEE754 single-precision -} ONNXTensorElementDataType; - -// Synced with onnx TypeProto oneof -typedef enum ONNXType { - ONNX_TYPE_UNKNOWN, - ONNX_TYPE_TENSOR, - ONNX_TYPE_SEQUENCE, - ONNX_TYPE_MAP, - ONNX_TYPE_OPAQUE, - ONNX_TYPE_SPARSETENSOR, - ONNX_TYPE_OPTIONAL -} ONNXType; - -// These types are synced with internal -// SparseFormatFlags -typedef enum OrtSparseFormat { - ORT_SPARSE_UNDEFINED = 0, - ORT_SPARSE_COO = 0x1, - ORT_SPARSE_CSRC = 0x2, - ORT_SPARSE_BLOCK_SPARSE = 0x4 -} OrtSparseFormat; - -// Enum allows to query sparse tensor indices -enum OrtSparseIndicesFormat { - ORT_SPARSE_COO_INDICES, - ORT_SPARSE_CSR_INNER_INDICES, - ORT_SPARSE_CSR_OUTER_INDICES, - ORT_SPARSE_BLOCK_SPARSE_INDICES -}; - -/** \brief Logging severity levels - * - * In typical API usage, specifying a logging severity level specifies the minimum severity of log messages to show. - */ -typedef enum OrtLoggingLevel { - ORT_LOGGING_LEVEL_VERBOSE, ///< Verbose informational messages (least severe). - ORT_LOGGING_LEVEL_INFO, ///< Informational messages. - ORT_LOGGING_LEVEL_WARNING, ///< Warning messages. - ORT_LOGGING_LEVEL_ERROR, ///< Error messages. - ORT_LOGGING_LEVEL_FATAL, ///< Fatal error messages (most severe). -} OrtLoggingLevel; - -typedef enum OrtErrorCode { - ORT_OK, - ORT_FAIL, - ORT_INVALID_ARGUMENT, - ORT_NO_SUCHFILE, - ORT_NO_MODEL, - ORT_ENGINE_ERROR, - ORT_RUNTIME_EXCEPTION, - ORT_INVALID_PROTOBUF, - ORT_MODEL_LOADED, - ORT_NOT_IMPLEMENTED, - ORT_INVALID_GRAPH, - ORT_EP_FAIL, -} OrtErrorCode; - -typedef enum OrtOpAttrType { - ORT_OP_ATTR_UNDEFINED = 0, - ORT_OP_ATTR_INT, - ORT_OP_ATTR_INTS, - ORT_OP_ATTR_FLOAT, - ORT_OP_ATTR_FLOATS, - ORT_OP_ATTR_STRING, - ORT_OP_ATTR_STRINGS, -} OrtOpAttrType; - -//! @} -#define ORT_RUNTIME_CLASS(X) \ - struct Ort##X; \ - typedef struct Ort##X Ort##X; - -/** \addtogroup Global - * ONNX Runtime C API - * @{ - */ -// The actual types defined have an Ort prefix -ORT_RUNTIME_CLASS(Env); -ORT_RUNTIME_CLASS(Status); // nullptr for Status* indicates success -ORT_RUNTIME_CLASS(MemoryInfo); -ORT_RUNTIME_CLASS(IoBinding); -ORT_RUNTIME_CLASS(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool) -ORT_RUNTIME_CLASS(Value); -ORT_RUNTIME_CLASS(RunOptions); -ORT_RUNTIME_CLASS(TypeInfo); -ORT_RUNTIME_CLASS(TensorTypeAndShapeInfo); -ORT_RUNTIME_CLASS(SessionOptions); -ORT_RUNTIME_CLASS(CustomOpDomain); -ORT_RUNTIME_CLASS(MapTypeInfo); -ORT_RUNTIME_CLASS(SequenceTypeInfo); -ORT_RUNTIME_CLASS(ModelMetadata); -ORT_RUNTIME_CLASS(ThreadPoolParams); -ORT_RUNTIME_CLASS(ThreadingOptions); -ORT_RUNTIME_CLASS(ArenaCfg); -ORT_RUNTIME_CLASS(PrepackedWeightsContainer); -ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2); -ORT_RUNTIME_CLASS(CUDAProviderOptionsV2); -ORT_RUNTIME_CLASS(CANNProviderOptions); -ORT_RUNTIME_CLASS(Op); -ORT_RUNTIME_CLASS(OpAttr); - -#ifdef _WIN32 -typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr; -#else -typedef OrtStatus* OrtStatusPtr; -#endif - -/** \brief Memory allocation interface - * - * Structure of function pointers that defines a memory allocator. This can be created and filled in by the user for custom allocators. - * - * When an allocator is passed to any function, be sure that the allocator object is not destroyed until the last allocated object using it is freed. - */ -typedef struct OrtAllocator { - uint32_t version; ///< Must be initialized to ORT_API_VERSION - void*(ORT_API_CALL* Alloc)(struct OrtAllocator* this_, size_t size); ///< Returns a pointer to an allocated block of `size` bytes - void(ORT_API_CALL* Free)(struct OrtAllocator* this_, void* p); ///< Free a block of memory previously allocated with OrtAllocator::Alloc - const struct OrtMemoryInfo*(ORT_API_CALL* Info)(const struct OrtAllocator* this_); ///< Return a pointer to an ::OrtMemoryInfo that describes this allocator -} OrtAllocator; - -typedef void(ORT_API_CALL* OrtLoggingFunction)( - void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location, - const char* message); - -/** \brief Graph optimization level - * - * Refer to https://www.onnxruntime.ai/docs/resources/graph-optimizations.html - * for an in-depth understanding of Graph Optimizations - */ -typedef enum GraphOptimizationLevel { - ORT_DISABLE_ALL = 0, - ORT_ENABLE_BASIC = 1, - ORT_ENABLE_EXTENDED = 2, - ORT_ENABLE_ALL = 99 -} GraphOptimizationLevel; - -typedef enum ExecutionMode { - ORT_SEQUENTIAL = 0, - ORT_PARALLEL = 1, -} ExecutionMode; - -/** \brief Language projection identifiers - * /see OrtApi::SetLanguageProjection - */ -typedef enum OrtLanguageProjection { - ORT_PROJECTION_C = 0, - ORT_PROJECTION_CPLUSPLUS = 1, - ORT_PROJECTION_CSHARP = 2, - ORT_PROJECTION_PYTHON = 3, - ORT_PROJECTION_JAVA = 4, - ORT_PROJECTION_WINML = 5, - ORT_PROJECTION_NODEJS = 6, -} OrtLanguageProjection; - -struct OrtKernelInfo; -typedef struct OrtKernelInfo OrtKernelInfo; -struct OrtKernelContext; -typedef struct OrtKernelContext OrtKernelContext; -struct OrtCustomOp; -typedef struct OrtCustomOp OrtCustomOp; - -typedef enum OrtAllocatorType { - OrtInvalidAllocator = -1, - OrtDeviceAllocator = 0, - OrtArenaAllocator = 1 -} OrtAllocatorType; - -/** \brief Memory types for allocated memory, execution provider specific types should be extended in each provider. - */ -// Whenever this struct is updated, please also update the MakeKey function in onnxruntime / core / framework / execution_provider.cc -typedef enum OrtMemType { - OrtMemTypeCPUInput = -2, ///< Any CPU memory used by non-CPU execution provider - OrtMemTypeCPUOutput = -1, ///< CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED - OrtMemTypeCPU = OrtMemTypeCPUOutput, ///< Temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED - OrtMemTypeDefault = 0, ///< The default allocator for execution provider -} OrtMemType; - -/** \brief This mimics OrtDevice type constants so they can be returned in the API - */ -typedef enum OrtMemoryInfoDeviceType { - OrtMemoryInfoDeviceType_CPU = 0, - OrtMemoryInfoDeviceType_GPU = 1, - OrtMemoryInfoDeviceType_FPGA = 2 -} OrtMemoryInfoDeviceType; - -/** \brief Algorithm to use for cuDNN Convolution Op - */ -typedef enum OrtCudnnConvAlgoSearch { - OrtCudnnConvAlgoSearchExhaustive, // expensive exhaustive benchmarking using cudnnFindConvolutionForwardAlgorithmEx - OrtCudnnConvAlgoSearchHeuristic, // lightweight heuristic based search using cudnnGetConvolutionForwardAlgorithm_v7 - OrtCudnnConvAlgoSearchDefault, // default algorithm using CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM -} OrtCudnnConvAlgoSearch; - -/** \brief CUDA Provider Options - * - * \see OrtApi::SessionOptionsAppendExecutionProvider_CUDA - */ -typedef struct OrtCUDAProviderOptions { -#ifdef __cplusplus - OrtCUDAProviderOptions() - : device_id{}, - cudnn_conv_algo_search{OrtCudnnConvAlgoSearchExhaustive}, - gpu_mem_limit{SIZE_MAX}, - arena_extend_strategy{}, - do_copy_in_default_stream{1}, - has_user_compute_stream{}, - user_compute_stream{}, - default_memory_arena_cfg{}, - tunable_op_enabled{false} {} -#endif - - /** \brief CUDA device Id - * Defaults to 0. - */ - int device_id; - - /** \brief CUDA Convolution algorithm search configuration. - * See enum OrtCudnnConvAlgoSearch for more details. - * Defaults to OrtCudnnConvAlgoSearchExhaustive. - */ - OrtCudnnConvAlgoSearch cudnn_conv_algo_search; - - /** \brief CUDA memory limit (To use all possible memory pass in maximum size_t) - * Defaults to SIZE_MAX. - * \note If a ::OrtArenaCfg has been applied, it will override this field - */ - size_t gpu_mem_limit; - - /** \brief Strategy used to grow the memory arena - * 0 = kNextPowerOfTwo
    - * 1 = kSameAsRequested
    - * Defaults to 0. - * \note If a ::OrtArenaCfg has been applied, it will override this field - */ - int arena_extend_strategy; - - /** \brief Flag indicating if copying needs to take place on the same stream as the compute stream in the CUDA EP - * 0 = Use separate streams for copying and compute. - * 1 = Use the same stream for copying and compute. - * Defaults to 1. - * WARNING: Setting this to 0 may result in data races for some models. - * Please see issue #4829 for more details. - */ - int do_copy_in_default_stream; - - /** \brief Flag indicating if there is a user provided compute stream - * Defaults to 0. - */ - int has_user_compute_stream; - - /** \brief User provided compute stream. - * If provided, please set `has_user_compute_stream` to 1. - */ - void* user_compute_stream; - - /** \brief CUDA memory arena configuration parameters - */ - OrtArenaCfg* default_memory_arena_cfg; - - /** \brief Enable TunableOp. - * Set it to 1 to enable TunableOp. Otherwise, it is disabled by default. - * This option can be superseded by environment variable ORT_CUDA_TUNABLE_OP_ENABLED. - */ - int tunable_op_enabled; - -} OrtCUDAProviderOptions; - -/** \brief ROCM Provider Options - * - * \see OrtApi::SessionOptionsAppendExecutionProvider_ROCM - */ -typedef struct OrtROCMProviderOptions { -#ifdef __cplusplus - OrtROCMProviderOptions() - : device_id{}, - miopen_conv_exhaustive_search{0}, - gpu_mem_limit{SIZE_MAX}, - arena_extend_strategy{}, - do_copy_in_default_stream{1}, - has_user_compute_stream{}, - user_compute_stream{}, - default_memory_arena_cfg{}, - tunable_op_enabled{false} {} -#endif - - /** \brief ROCM device Id - * Defaults to 0. - */ - int device_id; - - /** \brief ROCM MIOpen Convolution algorithm exaustive search option. - * Defaults to 0 (false). - */ - int miopen_conv_exhaustive_search; - - /** \brief ROCM memory limit (To use all possible memory pass in maximum size_t) - * Defaults to SIZE_MAX. - * \note If a ::OrtArenaCfg has been applied, it will override this field - */ - size_t gpu_mem_limit; - - /** \brief Strategy used to grow the memory arena - * 0 = kNextPowerOfTwo
    - * 1 = kSameAsRequested
    - * Defaults to 0. - * \note If a ::OrtArenaCfg has been applied, it will override this field - */ - int arena_extend_strategy; - - /** \brief Flag indicating if copying needs to take place on the same stream as the compute stream in the ROCM EP - * 0 = Use separate streams for copying and compute. - * 1 = Use the same stream for copying and compute. - * Defaults to 1. - * WARNING: Setting this to 0 may result in data races for some models. - * Please see issue #4829 for more details. - */ - int do_copy_in_default_stream; - - /** \brief Flag indicating if there is a user provided compute stream - * Defaults to 0. - */ - int has_user_compute_stream; - - /** \brief User provided compute stream. - * If provided, please set `has_user_compute_stream` to 1. - */ - void* user_compute_stream; - - /** \brief ROCM memory arena configuration parameters - */ - OrtArenaCfg* default_memory_arena_cfg; - - /** \brief Enable TunableOp. - * Set it to 1 to enable TunableOp. Otherwise, it is disabled by default. - * This option can be superseded by environment variable ORT_ROCM_TUNABLE_OP_ENABLED. - */ - int tunable_op_enabled; - -} OrtROCMProviderOptions; - -/** \brief TensorRT Provider Options - * - * \see OrtApi::SessionOptionsAppendExecutionProvider_TensorRT - */ -typedef struct OrtTensorRTProviderOptions { - int device_id; ///< CUDA device id (0 = default device) - int has_user_compute_stream; // indicator of user specified CUDA compute stream. - void* user_compute_stream; // user specified CUDA compute stream. - int trt_max_partition_iterations; // maximum iterations for TensorRT parser to get capability - int trt_min_subgraph_size; // minimum size of TensorRT subgraphs - size_t trt_max_workspace_size; // maximum workspace size for TensorRT. - int trt_fp16_enable; // enable TensorRT FP16 precision. Default 0 = false, nonzero = true - int trt_int8_enable; // enable TensorRT INT8 precision. Default 0 = false, nonzero = true - const char* trt_int8_calibration_table_name; // TensorRT INT8 calibration table name. - int trt_int8_use_native_calibration_table; // use native TensorRT generated calibration table. Default 0 = false, nonzero = true - int trt_dla_enable; // enable DLA. Default 0 = false, nonzero = true - int trt_dla_core; // DLA core number. Default 0 - int trt_dump_subgraphs; // dump TRT subgraph. Default 0 = false, nonzero = true - int trt_engine_cache_enable; // enable engine caching. Default 0 = false, nonzero = true - const char* trt_engine_cache_path; // specify engine cache path - int trt_engine_decryption_enable; // enable engine decryption. Default 0 = false, nonzero = true - const char* trt_engine_decryption_lib_path; // specify engine decryption library path - int trt_force_sequential_engine_build; // force building TensorRT engine sequentially. Default 0 = false, nonzero = true - // This is the legacy struct and don't add new fields here. - // For new field that can be represented by string, please add it in include/onnxruntime/core/providers/tensorrt/tensorrt_provider_options.h - // For non-string field, need to create a new separate api to handle it. -} OrtTensorRTProviderOptions; - -/** \brief MIGraphX Provider Options - * - * \see OrtApi::SessionOptionsAppendExecutionProvider_MIGraphX - */ -typedef struct OrtMIGraphXProviderOptions { - int device_id; // hip device id. - int migraphx_fp16_enable; // enable MIGraphX FP16 precision. Default 0 = false, nonzero = true - int migraphx_int8_enable; // enable MIGraphX INT8 precision. Default 0 = false, nonzero = true -} OrtMIGraphXProviderOptions; - -/** \brief OpenVINO Provider Options - * - * \see OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO - */ -typedef struct OrtOpenVINOProviderOptions { -#ifdef __cplusplus - OrtOpenVINOProviderOptions() : device_type{}, enable_vpu_fast_compile{}, device_id{}, - num_of_threads{}, cache_dir{}, - context{}, enable_opencl_throttling{}, enable_dynamic_shapes{} {} -#endif - /** \brief Device type string - * - * Valid settings are one of: "CPU_FP32", "CPU_FP16", "GPU_FP32", "GPU_FP16", "MYRIAD_FP16", "VAD-M_FP16" or "VAD-F_FP32" - */ - const char* device_type; - unsigned char enable_vpu_fast_compile; ///< 0 = disabled, nonzero = enabled - const char* device_id; - size_t num_of_threads; ///< 0 = Use default number of threads - const char* cache_dir; // path is set to empty by default - void* context; - unsigned char enable_opencl_throttling; ///< 0 = disabled, nonzero = enabled - unsigned char enable_dynamic_shapes; ///< 0 = disabled, nonzero = enabled -} OrtOpenVINOProviderOptions; - -struct OrtApi; -typedef struct OrtApi OrtApi; - -struct OrtTrainingApi; -typedef struct OrtTrainingApi OrtTrainingApi; - -/** \brief The helper interface to get the right version of OrtApi - * - * Get a pointer to this structure through ::OrtGetApiBase - */ -struct OrtApiBase { - /** \brief Get a pointer to the requested version of the ::OrtApi - * - * \param[in] version Must be ::ORT_API_VERSION - * \return The ::OrtApi for the version requested, nullptr will be returned if this version is unsupported, for example when using a runtime - * older than the version created with this header file. - */ - const OrtApi*(ORT_API_CALL* GetApi)(uint32_t version)NO_EXCEPTION; - const char*(ORT_API_CALL* GetVersionString)(void)NO_EXCEPTION; ///< Returns a null terminated string of the version of the Onnxruntime library (eg: "1.8.1") -}; -typedef struct OrtApiBase OrtApiBase; - -/** \brief The Onnxruntime library's entry point to access the C API - * - * Call this to get the a pointer to an ::OrtApiBase - */ -ORT_EXPORT const OrtApiBase* ORT_API_CALL OrtGetApiBase(void) NO_EXCEPTION; - -/** \brief Thread work loop function - * - * Onnxruntime will provide the working loop on custom thread creation - * Argument is an onnxruntime built-in type which will be provided when thread pool calls OrtCustomCreateThreadFn - */ -typedef void (*OrtThreadWorkerFn)(void* ort_worker_fn_param); - -typedef const struct OrtCustomHandleType { - char __place_holder; -}* OrtCustomThreadHandle; - -/** \brief Ort custom thread creation function - * - * The function should return a thread handle to be used in onnxruntime thread pools - * Onnxruntime will throw exception on return value of nullptr or 0, indicating that the function failed to create a thread - */ -typedef OrtCustomThreadHandle (*OrtCustomCreateThreadFn)(void* ort_custom_thread_creation_options, OrtThreadWorkerFn ort_thread_worker_fn, void* ort_worker_fn_param); - -/** \brief Custom thread join function - * - * Onnxruntime thread pool destructor will call the function to join a custom thread. - * Argument ort_custom_thread_handle is the value returned by OrtCustomCreateThreadFn - */ -typedef void (*OrtCustomJoinThreadFn)(OrtCustomThreadHandle ort_custom_thread_handle); - -typedef OrtStatus*(ORT_API_CALL* RegisterCustomOpsFn)(OrtSessionOptions* options, const OrtApiBase* api); - -/** \brief The C API - * - * All C API functions are defined inside this structure as pointers to functions. - * Call OrtApiBase::GetApi to get a pointer to it - * - * \nosubgrouping - */ -struct OrtApi { - /// \name OrtStatus - /// @{ - - /** - * \brief Create an OrtStatus from a null terminated string - * - * \param[in] code - * \param[in] msg A null-terminated string. Its contents will be copied. - * \return A new OrtStatus object, must be destroyed with OrtApi::ReleaseStatus - */ - OrtStatus*(ORT_API_CALL* CreateStatus)(OrtErrorCode code, _In_ const char* msg)NO_EXCEPTION ORT_ALL_ARGS_NONNULL; - - /** \brief Get OrtErrorCode from OrtStatus - * - * \param[in] status - * \return OrtErrorCode that \p status was created with - */ - OrtErrorCode(ORT_API_CALL* GetErrorCode)(_In_ const OrtStatus* status) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; - - /** \brief Get error string from OrtStatus - * - * \param[in] status - * \return The error message inside the `status`. Do not free the returned value. - */ - const char*(ORT_API_CALL* GetErrorMessage)(_In_ const OrtStatus* status)NO_EXCEPTION ORT_ALL_ARGS_NONNULL; - - /// @} - /// \name OrtEnv - /// @{ - - /** \brief Create an OrtEnv - * - * \param[in] log_severity_level The log severity level. - * \param[in] logid The log identifier. - * \param[out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateEnv, OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out); - - /** \brief Create an OrtEnv - * - * \param[in] logging_function A pointer to a logging function. - * \param[in] logger_param A pointer to arbitrary data passed as the ::OrtLoggingFunction `param` parameter to - * `logging_function`. - * \param[in] log_severity_level The log severity level. - * \param[in] logid The log identifier. - * \param[out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateEnvWithCustomLogger, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, - OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out); - - /** \brief Enable Telemetry - * - * \note Telemetry events are on by default since they are lightweight - * \param[in] env - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(EnableTelemetryEvents, _In_ const OrtEnv* env); - /** \brief Disable Telemetry - * - * \see OrtApi::EnableTelemetryEvents - * \param[in] env - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(DisableTelemetryEvents, _In_ const OrtEnv* env); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief Create an OrtSession from a model file - * - * \param[in] env - * \param[in] model_path - * \param[in] options - * \param[out] out Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - // TODO: document the path separator convention? '/' vs '\' - // TODO: should specify the access characteristics of model_path. Is this read only during the - // execution of CreateSession, or does the OrtSession retain a handle to the file/directory - // and continue to access throughout the OrtSession lifetime? - // What sort of access is needed to model_path : read or read/write? - ORT_API2_STATUS(CreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, - _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out); - - /** \brief Create an OrtSession from memory - * - * \param[in] env - * \param[in] model_data - * \param[in] model_data_length - * \param[in] options - * \param[out] out Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length, - _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out); - - /** \brief Run the model in an ::OrtSession - * - * Will not return until the model run has completed. Multiple threads might be used to run the model based on - * the options in the ::OrtSession and settings used when creating the ::OrtEnv - * - * \param[in] session - * \param[in] run_options If nullptr, will use a default ::OrtRunOptions - * \param[in] input_names Array of null terminated UTF8 encoded strings of the input names - * \param[in] inputs Array of ::OrtValue%s of the input values - * \param[in] input_len Number of elements in the input_names and inputs arrays - * \param[in] output_names Array of null terminated UTF8 encoded strings of the output names - * \param[in] output_names_len Number of elements in the output_names and outputs array - * \param[out] outputs Array of ::OrtValue%s that the outputs are stored in. This can also be - * an array of nullptr values, in this case ::OrtValue objects will be allocated and pointers - * to them will be set into the `outputs` array. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(Run, _Inout_ OrtSession* session, _In_opt_ const OrtRunOptions* run_options, - _In_reads_(input_len) const char* const* input_names, - _In_reads_(input_len) const OrtValue* const* inputs, size_t input_len, - _In_reads_(output_names_len) const char* const* output_names, size_t output_names_len, - _Inout_updates_all_(output_names_len) OrtValue** outputs); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Create an ::OrtSessionOptions object - * - * To use additional providers, you must build ORT with the extra providers enabled. Then call one of these - * functions to enable them in the session:
    - * OrtSessionOptionsAppendExecutionProvider_CPU
    - * OrtSessionOptionsAppendExecutionProvider_CUDA
    - * OrtSessionOptionsAppendExecutionProvider_(remaining providers...)
    - * The order they are called indicates the preference order as well. In other words call this method - * on your most preferred execution provider first followed by the less preferred ones. - * If none are called Ort will use its internal CPU execution provider. - * - * \param[out] options The newly created OrtSessionOptions. Must be freed with OrtApi::ReleaseSessionOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSessionOptions, _Outptr_ OrtSessionOptions** options); - - /** \brief Set filepath to save optimized model after graph level transformations - * - * \param[in] options - * \param[in] optimized_model_filepath - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetOptimizedModelFilePath, _Inout_ OrtSessionOptions* options, - _In_ const ORTCHAR_T* optimized_model_filepath); - - /** \brief Create a copy of an existing ::OrtSessionOptions - * - * \param[in] in_options OrtSessionOptions to copy - * \param[out] out_options Returned newly created ::OrtSessionOptions. Must be freed with OrtApi::ReleaseSessionOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CloneSessionOptions, _In_ const OrtSessionOptions* in_options, - _Outptr_ OrtSessionOptions** out_options); - - /** \brief Set execution mode - * - * Controls whether you want to execute operators in your graph sequentially or in parallel. Usually when the model - * has many branches, setting this option to ExecutionMode.ORT_PARALLEL will give you better performance. - * See [docs/ONNX_Runtime_Perf_Tuning.md] for more details. - * - * \param[in] options - * \param[in] execution_mode - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetSessionExecutionMode, _Inout_ OrtSessionOptions* options, ExecutionMode execution_mode); - - /** \brief Enable profiling for a session - * - * \param[in] options - * \param[in] profile_file_prefix - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(EnableProfiling, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix); - - /** \brief Disable profiling for a session - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(DisableProfiling, _Inout_ OrtSessionOptions* options); - - /** \brief Enable the memory pattern optimization - * - * The idea is if the input shapes are the same, we could trace the internal memory allocation - * and generate a memory pattern for future request. So next time we could just do one allocation - * with a big chunk for all the internal memory allocation. - * \note Memory pattern optimization is only available when Sequential Execution mode is enabled (see OrtApi::SetSessionExecutionMode) - * - * \see OrtApi::DisableMemPattern - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(EnableMemPattern, _Inout_ OrtSessionOptions* options); - - /** \brief Disable the memory pattern optimization - * - * \see OrtApi::EnableMemPattern - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(DisableMemPattern, _Inout_ OrtSessionOptions* options); - - /** \brief Enable the memory arena on CPU - * - * Arena may pre-allocate memory for future usage. - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(EnableCpuMemArena, _Inout_ OrtSessionOptions* options); - - /** \brief Disable the memory arena on CPU - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(DisableCpuMemArena, _Inout_ OrtSessionOptions* options); - - /** \brief Set session log id - * - * \param[in] options - * \param[in] logid The log identifier. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetSessionLogId, _Inout_ OrtSessionOptions* options, const char* logid); - - /** \brief Set session log verbosity level - * - * Applies to session load, initialization, etc - * - * \param[in] options - * \param[in] session_log_verbosity_level \snippet{doc} snippets.dox Log Verbosity Level - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetSessionLogVerbosityLevel, _Inout_ OrtSessionOptions* options, int session_log_verbosity_level); - - /** \brief Set session log severity level - * - * \param[in] options - * \param[in] session_log_severity_level The log severity level (refer to ::OrtLoggingLevel for possible values). - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetSessionLogSeverityLevel, _Inout_ OrtSessionOptions* options, int session_log_severity_level); - - /** \brief Set the optimization level to apply when loading a graph - * - * Please see https://www.onnxruntime.ai/docs/resources/graph-optimizations.html for an in-depth explanation - * \param[in,out] options The session options object - * \param[in] graph_optimization_level The optimization level - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetSessionGraphOptimizationLevel, _Inout_ OrtSessionOptions* options, - GraphOptimizationLevel graph_optimization_level); - - /** \brief Sets the number of threads used to parallelize the execution within nodes - * - * When running a single node operation, ex. add, this sets the maximum number of threads to use. - * - * \note If built with OpenMP, this has no effect on the number of threads used. In this case - * use the OpenMP env variables to configure the number of intra op num threads. - * - * \param[in] options - * \param[in] intra_op_num_threads Number of threads to use
    - * A value of 0 will use the default number of threads
    - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetIntraOpNumThreads, _Inout_ OrtSessionOptions* options, int intra_op_num_threads); - - /** \brief Sets the number of threads used to parallelize the execution of the graph - * - * If nodes can be run in parallel, this sets the maximum number of threads to use to run them in parallel. - * - * \note If sequential execution is enabled this value is ignored, it acts as if it was set to 1. - * - * \param[in] options - * \param[in] inter_op_num_threads Number of threads to use
    - * A value of 0 will use the default number of threads
    - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetInterOpNumThreads, _Inout_ OrtSessionOptions* options, int inter_op_num_threads); - - /// @} - /// \name OrtCustomOpDomain - /// @{ - - /** \brief Create a custom op domain - * - * \param[in] domain - * \param[out] out Newly created domain. Must be freed with OrtApi::ReleaseCustomOpDomain - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateCustomOpDomain, _In_ const char* domain, _Outptr_ OrtCustomOpDomain** out); - - /** \brief Add a custom op to a custom op domain - * - * \note The OrtCustomOp* pointer must remain valid until the ::OrtCustomOpDomain using it is released - * - * \param[in] custom_op_domain - * \param[in] op - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CustomOpDomain_Add, _Inout_ OrtCustomOpDomain* custom_op_domain, _In_ const OrtCustomOp* op); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Add custom op domain to a session options - * - * \note The OrtCustomOpDomain* must not be deleted until all sessions using it are released - * - * \param[in] options - * \param[in] custom_op_domain - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(AddCustomOpDomain, _Inout_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain); - - /** \deprecated Use OrtApi::RegisterCustomOpsLibrary_V2. - * - * Registers custom ops from a shared library. - * - * Loads a shared library (dll on windows, so on linux, etc) named 'library_path' and looks for this entry point: - * OrtStatus* RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); - * It then passes in the provided session options to this function along with the api base. - * The handle to the loaded library is returned in library_handle. It can be freed by the caller after all sessions using the passed in - * session options are destroyed, or if an error occurs and it is non null. - * - * \param[in] options - * \param[in] library_path - * \param[out] library_handle OS specific handle to the loaded library (Use FreeLibrary on Windows, dlclose on Linux, etc.. to unload) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RegisterCustomOpsLibrary, _Inout_ OrtSessionOptions* options, _In_ const char* library_path, _Outptr_ void** library_handle); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief Get input count for a session - * - * This number must also match the number of inputs passed to OrtApi::Run - * - * \see OrtApi::SessionGetInputTypeInfo, OrtApi::SessionGetInputName, OrtApi::Session - * - * \param[in] session - * \param[out] out Number of inputs - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetInputCount, _In_ const OrtSession* session, _Out_ size_t* out); - - /** \brief Get output count for a session - * - * This number must also match the number of outputs returned by OrtApi::Run - * - * \see OrtApi::SessionGetOutputTypeInfo, OrtApi::SessionGetOutputName, OrtApi::Session - * - * \param[in] session - * \param[out] out Number of outputs - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOutputCount, _In_ const OrtSession* session, _Out_ size_t* out); - - /** \brief Get overridable initializer count - * - * \see OrtApi::SessionGetOverridableInitializerTypeInfo, OrtApi::SessionGetOverridableInitializerName - * - * \param[in] session - * \param[in] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOverridableInitializerCount, _In_ const OrtSession* session, _Out_ size_t* out); - - /** \brief Get input type information - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetInputCount returns (exclusive) - * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetInputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info); - - /** \brief Get output type information - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOutputCount returns (exclusive) - * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOutputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info); - - /** \brief Get overridable initializer type information - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOverridableInitializerCount returns (exclusive) - * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOverridableInitializerTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info); - - /** \brief Get input name - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetInputCount returns (exclusive) - * \param[in] allocator - * \param[out] value Set to a null terminated UTF-8 encoded string allocated using `allocator`. Must be freed using `allocator`. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetInputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /** \brief Get output name - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOutputCount returns (exclusive) - * \param[in] allocator - * \param[out] value Set to a null terminated UTF-8 encoded string allocated using `allocator`. Must be freed using `allocator`. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOutputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /** \brief Get overridable initializer name - * - * \param[in] session - * \param[in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOverridableInitializerCount returns (exclusive) - * \param[in] allocator - * \param[out] value Set to a null terminated UTF-8 encoded string allocated using `allocator`. Must be freed using `allocator`. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetOverridableInitializerName, _In_ const OrtSession* session, size_t index, - _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /// @} - /// \name OrtRunOptions - /// @{ - - /** \brief Create an OrtRunOptions - * - * \param[out] out Returned newly created ::OrtRunOptions. Must be freed with OrtApi::ReleaseRunOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateRunOptions, _Outptr_ OrtRunOptions** out); - - /** \brief Set per-run log verbosity level - * - * \see OrtApi::RunOptionsGetRunLogVerbosityLevel - * - * \param[in] options - * \param[in] log_verbosity_level \snippet{doc} snippets.dox Log Verbosity Level - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RunOptionsSetRunLogVerbosityLevel, _Inout_ OrtRunOptions* options, int log_verbosity_level); - - /** \brief Set per-run log severity level - * - * \see OrtApi::RunOptionsGetRunLogSeverityLevel - * - * \param[in] options - * \param[in] log_severity_level The log severity level (refer to ::OrtLoggingLevel for possible values). - */ - ORT_API2_STATUS(RunOptionsSetRunLogSeverityLevel, _Inout_ OrtRunOptions* options, int log_severity_level); - - /** \brief Set per-run tag - * - * This is used in a per-run log identifier. - * - * \see OrtApi::RunOptionsGetRunTag - * - * \param[in] options - * \param[in] run_tag The run tag. - */ - ORT_API2_STATUS(RunOptionsSetRunTag, _Inout_ OrtRunOptions* options, _In_ const char* run_tag); - - /** \brief Get per-run log verbosity level - * - * \see OrtApi::RunOptionsSetRunLogVerbosityLevel - * - * \param[in] options - * \param[out] log_verbosity_level \snippet{doc} snippets.dox Log Verbosity Level - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* options, - _Out_ int* log_verbosity_level); - - /** \brief Get per-run log severity level - * - * \see OrtApi::RunOptionsSetRunLogSeverityLevel - * - * \param[in] options - * \param[out] log_severity_level The log severity level (refer to ::OrtLoggingLevel for possible values). - */ - ORT_API2_STATUS(RunOptionsGetRunLogSeverityLevel, _In_ const OrtRunOptions* options, _Out_ int* log_severity_level); - - /** \brief Get per-run tag - * - * This is used in a per-run log identifier. - * - * \see OrtApi::RunOptionsSetRunTag - * - * \param[in] options - * \param[out] run_tag The run tag. - * Do not free this value, it is owned by `options`. It will be invalidated if the run tag - * changes (i.e., with OrtApi::RunOptionsSetRunTag) or `options` is freed. - */ - ORT_API2_STATUS(RunOptionsGetRunTag, _In_ const OrtRunOptions* options, _Out_ const char** run_tag); - - /** \brief Set terminate flag - * - * If a currently executing session needs to be force terminated, this can be called from another thread to force it to fail with an error. - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RunOptionsSetTerminate, _Inout_ OrtRunOptions* options); - - /** \brief Clears the terminate flag - * - * Used so the OrtRunOptions instance can be used in a new OrtApi::Run call without it instantly terminating - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options); - - /// @} - /// \name OrtValue - /// @{ - - /** \brief Create a tensor - * - * Create a tensor using a supplied ::OrtAllocator - * - * \param[in] allocator - * \param[in] shape Pointer to the tensor shape dimensions. - * \param[in] shape_len The number of tensor shape dimensions. - * \param[in] type - * \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* shape, size_t shape_len, - ONNXTensorElementDataType type, _Outptr_ OrtValue** out); - - /** \brief Create a tensor backed by a user supplied buffer - * - * Create a tensor with user's buffer. You can fill the buffer either before calling this function or after. - * p_data is owned by caller. ReleaseValue won't release p_data. - * - * \param[in] info Memory description of where the p_data buffer resides (CPU vs GPU etc). - * \param[in] p_data Pointer to the data buffer. - * \param[in] p_data_len The number of bytes in the data buffer. - * \param[in] shape Pointer to the tensor shape dimensions. - * \param[in] shape_len The number of tensor shape dimensions. - * \param[in] type The data type. - * \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateTensorWithDataAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data, - size_t p_data_len, _In_ const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type, - _Outptr_ OrtValue** out); - - /** \brief Return if an ::OrtValue is a tensor type - * - * \param[in] value A tensor type (string tensors are not supported) - * \param[out] out Set to 1 iff ::OrtValue is a tensor, 0 otherwise - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(IsTensor, _In_ const OrtValue* value, _Out_ int* out); - - /** \brief Get a pointer to the raw data inside a tensor - * - * Used to read/write/modify the internal tensor data directly. - * \note The returned pointer is valid until the \p value is destroyed. - * - * \param[in] value A tensor type (string tensors are not supported) - * \param[out] out Filled in with a pointer to the internal storage - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorMutableData, _In_ OrtValue* value, _Outptr_ void** out); - - /** \brief Set all strings at once in a string tensor - * - * \param[in,out] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING - * \param[in] s An array of strings. Each string in this array must be null terminated. - * \param[in] s_len Count of strings in s (Must match the size of \p value's tensor shape) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(FillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len); - - /** \brief Get total byte length for all strings in a string tensor - * - * Typically used with OrtApi::GetStringTensorContent - * - * \param[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING - * \param[out] len Total byte length of all strings (does not include trailing nulls) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetStringTensorDataLength, _In_ const OrtValue* value, _Out_ size_t* len); - - /** \brief Get all strings from a string tensor - * - * An example of the results:
    - * Given \p value is a string tensor with the strings { "This" "is" "a" "test" }
    - * \p s must have a size of 11 bytes
    - * \p offsets must have 4 elements
    - * After the call, these values will be filled in:
    - * \p s will contain "Thisisatest"
    - * \p offsets will contain { 0, 4, 6, 7 }
    - * The length of the last string is just s_len - offsets[last] - * - * \param[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING - * \param[in] s Buffer to sequentially write all tensor strings to. Each string is NOT null-terminated. - * \param[in] s_len Number of bytes of buffer pointed to by \p s (Get it from OrtApi::GetStringTensorDataLength) - * \param[out] offsets Array of start offsets into the strings written to \p s - * \param[in] offsets_len Number of elements in offsets - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetStringTensorContent, _In_ const OrtValue* value, _Out_writes_bytes_all_(s_len) void* s, - size_t s_len, _Out_writes_all_(offsets_len) size_t* offsets, size_t offsets_len); - - /// @} - /// \name OrtTypeInfo - /// @{ - - /** \brief Get ::OrtTensorTypeAndShapeInfo from an ::OrtTypeInfo - * - * \param[in] type_info - * \param[out] out Do not free this value, it will be valid until type_info is freed. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CastTypeInfoToTensorInfo, _In_ const OrtTypeInfo* type_info, - _Outptr_result_maybenull_ const OrtTensorTypeAndShapeInfo** out); - - /** \brief Get ::ONNXType from ::OrtTypeInfo - * - * \param[in] type_info - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ enum ONNXType* out); - - /// @} - /// \name OrtTensorTypeAndShapeInfo - /// @{ - - /** \brief Create an ::OrtTensorTypeAndShapeInfo object - * - * \param[out] out Returns newly created ::OrtTensorTypeAndShapeInfo. Must be freed with OrtApi::ReleaseTensorTypeAndShapeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateTensorTypeAndShapeInfo, _Outptr_ OrtTensorTypeAndShapeInfo** out); - - /** \brief Set element type in ::OrtTensorTypeAndShapeInfo - * - * \param[in] info - * \param[in] type - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetTensorElementType, _Inout_ OrtTensorTypeAndShapeInfo* info, enum ONNXTensorElementDataType type); - - /** \brief Set shape information in ::OrtTensorTypeAndShapeInfo - * - * \param[in] info - * \param[in] dim_values Array with `dim_count` elements. Can contain negative values. - * \param[in] dim_count Number of elements in `dim_values` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetDimensions, OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count); - - /** \brief Get element type in ::OrtTensorTypeAndShapeInfo - * - * \see OrtApi::SetTensorElementType - * - * \param[in] info - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorElementType, _In_ const OrtTensorTypeAndShapeInfo* info, - _Out_ enum ONNXTensorElementDataType* out); - - /** \brief Get dimension count in ::OrtTensorTypeAndShapeInfo - * - * \see OrtApi::GetDimensions - * - * \param[in] info - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetDimensionsCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out); - - /** \brief Get dimensions in ::OrtTensorTypeAndShapeInfo - * - * \param[in] info - * \param[out] dim_values Array with `dim_values_length` elements. On return, filled with the dimensions stored in the ::OrtTensorTypeAndShapeInfo - * \param[in] dim_values_length Number of elements in `dim_values`. Use OrtApi::GetDimensionsCount to get this value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values, - size_t dim_values_length); - - /** \brief Get symbolic dimension names in ::OrtTensorTypeAndShapeInfo - * - * \param[in] info - * \param[in] dim_params Array with `dim_params_length` elements. On return filled with pointers to null terminated strings of the dimension names - * \param[in] dim_params_length Number of elements in `dim_params`. Use OrtApi::GetDimensionsCount to get this value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSymbolicDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, - _Out_writes_all_(dim_params_length) const char* dim_params[], size_t dim_params_length); - - /** \brief Get total number of elements in a tensor shape from an ::OrtTensorTypeAndShapeInfo - * - * Return the number of elements specified by the tensor shape (all dimensions multiplied by each other). - * For 0 dimensions, 1 is returned. If any dimension is less than 0, the result is always -1. - * - * Examples:
    - * [] = 1
    - * [1,3,4] = 12
    - * [2,0,4] = 0
    - * [-1,3,4] = -1
    - * - * \param[in] info - * \param[out] out Number of elements - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorShapeElementCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out); - - /// @} - /// \name OrtValue - /// @{ - - /** \brief Get type and shape information from a tensor ::OrtValue - * - * \param[in] value Must be a tensor (not a map/sequence/etc) or will return failure - * \param[out] out Newly created ::OrtTensorTypeAndShapeInfo. Must be freed with OrtApi::ReleaseTensorTypeAndShapeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorTypeAndShape, _In_ const OrtValue* value, _Outptr_ OrtTensorTypeAndShapeInfo** out); - - /** \brief Get type information of an OrtValue - * - * \param[in] value - * \param[out] out Newly created ::OrtTypeInfo. Must be freed with OrtApi::ReleaseTypeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTypeInfo, _In_ const OrtValue* value, _Outptr_result_maybenull_ OrtTypeInfo** out); - - /** \brief Get ONNXType of an ::OrtValue - * - * \param[in] value - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetValueType, _In_ const OrtValue* value, _Out_ enum ONNXType* out); - - /// @} - /// \name OrtMemoryInfo - /// @{ - - /** \brief Create an ::OrtMemoryInfo - * - * \param[in] name - * \param[in] type - * \param[in] id - * \param[in] mem_type - * \param[out] out Newly created ::OrtMemoryInfo. Must be freed with OrtAPi::ReleaseMemoryInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name, enum OrtAllocatorType type, int id, - enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out); - - /** \brief Create an ::OrtMemoryInfo for CPU memory - * - * Special case version of OrtApi::CreateMemoryInfo for CPU based memory. Same as using OrtApi::CreateMemoryInfo with name = "Cpu" and id = 0. - * - * \param[in] type - * \param[in] mem_type - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateCpuMemoryInfo, enum OrtAllocatorType type, enum OrtMemType mem_type, - _Outptr_ OrtMemoryInfo** out); - - /** \brief Compare ::OrtMemoryInfo objects for equality - * - * Compares all settings of each ::OrtMemoryInfo for equality - * - * \param[in] info1 - * \param[in] info2 - * \param[out] out Set to 0 if equal, -1 if not equal - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CompareMemoryInfo, _In_ const OrtMemoryInfo* info1, _In_ const OrtMemoryInfo* info2, _Out_ int* out); - - /** \brief Get name from ::OrtMemoryInfo - * - * \param[in] ptr - * \param[out] out Writes null terminated string to this pointer. Do NOT free the returned pointer. It is valid for the lifetime of the ::OrtMemoryInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(MemoryInfoGetName, _In_ const OrtMemoryInfo* ptr, _Out_ const char** out); - - /** \brief Get the id from ::OrtMemoryInfo - */ - ORT_API2_STATUS(MemoryInfoGetId, _In_ const OrtMemoryInfo* ptr, _Out_ int* out); - - /** \brief Get the ::OrtMemType from ::OrtMemoryInfo - */ - ORT_API2_STATUS(MemoryInfoGetMemType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtMemType* out); - - /** \brief Get the ::OrtAllocatorType from ::OrtMemoryInfo - */ - ORT_API2_STATUS(MemoryInfoGetType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtAllocatorType* out); - - /// @} - /// \name OrtAllocator - /// @{ - - /// \brief Calls OrtAllocator::Alloc function - ORT_API2_STATUS(AllocatorAlloc, _Inout_ OrtAllocator* ort_allocator, size_t size, _Outptr_ void** out); - /// \brief Calls OrtAllocator::Free function - ORT_API2_STATUS(AllocatorFree, _Inout_ OrtAllocator* ort_allocator, void* p); - /// \brief Calls OrtAllocator::Info function - ORT_API2_STATUS(AllocatorGetInfo, _In_ const OrtAllocator* ort_allocator, _Outptr_ const struct OrtMemoryInfo** out); - - /** \brief Get the default allocator - * - * The default allocator is a CPU based, non-arena. Always returns the same pointer to the same default allocator. - * - * \param[out] out Returned value should NOT be freed - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetAllocatorWithDefaultOptions, _Outptr_ OrtAllocator** out); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Override session symbolic dimensions - * - * Override symbolic dimensions (by specific denotation strings) with actual values if known at session initialization time to enable - * optimizations that can take advantage of fixed values (such as memory planning, etc) - * - * \param[in] options - * \param[in] dim_denotation - * \param[in] dim_value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(AddFreeDimensionOverride, _Inout_ OrtSessionOptions* options, _In_ const char* dim_denotation, - _In_ int64_t dim_value); - - /// @} - /// \name OrtValue - /// @{ - - /* Internal information (not seen in Doxygen) - * - * APIs to support non-tensor types - map and sequence. - * Currently only the following types are supported - * Note: the following types should be kept in sync with data_types.h - * Map types - * ========= - * std::map - * std::map - * std::map - * std::map - * std::map - * std::map - * std::map - * std::map - * - * Sequence types - * ============== - * std::vector - * std::vector - * std::vector - * std::vector - * std::vector> - * std::vector - */ - - /** \brief Get non tensor data from an ::OrtValue - * - * If `value` is of type ONNX_TYPE_MAP, you need to retrieve the keys and values - * separately. Use index=0 to retrieve keys and index=1 to retrieve values. - * If `value` is of type ONNX_TYPE_SEQUENCE, use index to retrieve the index'th element - * of the sequence. - * - * \param[in] value - * \param[in] index See above for usage based on `value` type - * \param[in] allocator Allocator used to allocate ::OrtValue - * \param[out] out Created ::OrtValue that holds the element requested. Must be freed with OrtApi::ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetValue, _In_ const OrtValue* value, int index, _Inout_ OrtAllocator* allocator, - _Outptr_ OrtValue** out); - - /** \brief Get non tensor value count from an ::OrtValue - * - * If `value` is of type ONNX_TYPE_MAP 2 will always be returned. For ONNX_TYPE_SEQUENCE - * the number of elements in the sequence will be returned - * - * \param[in] value - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetValueCount, _In_ const OrtValue* value, _Out_ size_t* out); - - /** \brief Create a map or sequence ::OrtValue - * - * To construct a map (ONNX_TYPE_MAP), use num_values = 2 and `in` should be an array of 2 ::OrtValue%s - * representing keys and values.
    - * - * To construct a sequence (ONNX_TYPE_SEQUENCE), use num_values = N where N is the number of the elements in the - * sequence. 'in' should be an array of N ::OrtValue%s. - * - * \param[in] in See above for details - * \param[in] num_values - * \param[in] value_type Must be either ONNX_TYPE_MAP or ONNX_TYPE_SEQUENCE - * \param[out] out Newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateValue, _In_reads_(num_values) const OrtValue* const* in, size_t num_values, - enum ONNXType value_type, _Outptr_ OrtValue** out); - - /** \brief Create an opaque (custom user defined type) ::OrtValue - * - * Constructs an ::OrtValue that contains a value of non-standard type created for - * experiments or while awaiting standardization. ::OrtValue in this case would contain - * an internal representation of the Opaque type. Opaque types are distinguished from - * each other by two strings 1) domain and 2) type name. The combination of the two - * must be unique, so the type representation is properly identified internally. The combination - * must be properly registered from within ORT at both compile/run time or by another API. - * - * To construct the ::OrtValue pass domain and type names, also a pointer to a data container - * the type of which must be known to both ORT and the client program. That data container may or may - * not match the internal representation of the Opaque type. The sizeof(data_container) is passed for - * verification purposes. - * - * \param[in] domain_name Null terminated string of the domain name - * \param[in] type_name Null terminated string of the type name - * \param[in] data_container User pointer Data to populate ::OrtValue - * \param[in] data_container_size Size in bytes of what `data_container` points to - * \param[out] out Newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateOpaqueValue, _In_z_ const char* domain_name, _In_z_ const char* type_name, - _In_ const void* data_container, size_t data_container_size, _Outptr_ OrtValue** out); - - /** \brief Get internal data from an opaque (custom user defined type) ::OrtValue - * - * Copies internal data from an opaque value into a user provided buffer - * - * \see OrtApi::CreateOpaqueValue - * - * \param[in] domain_name Null terminated string of the domain name - * \param[in] type_name Null terminated string of the type name - * \param[in] in The opaque ::OrtValue - * \param[out] data_container Buffer to copy data into - * \param[out] data_container_size Size in bytes of the buffer pointed to by data_container. Must match the size of the internal buffer. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetOpaqueValue, _In_ const char* domain_name, _In_ const char* type_name, _In_ const OrtValue* in, - _Out_ void* data_container, size_t data_container_size); - - /// @} - /// \name OrtKernelInfo - /// Custom operator APIs. - /// @{ - - /** \brief Get a float stored as an attribute in the graph node - * - * \param[in] info ::OrtKernelInfo instance - * \param[in] name Null terminated string of the name of the attribute - * \param[out] out Pointer to memory where the attribute will be stored - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttribute_float, _In_ const OrtKernelInfo* info, _In_ const char* name, - _Out_ float* out); - - /** \brief Fetch a 64-bit int stored as an attribute in the graph node - * - * \param[in] info ::OrtKernelInfo instance - * \param[in] name Null terminated string of the name of the attribute - * \param[out] out Pointer to memory where the attribute will be stored - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* info, _In_ const char* name, - _Out_ int64_t* out); - - /** \brief Fetch a string stored as an attribute in the graph node - * - * If `out` is nullptr, the value of `size` is set to the true size of the string - * attribute, and a success status is returned. - * - * If the `size` parameter is greater than or equal to the actual string attribute's size, - * the value of `size` is set to the true size of the string attribute, the provided memory - * is filled with the attribute's contents, and a success status is returned. - * - * If the `size` parameter is less than the actual string attribute's size and `out` - * is not nullptr, the value of `size` is set to the true size of the string attribute - * and a failure status is returned.) - * - * \param[in] info ::OrtKernelInfo instance - * \param[in] name Null terminated string of the name of the attribute - * \param[out] out Pointer to memory where the attribute will be stored - * \param[in,out] size See above comments for details - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out, - _Inout_ size_t* size); - - /// @} - /// \name OrtKernelContext - /// Custom operator APIs. - /// @{ - - /** \brief Used for custom operators, get the input count of a kernel - * - * \see ::OrtCustomOp - */ - ORT_API2_STATUS(KernelContext_GetInputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out); - - /** \brief Used for custom operators, get the output count of a kernel - * - * \see ::OrtCustomOp - */ - ORT_API2_STATUS(KernelContext_GetOutputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out); - - /** \brief Used for custom operators, get an input of a kernel - * - * \see ::OrtCustomOp - */ - ORT_API2_STATUS(KernelContext_GetInput, _In_ const OrtKernelContext* context, _In_ size_t index, - _Out_ const OrtValue** out); - - /** \brief Used for custom operators, get an output of a kernel - * - * \see ::OrtCustomOp - */ - ORT_API2_STATUS(KernelContext_GetOutput, _Inout_ OrtKernelContext* context, _In_ size_t index, - _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out); - - /// @} - /// \name OrtEnv - /// @{ - ORT_CLASS_RELEASE(Env); - /// @} - /// \name OrtStatus - /// @{ - ORT_CLASS_RELEASE(Status); - /// @} - /// \name OrtMemoryInfo - /// @{ - ORT_CLASS_RELEASE(MemoryInfo); - /// @} - /// \name OrtSession - /// @{ - ORT_CLASS_RELEASE(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool) - /// @} - /// \name OrtValue - /// @{ - ORT_CLASS_RELEASE(Value); - /// @} - /// \name OrtRunOptions - /// @{ - ORT_CLASS_RELEASE(RunOptions); - /// @} - /// \name OrtTypeInfo - /// @{ - ORT_CLASS_RELEASE(TypeInfo); - /// @} - /// \name OrtTensorTypeAndShapeInfo - /// @{ - ORT_CLASS_RELEASE(TensorTypeAndShapeInfo); - /// @} - /// \name OrtSessionOptions - /// @{ - ORT_CLASS_RELEASE(SessionOptions); - /// @} - /// \name OrtCustomOpDomain - /// @{ - ORT_CLASS_RELEASE(CustomOpDomain); - - /// @} - /// \name OrtTypeInfo - /// @{ - - /** \brief Get denotation from type information - * - * Augments ::OrtTypeInfo to return denotations on the type. - * - * This is used by WinML to determine if an input/output is intended to be an Image or a Tensor. - * - * \param[in] type_info - * \param[out] denotation Pointer to the null terminated denotation string is written to this pointer. This pointer is valid until the object is destroyed or the name is changed, do not free. - * \param[out] len Length in bytes of the string returned in `denotation` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetDenotationFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ const char** const denotation, - _Out_ size_t* len); - - /** \brief Get detailed map information from an ::OrtTypeInfo - * - * This augments ::OrtTypeInfo to return an ::OrtMapTypeInfo when the type is a map. - * The OrtMapTypeInfo has additional information about the map's key type and value type. - * - * This is used by WinML to support model reflection APIs. - * - * \param[out] type_info - * \param[out] out A pointer to the ::OrtMapTypeInfo. Do not free this value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CastTypeInfoToMapTypeInfo, _In_ const OrtTypeInfo* type_info, - _Outptr_result_maybenull_ const OrtMapTypeInfo** out); - - /** \brief Cast ::OrtTypeInfo to an ::OrtSequenceTypeInfo - * - * This api augments ::OrtTypeInfo to return an ::OrtSequenceTypeInfo when the type is a sequence. - * The ::OrtSequenceTypeInfo has additional information about the sequence's element type. - * - * This is used by WinML to support model reflection APIs. - * - * \param[in] type_info - * \param[out] out A pointer to the OrtSequenceTypeInfo. Do not free this value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CastTypeInfoToSequenceTypeInfo, _In_ const OrtTypeInfo* type_info, - _Outptr_result_maybenull_ const OrtSequenceTypeInfo** out); - - /// @} - /// \name OrtMapTypeInfo - /// @{ - - /** \brief Get key type from an ::OrtMapTypeInfo - * - * Key types are restricted to being scalar types. - * - * This is used by WinML to support model reflection APIs. - * - * \param[in] map_type_info - * \param[out] out - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetMapKeyType, _In_ const OrtMapTypeInfo* map_type_info, _Out_ enum ONNXTensorElementDataType* out); - - /** \brief Get the value type from an ::OrtMapTypeInfo - * - * \param[in] map_type_info - * \param[out] type_info - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetMapValueType, _In_ const OrtMapTypeInfo* map_type_info, _Outptr_ OrtTypeInfo** type_info); - - /// @} - /// \name OrtSequenceTypeInfo - /// @{ - - /** \brief Get element type from an ::OrtSequenceTypeInfo - * - * This is used by WinML to support model reflection APIs. - * - * \param[in] sequence_type_info - * \param[out] type_info - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSequenceElementType, _In_ const OrtSequenceTypeInfo* sequence_type_info, - _Outptr_ OrtTypeInfo** type_info); - - /// @} - /// \name OrtMapTypeInfo - /// @{ - ORT_CLASS_RELEASE(MapTypeInfo); - /// @} - /// \name OrtSequenceTypeInfo - /// @{ - ORT_CLASS_RELEASE(SequenceTypeInfo); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief End profiling and return filename of the profile data - * - * Profiling is turned on through OrtApi::EnableProfiling - * - * \param[in] session - * \param[in] allocator - * \param[out] out Null terminated string of the filename, allocated using `allocator`. Must be freed using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionEndProfiling, _In_ OrtSession* session, _Inout_ OrtAllocator* allocator, _Outptr_ char** out); - - /** \brief Get ::OrtModelMetadata from an ::OrtSession - * - * \param[in] session - * \param[out] out Newly created ::OrtModelMetadata. Must be freed using OrtApi::ReleaseModelMetadata - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetModelMetadata, _In_ const OrtSession* session, _Outptr_ OrtModelMetadata** out); - - /// @} - /// \name OrtModelMetadata - /// @{ - - /** \brief Get `producer name` from an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[in] allocator - * \param[out] value Set to a null terminated string allocated using `allocator`. Must be freed using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetProducerName, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /** \brief Get `graph name` from an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[in] allocator - * \param[out] value Set to a null terminated string allocated using `allocator`. Must be freed using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetGraphName, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /** \brief Get `domain` from an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[in] allocator - * \param[out] value Set to a null terminated string allocated using `allocator`. Must be freed using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetDomain, _In_ const OrtModelMetadata* model_metadata, _Inout_ OrtAllocator* allocator, - _Outptr_ char** value); - - /** \brief Get `description` from an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[in] allocator - * \param[out] value Set to a null terminated string allocated using `allocator`. Must be freed using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetDescription, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /** \brief Return data for a key in the custom metadata map in an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[in] allocator - * \param[in] key Null terminated string - * \param[out] value Set to a null terminated string allocated using `allocator`. Must be freed using `allocator` - * `value` will be set to nullptr if the given key is not found in the custom metadata map. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataLookupCustomMetadataMap, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _In_ const char* key, _Outptr_result_maybenull_ char** value); - - /** \brief Get version number from an ::OrtModelMetadata - * - * \param[in] model_metadata - * \param[out] value Set to the version number - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetVersion, _In_ const OrtModelMetadata* model_metadata, _Out_ int64_t* value); - - ORT_CLASS_RELEASE(ModelMetadata); - - /// @} - /// \name OrtEnv - /// @{ - - /** \brief Create an OrtEnv - * - * Create an environment with global threadpools that will be shared across sessions. - * Use this in conjunction with OrtApi::DisablePerSessionThreads or else the session will use - * its own thread pools. - * - * \param[in] log_severity_level The log severity level. - * \param[in] logid The log identifier. - * \param[in] tp_options - * \param[out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateEnvWithGlobalThreadPools, OrtLoggingLevel log_severity_level, _In_ const char* logid, - _In_ const OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Use global thread pool on a session - * - * Disable using per session thread pool and use the shared global threadpool. - * This should be used in conjunction with OrtApi::CreateEnvWithGlobalThreadPools. - * - * \param[in] options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(DisablePerSessionThreads, _Inout_ OrtSessionOptions* options); - - /// @} - /// \name OrtThreadingOptions - /// @{ - - /** \brief Create an ::OrtThreadingOptions - * - * \param[out] out Newly created ::OrtThreadingOptions. Must be freed with OrtApi::ReleaseThreadingOptions - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateThreadingOptions, _Outptr_ OrtThreadingOptions** out); - - ORT_CLASS_RELEASE(ThreadingOptions); - - /// @} - /// \name OrtModelMetadata - /// @{ - - /** - * - * \param[in] model_metadata - * \param[in] allocator - * \param[out] keys Array of null terminated strings (array count = num_keys) allocated using `allocator`. - * The strings and the pointer array must be freed using `allocator` - * `keys` will be set to nullptr if the custom metadata map is empty. - * \param[out] num_keys Set to the number of elements in the `keys` array - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetCustomMetadataMapKeys, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _Outptr_result_buffer_maybenull_(*num_keys) char*** keys, _Out_ int64_t* num_keys); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** - * - * Override symbolic dimensions (by specific name strings) with actual values - * if known at session initialization time to enable optimizations that can - * take advantage of fixed values (such as memory planning, etc) - * - */ - ORT_API2_STATUS(AddFreeDimensionOverrideByName, - _Inout_ OrtSessionOptions* options, _In_ const char* dim_name, - _In_ int64_t dim_value); - - /// @} - /// \name Misc - /// @{ - - /** \brief Get the names of all available providers - * - * \note The providers in the list are not guaranteed to be usable. They may fail to load due to missing system dependencies. - * For example, if the CUDA/cuDNN libraries are not installed, the CUDA provider will report an error when it is added to the session options. - * - * \param[out] out_ptr Set to a pointer to an array of null terminated strings of the available providers. The entries and the - * array itself must be freed using OrtApi::ReleaseAvailableProviders - * \param[out] provider_length Set to the number of entries in the `out_ptr` array - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetAvailableProviders, _Outptr_ char*** out_ptr, _Out_ int* provider_length); - - /** \brief Release data from OrtApi::GetAvailableProviders - * - * \param[in] ptr The `out_ptr` result from OrtApi::GetAvailableProviders. - * \param[in] providers_length The `provider_length` result from OrtApi::GetAvailableProviders - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ReleaseAvailableProviders, _In_ char** ptr, - _In_ int providers_length); - - /// @} - /// \name OrtValue - /// @{ - - /** \brief Get the length of a single string in a string tensor - * - * \param[in] value A string tensor - * \param[in] index Index of the string in the tensor - * \param[out] out Set to number of bytes of the string element - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetStringTensorElementLength, _In_ const OrtValue* value, size_t index, _Out_ size_t* out); - - /** \brief Get a single string from a string tensor - * - * \param[in] value A string tensor - * \param[in] s_len Number of bytes in the `s` buffer. Must match the value returned by OrtApi::GetStringTensorElementLength. - * \param[in] index Index of the string in the tensor - * \param[out] s The string element contents in UTF-8 encoding. The string is NOT null-terminated. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetStringTensorElement, _In_ const OrtValue* value, size_t s_len, size_t index, _Out_writes_bytes_all_(s_len) void* s); - - /** \brief Set a single string in a string tensor - * - * \param[in] value A string tensor - * \param[in] s A null terminated UTF-8 encoded string - * \param[in] index Index of the string in the tensor to set - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(FillStringTensorElement, _Inout_ OrtValue* value, _In_ const char* s, size_t index); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Set a session configuration entry as a pair of strings - * - * If a configuration with same key exists, this will overwrite the configuration with the given config_value. - * - * The config_key and the format of config_value are defined in onnxruntime_session_options_config_keys.h - * - * \param[in] options - * \param[in] config_key A null terminated string representation of the config key - * \param[in] config_value A null terminated string representation of the config value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(AddSessionConfigEntry, _Inout_ OrtSessionOptions* options, - _In_z_ const char* config_key, _In_z_ const char* config_value); - - /// @} - /// \name OrtAllocator - /// @{ - - /** \brief Create an allocator for an ::OrtSession following an ::OrtMemoryInfo - * - * \param[in] session - * \param[in] mem_info valid ::OrtMemoryInfo instance - * \param[out] out Newly created ::OrtAllocator. Must be freed with OrtApi::ReleaseAllocator - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateAllocator, _In_ const OrtSession* session, _In_ const OrtMemoryInfo* mem_info, - _Outptr_ OrtAllocator** out); - - /** \brief Release an ::OrtAllocator obtained from OrtApi::CreateAllocator - */ - ORT_CLASS_RELEASE(Allocator); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief Run a model using Io Bindings for the inputs & outputs - * - * \see OrtApi::Run - * - * \param[in] session - * \param[in] run_options - * \param[in] binding_ptr - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RunWithBinding, _Inout_ OrtSession* session, _In_ const OrtRunOptions* run_options, _In_ const OrtIoBinding* binding_ptr); - - /** \brief Create an ::OrtIoBinding instance - * - * An IoBinding object allows one to bind pre-allocated ::OrtValue%s to input names. - * Thus if you want to use a raw on device buffer as input or output you can avoid - * extra copy during runtime. - * - * \param[in] session - * \param[out] out Newly created ::OrtIoBinding. Must be freed with OrtApi::ReleaseIoBinding - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateIoBinding, _Inout_ OrtSession* session, _Outptr_ OrtIoBinding** out); - - /// @} - /// \name OrtIoBinding - /// @{ - - /** \brief Release an ::OrtIoBinding obtained from OrtApi::CreateIoBinding - */ - ORT_CLASS_RELEASE(IoBinding); - - /** \brief Bind an ::OrtValue to an ::OrtIoBinding input - * - * When using OrtApi::RunWithBinding this value is used for the named input - * - * \param[in] binding_ptr - * \param[in] name Name for the model input - * \param[in] val_ptr ::OrtValue of Tensor type. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(BindInput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr); - - /** \brief Bind an ::OrtValue to an ::OrtIoBinding output - * - * When using OrtApi::RunWithBinding this value is used for the named output - * - * \param[in] binding_ptr - * \param[in] name Null terminated string of the model output name - * \param[in] val_ptr ::OrtValue of Tensor type. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(BindOutput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr); - - /** \brief Bind an ::OrtIoBinding output to a device - * - * Binds the ::OrtValue to a device which is specified by ::OrtMemoryInfo. - * You can either create an instance of ::OrtMemoryInfo with a device id or obtain one from the allocator that you have created/are using - * This is useful when one or more outputs have dynamic shapes and, it is hard to pre-allocate and bind a chunk of - * memory within ::OrtValue ahead of time. - * - * \see OrtApi::RunWithBinding - * - * \param[in] binding_ptr - * \param[in] name Null terminated string of the device name - * \param[in] mem_info_ptr - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(BindOutputToDevice, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtMemoryInfo* mem_info_ptr); - - /** \brief Get the names of an ::OrtIoBinding's outputs - * - * Returns the names of the outputs in the order they were bound. This is useful after running the model - * with bound outputs because the returned names are in order in which output ::OrtValue are returned. This is useful if - * the order of outputs and their names is not known. - * - * \param[in] binding_ptr - * \param[in] allocator Allocator used to allocate continuous buffers for output strings and lengths. - * \param[out] buffer Returns an array of non-null terminated UTF-8 strings. The number of strings stored is returned in the count parameter. - * This buffer is allocated using `allocator` and must be freed using it. - * \param[out] lengths Returns an array of `count` lengths of the strings returned in `buffer` - * This buffer is allocated using `allocator` and must be freed using it. - * \param[out] count Number of strings returned. If `binding_ptr` has no bound outputs, zero is returned, - * no memory allocation is performed and buffer and lengths are set to nullptr. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetBoundOutputNames, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator, - _Out_ char** buffer, _Out_writes_all_(count) size_t** lengths, _Out_ size_t* count); - - /** \brief Get the output ::OrtValue objects from an ::OrtIoBinding - * - * Returns an array of pointers to individually allocated ::OrtValue%s that contain results of a model execution with OrtApi::RunWithBinding - * The array contains the same number of ::OrtValue%s and they are in the same order as they were bound with OrtApi::BindOutput - * or OrtApi::BindOutputToDevice. - * - * The returned ::OrtValue%s must be released using OrtApi::ReleaseValue after they are no longer needed. - * The array is allocated using the specified instance of the allocator and must be freed using the same allocator after - * all the ::OrtValue%s contained therein are individually released. - * - * \param[in] binding_ptr - * \param[in] allocator Allocator used to allocate output array - * \param[out] output Set to the allocated array of allocated ::OrtValue outputs. Set to nullptr if there are 0 outputs. - * \param[out] output_count Set to number of ::OrtValue%s returned - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetBoundOutputValues, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator, - _Out_writes_all_(output_count) OrtValue*** output, _Out_ size_t* output_count); - - /** \brief Clears any previously set Inputs for an ::OrtIoBinding - */ - void(ORT_API_CALL* ClearBoundInputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; - - /** \brief Clears any previously set Outputs for an ::OrtIoBinding - */ - void(ORT_API_CALL* ClearBoundOutputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; - - /// @} - /// \name OrtValue - /// @{ - - /** \brief Direct memory access to a specified tensor element - * - * For example, given a tensor with shape of [3,224,224], a pointer to the element at location [2,150,128] can be retrieved - * - * This function only works for numeric type tensors (No strings, etc). - * This is a no-copy method whose returned pointer is valid until the passed in ::OrtValue is free'd. - * - * \param[in] value - * \param[in] location_values Pointer to an array of index values that specify an element's location relative to its shape - * \param[in] location_values_count Number of elements in location_values. Must match the number of elements in the tensor's shape. - * \param[out] out Set to a pointer to the element specified - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(TensorAt, _Inout_ OrtValue* value, const int64_t* location_values, size_t location_values_count, _Outptr_ void** out); - - /// @} - /// \name OrtEnv - /// @{ - - /** \brief Create an allocator and register it with the ::OrtEnv - * - * Enables sharing the allocator between multiple sessions that use the same env instance. - * Lifetime of the created allocator will be valid for the duration of the environment. - * Returns an error if an allocator with the same ::OrtMemoryInfo is already registered. - * - * See https://onnxruntime.ai/docs/reference/api/c-api.html for details. - * - * \param[in] env ::OrtEnv instance - * \param[in] mem_info - * \param[in] arena_cfg Pass nullptr for defaults - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateAndRegisterAllocator, _Inout_ OrtEnv* env, _In_ const OrtMemoryInfo* mem_info, - _In_ const OrtArenaCfg* arena_cfg); - - /** \brief Set language projection - * - * Set the language projection for collecting telemetry data when Env is created. - * - * The default is ORT_PROJECTION_C, which means it will classify the language not in the list to C also. - * - * \param[in] ort_env - * \param[in] projection - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetLanguageProjection, _In_ const OrtEnv* ort_env, _In_ OrtLanguageProjection projection); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief Return the time that profiling was started - * - * \note The timer precision varies per platform. On Windows and MacOS, the precision will be ~100ns - * - * \param[in] session - * \param[out] out nanoseconds of profiling's start time - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionGetProfilingStartTimeNs, _In_ const OrtSession* session, _Outptr_ uint64_t* out); - - /// @} - /// \name OrtThreadingOptions - /// @{ - - /** \brief Set global intra-op thread count - * - * This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools - * - * \param[in] tp_options - * \param[in] intra_op_num_threads Number of threads, special values:
    - * 0 = Use default thread count
    - * 1 = The invoking thread will be used; no threads will be created in the thread pool. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalIntraOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int intra_op_num_threads); - - /** \brief Set global inter-op thread count - * - * This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools - * - * \param[in] tp_options - * \param[in] inter_op_num_threads Number of threads, special values:
    - * 0 = Use default thread count
    - * 1 = The invoking thread will be used; no threads will be created in the thread pool. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalInterOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int inter_op_num_threads); - - /** \brief Set global spin control options - * - * This will configure the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools. - * Allow spinning of thread pools when their queues are empty. This will set the value for both - * inter_op and intra_op threadpools. - * - * \param[in] tp_options - * \param[in] allow_spinning Valid values are 0 or 1.
    - * 0 = It won't spin (recommended if CPU usage is high)
    - * 1 = Threadpool will spin to wait for queue to become non-empty - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalSpinControl, _Inout_ OrtThreadingOptions* tp_options, int allow_spinning); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Add a pre-allocated initializer to a session - * - * If a model contains an initializer with a name that is same as the name passed to this call, - * ORT will use this initializer instance instead of deserializing one from the model file. This - * is useful when you want to share the same initializer across sessions. - * - * \param[in] options - * \param[in] name Null terminated string of the initializer name - * \param[in] val ::OrtValue containing the initializer. Its lifetime and the underlying initializer buffer must be - * managed by the user (created using the OrtApi::CreateTensorWithDataAsOrtValue) and it must outlive the session object - * to which it is added. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(AddInitializer, _Inout_ OrtSessionOptions* options, _In_z_ const char* name, - _In_ const OrtValue* val); - - /// @} - /// \name OrtEnv - /// @{ - - /** - * Create a custom environment with global threadpools and logger that will be shared across sessions. - * Use this in conjunction with OrtApi::DisablePerSessionThreads or else the session will use - * its own thread pools. - * - * \param[in] logging_function A pointer to a logging function. - * \param[in] logger_param A pointer to arbitrary data passed as the ::OrtLoggingFunction `param` parameter to - * `logging_function`. - * \param[in] log_severity_level The log severity level. - * \param[in] logid The log identifier. - * \param[in] tp_options - * \param[out] out Newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel log_severity_level, - _In_ const char* logid, _In_ const struct OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Append CUDA provider to session options - * - * If CUDA is not available (due to a non CUDA enabled build, or if CUDA is not installed on the system), this function will return failure. - * - * \param[in] options - * \param[in] cuda_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CUDA, - _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptions* cuda_options); - - /** \brief Append ROCM execution provider to the session options - * - * If ROCM is not available (due to a non ROCM enabled build, or if ROCM is not installed on the system), this function will return failure. - * - * \param[in] options - * \param[in] rocm_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_ROCM, - _In_ OrtSessionOptions* options, _In_ const OrtROCMProviderOptions* rocm_options); - - /** \brief Append OpenVINO execution provider to the session options - * - * If OpenVINO is not available (due to a non OpenVINO enabled build, or if OpenVINO is not installed on the system), this function will fail. - * - * \param[in] options - * \param[in] provider_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_OpenVINO, - _In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options); - - /// @} - /// \name OrtThreadingOptions - /// @{ - - /** \brief Set threading flush-to-zero and denormal-as-zero - * - * Sets global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools. - * Flush-to-zero and denormal-as-zero are applied to threads in both intra and inter global thread pool. - * \note This option is not needed if the models used have no denormals. Having no denormals is recommended as this option may hurt model accuracy. - * - * \param[in] tp_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* tp_options); - - /// @} - /// \name OrtArenaCfg - /// @{ - - /** \deprecated Use OrtApi::CreateArenaCfgV2 - * - * This will create the configuration of an arena that can eventually be used to define an arena based allocator's behavior - * - * \param[in] max_mem Use 0 to allow ORT to choose the default - * \param[in] arena_extend_strategy Use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested - * \param[in] initial_chunk_size_bytes Use -1 to allow ORT to choose the default - * \param[in] max_dead_bytes_per_chunk Use -1 to allow ORT to choose the default - * \param[in] out A pointer to an OrtArenaCfg instance - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, - int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out); - - ORT_CLASS_RELEASE(ArenaCfg); - - /// @} - /// \name OrtModelMetadata - /// @{ - - /** - * Use this to obtain the description of the graph present in the model - * (doc_string field of the GraphProto message within the ModelProto message). - * If it doesn't exist, an empty string will be returned. - * - * \param[in] model_metadata An instance of ::OrtModelMetadata - * \param[in] allocator Allocator used to allocate the string that will be returned back - * \param[out] value Set to a null terminated string allocated using `allocator`. The caller is responsible for freeing it using `allocator` - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(ModelMetadataGetGraphDescription, _In_ const OrtModelMetadata* model_metadata, - _Inout_ OrtAllocator* allocator, _Outptr_ char** value); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Append TensorRT provider to session options - * - * If TensorRT is not available (due to a non TensorRT enabled build, or if TensorRT is not installed on the system), this function will return failure. - * - * \param[in] options - * \param[in] tensorrt_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT, - _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options); - - /// @} - /// \name Misc - /// @{ - - /** \brief Set current GPU device ID - * - * Set the current device id of the GPU execution provider (CUDA/tensorrt/rocm). The device id should be less - * than the total number of devices available. This is only useful when multiple-GPUs are installed and it is - * required to restrict execution to a single GPU. - * - * \param[in] device_id - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetCurrentGpuDeviceId, _In_ int device_id); - - /** \brief Get current GPU device ID - * - * Get the current device id of the GPU execution provider (CUDA/tensorrt/rocm). - * - * \see OrtApi::SetCurrentGpuDeviceId - * - * \param[out] device_id - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetCurrentGpuDeviceId, _In_ int* device_id); - - /// @} - /// \name OrtKernelInfo - /// Custom operator APIs. - /// @{ - - /** \brief Fetch an array of int64_t values stored as an attribute in the graph node - * - * - * If `out` is nullptr, the value of `size` is set to the true size of the attribute - * array's size, and a success status is returned. - * - * If the `size` parameter is greater than or equal to the actual attribute array's size, - * the value of `size` is set to the true size of the attribute array's size, - * the provided memory is filled with the attribute's contents, - * and a success status is returned. - * - * If the `size` parameter is less than the actual attribute array's size and `out` - * is not nullptr, the value of `size` is set to the true size of the attribute array's size - * and a failure status is returned.) - * - * \param[in] info instance - * \param[in] name name of the attribute to be parsed - * \param[out] out pointer to memory where the attribute's contents are to be stored - * \param[in, out] size actual size of attribute array - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttributeArray_float, _In_ const OrtKernelInfo* info, _In_ const char* name, - _Out_ float* out, _Inout_ size_t* size); - - /** \brief Fetch an array of int64_t values stored as an attribute in the graph node - * - * If `out` is nullptr, the value of `size` is set to the true size of the attribute - * array's size, and a success status is returned. - * - * If the `size` parameter is greater than or equal to the actual attribute array's size, - * the value of `size` is set to the true size of the attribute array's size, - * the provided memory is filled with the attribute's contents, - * and a success status is returned. - * - * If the `size` parameter is less than the actual attribute array's size and `out` - * is not nullptr, the value of `size` is set to the true size of the attribute array's size - * and a failure status is returned.) - * - * \param[in] info instance - * \param[in] name name of the attribute to be parsed - * \param[out] out pointer to memory where the attribute's contents are to be stored - * \param[in, out] size actual size of attribute array - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttributeArray_int64, _In_ const OrtKernelInfo* info, _In_ const char* name, - _Out_ int64_t* out, _Inout_ size_t* size); - - /// @} - /// \name OrtArenaCfg - /// @{ - - /** \brief Create an ::OrtArenaCfg - * - * Create the configuration of an arena that can eventually be used to define an arena based allocator's behavior. - * - * Supported keys are (See https://onnxruntime.ai/docs/reference/api/c-api.html for details on what the - * following parameters mean and how to choose these values.): - * "max_mem": Maximum memory that can be allocated by the arena based allocator. - * Use 0 for ORT to pick the best value. Default is 0. - * "arena_extend_strategy": 0 = kNextPowerOfTwo, 1 = kSameAsRequested. - * Use -1 to allow ORT to choose the default. - * "initial_chunk_size_bytes": (Possible) Size of the first allocation in the arena. - * Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1 to allow ORT to choose the default. - * Ultimately, the first allocation size is determined by the allocation memory request. - * "max_dead_bytes_per_chunk": Threshold of unused memory in an allocated chunk of arena memory after - * crossing which the current chunk is chunked into 2. - * "initial_growth_chunk_size_bytes": (Possible) Size of the second allocation in the arena. - * Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1 to allow ORT to choose the default. - * Ultimately, the allocation size is determined by the allocation memory request. - * Further allocation sizes are governed by the arena extend strategy. - * - * \param[in] arena_config_keys Keys to configure the arena - * \param[in] arena_config_values Values to configure the arena - * \param[in] num_keys Number of keys in `arena_config_keys` and `arena_config_values` - * \param[out] out Newly created ::OrtArenaCfg. Must be freed with OrtApi::ReleaseArenaCfg - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateArenaCfgV2, _In_reads_(num_keys) const char* const* arena_config_keys, - _In_reads_(num_keys) const size_t* arena_config_values, _In_ size_t num_keys, - _Outptr_ OrtArenaCfg** out); - - /// @} - /// \name OrtRunOptions - /// @{ - - /** \brief Set a single run configuration entry as a pair of strings - * - * If a configuration with same key exists, this will overwrite the configuration with the given config_value - * - * The config_key and the format of config_value are defined in onnxruntime_run_options_config_keys.h - * - * \param[in] options - * \param[in] config_key A null terminated string representation of the config key - * \param[in] config_value A null terminated string representation of the config value - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(AddRunConfigEntry, _Inout_ OrtRunOptions* options, - _In_z_ const char* config_key, _In_z_ const char* config_value); - - /// @} - /// \name OrtPrepackedWeightsContainer - /// @{ - - /** \brief Create an ::OrtPrepackedWeightsContainer - * - * This container will hold pre-packed buffers of shared initializers for sharing between sessions - * (i.e.) if there are shared initializers that can be shared between sessions, the pre-packed buffers - * of these (if any) may possibly be shared to provide memory footprint savings. Pass this container - * to sessions that you would like to share pre-packed buffers of shared initializers at session - * creation time. - * - * \param[out] out Newly created ::OrtPrepackedWeightsContainer. Must be freed with OrtApi::ReleasePrepackedWeightsContainer - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreatePrepackedWeightsContainer, _Outptr_ OrtPrepackedWeightsContainer** out); - - /** \brief Release OrtPrepackedWeightsContainer instance - * - * \note instance must not be released until the sessions using it are released - */ - ORT_CLASS_RELEASE(PrepackedWeightsContainer); - - /// @} - /// \name OrtSession - /// @{ - - /** \brief Create session with prepacked weights container - * - * Same functionality offered by OrtApi::CreateSession except that a container that contains - * pre-packed weights' buffers is written into/read from by the created session. - * This is useful when used in conjunction with OrtApi::AddInitializer which injects - * shared initializer info into sessions. Wherever possible, the pre-packed versions of these - * shared initializers are cached in this container so that multiple sessions can just re-use - * these instead of duplicating these in memory. - * - * \param[in] env OrtEnv instance instance - * \param[in] model_path Null terminated string of the path (wchar on Windows, char otherwise) - * \param[in] options - * \param[in] prepacked_weights_container - * \param[out] out Newly created ::OrtSession. Must be freed with OrtApi::ReleaseSession - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSessionWithPrepackedWeightsContainer, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, - _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container, - _Outptr_ OrtSession** out); - - /** \brief Create session from memory with prepacked weights container - * - * Same functionality offered by OrtApi::CreateSessionFromArray except that a container that contains - * pre-packed weights' buffers is written into/read from by the created session. - * This is useful when used in conjunction with OrtApi::AddInitializer which injects - * shared initializer info into sessions. Wherever possible, the pre-packed versions of these - * shared initializers are cached in this container so that multiple sessions can just re-use - * these instead of duplicating these in memory. - * - * \param[in] env - * \param[in] model_data Array of bytes holding the model - * \param[in] model_data_length Number of bytes in `model_data_model` - * \param[in] options - * \param[in] prepacked_weights_container - * \param[out] out Newly created ::OrtSession. Must be freed with OrtApi::ReleaseSession - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSessionFromArrayWithPrepackedWeightsContainer, _In_ const OrtEnv* env, - _In_ const void* model_data, size_t model_data_length, - _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container, - _Outptr_ OrtSession** out); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Append TensorRT execution provider to the session options - * - * If TensorRT is not available (due to a non TensorRT enabled build), this function will return failure. - * - * This is slightly different from OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, it takes an - * ::OrtTensorRTProviderOptions which is publicly defined. This takes an opaque ::OrtTensorRTProviderOptionsV2 - * which must be created with OrtApi::CreateTensorRTProviderOptions. - * - * For OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, the user needs to instantiate ::OrtTensorRTProviderOptions - * as well as allocate/release buffers for some members of ::OrtTensorRTProviderOptions. - * Here, OrtApi::CreateTensorRTProviderOptions and Ortapi::ReleaseTensorRTProviderOptions will do the memory management for you. - * - * \param[in] options - * \param[in] tensorrt_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT_V2, - _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options); - - /// @} - /// \name OrtTensorRTProviderOptionsV2 - /// @{ - - /** \brief Create an OrtTensorRTProviderOptionsV2 - * - * \param[out] out Newly created ::OrtTensorRTProviderOptionsV2. Must be released with OrtApi::ReleaseTensorRTProviderOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateTensorRTProviderOptions, _Outptr_ OrtTensorRTProviderOptionsV2** out); - - /** \brief Set options in a TensorRT Execution Provider. - * - * Please refer to https://www.onnxruntime.ai/docs/reference/execution-providers/TensorRT-ExecutionProvider.html#c-api-example - * to know the available keys and values. Key should be in null terminated string format of the member of ::OrtTensorRTProviderOptionsV2 - * and value should be its related range. - * - * For example, key="trt_max_workspace_size" and value="2147483648" - * - * \param[in] tensorrt_options - * \param[in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys - * \param[in] provider_options_values Array of UTF-8 null-terminated string for provider options values - * \param[in] num_keys Number of elements in the `provider_option_keys` and `provider_options_values` arrays - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(UpdateTensorRTProviderOptions, _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options, - _In_reads_(num_keys) const char* const* provider_options_keys, - _In_reads_(num_keys) const char* const* provider_options_values, - _In_ size_t num_keys); - - /** \brief Get serialized TensorRT provider options string. - * - * For example, "trt_max_workspace_size=2147483648;trt_max_partition_iterations=10;trt_int8_enable=1;......" - * - * \param tensorrt_options - OrTensorRTProviderOptionsV2 instance - * \param allocator - a ptr to an instance of OrtAllocator obtained with OrtApi::CreateAllocator or OrtApi::GetAllocatorWithDefaultOptions - * the specified allocator will be used to allocate continuous buffers for output strings and lengths. - * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorRTProviderOptionsAsString, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr); - - /** \brief Release an ::OrtTensorRTProviderOptionsV2 - * - * \note This is an exception in the naming convention of other Release* functions, as the name of the method does not have the V2 suffix, but the type does - */ - void(ORT_API_CALL* ReleaseTensorRTProviderOptions)(_Frees_ptr_opt_ OrtTensorRTProviderOptionsV2* input); - - /// @} - /// \name OrtSessionOptions - /// @{ - - /** \brief Enable custom operators - * - * See onnxruntime-extensions: https://github.com/microsoft/onnxruntime-extensions.git - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(EnableOrtCustomOps, _Inout_ OrtSessionOptions* options); - - /// @} - /// \name OrtAllocator - /// @{ - - /** \brief Register a custom allocator - * - * Enables sharing between multiple sessions that use the same env instance. - * Returns an error if an allocator with the same ::OrtMemoryInfo is already registered. - * - * The behavior of this is exactly the same as OrtApi::CreateAndRegisterAllocator except - * instead of ORT creating an allocator based on provided info, in this case - * ORT uses the user-provided custom allocator. - * See https://onnxruntime.ai/docs/reference/api/c-api.html for details. - * - * \param[in] env - * \param[in] allocator User provided allocator - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(RegisterAllocator, _Inout_ OrtEnv* env, _In_ OrtAllocator* allocator); - - /** \brief Unregister a custom allocator - * - * It is an error if you provide an ::OrtMemoryInfo not corresponding to any - * registered allocators for sharing. - * - * \param[in] env - * \param[in] mem_info - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(UnregisterAllocator, _Inout_ OrtEnv* env, - _In_ const OrtMemoryInfo* mem_info); - - /// @} - /// \name OrtValue - /// @{ - - /** \brief Sets *out to 1 iff an ::OrtValue is a SparseTensor, and 0 otherwise - * - * \param[in] value existing ::OrtValue - * \param[out] out unless an error occurs, contains 1 iff the value contains an instance - * of sparse tensor or 0 otherwise. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(IsSparseTensor, _In_ const OrtValue* value, _Out_ int* out); - - /** \brief Create an ::OrtValue with a sparse tensor that is empty. - * - * Use FillSparseTensor() functions to populate sparse tensor with non-zero values and - * format specific indices data. - * Use ReleaseValue to destroy the sparse tensor, this will also release the buffer inside the output value - * if any was allocated. - * \param[in,out] allocator allocator to use when performing an allocation. Allocation will be performed - * by FillSparseTensor() APIs. The lifespan of the allocator instance must eclipse the lifespan - * this sparse tensor instance as the same allocator will be used to free memory. - * \param[in] dense_shape shape of the original dense tensor - * \param[in] dense_shape_len number of shape dimensions being passed - * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx - * \param[out] out Should be freed by calling ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSparseTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* dense_shape, - size_t dense_shape_len, ONNXTensorElementDataType type, _Outptr_ OrtValue** out); - - /** - * This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. - * This will allocate required memory and copy the supplied NNZ values and COO indices into that memory allocation. - * Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue. - * - * \param[in,out] ort_value ::OrtValue to populate with data - * \param[in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified - * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. - * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. - * \param[in] values_shape pointer to values shape array - * \param[in] values_shape_len length of the values_shape - * \param[in] values pointer to an array of values. For strings, pass const char**. - * \param[in] indices_data pointer to a location of COO indices - * \param[in] indices_num number of COO indices - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(FillSparseTensorCoo, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, - _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, - _In_ const int64_t* indices_data, size_t indices_num); - - /** - * This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. - * This will allocate required memory and copy the supplied NNZ values and CSR indices into that memory allocation. - * Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue. - * - * \param[in,out] ort_value ::OrtValue to populate with data - * \param[in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified - * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. - * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. - * \param[in] values_shape pointer to values shape array - * \param[in] values_shape_len length of the values_shape - * \param[in] values - pointer to an array of values. For strings, pass const char**. - * \param[in] inner_indices_data pointer to a location of CSR inner indices - * \param[in] inner_indices_num number of CSR inner indices - * \param[in] outer_indices_data pointer to a location of CSR outer indices - * \param[in] outer_indices_num number of CSR outer indices - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(FillSparseTensorCsr, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, - _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, - _In_ const int64_t* inner_indices_data, size_t inner_indices_num, - _In_ const int64_t* outer_indices_data, size_t outer_indices_num); - - /** - * This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. - * This will allocate required memory and copy the supplied NNZ values and BlockSparse indices into that memory allocation. - * Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue. - * - * \param[in,out] ort_value ::OrtValue to populate with data - * \param[in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified - * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. - * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. - * \param[in] values_shape - * \param[in] values_shape_len - * \param[in] values structure with values information - * \param[in] indices_shape_data pointer to a location of indices shape - * \param[in] indices_shape_len length of the block sparse indices shape - * \param[in] indices_data pointer to a location of indices data. Shape will determine the length of the indices data. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(FillSparseTensorBlockSparse, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, - _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, - _In_ const int64_t* indices_shape_data, size_t indices_shape_len, - _In_ const int32_t* indices_data); - - /** - * Create an ::OrtValue with a sparse tensor. This is the first step. - * Next, use UseIndices() functions to supply sparse tensor with - * format specific indices data and set its sparse format to a specific enum value. - * This will not perform memory allocations. It will - * use supplied user buffer which should outlive the created sparse tensor. - * Use OrtApi::ReleaseValue to destroy the sparse tensor. It would not release the supplied values buffer. - * This function can not be used to map strings from the user allocated memory. Strings must always be copied - * and have UTF-8 encoding. Therefore, use OrtApi::CreateSparseTensorAsOrtValue above and then fill it with data - * using appropriate Make*() function. - * - * \param[in] info memory info where sparse values reside. - * \param[in,out] p_data pointer to a user allocated buffer with values. To create a full sparse tensor with no non-zero - * values, pass nullptr - * \param[in] dense_shape shape of the original dense tensor - * \param[in] dense_shape_len number of shape dimensions being passed - * \param[in] values_shape shape of the values data. To create a fully sparse tensor with no non-zero values, - * pass {0} shape. - * \param[in] values_shape_len number of values shape dimensions - * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx - * \param[out] out Should be freed by calling ReleaseValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(CreateSparseTensorWithValuesAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data, - _In_ const int64_t* dense_shape, size_t dense_shape_len, - _In_ const int64_t* values_shape, size_t values_shape_len, - ONNXTensorElementDataType type, _Outptr_ OrtValue** out); - - /** - * This assigns Coo format indices to the SparseTensor that was created by - * OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to - * ORT_SPARSE_COO. This will not allocate any additional memory for data. The life span of - * indices_data buffer should eclipse the life span of this ::OrtValue. - * - * \param[in,out] ort_value ::OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue - * \param[in,out] indices_data pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. - * \param[in] indices_num number of COO indices. Should either be 0 for fully sparse tensors, be equal - * to the number of nnz values specified to OrtApi::CreateSparseTensorWithValuesAsOrtValue for 1-D {nnz} indices or - * be twice as number of nnz values for a 2-D indices {nnz, 2} - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(UseCooIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* indices_data, size_t indices_num); - - /** - * The assigns CSR format indices to the SparseTensor that was created by - * OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to - * ORT_SPARSE_CSRC. This will not allocate any additional memory for data. The life spans of - * inner_data and outer_data buffers should eclipse the life span of this ::OrtValue. - * - * \param[in,out] ort_value ::OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue - * \param[in,out] inner_data pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. - * \param[in] inner_num number of inner CSR indices. Should either be 0 for fully sparse tensors or be equal - * to the number of nnz values specified to OrtApi::CreateSparseTensorWithValuesAsOrtValue. - * \param[in,out] outer_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors. - * \param[in] outer_num number of CSR outer indices. Should either be 0 for fully sparse tensors or - * equal to rows + 1 of the dense shape. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(UseCsrIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* inner_data, size_t inner_num, - _Inout_ int64_t* outer_data, size_t outer_num); - - /** - * The assigns BlockSparse format indices to the SparseTensor that was created by - * OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to - * ORT_SPARSE_BLOCK_SPARSE. This will not allocate any additional memory for data. The life span of - * indices_data buffer must eclipse the lifespan of this ::OrtValue. - * - * \param[in,out] ort_value OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue - * \param[in] indices_shape pointer to indices shape. Use {0} for fully sparse tensors - * \param[in] indices_shape_len length of the indices shape - * \param[in,out] indices_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(UseBlockSparseIndices, _Inout_ OrtValue* ort_value, const int64_t* indices_shape, size_t indices_shape_len, _Inout_ int32_t* indices_data); - - /** \brief Returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor. - * - * \param[in] ort_value ::OrtValue that contains an instance of sparse tensor - * \param[out] out pointer to out parameter - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSparseTensorFormat, _In_ const OrtValue* ort_value, _Out_ enum OrtSparseFormat* out); - - /** \brief Returns data type and shape of sparse tensor values (nnz) iff ::OrtValue contains a SparseTensor. - * - * \param[in] ort_value An ::OrtValue that contains a fully constructed sparse tensor - * \param[out] out Must be freed by OrtApi::ReleaseTensorTypeAndShapeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSparseTensorValuesTypeAndShape, _In_ const OrtValue* ort_value, _Outptr_ OrtTensorTypeAndShapeInfo** out); - - /** \brief Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*(). - * - * \param[in] ort_value an instance of ::OrtValue containing sparse tensor - * \param[out] out returns a pointer to values data. Do not attempt to free this ptr. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSparseTensorValues, _In_ const OrtValue* ort_value, _Outptr_ const void** out); - - /** \brief Returns data type, shape for the type of indices specified by indices_format. - * - * \param[in] ort_value ::OrtValue containing sparse tensor. - * \param[in] indices_format One of the indices formats. It is an error to request a format that the sparse - * tensor does not contain. - * \param[out] out an instance of ::OrtTensorTypeAndShapeInfo. Must be freed by OrtApi::ReleaseTensorTypeAndShapeInfo - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSparseTensorIndicesTypeShape, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Outptr_ OrtTensorTypeAndShapeInfo** out); - - /** \brief Returns indices data for the type of the indices specified by indices_format - * - * \param[in] ort_value ::OrtValue containing sparse tensor. - * \param[in] indices_format One of the indices formats. It is an error to request a format that the sparse tensor does not contain. - * \param[out] num_indices Pointer to where the number of indices entries is returned - * \param[out] indices Returned pointer to the indices data. Do not free the returned pointer as it refers to internal data owned by the ::OrtValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetSparseTensorIndices, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Out_ size_t* num_indices, _Outptr_ const void** indices); - /// @} - /// \name OrtSessionOptions - /// @{ - - /** - * \brief Sets out to 1 iff an optional type OrtValue has an element, 0 otherwise (OrtValue is None) - * Use this API to find if the optional type OrtValue is None or not. - * If the optional type OrtValue is not None, use the OrtValue just like any other OrtValue. - * For example, if you get an OrtValue that corresponds to Optional(tensor) and - * if HasValue() returns true, use it as tensor and so on. - - * \param[in] value Input OrtValue. - * \param[out] out indicating if the input OrtValue contains data (1) or if it is a None (0) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(HasValue, _In_ const OrtValue* value, _Out_ int* out); - - /// @} - /// \name OrtKernelContext - /// Custom operator APIs. - /// @{ - - /** \brief Used for custom operators, gets the GPU compute stream to use to launch the custom a GPU kernel - * \see ::OrtCustomOp - * \param[in] context OrtKernelContext instance - * \param[out] out Returns pointer to a GPU compute stream that can be used to launch the custom GPU kernel. - * If retrieving the GPU compute stream is not relevant (GPU not enabled in the build, kernel partitioned to - * some other EP), then a nullptr is returned as the output param. - * Do not free or mutate the returned pointer as it refers to internal data owned by the underlying session. - * Only use it for custom kernel launching. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelContext_GetGPUComputeStream, _In_ const OrtKernelContext* context, _Outptr_ void** out); - - /// @} - /// \name GetTensorMemoryInfo - /// @{ - /** \brief Returns a pointer to the ::OrtMemoryInfo of a Tensor - * \param[in] value ::OrtValue containing tensor. - * \param[out] mem_info ::OrtMemoryInfo of the tensor. Do NOT free the returned pointer. It is valid for the lifetime of the ::OrtValue - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetTensorMemoryInfo, _In_ const OrtValue* value, _Out_ const OrtMemoryInfo** mem_info); - - /// @} - /// \name GetExecutionProviderApi - /// @{ - /** \brief Get a pointer to the requested version of the Execution Provider specific - * API extensions to the OrtApi - * \param[in] provider_name The name of the execution provider name. Currently only the following - * values are supported: "DML". - * \param[in] version Must be ::ORT_API_VERSION. - * \param[out] provider_api A void pointer containing a reference to the execution provider versioned api structure. - * For example, the provider_api pointer can be cast to the OrtDmlApi* when the provider_name is "DML". - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(GetExecutionProviderApi, _In_ const char* provider_name, _In_ uint32_t version, _Outptr_ const void** provider_api); - - /// @} - - /// \name SessionOptions - /// @{ - /** \brief Set custom thread creation function - * - * \param[in] options Session options - * \param[in] ort_custom_create_thread_fn Custom thread creation function - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsSetCustomCreateThreadFn, _Inout_ OrtSessionOptions* options, _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn); - - /** \brief Set creation options for custom thread - * - * \param[in] options Session options - * \param[in] ort_custom_thread_creation_options Custom thread creation options (can be nullptr) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsSetCustomThreadCreationOptions, _Inout_ OrtSessionOptions* options, _In_ void* ort_custom_thread_creation_options); - - /** \brief Set custom thread join function - * - * \param[in] options Session options - * \param[in] ort_custom_join_thread_fn Custom join thread function, must not be nullptr when ort_custom_create_thread_fn is set - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SessionOptionsSetCustomJoinThreadFn, _Inout_ OrtSessionOptions* options, _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn); - /// @} - - /// \name OrtThreadingOptions - /// @{ - /** \brief Set custom thread creation function for global thread pools - * - * \param[inout] tp_options - * \param[in] ort_custom_create_thread_fn Custom thread creation function - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalCustomCreateThreadFn, _Inout_ OrtThreadingOptions* tp_options, _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn); - - /** \brief Set custom thread creation options for global thread pools - * - * \param[inout] tp_options - * \param[in] ort_custom_thread_creation_options Custom thread creation options (can be nullptr) - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalCustomThreadCreationOptions, _Inout_ OrtThreadingOptions* tp_options, _In_ void* ort_custom_thread_creation_options); - - /** \brief Set custom thread join function for global thread pools - * - * \param[inout] tp_options - * \param[in] ort_custom_join_thread_fn Custom thread join function, must not be nullptr when global ort_custom_create_thread_fn is set - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SetGlobalCustomJoinThreadFn, _Inout_ OrtThreadingOptions* tp_options, _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn); - /// @} - - /** \brief Synchronize bound inputs. The call may be necessary for some providers, such as cuda, - * in case the system that allocated bound memory operated on a different stream. However, the - * operation is provider specific and could be a no-op. - * - * \param[inout] binding_ptr - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SynchronizeBoundInputs, _Inout_ OrtIoBinding* binding_ptr); - - /** \brief Synchronize bound outputs. The call may be necessary for some providers, such as cuda, - * in case the system that allocated bound memory operated on a different stream. However, the - * operation is provider specific and could be a no-op. - * - * \param[inout] binding_ptr - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(SynchronizeBoundOutputs, _Inout_ OrtIoBinding* binding_ptr); - - /// \name OrtSessionOptions - /// @{ - - /** \brief Append CUDA execution provider to the session options - * - * If CUDA is not available (due to a non CUDA enabled build), this function will return failure. - * - * This is slightly different from OrtApi::SessionOptionsAppendExecutionProvider_CUDA, it takes an - * ::OrtCUDAProviderOptions which is publicly defined. This takes an opaque ::OrtCUDAProviderOptionsV2 - * which must be created with OrtApi::CreateCUDAProviderOptions. - * - * For OrtApi::SessionOptionsAppendExecutionProvider_CUDA, the user needs to instantiate ::OrtCUDAProviderOptions - * as well as allocate/release buffers for some members of ::OrtCUDAProviderOptions. - * Here, OrtApi::CreateCUDAProviderOptions and Ortapi::ReleaseCUDAProviderOptions will do the memory management for you. - * - * \param[in] options - * \param[in] cuda_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.11. - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CUDA_V2, - _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptionsV2* cuda_options); - - /// @} - /// \name OrtCUDAProviderOptionsV2 - /// @{ - - /** \brief Create an OrtCUDAProviderOptionsV2 - * - * \param[out] out Newly created ::OrtCUDAProviderOptionsV2. Must be released with OrtApi::ReleaseCudaProviderOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.11. - */ - ORT_API2_STATUS(CreateCUDAProviderOptions, _Outptr_ OrtCUDAProviderOptionsV2** out); - - /** \brief Set options in a CUDA Execution Provider. - * - * Please refer to https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#configuration-options - * to know the available keys and values. Key should be in null terminated string format of the member of ::OrtCUDAProviderOptionsV2 - * and value should be its related range. - * - * For example, key="device_id" and value="0" - * - * \param[in] cuda_options - * \param[in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys - * \param[in] provider_options_values Array of UTF-8 null-terminated string for provider options values - * \param[in] num_keys Number of elements in the `provider_option_keys` and `provider_options_values` arrays - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.11. - */ - ORT_API2_STATUS(UpdateCUDAProviderOptions, _Inout_ OrtCUDAProviderOptionsV2* cuda_options, - _In_reads_(num_keys) const char* const* provider_options_keys, - _In_reads_(num_keys) const char* const* provider_options_values, - _In_ size_t num_keys); - - /** - * Get serialized CUDA provider options string. - * - * For example, "device_id=0;arena_extend_strategy=0;......" - * - * \param cuda_options - OrtCUDAProviderOptionsV2 instance - * \param allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions() - * the specified allocator will be used to allocate continuous buffers for output strings and lengths. - * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.11. - */ - ORT_API2_STATUS(GetCUDAProviderOptionsAsString, _In_ const OrtCUDAProviderOptionsV2* cuda_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr); - - /** \brief Release an ::OrtCUDAProviderOptionsV2 - * - * \note This is an exception in the naming convention of other Release* functions, as the name of the method does not have the V2 suffix, but the type does - * - * \since Version 1.11. - */ - void(ORT_API_CALL* ReleaseCUDAProviderOptions)(_Frees_ptr_opt_ OrtCUDAProviderOptionsV2* input); - - /// @} - - /** \brief Append MIGraphX provider to session options - * - * If MIGraphX is not available (due to a non MIGraphX enabled build, or if MIGraphX is not installed on the system), this function will return failure. - * - * \param[in] options - * \param[in] migraphx_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.11. - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_MIGraphX, - _In_ OrtSessionOptions* options, _In_ const OrtMIGraphXProviderOptions* migraphx_options); - - /** \brief Replace initialized Tensors with external data with the data provided in initializers. - * - * The function will find the initialized TensorProtos with external data in the graph with the provided names and - * replace them with the provided tensors. The API verifies that the TensorProto being replaced - * has an external data reference and has the same name, dimensions and data type as its replacement. The replacement - * will occur before any of the optimizations take place. The data will be copied into the graph - * since TensorProto can't refer to the user provided buffers. - * - * Once the model has been loaded, the OrtValue(s) added to SessionOptions instance will be removed - * from the internal SessionOptions copy to save memory, the user provided buffers can then be deallocated - * and the SessionOptions instance that refers to them can be destroyed. - * - * \param[in] options - * \param[in] initializer_names Array of null terminated UTF-8 encoded strings of the initializers names. - * \param[in] initializers Array of ::OrtValue type - * \param[in] initializers_num Number of elements in the initializer_names and initializers - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.12. - */ - ORT_API2_STATUS(AddExternalInitializers, _In_ OrtSessionOptions* options, - _In_reads_(input_len) const char* const* initializer_names, - _In_reads_(input_len) const OrtValue* const* initializers, size_t initializers_num); - - /** \brief: Create attribute of onnxruntime operator - * - * \param[in] name Name of the attribute - * \param[in] data Data content of the attribute - * \param[in] len Number of bytes stored in data - * \param[in] type Data type - * \param[out] op_attr Attribute that has been created, which must be released by OrtApi::ReleaseOpAttr - * - * \since Version 1.12. - */ - ORT_API2_STATUS(CreateOpAttr, - _In_ const char* name, - _In_ const void* data, - _In_ int len, - _In_ OrtOpAttrType type, - _Outptr_ OrtOpAttr** op_attr); - - /* \brief: Release op attribute - * - * \param[in] opAttr Attribute created by OrtApi::CreateOpAttr - * - * \since Version 1.12. - */ - ORT_CLASS_RELEASE(OpAttr); - - /** \brief: Create onnxruntime native operator - * - * \param[in] info Kernel info - * \param[in] op_name Operator name - * \param[in] domain Operator domain - * \param[in] version Operator opset version - * \param[in] type_constraint_names Name of the type contraints, such as "T" or "T1" - * \param[in] type_constraint_values Type of each contraints - * \param[in] type_constraint_count Number of contraints - * \param[in] attr_values Attributes used to initialize the operator - * \param[in] attr_count Number of the attributes - * \param[in] input_count Number of inputs - * \param[in] output_count Number of outputs - * \param[out] ort_op Operator that has been created - * - * \since Version 1.12. - */ - ORT_API2_STATUS(CreateOp, - _In_ const OrtKernelInfo* info, - _In_ const char* op_name, - _In_ const char* domain, - _In_ int version, - _In_opt_ const char** type_constraint_names, - _In_opt_ const ONNXTensorElementDataType* type_constraint_values, - _In_opt_ int type_constraint_count, - _In_opt_ const OrtOpAttr* const* attr_values, - _In_opt_ int attr_count, - _In_ int input_count, - _In_ int output_count, - _Outptr_ OrtOp** ort_op); - - /** \brief: Invoke the operator created by OrtApi::CreateOp - * The inputs must follow the order as specified in onnx specification - * - * \param[in] context Kernel context - * \param[in] ort_op Operator that has been created - * \param[in] input_values Array of inputs - * \param[in] input_count Number of inputs - * \param[in] output_values Array of outputs - * \param[in] output_count Number of outputs - * - * \since Version 1.12. - */ - ORT_API2_STATUS(InvokeOp, - _In_ const OrtKernelContext* context, - _In_ const OrtOp* ort_op, - _In_ const OrtValue* const* input_values, - _In_ int input_count, - _Inout_ OrtValue* const* output_values, - _In_ int output_count); - - /* \brief: Release an onnxruntime operator - * - * \param[in] Op Operator created by OrtApi::CreateOp - * - * \since Version 1.12. - */ - ORT_CLASS_RELEASE(Op); - - /** \brief: Append execution provider to the session options. - * \param[in] options - * \param[in] provider_name - provider to add. - * \param[in] provider_options_keys - keys to configure the provider options - * \param[in] provider_options_values - values to configure the provider options - * \param[in] num_keys - number of keys passed in - * - * Currently supported providers: - * SNPE - * XNNPACK - * - * Note: If an execution provider has a dedicated SessionOptionsAppendExecutionProvider_ function - * that should be used to add it. - * - * SNPE supported keys: - * "runtime": SNPE runtime engine, options: "CPU", "CPU_FLOAT32", "GPU", "GPU_FLOAT32_16_HYBRID", "GPU_FLOAT16", - * "DSP", "DSP_FIXED8_TF", "AIP_FIXED_TF", "AIP_FIXED8_TF". - * Mapping to SNPE Runtime_t definition: CPU, CPU_FLOAT32 => zdl::DlSystem::Runtime_t::CPU; - * GPU, GPU_FLOAT32_16_HYBRID => zdl::DlSystem::Runtime_t::GPU; - * GPU_FLOAT16 => zdl::DlSystem::Runtime_t::GPU_FLOAT16; - * DSP, DSP_FIXED8_TF => zdl::DlSystem::Runtime_t::DSP. - * AIP_FIXED_TF, AIP_FIXED8_TF => zdl::DlSystem::Runtime_t::AIP_FIXED_TF. - * "priority": execution priority, options: "low", "normal". - * "buffer_type": ITensor or user buffers, options: "ITENSOR", user buffer with different types - "TF8", "TF16", "UINT8", "FLOAT". - * "ITENSOR" -- default, ITensor which is float only. - * "TF8" -- quantized model required, "FLOAT" -- for both quantized or non-quantized model - * If SNPE is not available (due to a non Snpe enabled build or its dependencies not being installed), this function will fail. - * - * XNNPACK supported keys: - * "intra_op_num_threads": number of thread-pool size to use for XNNPACK execution provider. - * default value is 0, which means to use the session thread-pool size. - * - * \since Version 1.12. - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider, _In_ OrtSessionOptions* options, - _In_ const char* provider_name, - _In_reads_(num_keys) const char* const* provider_options_keys, - _In_reads_(num_keys) const char* const* provider_options_values, - _In_ size_t num_keys); - - /* \brief: Get a copy of kernel info - * - * \param[in] info Kernel info - * \param[out] info_copy Copy of kernel info - * - * \since Version 1.12. - */ - ORT_API2_STATUS(CopyKernelInfo, - _In_ const OrtKernelInfo* info, - _Outptr_ OrtKernelInfo** info_copy); - - /* \brief: Release kernel info - * - * \param[in] KernelInfo A copy of kernel info returned by CopyKernelInfo - * - * \since Version 1.12. - */ - ORT_CLASS_RELEASE(KernelInfo); - - /* \brief: Get the training C Api - * - * \since Version 1.13 - */ - const OrtTrainingApi*(ORT_API_CALL* GetTrainingApi)(uint32_t version)NO_EXCEPTION; - - /** \brief Append CANN provider to session options - * - * If CANN is not available (due to a non CANN enabled build, or if CANN is not installed on the system), this function will return failure. - * - * \param[in] options - * \param[in] cann_options - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.13. - */ - ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CANN, - _In_ OrtSessionOptions* options, _In_ const OrtCANNProviderOptions* cann_options); - - /** \brief Create an OrtCANNProviderOptions - * - * \param[out] out created ::OrtCANNProviderOptions. Must be released with OrtApi::ReleaseCANNProviderOptions - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.13. - */ - ORT_API2_STATUS(CreateCANNProviderOptions, _Outptr_ OrtCANNProviderOptions** out); - - /** \brief Set options in a CANN Execution Provider. - * - * \param[in] cann_options - * \param[in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys - * \param[in] provider_options_values Array of UTF-8 null-terminated string for provider options values - * \param[in] num_keys Number of elements in the `provider_option_keys` and `provider_options_values` arrays - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.13. - */ - ORT_API2_STATUS(UpdateCANNProviderOptions, _Inout_ OrtCANNProviderOptions* cann_options, - _In_reads_(num_keys) const char* const* provider_options_keys, - _In_reads_(num_keys) const char* const* provider_options_values, - _In_ size_t num_keys); - - /** \brief Get serialized CANN provider options string. - * - * \param[in] cann_options OrtCANNProviderOptions instance - * \param[in] allocator a ptr to an instance of OrtAllocator obtained with CreateAllocator() - * or GetAllocatorWithDefaultOptions(), the specified allocator will be used to allocate - * continuous buffers for output strings and lengths. - * \param[out] ptr is a UTF-8 null terminated string allocated using 'allocator'. - * The caller is responsible for using the same allocator to free it. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * - * \since Version 1.13. - */ - ORT_API2_STATUS(GetCANNProviderOptionsAsString, _In_ const OrtCANNProviderOptions* cann_options, - _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr); - - /** \brief Release an OrtCANNProviderOptions - * - * \param[in] the pointer of OrtCANNProviderOptions which will been deleted - * - * \since Version 1.13. - */ - void(ORT_API_CALL* ReleaseCANNProviderOptions)(_Frees_ptr_opt_ OrtCANNProviderOptions* input); - - /* \brief Get OrtDevice type from MemoryInfo - * - * \since Version 1.14 - */ - void(ORT_API_CALL* MemoryInfoGetDeviceType)(_In_ const OrtMemoryInfo* ptr, _Out_ OrtMemoryInfoDeviceType* out); - - /* \brief Update the OrtEnv instance with custom log severity level - * - * \param[in] ort_env The OrtEnv instance being used - * \param[in] log_severity_level The log severity level. - * - * \since Version 1.14. - */ - ORT_API2_STATUS(UpdateEnvWithCustomLogLevel, _In_ OrtEnv* ort_env, OrtLoggingLevel log_severity_level); - - /* \brief Set affinities for intra op threads - * - * Affinity string follows format: - * logical_processor_id,logical_processor_id;logical_processor_id,logical_processor_id - * Semicolon isolates configurations among threads, while comma split processors where ith thread expected to attach to. - * e.g. 1,2,3;4,5 - * specifies affinities for two threads, with the 1st thread attach to the 1st, 2nd, and 3rd processor, and 2nd thread to the 4th and 5th. - * To ease the configuration, an "interval" is also allowed: - * e.g. 1-8;8-16;17-24 - * orders that the 1st thread runs on first eight processors, 2nd thread runs on next eight processors, and so forth. - * Note: - * 1. Once set, the number of thread affinities must equal to intra_op_num_threads - 1, - * ort does not set affinity on the main thread which is started and managed by the calling app; - * 2. For windows, ort will infer the group id from a logical processor id, for example, assuming there are two groups with each has 64 logical processors, - * an id of 64 will be inferred as the last processor of the 1st group, while 65 will be interpreted as the 1st processor of the second group. - * Hence 64-65 is an invalid configuration, because a windows thread cannot be attached to processors across group boundary. - * - * \since Version 1.14 - */ - ORT_API2_STATUS(SetGlobalIntraOpThreadAffinity, _Inout_ OrtThreadingOptions* tp_options, const char* affinity_string); - - /** \brief Register custom ops from a shared library. - * - * Loads a shared library (.dll on windows, .so on linux, etc) named 'library_name' and looks for this entry point: - * OrtStatus* RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); - * It then passes in the provided session options to this function along with the api base. - * - * The handle to the loaded library is automatically released by ORT when the last OrtSession that references the - * library handle is released. If no OrtSession is created, then the library handle is released when the provided - * OrtSessionOptions is released. - * - * \param[in] options The session options. - * \param[in] library_name The name of the shared library to load and register. Refer to OS-specific dynamic library - * loading utilities (e.g., LoadLibraryEx on Windows or dlopen on Linux/MacOS) for information - * on the format of library names and search paths. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(RegisterCustomOpsLibrary_V2, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* library_name); - - /** \brief Register custom ops by calling a RegisterCustomOpsFn function. - * - * Searches for registration_func_name and if found calls it. - * - * The library containing the function must either be linked against or previously loaded by the executable. - * - * If you want ONNX Runtime to load the library and manage its lifetime, use RegisterCustomOpsLibrary_V2. - * - * RegisterCustomOpsUsingFunction can be used in scenarios where it may not be possible for ONNX Runtime to load - * the library from a path. e.g. mobile platforms where the library must be linked into the app. - * - * The registration function must have the signature of RegisterCustomOpsFn: - * OrtStatus* (*fn)(OrtSessionOptions* options, const OrtApiBase* api); - * - * See https://onnxruntime.ai/docs/reference/operators/add-custom-op.html for details on how the registration - * function should be implemented. - * - * \param[in] options OrtSessionOptions that is passed through as the first argument in the call to the - * registration function. - * \param[in] registration_func_name Name of registration function to use. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(RegisterCustomOpsUsingFunction, _Inout_ OrtSessionOptions* options, - _In_ const char* registration_func_name); - - /// @} - /// \name OrtKernelInfo - /// Custom operator APIs. - /// @{ - - /** \brief Get the number of inputs from ::OrtKernelInfo. - * - * Used in the CreateKernel callback of an OrtCustomOp to query the number of inputs - * during kernel/session creation. - * - * \param[in] info Instance of ::OrtKernelInfo. - * \param[out] out Pointer to variable assigned with the result on success. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetInputCount, _In_ const OrtKernelInfo* info, _Out_ size_t* out); - - /** \brief Get the number of outputs from ::OrtKernelInfo. - * - * Used in the CreateKernel callback of an OrtCustomOp to query the number of outputs - * during kernel/session creation. - * - * \param[in] info Instance of ::OrtKernelInfo. - * \param[out] out Pointer to variable assigned with the result on success. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetOutputCount, _In_ const OrtKernelInfo* info, _Out_ size_t* out); - - /** \brief Get the name of a ::OrtKernelInfo's input. - * - * Used in the CreateKernel callback of an OrtCustomOp to query an input's name - * during kernel/session creation. - * - * If `out` is nullptr, the value of `size` is set to the size of the name - * string (including null-terminator), and a success status is returned. - * - * If the `size` parameter is greater than or equal to the name string's size, - * the value of `size` is set to the true size of the string (including null-terminator), - * the provided memory is filled with the string's contents, and a success status is returned. - * - * If the `size` parameter is less than the actual string's size and `out` - * is not nullptr, the value of `size` is set to the true size of the string - * and a failure status is returned. - * - * \param[in] info An instance of ::OrtKernelInfo. - * \param[in] index The index of the input name to get. Returns a failure status if out-of-bounds. - * \param[out] out Memory location into which to write the UTF-8 null-terminated string representing the input's name. - * \param[in,out] size Pointer to the size of the `out` buffer. See above comments for details. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetInputName, _In_ const OrtKernelInfo* info, size_t index, _Out_ char* out, - _Inout_ size_t* size); - - /** \brief Get the name of a ::OrtKernelInfo's output. - * - * Used in the CreateKernel callback of an OrtCustomOp to query an output's name - * during kernel/session creation. - * - * If `out` is nullptr, the value of `size` is set to the size of the name - * string (including null-terminator), and a success status is returned. - * - * If the `size` parameter is greater than or equal to the name string's size, - * the value of `size` is set to the true size of the string (including null-terminator), - * the provided memory is filled with the string's contents, and a success status is returned. - * - * If the `size` parameter is less than the actual string's size and `out` - * is not nullptr, the value of `size` is set to the true size of the string - * and a failure status is returned. - * - * \param[in] info An instance of ::OrtKernelInfo. - * \param[in] index The index of the output name to get. Returns a failure status if out-of-bounds. - * \param[out] out Memory location into which to write the UTF-8 null-terminated string representing the output's - * name. - * \param[in,out] size Pointer to the size of the `out` buffer. See above comments for details. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetOutputName, _In_ const OrtKernelInfo* info, size_t index, _Out_ char* out, - _Inout_ size_t* size); - - /** \brief Get the type information for a ::OrtKernelInfo's input. - * - * Used in the CreateKernel callback of an OrtCustomOp to query the shape and type information - * of an input during kernel/session creation. - * - * \param[in] info An instance of ::OrtKernelInfo. - * \param[out] type_info Pointer set to the resulting ::OrtTypeInfo. Must be freed with OrtApi::ReleaseTypeInfo. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetInputTypeInfo, _In_ const OrtKernelInfo* info, size_t index, - _Outptr_ OrtTypeInfo** type_info); - - /** \brief Get the type information for a ::OrtKernelInfo's output. - * - * Used in the CreateKernel callback of an OrtCustomOp to query the shape and type information - * of an output during kernel/session creation. - * - * \param[in] info An instance of ::OrtKernelInfo. - * \param[out] type_info Pointer set to the resulting ::OrtTypeInfo. Must be freed with OrtApi::ReleaseTypeInfo. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(KernelInfo_GetOutputTypeInfo, _In_ const OrtKernelInfo* info, size_t index, - _Outptr_ OrtTypeInfo** type_info); - - /** \brief Get a ::OrtValue tensor stored as an attribute in the graph node. - * - * Used in the CreateKernel callback of an OrtCustomOp to get a tensor attribute. - * - * \param[in] info ::OrtKernelInfo instance. - * \param[in] name UTF-8 null-terminated string representing the attribute's name. - * \param[in] allocator Allocator used to allocate the internal tensor state. - * \param[out] out Returns newly created ::OrtValue. Must be freed with OrtApi::ReleaseValue, - * which will also free internal tensor state allocated with the provided allocator. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - */ - ORT_API2_STATUS(KernelInfoGetAttribute_tensor, _In_ const OrtKernelInfo* info, _In_z_ const char* name, - _Inout_ OrtAllocator* allocator, _Outptr_ OrtValue** out); - - /// @} - /// \name OrtSessionOptions - /// Custom operator APIs - /// @{ - - /** \brief Checks if the given session configuration entry exists. - * - * The config_key formats are defined in onnxruntime_session_options_config_keys.h - * - * Can be used in a custom operator library to check for session configuration entries - * that target one or more custom operators in the library. Example: The config entry - * custom_op.myop.some_key targets a custom op named "myop". - * - * \param[in] options The ::OrtSessionOptions instance. - * \param[in] config_key A null-terminated UTF-8 string representation of the configuration key. - * \param[out] out Pointer set to 1 if the entry exists and 0 otherwise. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(HasSessionConfigEntry, _In_ const OrtSessionOptions* options, - _In_z_ const char* config_key, _Out_ int* out); - - /** \brief Get a session configuration value. - * - * Returns a failure status if the configuration key does not exist. - * The config_key and the format of config_value are defined in onnxruntime_session_options_config_keys.h - * - * If `config_value` is nullptr, the value of `size` is set to the true size of the string - * value (including null-terminator), and a success status is returned. - * - * If the `size` parameter is greater than or equal to the actual string value's size, - * the value of `size` is set to the true size of the string value, the provided memory - * is filled with the value's contents, and a success status is returned. - * - * If the `size` parameter is less than the actual string value's size and `config_value` - * is not nullptr, the value of `size` is set to the true size of the string value - * and a failure status is returned. - * - * Can be used in a custom operator library to get session configuration entries - * that target one or more custom operators in the library. Example: The config entry - * custom_op.myop.some_key targets a custom op named "myop". - * - * \param[in] options The session options. - * \param[in] config_key A null-terminated UTF-8 string representation of the config key. - * \param[in] config_value Pointer to memory where the null-terminated UTF-8 string value will be stored. - * \param[in,out] size Pointer to the size of the `config_value` buffer. See above comments for details. - * - * \snippet{doc} snippets.dox OrtStatus Return Value - * \since Version 1.14 - */ - ORT_API2_STATUS(GetSessionConfigEntry, _In_ const OrtSessionOptions* options, - _In_z_ const char* config_key, _Out_ char* config_value, _Inout_ size_t* size); - - /// @} - -#ifdef __cplusplus - OrtApi(const OrtApi&) = delete; // Prevent users from accidentally copying the API structure, it should always be passed as a pointer -#endif -}; - -/* - * Steps to use a custom op: - * 1 Create an OrtCustomOpDomain with the domain name used by the custom ops - * 2 Create an OrtCustomOp structure for each op and add them to the domain - * 3 Call OrtAddCustomOpDomain to add the custom domain of ops to the session options - */ - -// Specifies some characteristics of inputs/outputs of custom ops: -// Specify if the inputs/outputs are one of: -// 1) Non-optional (input/output must be present in the node) -// 2) Optional (input/output may be absent in the node) -// 3) Variadic: A variadic input or output specifies N (i.e., the minimum arity) or more operands. -// Only the last input or output of a custom op may be marked as variadic. -// The homogeneity of the variadic input or output determines whether all operands must be of the same -// tensor element type. -typedef enum OrtCustomOpInputOutputCharacteristic { - INPUT_OUTPUT_REQUIRED = 0, - INPUT_OUTPUT_OPTIONAL, - INPUT_OUTPUT_VARIADIC, -} OrtCustomOpInputOutputCharacteristic; - -/* - * The OrtCustomOp structure defines a custom op's schema and its kernel callbacks. The callbacks are filled in by - * the implementor of the custom op. - */ -struct OrtCustomOp { - uint32_t version; // Must be initialized to ORT_API_VERSION - - // This callback creates the kernel, which is a user defined parameter that is passed to the Kernel* callbacks below. - void*(ORT_API_CALL* CreateKernel)(_In_ const struct OrtCustomOp* op, _In_ const OrtApi* api, - _In_ const OrtKernelInfo* info); - - // Returns the name of the op - const char*(ORT_API_CALL* GetName)(_In_ const struct OrtCustomOp* op); - - // Returns the type of the execution provider, return nullptr to use CPU execution provider - const char*(ORT_API_CALL* GetExecutionProviderType)(_In_ const struct OrtCustomOp* op); - - // Returns the count and types of the input & output tensors - ONNXTensorElementDataType(ORT_API_CALL* GetInputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index); - size_t(ORT_API_CALL* GetInputTypeCount)(_In_ const struct OrtCustomOp* op); - ONNXTensorElementDataType(ORT_API_CALL* GetOutputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index); - size_t(ORT_API_CALL* GetOutputTypeCount)(_In_ const struct OrtCustomOp* op); - - // Op kernel callbacks - void(ORT_API_CALL* KernelCompute)(_In_ void* op_kernel, _In_ OrtKernelContext* context); - void(ORT_API_CALL* KernelDestroy)(_In_ void* op_kernel); - - // Returns the characteristics of the input & output tensors - OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetInputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index); - OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index); - - // Returns the memory type of the input tensors. This API allows the custom op - // to place the inputs on specific devices. By default, it returns - // OrtMemTypeDefault, which means the input is placed on the default device for - // the execution provider. If the inputs need to be with different memory tyeps, - // this function can be overridden to return the specific memory types. - OrtMemType(ORT_API_CALL* GetInputMemoryType)(_In_ const struct OrtCustomOp* op, _In_ size_t index); - - // Returns the minimum number of input arguments expected for the variadic input. - // Applicable only for custom ops that have a variadic input. - int(ORT_API_CALL* GetVariadicInputMinArity)(_In_ const struct OrtCustomOp* op); - - // Returns true (non-zero) if all arguments of a variadic input have to be of the same type (homogeneous), - // and false (zero) otherwise. - // Applicable only for custom ops that have a variadic input. - int(ORT_API_CALL* GetVariadicInputHomogeneity)(_In_ const struct OrtCustomOp* op); - - // Returns the minimum number of output values expected for the variadic output. - // Applicable only for custom ops that have a variadic output. - int(ORT_API_CALL* GetVariadicOutputMinArity)(_In_ const struct OrtCustomOp* op); - - // Returns true (non-zero) if all outputs values of a variadic output have to be of the same type (homogeneous), - // and false (zero) otherwise. - // Applicable only for custom ops that have a variadic output. - int(ORT_API_CALL* GetVariadicOutputHomogeneity)(_In_ const struct OrtCustomOp* op); -}; - -/* - * This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality - * This function always exists, but will only succeed if Onnxruntime was built with CUDA support and the CUDA provider shared library exists - * - * \param device_id CUDA device id, starts from zero. - */ -ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id); - -/* - * This is the old way to add the MIGraphX provider to the session, please use - * SessionOptionsAppendExecutionProvider_MIGraphX above to access the latest functionality - * This function always exists, but will only succeed if Onnxruntime was built with - * HIP support and the MIGraphX provider shared library exists - * - * \param device_id HIP device id, starts from zero. - */ -ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_MIGraphX, _In_ OrtSessionOptions* options, int device_id); - -#ifdef __cplusplus -} -#endif - -//! @} diff --git a/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_api.h b/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_api.h deleted file mode 100644 index 97b2aa484..000000000 --- a/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_api.h +++ /dev/null @@ -1,1876 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// Summary: The Ort C++ API is a header only wrapper around the Ort C API. -// -// The C++ API simplifies usage by returning values directly instead of error codes, throwing exceptions on errors -// and automatically releasing resources in the destructors. The primary purpose of C++ API is exception safety so -// all the resources follow RAII and do not leak memory. -// -// Each of the C++ wrapper classes holds only a pointer to the C internal object. Treat them like smart pointers. -// To create an empty object, pass 'nullptr' to the constructor (for example, Env e{nullptr};). However, you can't use them -// until you assign an instance that actually holds an underlying object. -// -// For Ort objects only move assignment between objects is allowed, there are no copy constructors. -// Some objects have explicit 'Clone' methods for this purpose. -// -// ConstXXXX types are copyable since they do not own the underlying C object, so you can pass them to functions as arguments -// by value or by reference. ConstXXXX types are restricted to const only interfaces. -// -// UnownedXXXX are similar to ConstXXXX but also allow non-const interfaces. -// -// The lifetime of the corresponding owning object must eclipse the lifetimes of the ConstXXXX/UnownedXXXX types. They exists so you do not -// have to fallback to C types and the API with the usual pitfalls. In general, do not use C API from your C++ code. - -#pragma once -#include "onnxruntime_c_api.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef ORT_NO_EXCEPTIONS -#include -#endif - -/** \brief All C++ Onnxruntime APIs are defined inside this namespace - * - */ -namespace Ort { - -/** \brief All C++ methods that can fail will throw an exception of this type - * - * If ORT_NO_EXCEPTIONS is defined, then any error will result in a call to abort() - */ -struct Exception : std::exception { - Exception(std::string&& string, OrtErrorCode code) : message_{std::move(string)}, code_{code} {} - - OrtErrorCode GetOrtErrorCode() const { return code_; } - const char* what() const noexcept override { return message_.c_str(); } - - private: - std::string message_; - OrtErrorCode code_; -}; - -#ifdef ORT_NO_EXCEPTIONS -// The #ifndef is for the very special case where the user of this library wants to define their own way of handling errors. -// NOTE: This header expects control flow to not continue after calling ORT_CXX_API_THROW -#ifndef ORT_CXX_API_THROW -#define ORT_CXX_API_THROW(string, code) \ - do { \ - std::cerr << Ort::Exception(string, code) \ - .what() \ - << std::endl; \ - abort(); \ - } while (false) -#endif -#else -#define ORT_CXX_API_THROW(string, code) \ - throw Ort::Exception(string, code) -#endif - -// This is used internally by the C++ API. This class holds the global variable that points to the OrtApi, -// it's in a template so that we can define a global variable in a header and make -// it transparent to the users of the API. -template -struct Global { - static const OrtApi* api_; -}; - -// If macro ORT_API_MANUAL_INIT is defined, no static initialization will be performed. Instead, user must call InitApi() before using it. -template -#ifdef ORT_API_MANUAL_INIT -const OrtApi* Global::api_{}; -inline void InitApi() { Global::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION); } - -// Used by custom operator libraries that are not linked to onnxruntime. Sets the global API object, which is -// required by C++ APIs. -// -// Example mycustomop.cc: -// -// #define ORT_API_MANUAL_INIT -// #include -// #undef ORT_API_MANUAL_INIT -// -// OrtStatus* ORT_API_CALL RegisterCustomOps(OrtSessionOptions* options, const OrtApiBase* api_base) { -// Ort::InitApi(api_base->GetApi(ORT_API_VERSION)); -// // ... -// } -// -inline void InitApi(const OrtApi* api) { Global::api_ = api; } -#else -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(push) -// "Global initializer calls a non-constexpr function." Therefore you can't use ORT APIs in the other global initializers. -// Please define ORT_API_MANUAL_INIT if it conerns you. -#pragma warning(disable : 26426) -#endif -const OrtApi* Global::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION); -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(pop) -#endif -#endif - -/// This returns a reference to the OrtApi interface in use -inline const OrtApi& GetApi() { return *Global::api_; } - -/// -/// This is a C++ wrapper for OrtApi::GetAvailableProviders() and -/// returns a vector of strings representing the available execution providers. -/// -/// vector of strings -std::vector GetAvailableProviders(); - -/** \brief IEEE 754 half-precision floating point data type - * \details It is necessary for type dispatching to make use of C++ API - * The type is implicitly convertible to/from uint16_t. - * The size of the structure should align with uint16_t and one can freely cast - * uint16_t buffers to/from Ort::Float16_t to feed and retrieve data. - * - * Generally, you can feed any of your types as float16/blfoat16 data to create a tensor - * on top of it, providing it can form a continuous buffer with 16-bit elements with no padding. - * And you can also feed a array of uint16_t elements directly. For example, - * - * \code{.unparsed} - * uint16_t values[] = { 15360, 16384, 16896, 17408, 17664}; - * constexpr size_t values_length = sizeof(values) / sizeof(values[0]); - * std::vector dims = {values_length}; // one dimensional example - * Ort::MemoryInfo info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault); - * // Note we are passing bytes count in this api, not number of elements -> sizeof(values) - * auto float16_tensor = Ort::Value::CreateTensor(info, values, sizeof(values), - * dims.data(), dims.size(), ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16); - * \endcode - * - * Here is another example, a little bit more elaborate. Let's assume that you use your own float16 type and you want to use - * a templated version of the API above so the type is automatically set based on your type. You will need to supply an extra - * template specialization. - * - * \code{.unparsed} - * namespace yours { struct half {}; } // assume this is your type, define this: - * namespace Ort { - * template<> - * struct TypeToTensorType { static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16; }; - * } //namespace Ort - * - * std::vector values; - * std::vector dims = {values.size()}; // one dimensional example - * Ort::MemoryInfo info("Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault); - * // Here we are passing element count -> values.size() - * auto float16_tensor = Ort::Value::CreateTensor(info, values.data(), values.size(), dims.data(), dims.size()); - * - * \endcode - */ -struct Float16_t { - uint16_t value; - constexpr Float16_t() noexcept : value(0) {} - constexpr Float16_t(uint16_t v) noexcept : value(v) {} - constexpr operator uint16_t() const noexcept { return value; } - constexpr bool operator==(const Float16_t& rhs) const noexcept { return value == rhs.value; }; - constexpr bool operator!=(const Float16_t& rhs) const noexcept { return value != rhs.value; }; -}; - -static_assert(sizeof(Float16_t) == sizeof(uint16_t), "Sizes must match"); - -/** \brief bfloat16 (Brain Floating Point) data type - * \details It is necessary for type dispatching to make use of C++ API - * The type is implicitly convertible to/from uint16_t. - * The size of the structure should align with uint16_t and one can freely cast - * uint16_t buffers to/from Ort::BFloat16_t to feed and retrieve data. - * - * See also code examples for Float16_t above. - */ -struct BFloat16_t { - uint16_t value; - constexpr BFloat16_t() noexcept : value(0) {} - constexpr BFloat16_t(uint16_t v) noexcept : value(v) {} - constexpr operator uint16_t() const noexcept { return value; } - constexpr bool operator==(const BFloat16_t& rhs) const noexcept { return value == rhs.value; }; - constexpr bool operator!=(const BFloat16_t& rhs) const noexcept { return value != rhs.value; }; -}; - -static_assert(sizeof(BFloat16_t) == sizeof(uint16_t), "Sizes must match"); - -namespace detail { -// This is used internally by the C++ API. This macro is to make it easy to generate overloaded methods for all of the various OrtRelease* functions for every Ort* type -// This can't be done in the C API since C doesn't have function overloading. -#define ORT_DEFINE_RELEASE(NAME) \ - inline void OrtRelease(Ort##NAME* ptr) { GetApi().Release##NAME(ptr); } - -ORT_DEFINE_RELEASE(Allocator); -ORT_DEFINE_RELEASE(MemoryInfo); -ORT_DEFINE_RELEASE(CustomOpDomain); -ORT_DEFINE_RELEASE(ThreadingOptions); -ORT_DEFINE_RELEASE(Env); -ORT_DEFINE_RELEASE(RunOptions); -ORT_DEFINE_RELEASE(Session); -ORT_DEFINE_RELEASE(SessionOptions); -ORT_DEFINE_RELEASE(TensorTypeAndShapeInfo); -ORT_DEFINE_RELEASE(SequenceTypeInfo); -ORT_DEFINE_RELEASE(MapTypeInfo); -ORT_DEFINE_RELEASE(TypeInfo); -ORT_DEFINE_RELEASE(Value); -ORT_DEFINE_RELEASE(ModelMetadata); -ORT_DEFINE_RELEASE(IoBinding); -ORT_DEFINE_RELEASE(ArenaCfg); -ORT_DEFINE_RELEASE(Status); -ORT_DEFINE_RELEASE(OpAttr); -ORT_DEFINE_RELEASE(Op); -ORT_DEFINE_RELEASE(KernelInfo); - -#undef ORT_DEFINE_RELEASE - -/** \brief This is a tagging template type. Use it with Base to indicate that the C++ interface object - * has no ownership of the underlying C object. - */ -template -struct Unowned { - using Type = T; -}; - -/** \brief Used internally by the C++ API. C++ wrapper types inherit from this. - * This is a zero cost abstraction to wrap the C API objects and delete them on destruction. - * - * All of the C++ classes - * a) serve as containers for pointers to objects that are created by the underlying C API. - * Their size is just a pointer size, no need to dynamically allocate them. Use them by value. - * b) Each of struct XXXX, XXX instances function as smart pointers to the underlying C API objects. - * they would release objects owned automatically when going out of scope, they are move-only. - * c) ConstXXXX and UnownedXXX structs function as non-owning, copyable containers for the above pointers. - * ConstXXXX allow calling const interfaces only. They give access to objects that are owned by somebody else - * such as Onnxruntime or instances of XXXX classes. - * d) serve convenient interfaces that return C++ objects and further enhance exception and type safety so they can be used - * in C++ code. - * - */ - -/// -/// This is a non-const pointer holder that is move-only. Disposes of the pointer on destruction. -/// -template -struct Base { - using contained_type = T; - - constexpr Base() = default; - constexpr explicit Base(contained_type* p) noexcept : p_{p} {} - ~Base() { OrtRelease(p_); } - - Base(const Base&) = delete; - Base& operator=(const Base&) = delete; - - Base(Base&& v) noexcept : p_{v.p_} { v.p_ = nullptr; } - Base& operator=(Base&& v) noexcept { - OrtRelease(p_); - p_ = v.release(); - return *this; - } - - constexpr operator contained_type*() const noexcept { return p_; } - - /// \brief Relinquishes ownership of the contained C object pointer - /// The underlying object is not destroyed - contained_type* release() { - T* p = p_; - p_ = nullptr; - return p; - } - - protected: - contained_type* p_{}; -}; - -// Undefined. For const types use Base> -template -struct Base; - -/// -/// Covers unowned pointers owned by either the ORT -/// or some other instance of CPP wrappers. -/// Used for ConstXXX and UnownedXXXX types that are copyable. -/// Also convenient to wrap raw OrtXX pointers . -/// -/// -template -struct Base> { - using contained_type = typename Unowned::Type; - - constexpr Base() = default; - constexpr explicit Base(contained_type* p) noexcept : p_{p} {} - - ~Base() = default; - - Base(const Base&) = default; - Base& operator=(const Base&) = default; - - Base(Base&& v) noexcept : p_{v.p_} { v.p_ = nullptr; } - Base& operator=(Base&& v) noexcept { - p_ = nullptr; - std::swap(p_, v.p_); - return *this; - } - - constexpr operator contained_type*() const noexcept { return p_; } - - protected: - contained_type* p_{}; -}; - -// Light functor to release memory with OrtAllocator -struct AllocatedFree { - OrtAllocator* allocator_; - explicit AllocatedFree(OrtAllocator* allocator) - : allocator_(allocator) {} - void operator()(void* ptr) const { - if (ptr) allocator_->Free(allocator_, ptr); - } -}; - -} // namespace detail - -struct AllocatorWithDefaultOptions; -struct Env; -struct TypeInfo; -struct Value; -struct ModelMetadata; - -/** \brief unique_ptr typedef used to own strings allocated by OrtAllocators - * and release them at the end of the scope. The lifespan of the given allocator - * must eclipse the lifespan of AllocatedStringPtr instance - */ -using AllocatedStringPtr = std::unique_ptr; - -/** \brief The Status that holds ownership of OrtStatus received from C API - * Use it to safely destroy OrtStatus* returned from the C API. Use appropriate - * constructors to construct an instance of a Status object from exceptions. - */ -struct Status : detail::Base { - explicit Status(std::nullptr_t) {} ///< Create an empty object, must be assigned a valid one to be used - explicit Status(OrtStatus* status); ///< Takes ownership of OrtStatus instance returned from the C API. Must be non-null - explicit Status(const Exception&); ///< Creates status instance out of exception - explicit Status(const std::exception&); ///< Creates status instance out of exception - std::string GetErrorMessage() const; - OrtErrorCode GetErrorCode() const; -}; - -/** \brief The ThreadingOptions - * - * The ThreadingOptions used for set global threadpools' options of The Env. - */ -struct ThreadingOptions : detail::Base { - /// \brief Wraps OrtApi::CreateThreadingOptions - ThreadingOptions(); - - /// \brief Wraps OrtApi::SetGlobalIntraOpNumThreads - ThreadingOptions& SetGlobalIntraOpNumThreads(int intra_op_num_threads); - - /// \brief Wraps OrtApi::SetGlobalInterOpNumThreads - ThreadingOptions& SetGlobalInterOpNumThreads(int inter_op_num_threads); - - /// \brief Wraps OrtApi::SetGlobalSpinControl - ThreadingOptions& SetGlobalSpinControl(int allow_spinning); - - /// \brief Wraps OrtApi::SetGlobalDenormalAsZero - ThreadingOptions& SetGlobalDenormalAsZero(); - - /// \brief Wraps OrtApi::SetGlobalCustomCreateThreadFn - ThreadingOptions& SetGlobalCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn); - - /// \brief Wraps OrtApi::SetGlobalCustomThreadCreationOptions - ThreadingOptions& SetGlobalCustomThreadCreationOptions(void* ort_custom_thread_creation_options); - - /// \brief Wraps OrtApi::SetGlobalCustomJoinThreadFn - ThreadingOptions& SetGlobalCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn); -}; - -/** \brief The Env (Environment) - * - * The Env holds the logging state used by all other objects. - * Note: One Env must be created before using any other Onnxruntime functionality - */ -struct Env : detail::Base { - explicit Env(std::nullptr_t) {} ///< Create an empty Env object, must be assigned a valid one to be used - - /// \brief Wraps OrtApi::CreateEnv - Env(OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = ""); - - /// \brief Wraps OrtApi::CreateEnvWithCustomLogger - Env(OrtLoggingLevel logging_level, const char* logid, OrtLoggingFunction logging_function, void* logger_param); - - /// \brief Wraps OrtApi::CreateEnvWithGlobalThreadPools - Env(const OrtThreadingOptions* tp_options, OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = ""); - - /// \brief Wraps OrtApi::CreateEnvWithCustomLoggerAndGlobalThreadPools - Env(const OrtThreadingOptions* tp_options, OrtLoggingFunction logging_function, void* logger_param, - OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = ""); - - /// \brief C Interop Helper - explicit Env(OrtEnv* p) : Base{p} {} - - Env& EnableTelemetryEvents(); ///< Wraps OrtApi::EnableTelemetryEvents - Env& DisableTelemetryEvents(); ///< Wraps OrtApi::DisableTelemetryEvents - - Env& UpdateEnvWithCustomLogLevel(OrtLoggingLevel log_severity_level); ///< Wraps OrtApi::UpdateEnvWithCustomLogLevel - - Env& CreateAndRegisterAllocator(const OrtMemoryInfo* mem_info, const OrtArenaCfg* arena_cfg); ///< Wraps OrtApi::CreateAndRegisterAllocator -}; - -/** \brief Custom Op Domain - * - */ -struct CustomOpDomain : detail::Base { - explicit CustomOpDomain(std::nullptr_t) {} ///< Create an empty CustomOpDomain object, must be assigned a valid one to be used - - /// \brief Wraps OrtApi::CreateCustomOpDomain - explicit CustomOpDomain(const char* domain); - - // This does not take ownership of the op, simply registers it. - void Add(const OrtCustomOp* op); ///< Wraps CustomOpDomain_Add -}; - -/** \brief RunOptions - * - */ -struct RunOptions : detail::Base { - explicit RunOptions(std::nullptr_t) {} ///< Create an empty RunOptions object, must be assigned a valid one to be used - RunOptions(); ///< Wraps OrtApi::CreateRunOptions - - RunOptions& SetRunLogVerbosityLevel(int); ///< Wraps OrtApi::RunOptionsSetRunLogVerbosityLevel - int GetRunLogVerbosityLevel() const; ///< Wraps OrtApi::RunOptionsGetRunLogVerbosityLevel - - RunOptions& SetRunLogSeverityLevel(int); ///< Wraps OrtApi::RunOptionsSetRunLogSeverityLevel - int GetRunLogSeverityLevel() const; ///< Wraps OrtApi::RunOptionsGetRunLogSeverityLevel - - RunOptions& SetRunTag(const char* run_tag); ///< wraps OrtApi::RunOptionsSetRunTag - const char* GetRunTag() const; ///< Wraps OrtApi::RunOptionsGetRunTag - - RunOptions& AddConfigEntry(const char* config_key, const char* config_value); ///< Wraps OrtApi::AddRunConfigEntry - - /** \brief Terminates all currently executing Session::Run calls that were made using this RunOptions instance - * - * If a currently executing session needs to be force terminated, this can be called from another thread to force it to fail with an error - * Wraps OrtApi::RunOptionsSetTerminate - */ - RunOptions& SetTerminate(); - - /** \brief Clears the terminate flag so this RunOptions instance can be used in a new Session::Run call without it instantly terminating - * - * Wraps OrtApi::RunOptionsUnsetTerminate - */ - RunOptions& UnsetTerminate(); -}; - - -namespace detail { -// Utility function that returns a SessionOption config entry key for a specific custom operator. -// Ex: custom_op.[custom_op_name].[config] -std::string MakeCustomOpConfigEntryKey(const char* custom_op_name, const char* config); -} // namespace detail - -/// -/// Class that represents session configuration entries for one or more custom operators. -/// -/// Example: -/// Ort::CustomOpConfigs op_configs; -/// op_configs.AddConfig("my_custom_op", "device_type", "CPU"); -/// -/// Passed to Ort::SessionOptions::RegisterCustomOpsLibrary. -/// -struct CustomOpConfigs { - CustomOpConfigs() = default; - ~CustomOpConfigs() = default; - CustomOpConfigs(const CustomOpConfigs&) = default; - CustomOpConfigs& operator=(const CustomOpConfigs&) = default; - CustomOpConfigs(CustomOpConfigs&& o) = default; - CustomOpConfigs& operator=(CustomOpConfigs&& o) = default; - - /** \brief Adds a session configuration entry/value for a specific custom operator. - * - * \param custom_op_name The name of the custom operator for which to add a configuration entry. - * Must match the name returned by the CustomOp's GetName() method. - * \param config_key The name of the configuration entry. - * \param config_value The value of the configuration entry. - * \return A reference to this object to enable call chaining. - */ - CustomOpConfigs& AddConfig(const char* custom_op_name, const char* config_key, const char* config_value); - - /** \brief Returns a flattened map of custom operator configuration entries and their values. - * - * The keys has been flattened to include both the custom operator name and the configuration entry key name. - * For example, a prior call to AddConfig("my_op", "key", "value") corresponds to the flattened key/value pair - * {"my_op.key", "value"}. - * - * \return An unordered map of flattened configurations. - */ - const std::unordered_map& GetFlattenedConfigs() const; - - private: - std::unordered_map flat_configs_; -}; - -/** \brief Options object used when creating a new Session object - * - * Wraps ::OrtSessionOptions object and methods - */ - -struct SessionOptions; - -namespace detail { -// we separate const-only methods because passing const ptr to non-const methods -// is only discovered when inline methods are compiled which is counter-intuitive -template -struct ConstSessionOptionsImpl : Base { - using B = Base; - using B::B; - - SessionOptions Clone() const; ///< Creates and returns a copy of this SessionOptions object. Wraps OrtApi::CloneSessionOptions - - std::string GetConfigEntry(const char* config_key) const; ///< Wraps OrtApi::GetSessionConfigEntry - bool HasConfigEntry(const char* config_key) const; ///< Wraps OrtApi::HasSessionConfigEntry - std::string GetConfigEntryOrDefault(const char* config_key, const std::string& def); -}; - -template -struct SessionOptionsImpl : ConstSessionOptionsImpl { - using B = ConstSessionOptionsImpl; - using B::B; - - SessionOptionsImpl& SetIntraOpNumThreads(int intra_op_num_threads); ///< Wraps OrtApi::SetIntraOpNumThreads - SessionOptionsImpl& SetInterOpNumThreads(int inter_op_num_threads); ///< Wraps OrtApi::SetInterOpNumThreads - SessionOptionsImpl& SetGraphOptimizationLevel(GraphOptimizationLevel graph_optimization_level); ///< Wraps OrtApi::SetSessionGraphOptimizationLevel - - SessionOptionsImpl& EnableCpuMemArena(); ///< Wraps OrtApi::EnableCpuMemArena - SessionOptionsImpl& DisableCpuMemArena(); ///< Wraps OrtApi::DisableCpuMemArena - - SessionOptionsImpl& SetOptimizedModelFilePath(const ORTCHAR_T* optimized_model_file); ///< Wraps OrtApi::SetOptimizedModelFilePath - - SessionOptionsImpl& EnableProfiling(const ORTCHAR_T* profile_file_prefix); ///< Wraps OrtApi::EnableProfiling - SessionOptionsImpl& DisableProfiling(); ///< Wraps OrtApi::DisableProfiling - - SessionOptionsImpl& EnableOrtCustomOps(); ///< Wraps OrtApi::EnableOrtCustomOps - - SessionOptionsImpl& EnableMemPattern(); ///< Wraps OrtApi::EnableMemPattern - SessionOptionsImpl& DisableMemPattern(); ///< Wraps OrtApi::DisableMemPattern - - SessionOptionsImpl& SetExecutionMode(ExecutionMode execution_mode); ///< Wraps OrtApi::SetSessionExecutionMode - - SessionOptionsImpl& SetLogId(const char* logid); ///< Wraps OrtApi::SetSessionLogId - SessionOptionsImpl& SetLogSeverityLevel(int level); ///< Wraps OrtApi::SetSessionLogSeverityLevel - - SessionOptionsImpl& Add(OrtCustomOpDomain* custom_op_domain); ///< Wraps OrtApi::AddCustomOpDomain - - SessionOptionsImpl& DisablePerSessionThreads(); ///< Wraps OrtApi::DisablePerSessionThreads - - SessionOptionsImpl& AddConfigEntry(const char* config_key, const char* config_value); ///< Wraps OrtApi::AddSessionConfigEntry - - SessionOptionsImpl& AddInitializer(const char* name, const OrtValue* ort_val); ///< Wraps OrtApi::AddInitializer - SessionOptionsImpl& AddExternalInitializers(const std::vector& names, const std::vector& ort_values); ///< Wraps OrtApi::AddExternalInitializers - - SessionOptionsImpl& AppendExecutionProvider_CUDA(const OrtCUDAProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA - SessionOptionsImpl& AppendExecutionProvider_CUDA_V2(const OrtCUDAProviderOptionsV2& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA_V2 - SessionOptionsImpl& AppendExecutionProvider_ROCM(const OrtROCMProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_ROCM - SessionOptionsImpl& AppendExecutionProvider_OpenVINO(const OrtOpenVINOProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO - SessionOptionsImpl& AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT - SessionOptionsImpl& AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT - SessionOptionsImpl& AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions& provider_options); ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_MIGraphX - ///< Wraps OrtApi::SessionOptionsAppendExecutionProvider_CANN - SessionOptionsImpl& AppendExecutionProvider_CANN(const OrtCANNProviderOptions& provider_options); - /// Wraps OrtApi::SessionOptionsAppendExecutionProvider. Currently supports SNPE and XNNPACK. - SessionOptionsImpl& AppendExecutionProvider(const std::string& provider_name, - const std::unordered_map& provider_options = {}); - - SessionOptionsImpl& SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn); ///< Wraps OrtApi::SessionOptionsSetCustomCreateThreadFn - SessionOptionsImpl& SetCustomThreadCreationOptions(void* ort_custom_thread_creation_options); ///< Wraps OrtApi::SessionOptionsSetCustomThreadCreationOptions - SessionOptionsImpl& SetCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn); ///< Wraps OrtApi::SessionOptionsSetCustomJoinThreadFn - - ///< Registers the custom operator from the specified shared library via OrtApi::RegisterCustomOpsLibrary_V2. - ///< The custom operator configurations are optional. If provided, custom operator configs are set via - ///< OrtApi::AddSessionConfigEntry. - SessionOptionsImpl& RegisterCustomOpsLibrary(const ORTCHAR_T* library_name, const CustomOpConfigs& custom_op_configs = {}); - - SessionOptionsImpl& RegisterCustomOpsUsingFunction(const char* function_name); ///< Wraps OrtApi::RegisterCustomOpsUsingFunction -}; -} // namespace detail - -using UnownedSessionOptions = detail::SessionOptionsImpl>; -using ConstSessionOptions = detail::ConstSessionOptionsImpl>; - -/** \brief Wrapper around ::OrtSessionOptions - * - */ -struct SessionOptions : detail::SessionOptionsImpl { - explicit SessionOptions(std::nullptr_t) {} ///< Create an empty SessionOptions object, must be assigned a valid one to be used - SessionOptions(); ///< Wraps OrtApi::CreateSessionOptions - explicit SessionOptions(OrtSessionOptions* p) : SessionOptionsImpl{p} {} ///< Used for interop with the C API - UnownedSessionOptions GetUnowned() const { return UnownedSessionOptions{this->p_}; } - ConstSessionOptions GetConst() const { return ConstSessionOptions{this->p_}; } -}; - -/** \brief Wrapper around ::OrtModelMetadata - * - */ -struct ModelMetadata : detail::Base { - explicit ModelMetadata(std::nullptr_t) {} ///< Create an empty ModelMetadata object, must be assigned a valid one to be used - explicit ModelMetadata(OrtModelMetadata* p) : Base{p} {} ///< Used for interop with the C API - - /** \brief Returns a copy of the producer name. - * - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetProducerNameAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetProducerName - - /** \brief Returns a copy of the graph name. - * - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetGraphNameAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphName - - /** \brief Returns a copy of the domain name. - * - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetDomainAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDomain - - /** \brief Returns a copy of the description. - * - * \param allocator to allocate memory for the copy of the string returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetDescriptionAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetDescription - - /** \brief Returns a copy of the graph description. - * - * \param allocator to allocate memory for the copy of the string returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetGraphDescriptionAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetGraphDescription - - /** \brief Returns a vector of copies of the custom metadata keys. - * - * \param allocator to allocate memory for the copy of the string returned - * \return a instance std::vector of smart pointers that would deallocate the buffers when out of scope. - * The OrtAllocator instance must be valid at the point of memory release. - */ - std::vector GetCustomMetadataMapKeysAllocated(OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataGetCustomMetadataMapKeys - - /** \brief Looks up a value by a key in the Custom Metadata map - * - * \param key zero terminated string key to lookup - * \param allocator to allocate memory for the copy of the string returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * maybe nullptr if key is not found. - * - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr LookupCustomMetadataMapAllocated(const char* key, OrtAllocator* allocator) const; ///< Wraps OrtApi::ModelMetadataLookupCustomMetadataMap - - int64_t GetVersion() const; ///< Wraps OrtApi::ModelMetadataGetVersion -}; - -struct IoBinding; - -namespace detail { - -// we separate const-only methods because passing const ptr to non-const methods -// is only discovered when inline methods are compiled which is counter-intuitive -template -struct ConstSessionImpl : Base { - using B = Base; - using B::B; - - size_t GetInputCount() const; ///< Returns the number of model inputs - size_t GetOutputCount() const; ///< Returns the number of model outputs - size_t GetOverridableInitializerCount() const; ///< Returns the number of inputs that have defaults that can be overridden - - /** \brief Returns a copy of input name at the specified index. - * - * \param index must less than the value returned by GetInputCount() - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetInputNameAllocated(size_t index, OrtAllocator* allocator) const; - - /** \brief Returns a copy of output name at then specified index. - * - * \param index must less than the value returned by GetOutputCount() - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetOutputNameAllocated(size_t index, OrtAllocator* allocator) const; - - /** \brief Returns a copy of the overridable initializer name at then specified index. - * - * \param index must less than the value returned by GetOverridableInitializerCount() - * \param allocator to allocate memory for the copy of the name returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr GetOverridableInitializerNameAllocated(size_t index, OrtAllocator* allocator) const; ///< Wraps OrtApi::SessionGetOverridableInitializerName - - uint64_t GetProfilingStartTimeNs() const; ///< Wraps OrtApi::SessionGetProfilingStartTimeNs - ModelMetadata GetModelMetadata() const; ///< Wraps OrtApi::SessionGetModelMetadata - - TypeInfo GetInputTypeInfo(size_t index) const; ///< Wraps OrtApi::SessionGetInputTypeInfo - TypeInfo GetOutputTypeInfo(size_t index) const; ///< Wraps OrtApi::SessionGetOutputTypeInfo - TypeInfo GetOverridableInitializerTypeInfo(size_t index) const; ///< Wraps OrtApi::SessionGetOverridableInitializerTypeInfo -}; - -template -struct SessionImpl : ConstSessionImpl { - using B = ConstSessionImpl; - using B::B; - - /** \brief Run the model returning results in an Ort allocated vector. - * - * Wraps OrtApi::Run - * - * The caller provides a list of inputs and a list of the desired outputs to return. - * - * See the output logs for more information on warnings/errors that occur while processing the model. - * Common errors are.. (TODO) - * - * \param[in] run_options - * \param[in] input_names Array of null terminated strings of length input_count that is the list of input names - * \param[in] input_values Array of Value objects of length input_count that is the list of input values - * \param[in] input_count Number of inputs (the size of the input_names & input_values arrays) - * \param[in] output_names Array of C style strings of length output_count that is the list of output names - * \param[in] output_count Number of outputs (the size of the output_names array) - * \return A std::vector of Value objects that directly maps to the output_names array (eg. output_name[0] is the first entry of the returned vector) - */ - std::vector Run(const RunOptions& run_options, const char* const* input_names, const Value* input_values, size_t input_count, - const char* const* output_names, size_t output_count); - - /** \brief Run the model returning results in user provided outputs - * Same as Run(const RunOptions&, const char* const*, const Value*, size_t,const char* const*, size_t) - */ - void Run(const RunOptions& run_options, const char* const* input_names, const Value* input_values, size_t input_count, - const char* const* output_names, Value* output_values, size_t output_count); - - void Run(const RunOptions& run_options, const IoBinding&); ///< Wraps OrtApi::RunWithBinding - - /** \brief End profiling and return a copy of the profiling file name. - * - * \param allocator to allocate memory for the copy of the string returned - * \return a instance of smart pointer that would deallocate the buffer when out of scope. - * The OrtAllocator instances must be valid at the point of memory release. - */ - AllocatedStringPtr EndProfilingAllocated(OrtAllocator* allocator); ///< Wraps OrtApi::SessionEndProfiling -}; - -} // namespace detail - -using ConstSession = detail::ConstSessionImpl>; -using UnownedSession = detail::SessionImpl>; - -/** \brief Wrapper around ::OrtSession - * - */ -struct Session : detail::SessionImpl { - explicit Session(std::nullptr_t) {} ///< Create an empty Session object, must be assigned a valid one to be used - Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options); ///< Wraps OrtApi::CreateSession - Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options, - OrtPrepackedWeightsContainer* prepacked_weights_container); ///< Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer - Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options); ///< Wraps OrtApi::CreateSessionFromArray - Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options, - OrtPrepackedWeightsContainer* prepacked_weights_container); ///< Wraps OrtApi::CreateSessionFromArrayWithPrepackedWeightsContainer - - ConstSession GetConst() const { return ConstSession{this->p_}; } - UnownedSession GetUnowned() const { return UnownedSession{this->p_}; } -}; - -namespace detail { -template -struct MemoryInfoImpl : Base { - using B = Base; - using B::B; - - std::string GetAllocatorName() const; - OrtAllocatorType GetAllocatorType() const; - int GetDeviceId() const; - OrtMemoryInfoDeviceType GetDeviceType() const; - OrtMemType GetMemoryType() const; - - template - bool operator==(const MemoryInfoImpl& o) const; -}; -} // namespace detail - -// Const object holder that does not own the underlying object -using ConstMemoryInfo = detail::MemoryInfoImpl>; - -/** \brief Wrapper around ::OrtMemoryInfo - * - */ -struct MemoryInfo : detail::MemoryInfoImpl { - static MemoryInfo CreateCpu(OrtAllocatorType type, OrtMemType mem_type1); - explicit MemoryInfo(std::nullptr_t) {} ///< No instance is created - explicit MemoryInfo(OrtMemoryInfo* p) : MemoryInfoImpl{p} {} ///< Take ownership of a pointer created by C Api - MemoryInfo(const char* name, OrtAllocatorType type, int id, OrtMemType mem_type); - ConstMemoryInfo GetConst() const { return ConstMemoryInfo{this->p_}; } -}; - -namespace detail { -template -struct TensorTypeAndShapeInfoImpl : Base { - using B = Base; - using B::B; - - ONNXTensorElementDataType GetElementType() const; ///< Wraps OrtApi::GetTensorElementType - size_t GetElementCount() const; ///< Wraps OrtApi::GetTensorShapeElementCount - - size_t GetDimensionsCount() const; ///< Wraps OrtApi::GetDimensionsCount - - /** \deprecated use GetShape() returning std::vector - * [[deprecated]] - * This interface is unsafe to use - */ - [[deprecated("use GetShape()")]] void GetDimensions(int64_t* values, size_t values_count) const; ///< Wraps OrtApi::GetDimensions - - void GetSymbolicDimensions(const char** values, size_t values_count) const; ///< Wraps OrtApi::GetSymbolicDimensions - - std::vector GetShape() const; ///< Uses GetDimensionsCount & GetDimensions to return a std::vector of the shape -}; - -} // namespace detail - -using ConstTensorTypeAndShapeInfo = detail::TensorTypeAndShapeInfoImpl>; - -/** \brief Wrapper around ::OrtTensorTypeAndShapeInfo - * - */ -struct TensorTypeAndShapeInfo : detail::TensorTypeAndShapeInfoImpl { - explicit TensorTypeAndShapeInfo(std::nullptr_t) {} ///< Create an empty TensorTypeAndShapeInfo object, must be assigned a valid one to be used - explicit TensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo* p) : TensorTypeAndShapeInfoImpl{p} {} ///< Used for interop with the C API - ConstTensorTypeAndShapeInfo GetConst() const { return ConstTensorTypeAndShapeInfo{this->p_}; } -}; - -namespace detail { -template -struct SequenceTypeInfoImpl : Base { - using B = Base; - using B::B; - TypeInfo GetSequenceElementType() const; ///< Wraps OrtApi::GetSequenceElementType -}; - -} // namespace detail - -using ConstSequenceTypeInfo = detail::SequenceTypeInfoImpl>; - -/** \brief Wrapper around ::OrtSequenceTypeInfo - * - */ -struct SequenceTypeInfo : detail::SequenceTypeInfoImpl { - explicit SequenceTypeInfo(std::nullptr_t) {} ///< Create an empty SequenceTypeInfo object, must be assigned a valid one to be used - explicit SequenceTypeInfo(OrtSequenceTypeInfo* p) : SequenceTypeInfoImpl{p} {} ///< Used for interop with the C API - ConstSequenceTypeInfo GetConst() const { return ConstSequenceTypeInfo{this->p_}; } -}; - -namespace detail { -template -struct MapTypeInfoImpl : detail::Base { - using B = Base; - using B::B; - ONNXTensorElementDataType GetMapKeyType() const; ///< Wraps OrtApi::GetMapKeyType - TypeInfo GetMapValueType() const; ///< Wraps OrtApi::GetMapValueType -}; - -} // namespace detail - -using ConstMapTypeInfo = detail::MapTypeInfoImpl>; - -/** \brief Wrapper around ::OrtMapTypeInfo - * - */ -struct MapTypeInfo : detail::MapTypeInfoImpl { - explicit MapTypeInfo(std::nullptr_t) {} ///< Create an empty MapTypeInfo object, must be assigned a valid one to be used - explicit MapTypeInfo(OrtMapTypeInfo* p) : MapTypeInfoImpl{p} {} ///< Used for interop with the C API - ConstMapTypeInfo GetConst() const { return ConstMapTypeInfo{this->p_}; } -}; - -namespace detail { -template -struct TypeInfoImpl : detail::Base { - using B = Base; - using B::B; - - ConstTensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const; ///< Wraps OrtApi::CastTypeInfoToTensorInfo - ConstSequenceTypeInfo GetSequenceTypeInfo() const; ///< Wraps OrtApi::CastTypeInfoToSequenceTypeInfo - ConstMapTypeInfo GetMapTypeInfo() const; ///< Wraps OrtApi::CastTypeInfoToMapTypeInfo - - ONNXType GetONNXType() const; -}; -} // namespace detail - -/// -/// Contains a constant, unowned OrtTypeInfo that can be copied and passed around by value. -/// Provides access to const OrtTypeInfo APIs. -/// -using ConstTypeInfo = detail::TypeInfoImpl>; - -/// -/// Type information that may contain either TensorTypeAndShapeInfo or -/// the information about contained sequence or map depending on the ONNXType. -/// -struct TypeInfo : detail::TypeInfoImpl { - explicit TypeInfo(std::nullptr_t) {} ///< Create an empty TypeInfo object, must be assigned a valid one to be used - explicit TypeInfo(OrtTypeInfo* p) : TypeInfoImpl{p} {} ///< C API Interop - - ConstTypeInfo GetConst() const { return ConstTypeInfo{this->p_}; } -}; - -namespace detail { -// This structure is used to feed sparse tensor values -// information for use with FillSparseTensor() API -// if the data type for the sparse tensor values is numeric -// use data.p_data, otherwise, use data.str pointer to feed -// values. data.str is an array of const char* that are zero terminated. -// number of strings in the array must match shape size. -// For fully sparse tensors use shape {0} and set p_data/str -// to nullptr. -struct OrtSparseValuesParam { - const int64_t* values_shape; - size_t values_shape_len; - union { - const void* p_data; - const char** str; - } data; -}; - -// Provides a way to pass shape in a single -// argument -struct Shape { - const int64_t* shape; - size_t shape_len; -}; - -template -struct ConstValueImpl : Base { - using B = Base; - using B::B; - - /// - /// Obtains a pointer to a user defined data for experimental purposes - /// - template - void GetOpaqueData(const char* domain, const char* type_name, R&) const; ///< Wraps OrtApi::GetOpaqueValue - - bool IsTensor() const; ///< Returns true if Value is a tensor, false for other types like map/sequence/etc - bool HasValue() const; /// < Return true if OrtValue contains data and returns false if the OrtValue is a None - - size_t GetCount() const; // If a non tensor, returns 2 for map and N for sequence, where N is the number of elements - Value GetValue(int index, OrtAllocator* allocator) const; - - /// - /// This API returns a full length of string data contained within either a tensor or a sparse Tensor. - /// For sparse tensor it returns a full length of stored non-empty strings (values). The API is useful - /// for allocating necessary memory and calling GetStringTensorContent(). - /// - /// total length of UTF-8 encoded bytes contained. No zero terminators counted. - size_t GetStringTensorDataLength() const; - - /// - /// The API copies all of the UTF-8 encoded string data contained within a tensor or a sparse tensor - /// into a supplied buffer. Use GetStringTensorDataLength() to find out the length of the buffer to allocate. - /// The user must also allocate offsets buffer with the number of entries equal to that of the contained - /// strings. - /// - /// Strings are always assumed to be on CPU, no X-device copy. - /// - /// user allocated buffer - /// length in bytes of the allocated buffer - /// a pointer to the offsets user allocated buffer - /// count of offsets, must be equal to the number of strings contained. - /// that can be obtained from the shape of the tensor or from GetSparseTensorValuesTypeAndShapeInfo() - /// for sparse tensors - void GetStringTensorContent(void* buffer, size_t buffer_length, size_t* offsets, size_t offsets_count) const; - - /// - /// Returns a const typed pointer to the tensor contained data. - /// No type checking is performed, the caller must ensure the type matches the tensor type. - /// - /// - /// const pointer to data, no copies made - template - const R* GetTensorData() const; ///< Wraps OrtApi::GetTensorMutableData /// - - /// - /// Returns a non-typed pointer to a tensor contained data. - /// - /// const pointer to data, no copies made - const void* GetTensorRawData() const; - - /// - /// The API returns type information for data contained in a tensor. For sparse - /// tensors it returns type information for contained non-zero values. - /// It returns dense shape for sparse tensors. - /// - /// TypeInfo - TypeInfo GetTypeInfo() const; - - /// - /// The API returns type information for data contained in a tensor. For sparse - /// tensors it returns type information for contained non-zero values. - /// It returns dense shape for sparse tensors. - /// - /// TensorTypeAndShapeInfo - TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const; - - /// - /// This API returns information about the memory allocation used to hold data. - /// - /// Non owning instance of MemoryInfo - ConstMemoryInfo GetTensorMemoryInfo() const; - - /// - /// The API copies UTF-8 encoded bytes for the requested string element - /// contained within a tensor or a sparse tensor into a provided buffer. - /// Use GetStringTensorElementLength() to obtain the length of the buffer to allocate. - /// - /// - /// - /// - void GetStringTensorElement(size_t buffer_length, size_t element_index, void* buffer) const; - - /// - /// The API returns a byte length of UTF-8 encoded string element - /// contained in either a tensor or a spare tensor values. - /// - /// - /// byte length for the specified string element - size_t GetStringTensorElementLength(size_t element_index) const; - -#if !defined(DISABLE_SPARSE_TENSORS) - /// - /// The API returns the sparse data format this OrtValue holds in a sparse tensor. - /// If the sparse tensor was not fully constructed, i.e. Use*() or Fill*() API were not used - /// the value returned is ORT_SPARSE_UNDEFINED. - /// - /// Format enum - OrtSparseFormat GetSparseFormat() const; - - /// - /// The API returns type and shape information for stored non-zero values of the - /// sparse tensor. Use GetSparseTensorValues() to obtain values buffer pointer. - /// - /// TensorTypeAndShapeInfo values information - TensorTypeAndShapeInfo GetSparseTensorValuesTypeAndShapeInfo() const; - - /// - /// The API returns type and shape information for the specified indices. Each supported - /// indices have their own enum values even if a give format has more than one kind of indices. - /// Use GetSparseTensorIndicesData() to obtain pointer to indices buffer. - /// - /// enum requested - /// type and shape information - TensorTypeAndShapeInfo GetSparseTensorIndicesTypeShapeInfo(OrtSparseIndicesFormat format) const; - - /// - /// The API retrieves a pointer to the internal indices buffer. The API merely performs - /// a convenience data type casting on the return type pointer. Make sure you are requesting - /// the right type, use GetSparseTensorIndicesTypeShapeInfo(); - /// - /// type to cast to - /// requested indices kind - /// number of indices entries - /// Pinter to the internal sparse tensor buffer containing indices. Do not free this pointer. - template - const R* GetSparseTensorIndicesData(OrtSparseIndicesFormat indices_format, size_t& num_indices) const; - - /// - /// Returns true if the OrtValue contains a sparse tensor - /// - /// - bool IsSparseTensor() const; - - /// - /// The API returns a pointer to an internal buffer of the sparse tensor - /// containing non-zero values. The API merely does casting. Make sure you - /// are requesting the right data type by calling GetSparseTensorValuesTypeAndShapeInfo() - /// first. - /// - /// numeric data types only. Use GetStringTensor*() to retrieve strings. - /// a pointer to the internal values buffer. Do not free this pointer. - template - const R* GetSparseTensorValues() const; - -#endif -}; - -template -struct ValueImpl : ConstValueImpl { - using B = ConstValueImpl; - using B::B; - - /// - /// Returns a non-const typed pointer to an OrtValue/Tensor contained buffer - /// No type checking is performed, the caller must ensure the type matches the tensor type. - /// - /// non-const pointer to data, no copies made - template - R* GetTensorMutableData(); - - /// - /// Returns a non-typed non-const pointer to a tensor contained data. - /// - /// pointer to data, no copies made - void* GetTensorMutableRawData(); - - /// - // Obtain a reference to an element of data at the location specified - /// by the vector of dims. - /// - /// - /// [in] expressed by a vecotr of dimensions offsets - /// - template - R& At(const std::vector& location); - - /// - /// Set all strings at once in a string tensor - /// - /// [in] An array of strings. Each string in this array must be null terminated. - /// [in] Count of strings in s (Must match the size of \p value's tensor shape) - void FillStringTensor(const char* const* s, size_t s_len); - - /// - /// Set a single string in a string tensor - /// - /// [in] A null terminated UTF-8 encoded string - /// [in] Index of the string in the tensor to set - void FillStringTensorElement(const char* s, size_t index); - -#if !defined(DISABLE_SPARSE_TENSORS) - /// - /// Supplies COO format specific indices and marks the contained sparse tensor as being a COO format tensor. - /// Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user - /// allocated buffers lifespan must eclipse that of the OrtValue. - /// The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. - /// - /// pointer to the user allocated buffer with indices. Use nullptr for fully sparse tensors. - /// number of indices entries. Use 0 for fully sparse tensors - void UseCooIndices(int64_t* indices_data, size_t indices_num); - - /// - /// Supplies CSR format specific indices and marks the contained sparse tensor as being a CSR format tensor. - /// Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user - /// allocated buffers lifespan must eclipse that of the OrtValue. - /// The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. - /// - /// pointer to the user allocated buffer with inner indices or nullptr for fully sparse tensors - /// number of csr inner indices or 0 for fully sparse tensors - /// pointer to the user allocated buffer with outer indices or nullptr for fully sparse tensors - /// number of csr outer indices or 0 for fully sparse tensors - void UseCsrIndices(int64_t* inner_data, size_t inner_num, int64_t* outer_data, size_t outer_num); - - /// - /// Supplies BlockSparse format specific indices and marks the contained sparse tensor as being a BlockSparse format tensor. - /// Values are supplied with a CreateSparseTensor() API. The supplied indices are not copied and the user - /// allocated buffers lifespan must eclipse that of the OrtValue. - /// The location of the indices is assumed to be the same as specified by OrtMemoryInfo argument at the creation time. - /// - /// indices shape or a {0} for fully sparse - /// user allocated buffer with indices or nullptr for fully spare tensors - void UseBlockSparseIndices(const Shape& indices_shape, int32_t* indices_data); - - /// - /// The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API - /// and copy the values and COO indices into it. If data_mem_info specifies that the data is located - /// at difference device than the allocator, a X-device copy will be performed if possible. - /// - /// specified buffer memory description - /// values buffer information. - /// coo indices buffer or nullptr for fully sparse data - /// number of COO indices or 0 for fully sparse data - void FillSparseTensorCoo(const OrtMemoryInfo* data_mem_info, const OrtSparseValuesParam& values_param, - const int64_t* indices_data, size_t indices_num); - - /// - /// The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API - /// and copy the values and CSR indices into it. If data_mem_info specifies that the data is located - /// at difference device than the allocator, a X-device copy will be performed if possible. - /// - /// specified buffer memory description - /// values buffer information - /// csr inner indices pointer or nullptr for fully sparse tensors - /// number of csr inner indices or 0 for fully sparse tensors - /// pointer to csr indices data or nullptr for fully sparse tensors - /// number of csr outer indices or 0 - void FillSparseTensorCsr(const OrtMemoryInfo* data_mem_info, - const OrtSparseValuesParam& values, - const int64_t* inner_indices_data, size_t inner_indices_num, - const int64_t* outer_indices_data, size_t outer_indices_num); - - /// - /// The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API - /// and copy the values and BlockSparse indices into it. If data_mem_info specifies that the data is located - /// at difference device than the allocator, a X-device copy will be performed if possible. - /// - /// specified buffer memory description - /// values buffer information - /// indices shape. use {0} for fully sparse tensors - /// pointer to indices data or nullptr for fully sparse tensors - void FillSparseTensorBlockSparse(const OrtMemoryInfo* data_mem_info, - const OrtSparseValuesParam& values, - const Shape& indices_shape, - const int32_t* indices_data); - -#endif -}; - -} // namespace detail - -using ConstValue = detail::ConstValueImpl>; -using UnownedValue = detail::ValueImpl>; - -/** \brief Wrapper around ::OrtValue - * - */ -struct Value : detail::ValueImpl { - using Base = detail::ValueImpl; - using OrtSparseValuesParam = detail::OrtSparseValuesParam; - using Shape = detail::Shape; - - explicit Value(std::nullptr_t) {} ///< Create an empty Value object, must be assigned a valid one to be used - explicit Value(OrtValue* p) : Base{p} {} ///< Used for interop with the C API - Value(Value&&) = default; - Value& operator=(Value&&) = default; - - ConstValue GetConst() const { return ConstValue{this->p_}; } - UnownedValue GetUnowned() const { return UnownedValue{this->p_}; } - - /** \brief Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue. - * \tparam T The numeric datatype. This API is not suitable for strings. - * \param info Memory description of where the p_data buffer resides (CPU vs GPU etc). - * \param p_data Pointer to the data buffer. - * \param p_data_element_count The number of elements in the data buffer. - * \param shape Pointer to the tensor shape dimensions. - * \param shape_len The number of tensor shape dimensions. - */ - template - static Value CreateTensor(const OrtMemoryInfo* info, T* p_data, size_t p_data_element_count, const int64_t* shape, size_t shape_len); - - /** \brief Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue. - * \param info Memory description of where the p_data buffer resides (CPU vs GPU etc). - * \param p_data Pointer to the data buffer. - * \param p_data_byte_count The number of bytes in the data buffer. - * \param shape Pointer to the tensor shape dimensions. - * \param shape_len The number of tensor shape dimensions. - * \param type The data type. - */ - static Value CreateTensor(const OrtMemoryInfo* info, void* p_data, size_t p_data_byte_count, const int64_t* shape, size_t shape_len, - ONNXTensorElementDataType type); - - /** \brief Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue. - * \tparam T The numeric datatype. This API is not suitable for strings. - * \param allocator The allocator to use. - * \param shape Pointer to the tensor shape dimensions. - * \param shape_len The number of tensor shape dimensions. - */ - template - static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len); - - /** \brief Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue. - * \param allocator The allocator to use. - * \param shape Pointer to the tensor shape dimensions. - * \param shape_len The number of tensor shape dimensions. - * \param type The data type. - */ - static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type); - - static Value CreateMap(Value& keys, Value& values); ///< Wraps OrtApi::CreateValue - static Value CreateSequence(std::vector& values); ///< Wraps OrtApi::CreateValue - - template - static Value CreateOpaque(const char* domain, const char* type_name, const T&); ///< Wraps OrtApi::CreateOpaqueValue - -#if !defined(DISABLE_SPARSE_TENSORS) - /// - /// This is a simple forwarding method to the other overload that helps deducing - /// data type enum value from the type of the buffer. - /// - /// numeric datatype. This API is not suitable for strings. - /// Memory description where the user buffers reside (CPU vs GPU etc) - /// pointer to the user supplied buffer, use nullptr for fully sparse tensors - /// a would be dense shape of the tensor - /// non zero values shape. Use a single 0 shape for fully sparse tensors. - /// - template - static Value CreateSparseTensor(const OrtMemoryInfo* info, T* p_data, const Shape& dense_shape, - const Shape& values_shape); - - /// - /// Creates an OrtValue instance containing SparseTensor. This constructs - /// a sparse tensor that makes use of user allocated buffers. It does not make copies - /// of the user provided data and does not modify it. The lifespan of user provided buffers should - /// eclipse the life span of the resulting OrtValue. This call constructs an instance that only contain - /// a pointer to non-zero values. To fully populate the sparse tensor call UseIndices() API below - /// to supply a sparse format specific indices. - /// This API is not suitable for string data. Use CreateSparseTensor() with allocator specified so strings - /// can be properly copied into the allocated buffer. - /// - /// Memory description where the user buffers reside (CPU vs GPU etc) - /// pointer to the user supplied buffer, use nullptr for fully sparse tensors - /// a would be dense shape of the tensor - /// non zero values shape. Use a single 0 shape for fully sparse tensors. - /// data type - /// Ort::Value instance containing SparseTensor - static Value CreateSparseTensor(const OrtMemoryInfo* info, void* p_data, const Shape& dense_shape, - const Shape& values_shape, ONNXTensorElementDataType type); - - /// - /// This is a simple forwarding method to the below CreateSparseTensor. - /// This helps to specify data type enum in terms of C++ data type. - /// Use CreateSparseTensor - /// - /// numeric data type only. String data enum must be specified explicitly. - /// allocator to use - /// a would be dense shape of the tensor - /// Ort::Value - template - static Value CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape); - - /// - /// Creates an instance of OrtValue containing sparse tensor. The created instance has no data. - /// The data must be supplied by on of the FillSparseTensor() methods that take both non-zero values - /// and indices. The data will be copied into a buffer that would be allocated using the supplied allocator. - /// Use this API to create OrtValues that contain sparse tensors with all supported data types including - /// strings. - /// - /// allocator to use. The allocator lifespan must eclipse that of the resulting OrtValue - /// a would be dense shape of the tensor - /// data type - /// an instance of Ort::Value - static Value CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape, ONNXTensorElementDataType type); - -#endif // !defined(DISABLE_SPARSE_TENSORS) -}; - -/// -/// Represents native memory allocation coming from one of the -/// OrtAllocators registered with OnnxRuntime. -/// Use it to wrap an allocation made by an allocator -/// so it can be automatically released when no longer needed. -/// -struct MemoryAllocation { - MemoryAllocation(OrtAllocator* allocator, void* p, size_t size); - ~MemoryAllocation(); - MemoryAllocation(const MemoryAllocation&) = delete; - MemoryAllocation& operator=(const MemoryAllocation&) = delete; - MemoryAllocation(MemoryAllocation&&) noexcept; - MemoryAllocation& operator=(MemoryAllocation&&) noexcept; - - void* get() { return p_; } - size_t size() const { return size_; } - - private: - OrtAllocator* allocator_; - void* p_; - size_t size_; -}; - -namespace detail { -template -struct AllocatorImpl : Base { - using B = Base; - using B::B; - - void* Alloc(size_t size); - MemoryAllocation GetAllocation(size_t size); - void Free(void* p); - ConstMemoryInfo GetInfo() const; -}; - -} // namespace detail - -/** \brief Wrapper around ::OrtAllocator default instance that is owned by Onnxruntime - * - */ -struct AllocatorWithDefaultOptions : detail::AllocatorImpl> { - explicit AllocatorWithDefaultOptions(std::nullptr_t) {} ///< Convenience to create a class member and then replace with an instance - AllocatorWithDefaultOptions(); -}; - -/** \brief Wrapper around ::OrtAllocator - * - */ -struct Allocator : detail::AllocatorImpl { - explicit Allocator(std::nullptr_t) {} ///< Convenience to create a class member and then replace with an instance - Allocator(const Session& session, const OrtMemoryInfo*); -}; - -using UnownedAllocator = detail::AllocatorImpl>; - -namespace detail { -namespace binding_utils { -// Bring these out of template -std::vector GetOutputNamesHelper(const OrtIoBinding* binding, OrtAllocator*); -std::vector GetOutputValuesHelper(const OrtIoBinding* binding, OrtAllocator*); -} // namespace binding_utils - -template -struct ConstIoBindingImpl : Base { - using B = Base; - using B::B; - - std::vector GetOutputNames() const; - std::vector GetOutputNames(OrtAllocator*) const; - std::vector GetOutputValues() const; - std::vector GetOutputValues(OrtAllocator*) const; -}; - -template -struct IoBindingImpl : ConstIoBindingImpl { - using B = ConstIoBindingImpl; - using B::B; - - void BindInput(const char* name, const Value&); - void BindOutput(const char* name, const Value&); - void BindOutput(const char* name, const OrtMemoryInfo*); - void ClearBoundInputs(); - void ClearBoundOutputs(); - void SynchronizeInputs(); - void SynchronizeOutputs(); -}; - -} // namespace detail - -using ConstIoBinding = detail::ConstIoBindingImpl>; -using UnownedIoBinding = detail::IoBindingImpl>; - -/** \brief Wrapper around ::OrtIoBinding - * - */ -struct IoBinding : detail::IoBindingImpl { - explicit IoBinding(std::nullptr_t) {} ///< Create an empty object for convenience. Sometimes, we want to initialize members later. - explicit IoBinding(Session& session); - ConstIoBinding GetConst() const { return ConstIoBinding{this->p_}; } - UnownedIoBinding GetUnowned() const { return UnownedIoBinding{this->p_}; } -}; - -/*! \struct Ort::ArenaCfg - * \brief it is a structure that represents the configuration of an arena based allocator - * \details Please see docs/C_API.md for details - */ -struct ArenaCfg : detail::Base { - explicit ArenaCfg(std::nullptr_t) {} ///< Create an empty ArenaCfg object, must be assigned a valid one to be used - /** - * Wraps OrtApi::CreateArenaCfg - * \param max_mem - use 0 to allow ORT to choose the default - * \param arena_extend_strategy - use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested - * \param initial_chunk_size_bytes - use -1 to allow ORT to choose the default - * \param max_dead_bytes_per_chunk - use -1 to allow ORT to choose the default - * See docs/C_API.md for details on what the following parameters mean and how to choose these values - */ - ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk); -}; - -// -// Custom OPs (only needed to implement custom OPs) -// - -/// -/// This struct provides life time management for custom op attribute -/// -struct OpAttr : detail::Base { - OpAttr(const char* name, const void* data, int len, OrtOpAttrType type); -}; - -/// -/// This class wraps a raw pointer OrtKernelContext* that is being passed -/// to the custom kernel Compute() method. Use it to safely access context -/// attributes, input and output parameters with exception safety guarantees. -/// See usage example in onnxruntime/test/testdata/custom_op_library/custom_op_library.cc -/// -struct KernelContext { - explicit KernelContext(OrtKernelContext* context); - size_t GetInputCount() const; - size_t GetOutputCount() const; - ConstValue GetInput(size_t index) const; - UnownedValue GetOutput(size_t index, const int64_t* dim_values, size_t dim_count) const; - UnownedValue GetOutput(size_t index, const std::vector& dims) const; - void* GetGPUComputeStream() const; - - private: - OrtKernelContext* ctx_; -}; - -struct KernelInfo; - -namespace detail { -namespace attr_utils { -void GetAttr(const OrtKernelInfo* p, const char* name, float&); -void GetAttr(const OrtKernelInfo* p, const char* name, int64_t&); -void GetAttr(const OrtKernelInfo* p, const char* name, std::string&); -void GetAttrs(const OrtKernelInfo* p, const char* name, std::vector&); -void GetAttrs(const OrtKernelInfo* p, const char* name, std::vector&); -} // namespace attr_utils - -template -struct KernelInfoImpl : Base { - using B = Base; - using B::B; - - KernelInfo Copy() const; - - template // R is only implemented for float, int64_t, and string - R GetAttribute(const char* name) const { - R val; - attr_utils::GetAttr(this->p_, name, val); - return val; - } - - template // R is only implemented for std::vector, std::vector - std::vector GetAttributes(const char* name) const { - std::vector result; - attr_utils::GetAttrs(this->p_, name, result); - return result; - } - - Value GetTensorAttribute(const char* name, OrtAllocator* allocator) const; - - size_t GetInputCount() const; - size_t GetOutputCount() const; - - std::string GetInputName(size_t index) const; - std::string GetOutputName(size_t index) const; - - TypeInfo GetInputTypeInfo(size_t index) const; - TypeInfo GetOutputTypeInfo(size_t index) const; -}; - -} // namespace detail - -using ConstKernelInfo = detail::KernelInfoImpl>; - -/// -/// This struct owns the OrtKernInfo* pointer when a copy is made. -/// For convenient wrapping of OrtKernelInfo* passed to kernel constructor -/// and query attributes, warp the pointer with Ort::Unowned instance -/// so it does not destroy the pointer the kernel does not own. -/// -struct KernelInfo : detail::KernelInfoImpl { - explicit KernelInfo(std::nullptr_t) {} ///< Create an empty instance to initialize later - explicit KernelInfo(OrtKernelInfo* info); ///< Take ownership of the instance - ConstKernelInfo GetConst() const { return ConstKernelInfo{this->p_}; } -}; - -/// -/// Create and own custom defined operation. -/// -struct Op : detail::Base { - explicit Op(std::nullptr_t) {} ///< Create an empty Operator object, must be assigned a valid one to be used - - explicit Op(OrtOp*); ///< Take ownership of the OrtOp - - static Op Create(const OrtKernelInfo* info, const char* op_name, const char* domain, - int version, const char** type_constraint_names, - const ONNXTensorElementDataType* type_constraint_values, - size_t type_constraint_count, - const OpAttr* attr_values, - size_t attr_count, - size_t input_count, size_t output_count); - - void Invoke(const OrtKernelContext* context, - const Value* input_values, - size_t input_count, - Value* output_values, - size_t output_count); - - // For easier refactoring - void Invoke(const OrtKernelContext* context, - const OrtValue* const* input_values, - size_t input_count, - OrtValue* const* output_values, - size_t output_count); -}; - -/// -/// This entire structure is deprecated, but we not marking -/// it as a whole yet since we want to preserve for the next release. -/// -struct CustomOpApi { - CustomOpApi(const OrtApi& api) : api_(api) {} - - /** \deprecated use Ort::Value::GetTensorTypeAndShape() - * [[deprecated]] - * This interface produces a pointer that must be released. Not exception safe. - */ - [[deprecated("use Ort::Value::GetTensorTypeAndShape()")]] OrtTensorTypeAndShapeInfo* GetTensorTypeAndShape(_In_ const OrtValue* value); - - /** \deprecated use Ort::TensorTypeAndShapeInfo::GetElementCount() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::TensorTypeAndShapeInfo::GetElementCount()")]] size_t GetTensorShapeElementCount(_In_ const OrtTensorTypeAndShapeInfo* info); - - /** \deprecated use Ort::TensorTypeAndShapeInfo::GetElementType() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::TensorTypeAndShapeInfo::GetElementType()")]] ONNXTensorElementDataType GetTensorElementType(const OrtTensorTypeAndShapeInfo* info); - - /** \deprecated use Ort::TensorTypeAndShapeInfo::GetDimensionsCount() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::TensorTypeAndShapeInfo::GetDimensionsCount()")]] size_t GetDimensionsCount(_In_ const OrtTensorTypeAndShapeInfo* info); - - /** \deprecated use Ort::TensorTypeAndShapeInfo::GetShape() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::TensorTypeAndShapeInfo::GetShape()")]] void GetDimensions(_In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values, size_t dim_values_length); - - /** \deprecated - * [[deprecated]] - * This interface sets dimensions to TensorTypeAndShapeInfo, but has no effect on the OrtValue. - */ - [[deprecated("Do not use")]] void SetDimensions(OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count); - - /** \deprecated use Ort::Value::GetTensorMutableData() - * [[deprecated]] - * This interface is redundant. - */ - template - [[deprecated("use Ort::Value::GetTensorMutableData()")]] T* GetTensorMutableData(_Inout_ OrtValue* value); - - /** \deprecated use Ort::Value::GetTensorData() - * [[deprecated]] - * This interface is redundant. - */ - template - [[deprecated("use Ort::Value::GetTensorData()")]] const T* GetTensorData(_Inout_ const OrtValue* value); - - /** \deprecated use Ort::Value::GetTensorMemoryInfo() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::Value::GetTensorMemoryInfo()")]] const OrtMemoryInfo* GetTensorMemoryInfo(_In_ const OrtValue* value); - - /** \deprecated use Ort::TensorTypeAndShapeInfo::GetShape() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::TensorTypeAndShapeInfo::GetShape()")]] std::vector GetTensorShape(const OrtTensorTypeAndShapeInfo* info); - - /** \deprecated use TensorTypeAndShapeInfo instances for automatic ownership. - * [[deprecated]] - * This interface is not exception safe. - */ - [[deprecated("use TensorTypeAndShapeInfo")]] void ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo* input); - - /** \deprecated use Ort::KernelContext::GetInputCount - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::KernelContext::GetInputCount")]] size_t KernelContext_GetInputCount(const OrtKernelContext* context); - - /** \deprecated use Ort::KernelContext::GetInput - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::KernelContext::GetInput")]] const OrtValue* KernelContext_GetInput(const OrtKernelContext* context, _In_ size_t index); - - /** \deprecated use Ort::KernelContext::GetOutputCount - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::KernelContext::GetOutputCount")]] size_t KernelContext_GetOutputCount(const OrtKernelContext* context); - - /** \deprecated use Ort::KernelContext::GetOutput - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::KernelContext::GetOutput")]] OrtValue* KernelContext_GetOutput(OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count); - - /** \deprecated use Ort::KernelContext::GetGPUComputeStream - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::KernelContext::GetGPUComputeStream")]] void* KernelContext_GetGPUComputeStream(const OrtKernelContext* context); - - /** \deprecated use Ort::ThrowOnError() - * [[deprecated]] - * This interface is redundant. - */ - [[deprecated("use Ort::ThrowOnError()")]] void ThrowOnError(OrtStatus* result); - - /** \deprecated use Ort::OpAttr - * [[deprecated]] - * This interface is not exception safe. - */ - [[deprecated("use Ort::OpAttr")]] OrtOpAttr* CreateOpAttr(_In_ const char* name, - _In_ const void* data, - _In_ int len, - _In_ OrtOpAttrType type); - - /** \deprecated use Ort::OpAttr - * [[deprecated]] - * This interface is not exception safe. - */ - [[deprecated("use Ort::OpAttr")]] void ReleaseOpAttr(_Frees_ptr_opt_ OrtOpAttr* op_attr); - - /** \deprecated use Ort::Op - * [[deprecated]] - * This interface is not exception safe. - */ - [[deprecated("use Ort::Op")]] OrtOp* CreateOp(_In_ const OrtKernelInfo* info, - _In_ const char* op_name, - _In_ const char* domain, - _In_ int version, - _In_opt_ const char** type_constraint_names, - _In_opt_ const ONNXTensorElementDataType* type_constraint_values, - _In_opt_ int type_constraint_count, - _In_opt_ const OrtOpAttr* const* attr_values, - _In_opt_ int attr_count, - _In_ int input_count, - _In_ int output_count); - - /** \deprecated use Ort::Op::Invoke - * [[deprecated]] - * This interface is redundant - */ - [[deprecated("use Ort::Op::Invoke")]] void InvokeOp(_In_ const OrtKernelContext* context, - _In_ const OrtOp* ort_op, - _In_ const OrtValue* const* input_values, - _In_ int input_count, - _Inout_ OrtValue* const* output_values, - _In_ int output_count); - - /** \deprecated use Ort::Op for automatic lifespan management. - * [[deprecated]] - * This interface is not exception safe. - */ - [[deprecated("use Ort::Op")]] void ReleaseOp(_Frees_ptr_opt_ OrtOp* ort_op); - - /** \deprecated use Ort::KernelInfo for automatic lifespan management or for - * querying attributes - * [[deprecated]] - * This interface is redundant - */ - template // T is only implemented for std::vector, std::vector, float, int64_t, and string - [[deprecated("use Ort::KernelInfo::GetAttribute")]] T KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name); - - /** \deprecated use Ort::KernelInfo::Copy - * querying attributes - * [[deprecated]] - * This interface is not exception safe - */ - [[deprecated("use Ort::KernelInfo::Copy")]] OrtKernelInfo* CopyKernelInfo(_In_ const OrtKernelInfo* info); - - /** \deprecated use Ort::KernelInfo for lifespan management - * querying attributes - * [[deprecated]] - * This interface is not exception safe - */ - [[deprecated("use Ort::KernelInfo")]] void ReleaseKernelInfo(_Frees_ptr_opt_ OrtKernelInfo* info_copy); - - private: - const OrtApi& api_; -}; - -template -struct CustomOpBase : OrtCustomOp { - CustomOpBase() { - OrtCustomOp::version = ORT_API_VERSION; - OrtCustomOp::CreateKernel = [](const OrtCustomOp* this_, const OrtApi* api, const OrtKernelInfo* info) { return static_cast(this_)->CreateKernel(*api, info); }; - OrtCustomOp::GetName = [](const OrtCustomOp* this_) { return static_cast(this_)->GetName(); }; - - OrtCustomOp::GetExecutionProviderType = [](const OrtCustomOp* this_) { return static_cast(this_)->GetExecutionProviderType(); }; - - OrtCustomOp::GetInputTypeCount = [](const OrtCustomOp* this_) { return static_cast(this_)->GetInputTypeCount(); }; - OrtCustomOp::GetInputType = [](const OrtCustomOp* this_, size_t index) { return static_cast(this_)->GetInputType(index); }; - OrtCustomOp::GetInputMemoryType = [](const OrtCustomOp* this_, size_t index) { return static_cast(this_)->GetInputMemoryType(index); }; - - OrtCustomOp::GetOutputTypeCount = [](const OrtCustomOp* this_) { return static_cast(this_)->GetOutputTypeCount(); }; - OrtCustomOp::GetOutputType = [](const OrtCustomOp* this_, size_t index) { return static_cast(this_)->GetOutputType(index); }; - - OrtCustomOp::KernelCompute = [](void* op_kernel, OrtKernelContext* context) { static_cast(op_kernel)->Compute(context); }; -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(push) -#pragma warning(disable : 26409) -#endif - OrtCustomOp::KernelDestroy = [](void* op_kernel) { delete static_cast(op_kernel); }; -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(pop) -#endif - OrtCustomOp::GetInputCharacteristic = [](const OrtCustomOp* this_, size_t index) { return static_cast(this_)->GetInputCharacteristic(index); }; - OrtCustomOp::GetOutputCharacteristic = [](const OrtCustomOp* this_, size_t index) { return static_cast(this_)->GetOutputCharacteristic(index); }; - - OrtCustomOp::GetVariadicInputMinArity = [](const OrtCustomOp* this_) { return static_cast(this_)->GetVariadicInputMinArity(); }; - OrtCustomOp::GetVariadicInputHomogeneity = [](const OrtCustomOp* this_) { return static_cast(static_cast(this_)->GetVariadicInputHomogeneity()); }; - OrtCustomOp::GetVariadicOutputMinArity = [](const OrtCustomOp* this_) { return static_cast(this_)->GetVariadicOutputMinArity(); }; - OrtCustomOp::GetVariadicOutputHomogeneity = [](const OrtCustomOp* this_) { return static_cast(static_cast(this_)->GetVariadicOutputHomogeneity()); }; - } - - // Default implementation of GetExecutionProviderType that returns nullptr to default to the CPU provider - const char* GetExecutionProviderType() const { return nullptr; } - - // Default implementations of GetInputCharacteristic() and GetOutputCharacteristic() below - // (inputs and outputs are required by default) - OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t /*index*/) const { - return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED; - } - - OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t /*index*/) const { - return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED; - } - - // Default implemention of GetInputMemoryType() that returns OrtMemTypeDefault - OrtMemType GetInputMemoryType(size_t /*index*/) const { - return OrtMemTypeDefault; - } - - // Default implementation of GetVariadicInputMinArity() returns 1 to specify that a variadic input - // should expect at least 1 argument. - int GetVariadicInputMinArity() const { - return 1; - } - - // Default implementation of GetVariadicInputHomegeneity() returns true to specify that all arguments - // to a variadic input should be of the same type. - bool GetVariadicInputHomogeneity() const { - return true; - } - - // Default implementation of GetVariadicOutputMinArity() returns 1 to specify that a variadic output - // should produce at least 1 output value. - int GetVariadicOutputMinArity() const { - return 1; - } - - // Default implementation of GetVariadicOutputHomegeneity() returns true to specify that all output values - // produced by a variadic output should be of the same type. - bool GetVariadicOutputHomogeneity() const { - return true; - } - - // Declare list of session config entries used by this Custom Op. - // Implement this function in order to get configs from CustomOpBase::GetSessionConfigs(). - // This default implementation returns an empty vector of config entries. - std::vector GetSessionConfigKeys() const { - return std::vector{}; - } - - protected: - // Helper function that returns a map of session config entries specified by CustomOpBase::GetSessionConfigKeys. - void GetSessionConfigs(std::unordered_map& out, ConstSessionOptions options) const; -}; - -} // namespace Ort - -#include "onnxruntime_cxx_inline.h" diff --git a/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_inline.h b/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_inline.h deleted file mode 100644 index 6d391ad0f..000000000 --- a/funasr/runtime/onnxruntime/win/include/onnxruntime_cxx_inline.h +++ /dev/null @@ -1,1874 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// Do not include this file directly. Please include "onnxruntime_cxx_api.h" instead. -// If interested in trying out features of the new experimental C++ API, include "experimental_onnxruntime_cxx_api.h" instead. -// -// These are the inline implementations of the C++ header APIs. They're in this separate file as to not clutter -// the main C++ file with implementation details. - -namespace Ort { - -namespace detail { -inline void ThrowStatus(const Status& st) { - std::string error_message = st.GetErrorMessage(); - OrtErrorCode error_code = st.GetErrorCode(); - ORT_CXX_API_THROW(std::move(error_message), error_code); -} -} // namespace detail - -inline void ThrowOnError(OrtStatus* ort_status) { - if (ort_status) { - Ort::Status st(ort_status); - detail::ThrowStatus(st); - } -} - -inline void ThrowOnError(const Status& st) { - if (st) { - detail::ThrowStatus(st); - } -} - -inline Status::Status(OrtStatus* status) : Base{status} { -} - -inline Status::Status(const std::exception& e) { - p_ = GetApi().CreateStatus(ORT_FAIL, e.what()); -} - -inline Status::Status(const Exception& e) { - p_ = GetApi().CreateStatus(e.GetOrtErrorCode(), e.what()); -} - -inline std::string Status::GetErrorMessage() const { - std::string message(GetApi().GetErrorMessage(p_)); - return message; -} - -inline OrtErrorCode Status::GetErrorCode() const { - return GetApi().GetErrorCode(p_); -} - -// This template converts a C++ type into it's ONNXTensorElementDataType -template -struct TypeToTensorType; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64; -}; -template <> -struct TypeToTensorType { - static constexpr ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL; -}; - -inline MemoryAllocation::MemoryAllocation(OrtAllocator* allocator, void* p, size_t size) - : allocator_(allocator), p_(p), size_(size) { -} - -inline MemoryAllocation::~MemoryAllocation() { - if (p_ != nullptr) { - // We do not throw out of destructor - auto ret = GetApi().AllocatorFree(allocator_, p_); - static_cast(ret); - } -} - -inline MemoryAllocation::MemoryAllocation(MemoryAllocation&& o) noexcept : allocator_(nullptr), p_(nullptr), size_(0) { - *this = std::move(o); -} - -inline MemoryAllocation& MemoryAllocation::operator=(MemoryAllocation&& o) noexcept { - OrtAllocator* alloc = nullptr; - void* p = nullptr; - size_t sz = 0; - - // Swap out this - std::swap(alloc, allocator_); - std::swap(p, p_); - std::swap(sz, size_); - - // Swap with incoming - std::swap(allocator_, o.allocator_); - std::swap(p_, o.p_); - std::swap(size_, o.size_); - - // Destroy this instance if needed - MemoryAllocation this_alloc(alloc, p, sz); - return *this; -} - -namespace detail { - -template -inline void* AllocatorImpl::Alloc(size_t size) { - void* out; - ThrowOnError(GetApi().AllocatorAlloc(this->p_, size, &out)); - return out; -} - -template -inline MemoryAllocation AllocatorImpl::GetAllocation(size_t size) { - void* out; - ThrowOnError(GetApi().AllocatorAlloc(this->p_, size, &out)); - MemoryAllocation result(this->p_, out, size); - return result; -} - -template -inline void AllocatorImpl::Free(void* p) { - ThrowOnError(GetApi().AllocatorFree(this->p_, p)); -} - -template -inline ConstMemoryInfo AllocatorImpl::GetInfo() const { - const OrtMemoryInfo* out; - ThrowOnError(GetApi().AllocatorGetInfo(this->p_, &out)); - return ConstMemoryInfo{out}; -} - -} // namespace detail - -inline AllocatorWithDefaultOptions::AllocatorWithDefaultOptions() { - ThrowOnError(GetApi().GetAllocatorWithDefaultOptions(&this->p_)); -} - -inline Allocator::Allocator(const Session& sess, const OrtMemoryInfo* mem_info) { - ThrowOnError(GetApi().CreateAllocator(sess, mem_info, &this->p_)); -} - -namespace detail { - -template -inline std::string MemoryInfoImpl::GetAllocatorName() const { - const char* name = nullptr; - ThrowOnError(GetApi().MemoryInfoGetName(this->p_, &name)); - return std::string(name); -} - -template -inline OrtAllocatorType MemoryInfoImpl::GetAllocatorType() const { - OrtAllocatorType type; - ThrowOnError(GetApi().MemoryInfoGetType(this->p_, &type)); - return type; -} - -template -inline int MemoryInfoImpl::GetDeviceId() const { - int id = 0; - ThrowOnError(GetApi().MemoryInfoGetId(this->p_, &id)); - return id; -} - -template -inline OrtMemoryInfoDeviceType MemoryInfoImpl::GetDeviceType() const { - OrtMemoryInfoDeviceType type; - GetApi().MemoryInfoGetDeviceType(this->p_, &type); - return type; -} - -template -inline OrtMemType MemoryInfoImpl::GetMemoryType() const { - OrtMemType type; - ThrowOnError(GetApi().MemoryInfoGetMemType(this->p_, &type)); - return type; -} - -template -template -inline bool MemoryInfoImpl::operator==(const MemoryInfoImpl& o) const { - int comp_result = 0; - ThrowOnError(Ort::GetApi().CompareMemoryInfo(this->p_, o, &comp_result)); - return comp_result == 0; -} - -} // namespace detail - -inline MemoryInfo MemoryInfo::CreateCpu(OrtAllocatorType type, OrtMemType mem_type) { - OrtMemoryInfo* p; - ThrowOnError(GetApi().CreateCpuMemoryInfo(type, mem_type, &p)); - return MemoryInfo(p); -} - -inline MemoryInfo::MemoryInfo(const char* name, OrtAllocatorType type, int id, OrtMemType mem_type) { - ThrowOnError(GetApi().CreateMemoryInfo(name, type, id, mem_type, &this->p_)); -} - -namespace detail { -template -inline std::vector ConstIoBindingImpl::GetOutputNames() const { - AllocatorWithDefaultOptions allocator; - return binding_utils::GetOutputNamesHelper(this->p_, allocator); -} - -template -inline std::vector ConstIoBindingImpl::GetOutputNames(OrtAllocator* allocator) const { - return binding_utils::GetOutputNamesHelper(this->p_, allocator); -} - -template -inline std::vector ConstIoBindingImpl::GetOutputValues() const { - AllocatorWithDefaultOptions allocator; - return binding_utils::GetOutputValuesHelper(this->p_, allocator); -} - -template -inline std::vector ConstIoBindingImpl::GetOutputValues(OrtAllocator* allocator) const { - return binding_utils::GetOutputValuesHelper(this->p_, allocator); -} - -template -inline void IoBindingImpl::BindInput(const char* name, const Value& value) { - ThrowOnError(GetApi().BindInput(this->p_, name, value)); -} - -template -inline void IoBindingImpl::BindOutput(const char* name, const Value& value) { - ThrowOnError(GetApi().BindOutput(this->p_, name, value)); -} - -template -inline void IoBindingImpl::BindOutput(const char* name, const OrtMemoryInfo* mem_info) { - ThrowOnError(GetApi().BindOutputToDevice(this->p_, name, mem_info)); -} - -template -inline void IoBindingImpl::ClearBoundInputs() { - GetApi().ClearBoundInputs(this->p_); -} - -template -inline void IoBindingImpl::ClearBoundOutputs() { - GetApi().ClearBoundOutputs(this->p_); -} - -template -inline void IoBindingImpl::SynchronizeInputs() { - ThrowOnError(GetApi().SynchronizeBoundInputs(this->p_)); -} - -template -inline void IoBindingImpl::SynchronizeOutputs() { - ThrowOnError(GetApi().SynchronizeBoundOutputs(this->p_)); -} - -namespace binding_utils { -inline std::vector GetOutputNamesHelper(const OrtIoBinding* binding, OrtAllocator* allocator) { - std::vector result; - auto free_fn = detail::AllocatedFree(allocator); - using Ptr = std::unique_ptr; - - char* buffer = nullptr; - size_t* lengths = nullptr; - size_t count = 0; - ThrowOnError(GetApi().GetBoundOutputNames(binding, allocator, &buffer, &lengths, &count)); - - if (count == 0) { - return result; - } - - Ptr buffer_g(buffer, free_fn); - Ptr lengths_g(lengths, free_fn); - - result.reserve(count); - for (size_t i = 0; i < count; ++i) { - auto sz = *lengths; - result.emplace_back(buffer, sz); - buffer += sz; - ++lengths; - } - return result; -} - -inline std::vector GetOutputValuesHelper(const OrtIoBinding* binding, OrtAllocator* allocator) { - std::vector result; - size_t owned = 0; - size_t output_count = 0; - // Lambda to release the buffer when no longer needed and - // make sure that we destroy all instances on exception - auto free_fn = [&owned, &output_count, allocator](OrtValue** buffer) { - if (buffer) { - while (owned < output_count) { - auto* p = buffer + owned++; - GetApi().ReleaseValue(*p); - } - allocator->Free(allocator, buffer); - } - }; - using Ptr = std::unique_ptr; - - OrtValue** output_buffer = nullptr; - ThrowOnError(GetApi().GetBoundOutputValues(binding, allocator, &output_buffer, &output_count)); - if (output_count == 0) { - return result; - } - - Ptr buffer_g(output_buffer, free_fn); - - result.reserve(output_count); - for (size_t i = 0; i < output_count; ++i) { - result.emplace_back(output_buffer[i]); - ++owned; - } - return result; -} - -} // namespace binding_utils -} // namespace detail - -inline IoBinding::IoBinding(Session& session) { - ThrowOnError(GetApi().CreateIoBinding(session, &this->p_)); -} - -inline ArenaCfg::ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk) { - ThrowOnError(GetApi().CreateArenaCfg(max_mem, arena_extend_strategy, initial_chunk_size_bytes, max_dead_bytes_per_chunk, &p_)); -} - -inline ThreadingOptions::ThreadingOptions() { - ThrowOnError(GetApi().CreateThreadingOptions(&p_)); -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalIntraOpNumThreads(int intra_op_num_threads) { - ThrowOnError(GetApi().SetGlobalIntraOpNumThreads(p_, intra_op_num_threads)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalInterOpNumThreads(int inter_op_num_threads) { - ThrowOnError(GetApi().SetGlobalInterOpNumThreads(p_, inter_op_num_threads)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalSpinControl(int allow_spinning) { - ThrowOnError(GetApi().SetGlobalSpinControl(p_, allow_spinning)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalDenormalAsZero() { - ThrowOnError(GetApi().SetGlobalDenormalAsZero(p_)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn) { - ThrowOnError(GetApi().SetGlobalCustomCreateThreadFn(p_, ort_custom_create_thread_fn)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalCustomThreadCreationOptions(void* ort_custom_thread_creation_options) { - ThrowOnError(GetApi().SetGlobalCustomThreadCreationOptions(p_, ort_custom_thread_creation_options)); - return *this; -} - -inline ThreadingOptions& ThreadingOptions::SetGlobalCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn) { - ThrowOnError(GetApi().SetGlobalCustomJoinThreadFn(p_, ort_custom_join_thread_fn)); - return *this; -} - -inline Env::Env(OrtLoggingLevel logging_level, _In_ const char* logid) { - ThrowOnError(GetApi().CreateEnv(logging_level, logid, &p_)); - if (strcmp(logid, "onnxruntime-node") == 0) { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_NODEJS)); - } else { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_CPLUSPLUS)); - } -} - -inline Env::Env(OrtLoggingLevel logging_level, const char* logid, OrtLoggingFunction logging_function, void* logger_param) { - ThrowOnError(GetApi().CreateEnvWithCustomLogger(logging_function, logger_param, logging_level, logid, &p_)); - if (strcmp(logid, "onnxruntime-node") == 0) { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_NODEJS)); - } else { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_CPLUSPLUS)); - } -} - -inline Env::Env(const OrtThreadingOptions* tp_options, OrtLoggingLevel logging_level, _In_ const char* logid) { - ThrowOnError(GetApi().CreateEnvWithGlobalThreadPools(logging_level, logid, tp_options, &p_)); - if (strcmp(logid, "onnxruntime-node") == 0) { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_NODEJS)); - } else { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_CPLUSPLUS)); - } -} - -inline Env::Env(const OrtThreadingOptions* tp_options, OrtLoggingFunction logging_function, void* logger_param, - OrtLoggingLevel logging_level, _In_ const char* logid) { - ThrowOnError(GetApi().CreateEnvWithCustomLoggerAndGlobalThreadPools(logging_function, logger_param, logging_level, logid, tp_options, &p_)); - if (strcmp(logid, "onnxruntime-node") == 0) { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_NODEJS)); - } else { - ThrowOnError(GetApi().SetLanguageProjection(p_, OrtLanguageProjection::ORT_PROJECTION_CPLUSPLUS)); - } -} - -inline Env& Env::EnableTelemetryEvents() { - ThrowOnError(GetApi().EnableTelemetryEvents(p_)); - return *this; -} - -inline Env& Env::DisableTelemetryEvents() { - ThrowOnError(GetApi().DisableTelemetryEvents(p_)); - return *this; -} - -inline Env& Env::UpdateEnvWithCustomLogLevel(OrtLoggingLevel log_severity_level) { - ThrowOnError(GetApi().UpdateEnvWithCustomLogLevel(p_, log_severity_level)); - return *this; -} - -inline Env& Env::CreateAndRegisterAllocator(const OrtMemoryInfo* mem_info, const OrtArenaCfg* arena_cfg) { - ThrowOnError(GetApi().CreateAndRegisterAllocator(p_, mem_info, arena_cfg)); - return *this; -} - -inline CustomOpDomain::CustomOpDomain(const char* domain) { - ThrowOnError(GetApi().CreateCustomOpDomain(domain, &p_)); -} - -inline void CustomOpDomain::Add(const OrtCustomOp* op) { - ThrowOnError(GetApi().CustomOpDomain_Add(p_, op)); -} - -inline RunOptions::RunOptions() { - ThrowOnError(GetApi().CreateRunOptions(&p_)); -} - -inline RunOptions& RunOptions::SetRunLogVerbosityLevel(int level) { - ThrowOnError(GetApi().RunOptionsSetRunLogVerbosityLevel(p_, level)); - return *this; -} - -inline RunOptions& RunOptions::SetRunLogSeverityLevel(int level) { - ThrowOnError(GetApi().RunOptionsSetRunLogSeverityLevel(p_, level)); - return *this; -} - -inline int RunOptions::GetRunLogVerbosityLevel() const { - int out; - ThrowOnError(GetApi().RunOptionsGetRunLogVerbosityLevel(p_, &out)); - return out; -} - -inline int RunOptions::GetRunLogSeverityLevel() const { - int out; - ThrowOnError(GetApi().RunOptionsGetRunLogSeverityLevel(p_, &out)); - return out; -} - -inline RunOptions& RunOptions::SetRunTag(const char* run_tag) { - ThrowOnError(GetApi().RunOptionsSetRunTag(p_, run_tag)); - return *this; -} - -inline const char* RunOptions::GetRunTag() const { - const char* out; - ThrowOnError(GetApi().RunOptionsGetRunTag(p_, &out)); - return out; -} - -inline RunOptions& RunOptions::AddConfigEntry(const char* config_key, const char* config_value) { - ThrowOnError(GetApi().AddRunConfigEntry(p_, config_key, config_value)); - return *this; -} - -inline RunOptions& RunOptions::SetTerminate() { - ThrowOnError(GetApi().RunOptionsSetTerminate(p_)); - return *this; -} - -inline RunOptions& RunOptions::UnsetTerminate() { - ThrowOnError(GetApi().RunOptionsUnsetTerminate(p_)); - return *this; -} - -namespace detail { - -template -inline Ort::SessionOptions ConstSessionOptionsImpl::Clone() const { - OrtSessionOptions* out; - ThrowOnError(GetApi().CloneSessionOptions(this->p_, &out)); - return SessionOptions{out}; -} - -template -inline std::string ConstSessionOptionsImpl::GetConfigEntry(const char* config_key) const { - size_t size = 0; - // Feed nullptr for the data buffer to query the true size of the string value - Ort::ThrowOnError(GetApi().GetSessionConfigEntry(this->p_, config_key, nullptr, &size)); - - std::string out; - out.resize(size); - Ort::ThrowOnError(GetApi().GetSessionConfigEntry(this->p_, config_key, &out[0], &size)); - out.resize(size - 1); // remove the terminating character '\0' - - return out; -} - -template -inline bool ConstSessionOptionsImpl::HasConfigEntry(const char* config_key) const { - int out = 0; - Ort::ThrowOnError(GetApi().HasSessionConfigEntry(this->p_, config_key, &out)); - return static_cast(out); -} - -template -inline std::string ConstSessionOptionsImpl::GetConfigEntryOrDefault(const char* config_key, const std::string& def) { - if (!this->HasConfigEntry(config_key)) { - return def; - } - - return this->GetConfigEntry(config_key); -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetIntraOpNumThreads(int intra_op_num_threads) { - ThrowOnError(GetApi().SetIntraOpNumThreads(this->p_, intra_op_num_threads)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetInterOpNumThreads(int inter_op_num_threads) { - ThrowOnError(GetApi().SetInterOpNumThreads(this->p_, inter_op_num_threads)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetGraphOptimizationLevel(GraphOptimizationLevel graph_optimization_level) { - ThrowOnError(GetApi().SetSessionGraphOptimizationLevel(this->p_, graph_optimization_level)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetOptimizedModelFilePath(const ORTCHAR_T* optimized_model_filepath) { - ThrowOnError(GetApi().SetOptimizedModelFilePath(this->p_, optimized_model_filepath)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::EnableProfiling(const ORTCHAR_T* profile_file_prefix) { - ThrowOnError(GetApi().EnableProfiling(this->p_, profile_file_prefix)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::DisableProfiling() { - ThrowOnError(GetApi().DisableProfiling(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::EnableOrtCustomOps() { - ThrowOnError(GetApi().EnableOrtCustomOps(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::EnableMemPattern() { - ThrowOnError(GetApi().EnableMemPattern(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::DisableMemPattern() { - ThrowOnError(GetApi().DisableMemPattern(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::EnableCpuMemArena() { - ThrowOnError(GetApi().EnableCpuMemArena(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::DisableCpuMemArena() { - ThrowOnError(GetApi().DisableCpuMemArena(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetExecutionMode(ExecutionMode execution_mode) { - ThrowOnError(GetApi().SetSessionExecutionMode(this->p_, execution_mode)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetLogId(const char* logid) { - ThrowOnError(GetApi().SetSessionLogId(this->p_, logid)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetLogSeverityLevel(int level) { - ThrowOnError(GetApi().SetSessionLogSeverityLevel(this->p_, level)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::Add(OrtCustomOpDomain* custom_op_domain) { - ThrowOnError(GetApi().AddCustomOpDomain(this->p_, custom_op_domain)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AddConfigEntry(const char* config_key, const char* config_value) { - ThrowOnError(GetApi().AddSessionConfigEntry(this->p_, config_key, config_value)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AddInitializer(const char* name, const OrtValue* ort_val) { - ThrowOnError(GetApi().AddInitializer(this->p_, name, ort_val)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::DisablePerSessionThreads() { - ThrowOnError(GetApi().DisablePerSessionThreads(this->p_)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AddExternalInitializers(const std::vector& names, - const std::vector& ort_values) { - const size_t inputs_num = names.size(); - if (inputs_num != ort_values.size()) { - ORT_CXX_API_THROW("Expecting names and ort_values to have the same length", ORT_INVALID_ARGUMENT); - } - std::vector names_ptr; - std::vector ort_values_ptrs; - names_ptr.reserve(inputs_num); - ort_values_ptrs.reserve(inputs_num); - for (size_t i = 0; i < inputs_num; ++i) { - names_ptr.push_back(names[i].c_str()); - ort_values_ptrs.push_back(ort_values[i]); - } - ThrowOnError(GetApi().AddExternalInitializers(this->p_, names_ptr.data(), ort_values_ptrs.data(), inputs_num)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_CUDA(const OrtCUDAProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_CUDA(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_CUDA_V2(const OrtCUDAProviderOptionsV2& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_CUDA_V2(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_ROCM(const OrtROCMProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_ROCM(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_TensorRT(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_TensorRT_V2(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_MIGraphX(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_CANN(const OrtCANNProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_CANN(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider( - const std::string& provider_name, - const std::unordered_map& provider_options) { - auto num_entries = provider_options.size(); - std::vector keys, values; - if (num_entries > 0) { - keys.reserve(num_entries); - values.reserve(num_entries); - - for (const auto& entry : provider_options) { - keys.push_back(entry.first.c_str()); - values.push_back(entry.second.c_str()); - } - } - - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider(this->p_, provider_name.c_str(), - keys.data(), values.data(), num_entries)); - - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn) { - ThrowOnError(GetApi().SessionOptionsSetCustomCreateThreadFn(this->p_, ort_custom_create_thread_fn)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetCustomThreadCreationOptions(void* ort_custom_thread_creation_options) { - ThrowOnError(GetApi().SessionOptionsSetCustomThreadCreationOptions(this->p_, ort_custom_thread_creation_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::SetCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn) { - ThrowOnError(GetApi().SessionOptionsSetCustomJoinThreadFn(this->p_, ort_custom_join_thread_fn)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::AppendExecutionProvider_OpenVINO(const OrtOpenVINOProviderOptions& provider_options) { - ThrowOnError(GetApi().SessionOptionsAppendExecutionProvider_OpenVINO(this->p_, &provider_options)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::RegisterCustomOpsLibrary(const ORTCHAR_T* library_name, - const CustomOpConfigs& custom_op_configs) { - // Add custom op config entries before registering the custom op library. Otherwise, the config entries _may_ be ignored by - // the custom op library. - for (const auto& config_iter : custom_op_configs.GetFlattenedConfigs()) { - AddConfigEntry(config_iter.first.c_str(), config_iter.second.c_str()); - } - - ThrowOnError(GetApi().RegisterCustomOpsLibrary_V2(this->p_, library_name)); - return *this; -} - -template -inline SessionOptionsImpl& SessionOptionsImpl::RegisterCustomOpsUsingFunction(const char* registration_function_name) { - ThrowOnError(GetApi().RegisterCustomOpsUsingFunction(this->p_, registration_function_name)); - return *this; -} - -/// Session -template -inline size_t ConstSessionImpl::GetInputCount() const { - size_t out; - ThrowOnError(GetApi().SessionGetInputCount(this->p_, &out)); - return out; -} - -template -inline size_t ConstSessionImpl::GetOutputCount() const { - size_t out; - ThrowOnError(GetApi().SessionGetOutputCount(this->p_, &out)); - return out; -} - -template -inline size_t ConstSessionImpl::GetOverridableInitializerCount() const { - size_t out; - ThrowOnError(GetApi().SessionGetOverridableInitializerCount(this->p_, &out)); - return out; -} - -template -inline AllocatedStringPtr ConstSessionImpl::GetInputNameAllocated(size_t index, OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().SessionGetInputName(this->p_, index, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -template -inline AllocatedStringPtr ConstSessionImpl::GetOutputNameAllocated(size_t index, OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().SessionGetOutputName(this->p_, index, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -template -inline AllocatedStringPtr ConstSessionImpl::GetOverridableInitializerNameAllocated(size_t index, OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().SessionGetOverridableInitializerName(this->p_, index, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -template -inline uint64_t ConstSessionImpl::GetProfilingStartTimeNs() const { - uint64_t out; - ThrowOnError(GetApi().SessionGetProfilingStartTimeNs(this->p_, &out)); - return out; -} - -template -inline ModelMetadata ConstSessionImpl::GetModelMetadata() const { - OrtModelMetadata* out; - ThrowOnError(GetApi().SessionGetModelMetadata(this->p_, &out)); - return ModelMetadata{out}; -} - -template -inline TypeInfo ConstSessionImpl::GetInputTypeInfo(size_t index) const { - OrtTypeInfo* out; - ThrowOnError(GetApi().SessionGetInputTypeInfo(this->p_, index, &out)); - return TypeInfo{out}; -} - -template -inline TypeInfo ConstSessionImpl::GetOutputTypeInfo(size_t index) const { - OrtTypeInfo* out; - ThrowOnError(GetApi().SessionGetOutputTypeInfo(this->p_, index, &out)); - return TypeInfo{out}; -} - -template -inline TypeInfo ConstSessionImpl::GetOverridableInitializerTypeInfo(size_t index) const { - OrtTypeInfo* out; - ThrowOnError(GetApi().SessionGetOverridableInitializerTypeInfo(this->p_, index, &out)); - return TypeInfo{out}; -} - -template -inline std::vector SessionImpl::Run(const RunOptions& run_options, const char* const* input_names, const Value* input_values, size_t input_count, - const char* const* output_names, size_t output_count) { - std::vector output_values; - output_values.reserve(output_count); - for (size_t i = 0; i < output_count; i++) - output_values.emplace_back(nullptr); - Run(run_options, input_names, input_values, input_count, output_names, output_values.data(), output_count); - return output_values; -} - -template -inline void SessionImpl::Run(const RunOptions& run_options, const char* const* input_names, const Value* input_values, size_t input_count, - const char* const* output_names, Value* output_values, size_t output_count) { - static_assert(sizeof(Value) == sizeof(OrtValue*), "Value is really just an array of OrtValue* in memory, so we can reinterpret_cast safely"); - auto ort_input_values = reinterpret_cast(input_values); - auto ort_output_values = reinterpret_cast(output_values); - ThrowOnError(GetApi().Run(this->p_, run_options, input_names, ort_input_values, input_count, output_names, output_count, ort_output_values)); -} - -template -inline void SessionImpl::Run(const RunOptions& run_options, const IoBinding& io_binding) { - ThrowOnError(GetApi().RunWithBinding(this->p_, run_options, io_binding)); -} - -template -inline AllocatedStringPtr SessionImpl::EndProfilingAllocated(OrtAllocator* allocator) { - char* out = nullptr; - ThrowOnError(GetApi().SessionEndProfiling(this->p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -} // namespace detail - -inline SessionOptions::SessionOptions() { - ThrowOnError(GetApi().CreateSessionOptions(&this->p_)); -} - -/// CustomOpConfigs -inline std::string detail::MakeCustomOpConfigEntryKey(const char* custom_op_name, const char* config) { - std::string config_key = "custom_op."; - - config_key += custom_op_name; - config_key += "."; - config_key += config; - - return config_key; -} - -inline CustomOpConfigs& CustomOpConfigs::AddConfig(const char* custom_op_name, const char* config_key, const char* config_value) { - const std::string full_flat_key = detail::MakeCustomOpConfigEntryKey(custom_op_name, config_key); - flat_configs_[full_flat_key] = config_value; - return *this; -} - -inline const std::unordered_map& CustomOpConfigs::GetFlattenedConfigs() const { - return flat_configs_; -} - -inline Session::Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options) { - ThrowOnError(GetApi().CreateSession(env, model_path, options, &this->p_)); -} - -inline Session::Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options, - OrtPrepackedWeightsContainer* prepacked_weights_container) { - ThrowOnError(GetApi().CreateSessionWithPrepackedWeightsContainer(env, model_path, options, prepacked_weights_container, &this->p_)); -} - -inline Session::Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { - ThrowOnError(GetApi().CreateSessionFromArray(env, model_data, model_data_length, options, &this->p_)); -} - -inline Session::Session(const Env& env, const void* model_data, size_t model_data_length, - const SessionOptions& options, OrtPrepackedWeightsContainer* prepacked_weights_container) { - ThrowOnError(GetApi().CreateSessionFromArrayWithPrepackedWeightsContainer(env, model_data, model_data_length, options, - prepacked_weights_container, &this->p_)); -} - -inline AllocatedStringPtr ModelMetadata::GetProducerNameAllocated(OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataGetProducerName(p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline AllocatedStringPtr ModelMetadata::GetGraphNameAllocated(OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataGetGraphName(p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline AllocatedStringPtr ModelMetadata::GetDomainAllocated(OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataGetDomain(p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline AllocatedStringPtr Ort::ModelMetadata::GetDescriptionAllocated(OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataGetDescription(p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline AllocatedStringPtr ModelMetadata::GetGraphDescriptionAllocated(OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataGetGraphDescription(p_, allocator, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline AllocatedStringPtr ModelMetadata::LookupCustomMetadataMapAllocated(const char* key, OrtAllocator* allocator) const { - char* out; - ThrowOnError(GetApi().ModelMetadataLookupCustomMetadataMap(p_, allocator, key, &out)); - return AllocatedStringPtr(out, detail::AllocatedFree(allocator)); -} - -inline std::vector ModelMetadata::GetCustomMetadataMapKeysAllocated(OrtAllocator* allocator) const { - auto deletor = detail::AllocatedFree(allocator); - std::vector result; - - char** out = nullptr; - int64_t num_keys = 0; - ThrowOnError(GetApi().ModelMetadataGetCustomMetadataMapKeys(p_, allocator, &out, &num_keys)); - if (num_keys <= 0) { - return result; - } - - // array of pointers will be freed - std::unique_ptr array_guard(out, deletor); - // reserve may throw - auto strings_deletor = [&deletor, num_keys](char** out) { for(int64_t i = 0; i < num_keys; ++i) deletor(out[i]); }; - std::unique_ptr strings_guard(out, strings_deletor); - result.reserve(static_cast(num_keys)); - strings_guard.release(); - for (int64_t i = 0; i < num_keys; ++i) { - result.push_back(AllocatedStringPtr(out[i], deletor)); - } - - return result; -} - -inline int64_t ModelMetadata::GetVersion() const { - int64_t out; - ThrowOnError(GetApi().ModelMetadataGetVersion(p_, &out)); - return out; -} - -namespace detail { - -template -inline ONNXTensorElementDataType TensorTypeAndShapeInfoImpl::GetElementType() const { - ONNXTensorElementDataType out; - ThrowOnError(GetApi().GetTensorElementType(this->p_, &out)); - return out; -} - -template -inline size_t TensorTypeAndShapeInfoImpl::GetElementCount() const { - size_t out; - ThrowOnError(GetApi().GetTensorShapeElementCount(this->p_, &out)); - return static_cast(out); -} - -template -inline size_t TensorTypeAndShapeInfoImpl::GetDimensionsCount() const { - size_t out; - ThrowOnError(GetApi().GetDimensionsCount(this->p_, &out)); - return out; -} - -template -inline void TensorTypeAndShapeInfoImpl::GetDimensions(int64_t* values, size_t values_count) const { - ThrowOnError(GetApi().GetDimensions(this->p_, values, values_count)); -} - -template -inline void TensorTypeAndShapeInfoImpl::GetSymbolicDimensions(const char** values, size_t values_count) const { - ThrowOnError(GetApi().GetSymbolicDimensions(this->p_, values, values_count)); -} - -template -inline std::vector TensorTypeAndShapeInfoImpl::GetShape() const { - std::vector out(GetDimensionsCount(), 0); - ThrowOnError(GetApi().GetDimensions(this->p_, out.data(), out.size())); - return out; -} - -} // namespace detail - -namespace detail { -template -inline ConstTensorTypeAndShapeInfo TypeInfoImpl::GetTensorTypeAndShapeInfo() const { - const OrtTensorTypeAndShapeInfo* out; - ThrowOnError(GetApi().CastTypeInfoToTensorInfo(this->p_, &out)); - return ConstTensorTypeAndShapeInfo{out}; -} - -template -inline ConstSequenceTypeInfo TypeInfoImpl::GetSequenceTypeInfo() const { - const OrtSequenceTypeInfo* out; - ThrowOnError(GetApi().CastTypeInfoToSequenceTypeInfo(this->p_, &out)); - return ConstSequenceTypeInfo{out}; -} - -template -inline ConstMapTypeInfo TypeInfoImpl::GetMapTypeInfo() const { - const OrtMapTypeInfo* out; - ThrowOnError(GetApi().CastTypeInfoToMapTypeInfo(this->p_, &out)); - return ConstMapTypeInfo{out}; -} - -template -inline ONNXType TypeInfoImpl::GetONNXType() const { - ONNXType out; - ThrowOnError(GetApi().GetOnnxTypeFromTypeInfo(this->p_, &out)); - return out; -} - -} // namespace detail - -namespace detail { -template -inline TypeInfo SequenceTypeInfoImpl::GetSequenceElementType() const { - OrtTypeInfo* output; - ThrowOnError(GetApi().GetSequenceElementType(this->p_, &output)); - return TypeInfo{output}; -} - -} // namespace detail - -namespace detail { -template -inline ONNXTensorElementDataType MapTypeInfoImpl::GetMapKeyType() const { - ONNXTensorElementDataType out; - ThrowOnError(GetApi().GetMapKeyType(this->p_, &out)); - return out; -} - -template -inline TypeInfo MapTypeInfoImpl::GetMapValueType() const { - OrtTypeInfo* output; - ThrowOnError(GetApi().GetMapValueType(this->p_, &output)); - return TypeInfo{output}; -} -} // namespace detail - -namespace detail { - -template -template -inline void ConstValueImpl::GetOpaqueData(const char* domain, const char* type_name, R& out) const { - ThrowOnError(GetApi().GetOpaqueValue(domain, type_name, this->p_, &out, sizeof(R))); -} - -template -inline bool ConstValueImpl::IsTensor() const { - int out; - ThrowOnError(GetApi().IsTensor(this->p_, &out)); - return out != 0; -} - -template -inline bool ConstValueImpl::HasValue() const { - int out; - ThrowOnError(GetApi().HasValue(this->p_, &out)); - return out != 0; -} - -template -inline size_t ConstValueImpl::GetCount() const { - size_t out; - ThrowOnError(GetApi().GetValueCount(this->p_, &out)); - return out; -} - -template -inline Value ConstValueImpl::GetValue(int index, OrtAllocator* allocator) const { - OrtValue* out; - ThrowOnError(GetApi().GetValue(this->p_, index, allocator, &out)); - return Value{out}; -} - -template -inline size_t ConstValueImpl::GetStringTensorDataLength() const { - size_t out; - ThrowOnError(GetApi().GetStringTensorDataLength(this->p_, &out)); - return out; -} - -template -inline size_t ConstValueImpl::GetStringTensorElementLength(size_t element_index) const { - size_t out; - ThrowOnError(GetApi().GetStringTensorElementLength(this->p_, element_index, &out)); - return out; -} - -template -template -inline const R* ConstValueImpl::GetTensorData() const { - R* out; - ThrowOnError(GetApi().GetTensorMutableData(const_cast(this->p_), (void**)&out)); - return out; -} - -template -inline const void* ConstValueImpl::GetTensorRawData() const { - void* out; - ThrowOnError(GetApi().GetTensorMutableData(const_cast(this->p_), &out)); - return out; -} - -template -inline TypeInfo ConstValueImpl::GetTypeInfo() const { - OrtTypeInfo* output; - ThrowOnError(GetApi().GetTypeInfo(this->p_, &output)); - return TypeInfo{output}; -} - -template -inline TensorTypeAndShapeInfo ConstValueImpl::GetTensorTypeAndShapeInfo() const { - OrtTensorTypeAndShapeInfo* output; - ThrowOnError(GetApi().GetTensorTypeAndShape(this->p_, &output)); - return TensorTypeAndShapeInfo{output}; -} - -template -inline ConstMemoryInfo ConstValueImpl::GetTensorMemoryInfo() const { - const OrtMemoryInfo* mem_info; - ThrowOnError(GetApi().GetTensorMemoryInfo(this->p_, &mem_info)); - return ConstMemoryInfo(mem_info); -} - -template -inline void ConstValueImpl::GetStringTensorElement(size_t buffer_length, size_t element_index, void* buffer) const { - ThrowOnError(GetApi().GetStringTensorElement(this->p_, buffer_length, element_index, buffer)); -} - -template -inline void ConstValueImpl::GetStringTensorContent(void* buffer, size_t buffer_length, size_t* offsets, size_t offsets_count) const { - ThrowOnError(GetApi().GetStringTensorContent(this->p_, buffer, buffer_length, offsets, offsets_count)); -} - -#if !defined(DISABLE_SPARSE_TENSORS) -template -inline OrtSparseFormat ConstValueImpl::GetSparseFormat() const { - OrtSparseFormat format; - ThrowOnError(GetApi().GetSparseTensorFormat(this->p_, &format)); - return format; -} - -template -inline TensorTypeAndShapeInfo ConstValueImpl::GetSparseTensorValuesTypeAndShapeInfo() const { - OrtTensorTypeAndShapeInfo* output; - ThrowOnError(GetApi().GetSparseTensorValuesTypeAndShape(this->p_, &output)); - return TensorTypeAndShapeInfo{output}; -} - -template -inline TensorTypeAndShapeInfo ConstValueImpl::GetSparseTensorIndicesTypeShapeInfo(OrtSparseIndicesFormat indices_format) const { - OrtTensorTypeAndShapeInfo* output; - ThrowOnError(GetApi().GetSparseTensorIndicesTypeShape(this->p_, indices_format, &output)); - return TensorTypeAndShapeInfo{output}; -} - -template -template -inline const R* ConstValueImpl::GetSparseTensorIndicesData(OrtSparseIndicesFormat indices_format, size_t& num_indices) const { - const void* out; - ThrowOnError(GetApi().GetSparseTensorIndices(this->p_, indices_format, &num_indices, &out)); - return reinterpret_cast(out); -} - -template -inline bool ConstValueImpl::IsSparseTensor() const { - int out; - ThrowOnError(GetApi().IsSparseTensor(this->p_, &out)); - return out != 0; -} - -template -template -inline const R* ConstValueImpl::GetSparseTensorValues() const { - const void* out; - ThrowOnError(GetApi().GetSparseTensorValues(this->p_, &out)); - return reinterpret_cast(out); -} - -#endif - -template -void ValueImpl::FillStringTensor(const char* const* s, size_t s_len) { - ThrowOnError(GetApi().FillStringTensor(this->p_, s, s_len)); -} - -template -void ValueImpl::FillStringTensorElement(const char* s, size_t index) { - ThrowOnError(GetApi().FillStringTensorElement(this->p_, s, index)); -} - -template -void* ValueImpl::GetTensorMutableRawData() { - void* out; - ThrowOnError(GetApi().GetTensorMutableData(this->p_, &out)); - return out; -} - -template -template -R* ValueImpl::GetTensorMutableData() { - R* out; - ThrowOnError(GetApi().GetTensorMutableData(this->p_, (void**)&out)); - return out; -} - -template -template -R& ValueImpl::At(const std::vector& location) { - static_assert(!std::is_same::value, "this api does not support std::string"); - R* out; - ThrowOnError(GetApi().TensorAt(this->p_, location.data(), location.size(), (void**)&out)); - return *out; -} - -#if !defined(DISABLE_SPARSE_TENSORS) -template -void ValueImpl::UseCooIndices(int64_t* indices_data, size_t indices_num) { - ThrowOnError(GetApi().UseCooIndices(this->p_, indices_data, indices_num)); -} - -template -void ValueImpl::UseCsrIndices(int64_t* inner_data, size_t inner_num, int64_t* outer_data, size_t outer_num) { - ThrowOnError(GetApi().UseCsrIndices(this->p_, inner_data, inner_num, outer_data, outer_num)); -} - -template -void ValueImpl::UseBlockSparseIndices(const Shape& indices_shape, int32_t* indices_data) { - ThrowOnError(GetApi().UseBlockSparseIndices(this->p_, indices_shape.shape, indices_shape.shape_len, indices_data)); -} - -template -void ValueImpl::FillSparseTensorCoo(const OrtMemoryInfo* mem_info, const OrtSparseValuesParam& values_param, - const int64_t* indices_data, size_t indices_num) { - ThrowOnError(GetApi().FillSparseTensorCoo(this->p_, mem_info, values_param.values_shape, - values_param.values_shape_len, values_param.data.p_data, - indices_data, indices_num)); -} - -template -void ValueImpl::FillSparseTensorCsr(const OrtMemoryInfo* data_mem_info, - const OrtSparseValuesParam& values, - const int64_t* inner_indices_data, size_t inner_indices_num, - const int64_t* outer_indices_data, size_t outer_indices_num) { - ThrowOnError(GetApi().FillSparseTensorCsr(this->p_, data_mem_info, values.values_shape, values.values_shape_len, values.data.p_data, - inner_indices_data, inner_indices_num, - outer_indices_data, outer_indices_num)); -} - -template -void ValueImpl::FillSparseTensorBlockSparse(const OrtMemoryInfo* data_mem_info, - const OrtSparseValuesParam& values, - const Shape& indices_shape, - const int32_t* indices_data) { - ThrowOnError(GetApi().FillSparseTensorBlockSparse(this->p_, data_mem_info, values.values_shape, values.values_shape_len, values.data.p_data, - indices_shape.shape, indices_shape.shape_len, - indices_data)); -} - -#endif // !defined(DISABLE_SPARSE_TENSORS) - -} // namespace detail - -template -inline Value Value::CreateTensor(const OrtMemoryInfo* info, T* p_data, size_t p_data_element_count, const int64_t* shape, size_t shape_len) { - return CreateTensor(info, p_data, p_data_element_count * sizeof(T), shape, shape_len, TypeToTensorType::type); -} - -inline Value Value::CreateTensor(const OrtMemoryInfo* info, void* p_data, size_t p_data_byte_count, const int64_t* shape, size_t shape_len, - ONNXTensorElementDataType type) { - OrtValue* out; - ThrowOnError(GetApi().CreateTensorWithDataAsOrtValue(info, p_data, p_data_byte_count, shape, shape_len, type, &out)); - return Value{out}; -} - -template -inline Value Value::CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len) { - return CreateTensor(allocator, shape, shape_len, TypeToTensorType::type); -} - -inline Value Value::CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type) { - OrtValue* out; - ThrowOnError(GetApi().CreateTensorAsOrtValue(allocator, shape, shape_len, type, &out)); - return Value{out}; -} - -#if !defined(DISABLE_SPARSE_TENSORS) - -template -inline Value Value::CreateSparseTensor(const OrtMemoryInfo* info, T* p_data, const Shape& dense_shape, - const Shape& values_shape) { - return CreateSparseTensor(info, p_data, dense_shape, values_shape, TypeToTensorType::type); -} - -inline Value Value::CreateSparseTensor(const OrtMemoryInfo* info, void* p_data, const Shape& dense_shape, - const Shape& values_shape, ONNXTensorElementDataType type) { - OrtValue* out; - ThrowOnError(GetApi().CreateSparseTensorWithValuesAsOrtValue(info, p_data, dense_shape.shape, dense_shape.shape_len, - values_shape.shape, values_shape.shape_len, type, &out)); - return Value{out}; -} - -template -inline Value Value::CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape) { - return CreateSparseTensor(allocator, dense_shape, TypeToTensorType::type); -} - -inline Value Value::CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape, - ONNXTensorElementDataType type) { - OrtValue* out; - ThrowOnError(GetApi().CreateSparseTensorAsOrtValue(allocator, dense_shape.shape, dense_shape.shape_len, type, &out)); - return Value{out}; -} -#endif // !defined(DISABLE_SPARSE_TENSORS) - -inline Value Value::CreateMap(Value& keys, Value& values) { - OrtValue* out; - OrtValue* inputs[2] = {keys, values}; - ThrowOnError(GetApi().CreateValue(inputs, 2, ONNX_TYPE_MAP, &out)); - return Value{out}; -} - -inline Value Value::CreateSequence(std::vector& values) { - OrtValue* out; - std::vector values_ort{values.data(), values.data() + values.size()}; - ThrowOnError(GetApi().CreateValue(values_ort.data(), values_ort.size(), ONNX_TYPE_SEQUENCE, &out)); - return Value{out}; -} - -template -inline Value Value::CreateOpaque(const char* domain, const char* type_name, const T& data_container) { - OrtValue* out; - ThrowOnError(GetApi().CreateOpaqueValue(domain, type_name, &data_container, sizeof(T), &out)); - return Value{out}; -} - -// -// Custom OP Inlines -// -inline KernelContext::KernelContext(OrtKernelContext* context) : ctx_(context) { -} - -inline size_t KernelContext::GetInputCount() const { - size_t out = 0; - Ort::ThrowOnError(GetApi().KernelContext_GetInputCount(ctx_, &out)); - return out; -} - -inline size_t KernelContext::GetOutputCount() const { - size_t out = 0; - Ort::ThrowOnError(GetApi().KernelContext_GetOutputCount(ctx_, &out)); - return out; -} - -inline ConstValue KernelContext::GetInput(size_t index) const { - const OrtValue* out = nullptr; - Ort::ThrowOnError(GetApi().KernelContext_GetInput(ctx_, index, &out)); - return ConstValue{out}; -} - -inline UnownedValue KernelContext::GetOutput(size_t index, const int64_t* dim_values, size_t dim_count) const { - OrtValue* out = nullptr; - Ort::ThrowOnError(GetApi().KernelContext_GetOutput(ctx_, index, dim_values, dim_count, &out)); - return UnownedValue(out); -} - -inline UnownedValue KernelContext::GetOutput(size_t index, const std::vector& dims) const { - OrtValue* out = nullptr; - Ort::ThrowOnError(GetApi().KernelContext_GetOutput(ctx_, index, dims.data(), dims.size(), &out)); - return UnownedValue(out); -} - -inline void* KernelContext::GetGPUComputeStream() const { - void* out = nullptr; - Ort::ThrowOnError(GetApi().KernelContext_GetGPUComputeStream(ctx_, &out)); - return out; -} - -inline OpAttr::OpAttr(const char* name, const void* data, int len, OrtOpAttrType type) { - Ort::ThrowOnError(GetApi().CreateOpAttr(name, data, len, type, &p_)); -} - -namespace detail { -template -inline KernelInfo KernelInfoImpl::Copy() const { - OrtKernelInfo* info_copy = nullptr; - Ort::ThrowOnError(GetApi().CopyKernelInfo(this->p_, &info_copy)); - return KernelInfo{info_copy}; -} - -template -inline size_t KernelInfoImpl::GetInputCount() const { - size_t out = 0; - ThrowOnError(GetApi().KernelInfo_GetInputCount(this->p_, &out)); - return out; -} - -template -inline size_t KernelInfoImpl::GetOutputCount() const { - size_t out = 0; - ThrowOnError(GetApi().KernelInfo_GetOutputCount(this->p_, &out)); - return out; -} - -template -inline std::string KernelInfoImpl::GetInputName(size_t index) const { - size_t size = 0; - - // Feed nullptr for the data buffer to query the true size of the string value - Ort::ThrowOnError(GetApi().KernelInfo_GetInputName(this->p_, index, nullptr, &size)); - - std::string out; - out.resize(size); - Ort::ThrowOnError(GetApi().KernelInfo_GetInputName(this->p_, index, &out[0], &size)); - out.resize(size - 1); // remove the terminating character '\0' - - return out; -} - -template -inline std::string KernelInfoImpl::GetOutputName(size_t index) const { - size_t size = 0; - - // Feed nullptr for the data buffer to query the true size of the string value - Ort::ThrowOnError(GetApi().KernelInfo_GetOutputName(this->p_, index, nullptr, &size)); - - std::string out; - out.resize(size); - Ort::ThrowOnError(GetApi().KernelInfo_GetOutputName(this->p_, index, &out[0], &size)); - out.resize(size - 1); // remove the terminating character '\0' - - return out; -} - -template -inline TypeInfo KernelInfoImpl::GetInputTypeInfo(size_t index) const { - OrtTypeInfo* out = nullptr; - ThrowOnError(GetApi().KernelInfo_GetInputTypeInfo(this->p_, index, &out)); - return TypeInfo{out}; -} - -template -inline TypeInfo KernelInfoImpl::GetOutputTypeInfo(size_t index) const { - OrtTypeInfo* out = nullptr; - ThrowOnError(GetApi().KernelInfo_GetOutputTypeInfo(this->p_, index, &out)); - return TypeInfo{out}; -} - -template -inline Value KernelInfoImpl::GetTensorAttribute(const char* name, OrtAllocator* allocator) const { - OrtValue* out = nullptr; - ThrowOnError(GetApi().KernelInfoGetAttribute_tensor(this->p_, name, allocator, &out)); - return Value{out}; -} - -inline void attr_utils::GetAttr(const OrtKernelInfo* p, const char* name, float& out) { - Ort::ThrowOnError(GetApi().KernelInfoGetAttribute_float(p, name, &out)); -} - -inline void attr_utils::GetAttr(const OrtKernelInfo* p, const char* name, int64_t& out) { - Ort::ThrowOnError(GetApi().KernelInfoGetAttribute_int64(p, name, &out)); -} - -inline void attr_utils::GetAttr(const OrtKernelInfo* p, const char* name, std::string& result) { - size_t size = 0; - // Feed nullptr for the data buffer to query the true size of the string attribute - Ort::ThrowOnError(GetApi().KernelInfoGetAttribute_string(p, name, nullptr, &size)); - - std::string out; - out.resize(size); - Ort::ThrowOnError(GetApi().KernelInfoGetAttribute_string(p, name, &out[0], &size)); - out.resize(size - 1); // remove the terminating character '\0' - out.swap(result); -} - -inline void attr_utils::GetAttrs(const OrtKernelInfo* p, const char* name, std::vector& result) { - size_t size = 0; - // Feed nullptr for the data buffer to query the true size of the attribute - Ort::ThrowOnError(GetApi().KernelInfoGetAttributeArray_float(p, name, nullptr, &size)); - - std::vector out; - out.resize(size); - Ort::ThrowOnError(GetApi().KernelInfoGetAttributeArray_float(p, name, out.data(), &size)); - out.swap(result); -} - -inline void attr_utils::GetAttrs(const OrtKernelInfo* p, const char* name, std::vector& result) { - size_t size = 0; - - // Feed nullptr for the data buffer to query the true size of the attribute - Ort::ThrowOnError(GetApi().KernelInfoGetAttributeArray_int64(p, name, nullptr, &size)); - - std::vector out; - out.resize(size); - Ort::ThrowOnError(GetApi().KernelInfoGetAttributeArray_int64(p, name, out.data(), &size)); - out.swap(result); -} -} // namespace detail - -inline KernelInfo::KernelInfo(OrtKernelInfo* info) : detail::KernelInfoImpl{info} {} - -inline Op::Op(OrtOp* p) : Base(p) {} - -inline Op Op::Create(const OrtKernelInfo* info, const char* op_name, const char* domain, int version, - const char** type_constraint_names, - const ONNXTensorElementDataType* type_constraint_values, - size_t type_constraint_count, - const OpAttr* attr_values, size_t attr_count, - size_t input_count, size_t output_count) { - static_assert(sizeof(OpAttr) == sizeof(OrtOpAttr*), - "OpAttr's is expected to be just an array of OrtOpAttr in memory so we can reinterpret safely"); - auto attr_input_values = reinterpret_cast(attr_values); - OrtOp* op; - Ort::ThrowOnError(GetApi().CreateOp(info, op_name, domain, version, type_constraint_names, type_constraint_values, - static_cast(type_constraint_count), - attr_input_values, - static_cast(attr_count), - static_cast(input_count), - static_cast(output_count), &op)); - return Op{op}; -} - -inline void Op::Invoke(const OrtKernelContext* context, - const Value* input_values, - size_t input_count, - Value* output_values, - size_t output_count) { - static_assert(sizeof(Value) == sizeof(OrtValue*), - "Value is really just an array of OrtValue* in memory, so we can reinterpret_cast safely"); - auto ort_input_values = reinterpret_cast(input_values); - auto ort_output_values = reinterpret_cast(output_values); - Ort::ThrowOnError(GetApi().InvokeOp(context, p_, ort_input_values, static_cast(input_count), - ort_output_values, static_cast(output_count))); -} - -inline void Op::Invoke(const OrtKernelContext* context, - const OrtValue* const* input_values, - size_t input_count, - OrtValue* const* output_values, - size_t output_count) { - Ort::ThrowOnError(GetApi().InvokeOp(context, p_, input_values, static_cast(input_count), - output_values, static_cast(output_count))); -} - -inline void CustomOpApi::ThrowOnError(OrtStatus* status) { - Ort::ThrowOnError(status); -} - -template <> -inline float CustomOpApi::KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name) { - float out; - Ort::ThrowOnError(api_.KernelInfoGetAttribute_float(info, name, &out)); - return out; -} - -template <> -inline int64_t CustomOpApi::KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name) { - int64_t out; - Ort::ThrowOnError(api_.KernelInfoGetAttribute_int64(info, name, &out)); - return out; -} - -template <> -inline std::string CustomOpApi::KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name) { - size_t size = 0; - std::string out; - - // Feed nullptr for the data buffer to query the true size of the string attribute - OrtStatus* status = api_.KernelInfoGetAttribute_string(info, name, nullptr, &size); - - if (status == nullptr) { - out.resize(size); - Ort::ThrowOnError(api_.KernelInfoGetAttribute_string(info, name, &out[0], &size)); - out.resize(size - 1); // remove the terminating character '\0' - } else { - Ort::ThrowOnError(status); - } - return out; -} - -template <> -inline std::vector CustomOpApi::KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name) { - size_t size = 0; - std::vector out; - - // Feed nullptr for the data buffer to query the true size of the attribute - OrtStatus* status = api_.KernelInfoGetAttributeArray_float(info, name, nullptr, &size); - - if (status == nullptr) { - out.resize(size); - Ort::ThrowOnError(api_.KernelInfoGetAttributeArray_float(info, name, out.data(), &size)); - } else { - Ort::ThrowOnError(status); - } - return out; -} - -template <> -inline std::vector CustomOpApi::KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name) { - size_t size = 0; - std::vector out; - - // Feed nullptr for the data buffer to query the true size of the attribute - OrtStatus* status = api_.KernelInfoGetAttributeArray_int64(info, name, nullptr, &size); - - if (status == nullptr) { - out.resize(size); - Ort::ThrowOnError(api_.KernelInfoGetAttributeArray_int64(info, name, out.data(), &size)); - } else { - Ort::ThrowOnError(status); - } - return out; -} -inline OrtTensorTypeAndShapeInfo* CustomOpApi::GetTensorTypeAndShape(_In_ const OrtValue* value) { - OrtTensorTypeAndShapeInfo* out; - Ort::ThrowOnError(api_.GetTensorTypeAndShape(value, &out)); - return out; -} - -inline size_t CustomOpApi::GetTensorShapeElementCount(_In_ const OrtTensorTypeAndShapeInfo* info) { - size_t out; - Ort::ThrowOnError(api_.GetTensorShapeElementCount(info, &out)); - return out; -} - -inline ONNXTensorElementDataType CustomOpApi::GetTensorElementType(const OrtTensorTypeAndShapeInfo* info) { - ONNXTensorElementDataType out; - Ort::ThrowOnError(api_.GetTensorElementType(info, &out)); - return out; -} - -inline size_t CustomOpApi::GetDimensionsCount(_In_ const OrtTensorTypeAndShapeInfo* info) { - size_t out; - Ort::ThrowOnError(api_.GetDimensionsCount(info, &out)); - return out; -} - -inline void CustomOpApi::GetDimensions(_In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values, size_t dim_values_length) { - Ort::ThrowOnError(api_.GetDimensions(info, dim_values, dim_values_length)); -} - -inline void CustomOpApi::SetDimensions(OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count) { - Ort::ThrowOnError(api_.SetDimensions(info, dim_values, dim_count)); -} - -template -inline T* CustomOpApi::GetTensorMutableData(_Inout_ OrtValue* value) { - T* data; - Ort::ThrowOnError(api_.GetTensorMutableData(value, reinterpret_cast(&data))); - return data; -} - -inline const OrtMemoryInfo* CustomOpApi::GetTensorMemoryInfo(_In_ const OrtValue* value) { - const OrtMemoryInfo* mem_info; - Ort::ThrowOnError(api_.GetTensorMemoryInfo(value, &mem_info)); - return mem_info; -} - -template -inline const T* CustomOpApi::GetTensorData(_Inout_ const OrtValue* value) { - T* data = nullptr; - Ort::ThrowOnError(api_.GetTensorMutableData(const_cast(value), reinterpret_cast(&data))); - return data; -} - -inline std::vector CustomOpApi::GetTensorShape(const OrtTensorTypeAndShapeInfo* info) { - size_t out; - Ort::ThrowOnError(api_.GetDimensionsCount(info, &out)); - std::vector output(out); - Ort::ThrowOnError(api_.GetDimensions(info, output.data(), out)); - return output; -} - -inline void CustomOpApi::ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo* input) { - api_.ReleaseTensorTypeAndShapeInfo(input); -} - -inline size_t CustomOpApi::KernelContext_GetInputCount(const OrtKernelContext* context) { - size_t out; - Ort::ThrowOnError(api_.KernelContext_GetInputCount(context, &out)); - return out; -} - -inline const OrtValue* CustomOpApi::KernelContext_GetInput(const OrtKernelContext* context, _In_ size_t index) { - const OrtValue* out; - Ort::ThrowOnError(api_.KernelContext_GetInput(context, index, &out)); - return out; -} - -inline size_t CustomOpApi::KernelContext_GetOutputCount(const OrtKernelContext* context) { - size_t out; - Ort::ThrowOnError(api_.KernelContext_GetOutputCount(context, &out)); - return out; -} - -inline OrtValue* CustomOpApi::KernelContext_GetOutput(OrtKernelContext* context, _In_ size_t index, - _In_ const int64_t* dim_values, size_t dim_count) { - OrtValue* out; - Ort::ThrowOnError(api_.KernelContext_GetOutput(context, index, dim_values, dim_count, &out)); - return out; -} - -inline void* CustomOpApi::KernelContext_GetGPUComputeStream(const OrtKernelContext* context) { - void* out; - Ort::ThrowOnError(api_.KernelContext_GetGPUComputeStream(context, &out)); - return out; -} - -inline OrtOpAttr* CustomOpApi::CreateOpAttr(_In_ const char* name, - _In_ const void* data, - _In_ int len, - _In_ OrtOpAttrType type) { - OrtOpAttr* op_attr{}; - Ort::ThrowOnError(api_.CreateOpAttr(name, data, len, type, &op_attr)); - return op_attr; -} - -inline void CustomOpApi::ReleaseOpAttr(_Frees_ptr_opt_ OrtOpAttr* op_attr) { - api_.ReleaseOpAttr(op_attr); -} - -inline OrtOp* CustomOpApi::CreateOp(_In_ const OrtKernelInfo* info, - _In_ const char* op_name, - _In_ const char* domain, - _In_ int version, - _In_opt_ const char** type_constraint_names, - _In_opt_ const ONNXTensorElementDataType* type_constraint_values, - _In_opt_ int type_constraint_count, - _In_opt_ const OrtOpAttr* const* attr_values, - _In_opt_ int attr_count, - _In_ int input_count, - _In_ int output_count) { - OrtOp* ort_op{}; - Ort::ThrowOnError(api_.CreateOp(info, op_name, domain, version, type_constraint_names, type_constraint_values, - type_constraint_count, attr_values, attr_count, input_count, output_count, &ort_op)); - return ort_op; -} - -inline void CustomOpApi::InvokeOp(_In_ const OrtKernelContext* context, - _In_ const OrtOp* ort_op, - _In_ const OrtValue* const* input_values, - _In_ int input_count, - _Inout_ OrtValue* const* output_values, - _In_ int output_count) { - Ort::ThrowOnError(api_.InvokeOp(context, ort_op, input_values, input_count, output_values, output_count)); -} - -inline void CustomOpApi::ReleaseOp(_Frees_ptr_opt_ OrtOp* ort_op) { - api_.ReleaseOp(ort_op); -} - -inline OrtKernelInfo* CustomOpApi::CopyKernelInfo(_In_ const OrtKernelInfo* info) { - OrtKernelInfo* info_copy{}; - Ort::ThrowOnError(api_.CopyKernelInfo(info, &info_copy)); - return info_copy; -} - -inline void CustomOpApi::ReleaseKernelInfo(_Frees_ptr_opt_ OrtKernelInfo* info_copy) { - api_.ReleaseKernelInfo(info_copy); -} - -inline std::vector GetAvailableProviders() { - int len; - char** providers; - ThrowOnError(GetApi().GetAvailableProviders(&providers, &len)); - std::vector available_providers(providers, providers + len); - ThrowOnError(GetApi().ReleaseAvailableProviders(providers, len)); - return available_providers; -} - -SessionOptions& AddInitializer(const char* name, const OrtValue* ort_val); - -template -void CustomOpBase::GetSessionConfigs(std::unordered_map& out, - ConstSessionOptions options) const { - const TOp* derived = static_cast(this); - std::vector keys = derived->GetSessionConfigKeys(); - - out.reserve(keys.size()); - - std::string config_entry_key = detail::MakeCustomOpConfigEntryKey(derived->GetName(), ""); - const size_t prefix_size = config_entry_key.length(); - - for (const auto& key : keys) { - config_entry_key.resize(prefix_size); - config_entry_key.append(key); - out[key] = options.GetConfigEntryOrDefault(config_entry_key.c_str(), ""); - } -} - -} // namespace Ort diff --git a/funasr/runtime/onnxruntime/win/include/onnxruntime_run_options_config_keys.h b/funasr/runtime/onnxruntime/win/include/onnxruntime_run_options_config_keys.h deleted file mode 100644 index 1f5fcd50e..000000000 --- a/funasr/runtime/onnxruntime/win/include/onnxruntime_run_options_config_keys.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -/* - * This file defines RunOptions Config Keys and format of the Config Values. - * - * The Naming Convention for a RunOptions Config Key, - * "[Area][.[SubArea1].[SubArea2]...].[Keyname]" - * Such as "ep.cuda.use_arena" - * The Config Key cannot be empty - * The maximum length of the Config Key is 128 - * - * The string format of a RunOptions Config Value is defined individually for each Config. - * The maximum length of the Config Value is 1024 - */ - -// Key for enabling shrinkages of user listed device memory arenas. -// Expects a list of semi-colon separated key value pairs separated by colon in the following format: -// "device_0:device_id_0;device_1:device_id_1" -// No white-spaces allowed in the provided list string. -// Currently, the only supported devices are : "cpu", "gpu" (case sensitive). -// If "cpu" is included in the list, DisableCpuMemArena() API must not be called (i.e.) arena for cpu should be enabled. -// Example usage: "cpu:0;gpu:0" (or) "gpu:0" -// By default, the value for this key is empty (i.e.) no memory arenas are shrunk -static const char* const kOrtRunOptionsConfigEnableMemoryArenaShrinkage = "memory.enable_memory_arena_shrinkage"; - -// Set to '1' to not synchronize execution providers with CPU at the end of session run. -// Per default it will be set to '0' -// Taking CUDA EP as an example, it omit triggering cudaStreamSynchronize on the compute stream. -static const char* const kOrtRunOptionsConfigDisableSynchronizeExecutionProviders = "disable_synchronize_execution_providers"; diff --git a/funasr/runtime/onnxruntime/win/include/onnxruntime_session_options_config_keys.h b/funasr/runtime/onnxruntime/win/include/onnxruntime_session_options_config_keys.h deleted file mode 100644 index 92482d71f..000000000 --- a/funasr/runtime/onnxruntime/win/include/onnxruntime_session_options_config_keys.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -/* - * This file defines SessionOptions Config Keys and format of the Config Values. - * - * The Naming Convention for a SessionOptions Config Key, - * "[Area][.[SubArea1].[SubArea2]...].[Keyname]" - * Such as "ep.cuda.use_arena" - * The Config Key cannot be empty - * The maximum length of the Config Key is 128 - * - * The string format of a SessionOptions Config Value is defined individually for each Config. - * The maximum length of the Config Value is 1024 - */ - -// Key for disable PrePacking, -// If the config value is set to "1" then the prepacking is disabled, otherwise prepacking is enabled (default value) -static const char* const kOrtSessionOptionsConfigDisablePrepacking = "session.disable_prepacking"; - -// A value of "1" means allocators registered in the env will be used. "0" means the allocators created in the session -// will be used. Use this to override the usage of env allocators on a per session level. -static const char* const kOrtSessionOptionsConfigUseEnvAllocators = "session.use_env_allocators"; - -// Set to 'ORT' (case sensitive) to load an ORT format model. -// If unset, model type will default to ONNX unless inferred from filename ('.ort' == ORT format) or bytes to be ORT -static const char* const kOrtSessionOptionsConfigLoadModelFormat = "session.load_model_format"; - -// Set to 'ORT' (case sensitive) to save optimized model in ORT format when SessionOptions.optimized_model_path is set. -// If unset, format will default to ONNX unless optimized_model_filepath ends in '.ort'. -static const char* const kOrtSessionOptionsConfigSaveModelFormat = "session.save_model_format"; - -// If a value is "1", flush-to-zero and denormal-as-zero are applied. The default is "0". -// When multiple sessions are created, a main thread doesn't override changes from succeeding session options, -// but threads in session thread pools follow option changes. -// When ORT runs with OpenMP, the same rule is applied, i.e. the first session option to flush-to-zero and -// denormal-as-zero is only applied to global OpenMP thread pool, which doesn't support per-session thread pool. -// Note that an alternative way not using this option at runtime is to train and export a model without denormals -// and that's recommended because turning this option on may hurt model accuracy. -static const char* const kOrtSessionOptionsConfigSetDenormalAsZero = "session.set_denormal_as_zero"; - -// It controls to run quantization model in QDQ (QuantizelinearDeQuantizelinear) format or not. -// "0": enable. ORT does fusion logic for QDQ format. -// "1": disable. ORT doesn't do fusion logic for QDQ format. -// Its default value is "0" -static const char* const kOrtSessionOptionsDisableQuantQDQ = "session.disable_quant_qdq"; - -// It controls whether to enable Double QDQ remover and Identical Children Consolidation -// "0": not to disable. ORT does remove the middle 2 Nodes from a Q->(QD->Q)->QD pairs -// "1": disable. ORT doesn't remove the middle 2 Nodes from a Q->(QD->Q)->QD pairs -// Its default value is "0" -static const char* const kOrtSessionOptionsDisableDoubleQDQRemover = "session.disable_double_qdq_remover"; - -// If set to "1", enables the removal of QuantizeLinear/DequantizeLinear node pairs once all QDQ handling has been -// completed. e.g. If after all QDQ handling has completed and we have -> FloatOp -> Q -> DQ -> FloatOp -> the -// Q -> DQ could potentially be removed. This will provide a performance benefit by avoiding going from float to -// 8-bit and back to float, but could impact accuracy. The impact on accuracy will be model specific and depend on -// other factors like whether the model was created using Quantization Aware Training or Post Training Quantization. -// As such, it's best to test to determine if enabling this works well for your scenario. -// The default value is "0" -// Available since version 1.11. -static const char* const kOrtSessionOptionsEnableQuantQDQCleanup = "session.enable_quant_qdq_cleanup"; - -// Enable or disable gelu approximation in graph optimization. "0": disable; "1": enable. The default is "0". -// GeluApproximation has side effects which may change the inference results. It is disabled by default due to this. -static const char* const kOrtSessionOptionsEnableGeluApproximation = "optimization.enable_gelu_approximation"; - -#ifdef ENABLE_TRAINING -// Specifies a list of op types for memory footprint reduction. -// The value should be a ","-delimited list of pair of -// . -// For example, "Gelu+Cast+:1:0,Dropout+:1:1". -// A valid "subgraph string" should be one subgraph representation output by ORT graph transformations. -// "optimization strategy" currently has valid values: 0 - disabled, 1 - recompute. -// "number of subgraph to apply" is used to control how many subgraphs to apply optimization, to avoid "oversaving" -// the memory. -static const char* const kOrtSessionOptionsMemoryOptimizerEnabler = "optimization.enable_memory_optimizer"; - -// Specifies the level for detecting subgraphs for memory footprint reduction. -// The value should be an integer. The default value is 0. -static const char* const kOrtSessionOptionsMemoryOptimizerProbeLevel = "optimization.enable_memory_probe_recompute_level"; -#endif - -// Enable or disable using device allocator for allocating initialized tensor memory. "1": enable; "0": disable. The default is "0". -// Using device allocators means the memory allocation is made using malloc/new. -static const char* const kOrtSessionOptionsUseDeviceAllocatorForInitializers = "session.use_device_allocator_for_initializers"; - -// Configure whether to allow the inter_op/intra_op threads spinning a number of times before blocking -// "0": thread will block if found no job to run -// "1": default, thread will spin a number of times before blocking -static const char* const kOrtSessionOptionsConfigAllowInterOpSpinning = "session.inter_op.allow_spinning"; -static const char* const kOrtSessionOptionsConfigAllowIntraOpSpinning = "session.intra_op.allow_spinning"; - -// Key for using model bytes directly for ORT format -// If a session is created using an input byte array contains the ORT format model data, -// By default we will copy the model bytes at the time of session creation to ensure the model bytes -// buffer is valid. -// Setting this option to "1" will disable copy the model bytes, and use the model bytes directly. The caller -// has to guarantee that the model bytes are valid until the ORT session using the model bytes is destroyed. -static const char* const kOrtSessionOptionsConfigUseORTModelBytesDirectly = "session.use_ort_model_bytes_directly"; - -/// -/// Key for using the ORT format model flatbuffer bytes directly for initializers. -/// This avoids copying the bytes and reduces peak memory usage during model loading and initialization. -/// Requires `session.use_ort_model_bytes_directly` to be true. -/// If set, the flatbuffer bytes provided when creating the InferenceSession MUST remain valid for the entire -/// duration of the InferenceSession. -/// -static const char* const kOrtSessionOptionsConfigUseORTModelBytesForInitializers = - "session.use_ort_model_bytes_for_initializers"; - -// This should only be specified when exporting an ORT format model for use on a different platform. -// If the ORT format model will be used on ARM platforms set to "1". For other platforms set to "0" -// Available since version 1.11. -static const char* const kOrtSessionOptionsQDQIsInt8Allowed = "session.qdqisint8allowed"; - -// x64 SSE4.1/AVX2/AVX512(with no VNNI) has overflow problem with quantizied matrix multiplication with U8S8. -// To avoid this we need to use slower U8U8 matrix multiplication instead. This option, if -// turned on, use slower U8U8 matrix multiplications. Only effective with AVX2 or AVX512 -// platforms. -static const char* const kOrtSessionOptionsAvx2PrecisionMode = "session.x64quantprecision"; - -// Specifies how minimal build graph optimizations are handled in a full build. -// These optimizations are at the extended level or higher. -// Possible values and their effects are: -// "save": Save runtime optimizations when saving an ORT format model. -// "apply": Only apply optimizations available in a minimal build. -// ""/: Apply optimizations available in a full build. -// Available since version 1.11. -static const char* const kOrtSessionOptionsConfigMinimalBuildOptimizations = - "optimization.minimal_build_optimizations"; - -// Note: The options specific to an EP should be specified prior to appending that EP to the session options object in -// order for them to take effect. - -// Specifies a list of stop op types. Nodes of a type in the stop op types and nodes downstream from them will not be -// run by the NNAPI EP. -// The value should be a ","-delimited list of op types. For example, "Add,Sub". -// If not specified, the default set of stop ops is used. To specify an empty stop ops types list and disable stop op -// exclusion, set the value to "". -static const char* const kOrtSessionOptionsConfigNnapiEpPartitioningStopOps = "ep.nnapi.partitioning_stop_ops"; - -// Enabling dynamic block-sizing for multithreading. -// With a positive value, thread pool will split a task of N iterations to blocks of size starting from: -// N / (num_of_threads * dynamic_block_base) -// As execution progresses, the size will decrease according to the diminishing residual of N, -// meaning the task will be distributed in smaller granularity for better parallelism. -// For some models, it helps to reduce the variance of E2E inference latency and boost performance. -// The feature will not function by default, specify any positive integer, e.g. "4", to enable it. -// Available since version 1.11. -static const char* const kOrtSessionOptionsConfigDynamicBlockBase = "session.dynamic_block_base"; - -// This option allows to decrease CPU usage between infrequent -// requests and forces any TP threads spinning stop immediately when the last of -// concurrent Run() call returns. -// Spinning is restarted on the next Run() call. -// Applies only to internal thread-pools -static const char* const kOrtSessionOptionsConfigForceSpinningStop = "session.force_spinning_stop"; - -// "1": all inconsistencies encountered during shape and type inference -// will result in failures. -// "0": in some cases warnings will be logged but processing will continue. The default. -// May be useful to expose bugs in models. -static const char* const kOrtSessionOptionsConfigStrictShapeTypeInference = "session.strict_shape_type_inference"; - -// The file saves configuration for partitioning node among logic streams -static const char* const kNodePartitionConfigFile = "session.node_partition_config_file"; - -// This Option allows setting affinities for intra op threads. -// Affinity string follows format: -// logical_processor_id,logical_processor_id;logical_processor_id,logical_processor_id -// Semicolon isolates configurations among threads, while comma split processors where ith thread expected to attach to. -// e.g.1,2,3;4,5 -// specifies affinities for two threads, with the 1st thread attach to the 1st, 2nd, and 3rd processor, and 2nd thread to the 4th and 5th. -// To ease the configuration, an "interval" is also allowed: -// e.g. 1-8;8-16;17-24 -// orders that the 1st thread runs on first eight processors, 2nd thread runs on next eight processors, and so forth. -// Note: -// 1. Once set, the number of thread affinities must equal to intra_op_num_threads - 1, since ort does not set affinity on the main thread which -// is started and managed by the calling app; -// 2. For windows, ort will infer the group id from a logical processor id, for example, assuming there are two groups with each has 64 logical processors, -// an id of 64 will be inferred as the last processor of the 1st group, while 65 will be interpreted as the 1st processor of the second group. -// Hence 64-65 is an invalid configuration, because a windows thread cannot be attached to processors across group boundary. -static const char* const kOrtSessionOptionsConfigIntraOpThreadAffinities = "session.intra_op_thread_affinities"; diff --git a/funasr/runtime/onnxruntime/win/include/provider_options.h b/funasr/runtime/onnxruntime/win/include/provider_options.h deleted file mode 100644 index aab13e808..000000000 --- a/funasr/runtime/onnxruntime/win/include/provider_options.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include - -namespace onnxruntime { - -// data types for execution provider options - -using ProviderOptions = std::unordered_map; -using ProviderOptionsVector = std::vector; -using ProviderOptionsMap = std::unordered_map; - -} // namespace onnxruntime diff --git a/funasr/runtime/onnxruntime/win/include/tensorrt_provider_factory.h b/funasr/runtime/onnxruntime/win/include/tensorrt_provider_factory.h deleted file mode 100644 index 44debc901..000000000 --- a/funasr/runtime/onnxruntime/win/include/tensorrt_provider_factory.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "onnxruntime_c_api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Tensorrt, _In_ OrtSessionOptions* options, int device_id); - -#ifdef __cplusplus -} -#endif diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.def b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.def deleted file mode 100644 index 4b50ecd41..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.def +++ /dev/null @@ -1,1017 +0,0 @@ -LIBRARY libfftw3-3.dll -EXPORTS -dfftw_cleanup_ -dfftw_cleanup__ -dfftw_cleanup_threads_ -dfftw_cleanup_threads__ -dfftw_cost_ -dfftw_cost__ -dfftw_destroy_plan_ -dfftw_destroy_plan__ -dfftw_estimate_cost_ -dfftw_estimate_cost__ -dfftw_execute_ -dfftw_execute__ -dfftw_execute_dft_ -dfftw_execute_dft__ -dfftw_execute_dft_c2r_ -dfftw_execute_dft_c2r__ -dfftw_execute_dft_r2c_ -dfftw_execute_dft_r2c__ -dfftw_execute_r2r_ -dfftw_execute_r2r__ -dfftw_execute_split_dft_ -dfftw_execute_split_dft__ -dfftw_execute_split_dft_c2r_ -dfftw_execute_split_dft_c2r__ -dfftw_execute_split_dft_r2c_ -dfftw_execute_split_dft_r2c__ -dfftw_export_wisdom_ -dfftw_export_wisdom__ -dfftw_flops_ -dfftw_flops__ -dfftw_forget_wisdom_ -dfftw_forget_wisdom__ -dfftw_import_system_wisdom_ -dfftw_import_system_wisdom__ -dfftw_import_wisdom_ -dfftw_import_wisdom__ -dfftw_init_threads_ -dfftw_init_threads__ -dfftw_plan_dft_ -dfftw_plan_dft__ -dfftw_plan_dft_1d_ -dfftw_plan_dft_1d__ -dfftw_plan_dft_2d_ -dfftw_plan_dft_2d__ -dfftw_plan_dft_3d_ -dfftw_plan_dft_3d__ -dfftw_plan_dft_c2r_ -dfftw_plan_dft_c2r__ -dfftw_plan_dft_c2r_1d_ -dfftw_plan_dft_c2r_1d__ -dfftw_plan_dft_c2r_2d_ -dfftw_plan_dft_c2r_2d__ -dfftw_plan_dft_c2r_3d_ -dfftw_plan_dft_c2r_3d__ -dfftw_plan_dft_r2c_ -dfftw_plan_dft_r2c__ -dfftw_plan_dft_r2c_1d_ -dfftw_plan_dft_r2c_1d__ -dfftw_plan_dft_r2c_2d_ -dfftw_plan_dft_r2c_2d__ -dfftw_plan_dft_r2c_3d_ -dfftw_plan_dft_r2c_3d__ -dfftw_plan_guru_dft_ -dfftw_plan_guru_dft__ -dfftw_plan_guru_dft_c2r_ -dfftw_plan_guru_dft_c2r__ -dfftw_plan_guru_dft_r2c_ -dfftw_plan_guru_dft_r2c__ -dfftw_plan_guru_r2r_ -dfftw_plan_guru_r2r__ -dfftw_plan_guru_split_dft_ -dfftw_plan_guru_split_dft__ -dfftw_plan_guru_split_dft_c2r_ -dfftw_plan_guru_split_dft_c2r__ -dfftw_plan_guru_split_dft_r2c_ -dfftw_plan_guru_split_dft_r2c__ -dfftw_plan_many_dft_ -dfftw_plan_many_dft__ -dfftw_plan_many_dft_c2r_ -dfftw_plan_many_dft_c2r__ -dfftw_plan_many_dft_r2c_ -dfftw_plan_many_dft_r2c__ -dfftw_plan_many_r2r_ -dfftw_plan_many_r2r__ -dfftw_plan_r2r_ -dfftw_plan_r2r__ -dfftw_plan_r2r_1d_ -dfftw_plan_r2r_1d__ -dfftw_plan_r2r_2d_ -dfftw_plan_r2r_2d__ -dfftw_plan_r2r_3d_ -dfftw_plan_r2r_3d__ -dfftw_plan_with_nthreads_ -dfftw_plan_with_nthreads__ -dfftw_print_plan_ -dfftw_print_plan__ -dfftw_set_timelimit_ -dfftw_set_timelimit__ -fftw_alignment_of -fftw_alloc_complex -fftw_alloc_real -fftw_assertion_failed -fftw_bufdist -fftw_check_alignment_of_sse2_pm -fftw_choose_radix -fftw_cleanup -fftw_cleanup_threads -fftw_codelet_e01_8 -fftw_codelet_e10_8 -fftw_codelet_hb_10 -fftw_codelet_hb_12 -fftw_codelet_hb_15 -fftw_codelet_hb_16 -fftw_codelet_hb_2 -fftw_codelet_hb_20 -fftw_codelet_hb2_16 -fftw_codelet_hb2_20 -fftw_codelet_hb2_25 -fftw_codelet_hb2_32 -fftw_codelet_hb2_4 -fftw_codelet_hb_25 -fftw_codelet_hb2_5 -fftw_codelet_hb2_8 -fftw_codelet_hb_3 -fftw_codelet_hb_32 -fftw_codelet_hb_4 -fftw_codelet_hb_5 -fftw_codelet_hb_6 -fftw_codelet_hb_64 -fftw_codelet_hb_7 -fftw_codelet_hb_8 -fftw_codelet_hb_9 -fftw_codelet_hc2cb_10 -fftw_codelet_hc2cb_12 -fftw_codelet_hc2cb_16 -fftw_codelet_hc2cb_2 -fftw_codelet_hc2cb_20 -fftw_codelet_hc2cb2_16 -fftw_codelet_hc2cb2_20 -fftw_codelet_hc2cb2_32 -fftw_codelet_hc2cb2_4 -fftw_codelet_hc2cb2_8 -fftw_codelet_hc2cb_32 -fftw_codelet_hc2cb_4 -fftw_codelet_hc2cb_6 -fftw_codelet_hc2cb_8 -fftw_codelet_hc2cbdft_10 -fftw_codelet_hc2cbdft_12 -fftw_codelet_hc2cbdft_16 -fftw_codelet_hc2cbdft_2 -fftw_codelet_hc2cbdft_20 -fftw_codelet_hc2cbdft2_16 -fftw_codelet_hc2cbdft2_20 -fftw_codelet_hc2cbdft2_32 -fftw_codelet_hc2cbdft2_4 -fftw_codelet_hc2cbdft2_8 -fftw_codelet_hc2cbdft_32 -fftw_codelet_hc2cbdft_4 -fftw_codelet_hc2cbdft_6 -fftw_codelet_hc2cbdft_8 -fftw_codelet_hc2cbdftv_10_avx -fftw_codelet_hc2cbdftv_10_sse2 -fftw_codelet_hc2cbdftv_12_avx -fftw_codelet_hc2cbdftv_12_sse2 -fftw_codelet_hc2cbdftv_16_avx -fftw_codelet_hc2cbdftv_16_sse2 -fftw_codelet_hc2cbdftv_20_avx -fftw_codelet_hc2cbdftv_20_sse2 -fftw_codelet_hc2cbdftv_2_avx -fftw_codelet_hc2cbdftv_2_sse2 -fftw_codelet_hc2cbdftv_32_avx -fftw_codelet_hc2cbdftv_32_sse2 -fftw_codelet_hc2cbdftv_4_avx -fftw_codelet_hc2cbdftv_4_sse2 -fftw_codelet_hc2cbdftv_6_avx -fftw_codelet_hc2cbdftv_6_sse2 -fftw_codelet_hc2cbdftv_8_avx -fftw_codelet_hc2cbdftv_8_sse2 -fftw_codelet_hc2cf_10 -fftw_codelet_hc2cf_12 -fftw_codelet_hc2cf_16 -fftw_codelet_hc2cf_2 -fftw_codelet_hc2cf_20 -fftw_codelet_hc2cf2_16 -fftw_codelet_hc2cf2_20 -fftw_codelet_hc2cf2_32 -fftw_codelet_hc2cf2_4 -fftw_codelet_hc2cf2_8 -fftw_codelet_hc2cf_32 -fftw_codelet_hc2cf_4 -fftw_codelet_hc2cf_6 -fftw_codelet_hc2cf_8 -fftw_codelet_hc2cfdft_10 -fftw_codelet_hc2cfdft_12 -fftw_codelet_hc2cfdft_16 -fftw_codelet_hc2cfdft_2 -fftw_codelet_hc2cfdft_20 -fftw_codelet_hc2cfdft2_16 -fftw_codelet_hc2cfdft2_20 -fftw_codelet_hc2cfdft2_32 -fftw_codelet_hc2cfdft2_4 -fftw_codelet_hc2cfdft2_8 -fftw_codelet_hc2cfdft_32 -fftw_codelet_hc2cfdft_4 -fftw_codelet_hc2cfdft_6 -fftw_codelet_hc2cfdft_8 -fftw_codelet_hc2cfdftv_10_avx -fftw_codelet_hc2cfdftv_10_sse2 -fftw_codelet_hc2cfdftv_12_avx -fftw_codelet_hc2cfdftv_12_sse2 -fftw_codelet_hc2cfdftv_16_avx -fftw_codelet_hc2cfdftv_16_sse2 -fftw_codelet_hc2cfdftv_20_avx -fftw_codelet_hc2cfdftv_20_sse2 -fftw_codelet_hc2cfdftv_2_avx -fftw_codelet_hc2cfdftv_2_sse2 -fftw_codelet_hc2cfdftv_32_avx -fftw_codelet_hc2cfdftv_32_sse2 -fftw_codelet_hc2cfdftv_4_avx -fftw_codelet_hc2cfdftv_4_sse2 -fftw_codelet_hc2cfdftv_6_avx -fftw_codelet_hc2cfdftv_6_sse2 -fftw_codelet_hc2cfdftv_8_avx -fftw_codelet_hc2cfdftv_8_sse2 -fftw_codelet_hf_10 -fftw_codelet_hf_12 -fftw_codelet_hf_15 -fftw_codelet_hf_16 -fftw_codelet_hf_2 -fftw_codelet_hf_20 -fftw_codelet_hf2_16 -fftw_codelet_hf2_20 -fftw_codelet_hf2_25 -fftw_codelet_hf2_32 -fftw_codelet_hf2_4 -fftw_codelet_hf_25 -fftw_codelet_hf2_5 -fftw_codelet_hf2_8 -fftw_codelet_hf_3 -fftw_codelet_hf_32 -fftw_codelet_hf_4 -fftw_codelet_hf_5 -fftw_codelet_hf_6 -fftw_codelet_hf_64 -fftw_codelet_hf_7 -fftw_codelet_hf_8 -fftw_codelet_hf_9 -fftw_codelet_n1_10 -fftw_codelet_n1_11 -fftw_codelet_n1_12 -fftw_codelet_n1_13 -fftw_codelet_n1_14 -fftw_codelet_n1_15 -fftw_codelet_n1_16 -fftw_codelet_n1_2 -fftw_codelet_n1_20 -fftw_codelet_n1_25 -fftw_codelet_n1_3 -fftw_codelet_n1_32 -fftw_codelet_n1_4 -fftw_codelet_n1_5 -fftw_codelet_n1_6 -fftw_codelet_n1_64 -fftw_codelet_n1_7 -fftw_codelet_n1_8 -fftw_codelet_n1_9 -fftw_codelet_n1bv_10_avx -fftw_codelet_n1bv_10_sse2 -fftw_codelet_n1bv_11_avx -fftw_codelet_n1bv_11_sse2 -fftw_codelet_n1bv_128_avx -fftw_codelet_n1bv_128_sse2 -fftw_codelet_n1bv_12_avx -fftw_codelet_n1bv_12_sse2 -fftw_codelet_n1bv_13_avx -fftw_codelet_n1bv_13_sse2 -fftw_codelet_n1bv_14_avx -fftw_codelet_n1bv_14_sse2 -fftw_codelet_n1bv_15_avx -fftw_codelet_n1bv_15_sse2 -fftw_codelet_n1bv_16_avx -fftw_codelet_n1bv_16_sse2 -fftw_codelet_n1bv_20_avx -fftw_codelet_n1bv_20_sse2 -fftw_codelet_n1bv_25_avx -fftw_codelet_n1bv_25_sse2 -fftw_codelet_n1bv_2_avx -fftw_codelet_n1bv_2_sse2 -fftw_codelet_n1bv_32_avx -fftw_codelet_n1bv_32_sse2 -fftw_codelet_n1bv_3_avx -fftw_codelet_n1bv_3_sse2 -fftw_codelet_n1bv_4_avx -fftw_codelet_n1bv_4_sse2 -fftw_codelet_n1bv_5_avx -fftw_codelet_n1bv_5_sse2 -fftw_codelet_n1bv_64_avx -fftw_codelet_n1bv_64_sse2 -fftw_codelet_n1bv_6_avx -fftw_codelet_n1bv_6_sse2 -fftw_codelet_n1bv_7_avx -fftw_codelet_n1bv_7_sse2 -fftw_codelet_n1bv_8_avx -fftw_codelet_n1bv_8_sse2 -fftw_codelet_n1bv_9_avx -fftw_codelet_n1bv_9_sse2 -fftw_codelet_n1fv_10_avx -fftw_codelet_n1fv_10_sse2 -fftw_codelet_n1fv_11_avx -fftw_codelet_n1fv_11_sse2 -fftw_codelet_n1fv_128_avx -fftw_codelet_n1fv_128_sse2 -fftw_codelet_n1fv_12_avx -fftw_codelet_n1fv_12_sse2 -fftw_codelet_n1fv_13_avx -fftw_codelet_n1fv_13_sse2 -fftw_codelet_n1fv_14_avx -fftw_codelet_n1fv_14_sse2 -fftw_codelet_n1fv_15_avx -fftw_codelet_n1fv_15_sse2 -fftw_codelet_n1fv_16_avx -fftw_codelet_n1fv_16_sse2 -fftw_codelet_n1fv_20_avx -fftw_codelet_n1fv_20_sse2 -fftw_codelet_n1fv_25_avx -fftw_codelet_n1fv_25_sse2 -fftw_codelet_n1fv_2_avx -fftw_codelet_n1fv_2_sse2 -fftw_codelet_n1fv_32_avx -fftw_codelet_n1fv_32_sse2 -fftw_codelet_n1fv_3_avx -fftw_codelet_n1fv_3_sse2 -fftw_codelet_n1fv_4_avx -fftw_codelet_n1fv_4_sse2 -fftw_codelet_n1fv_5_avx -fftw_codelet_n1fv_5_sse2 -fftw_codelet_n1fv_64_avx -fftw_codelet_n1fv_64_sse2 -fftw_codelet_n1fv_6_avx -fftw_codelet_n1fv_6_sse2 -fftw_codelet_n1fv_7_avx -fftw_codelet_n1fv_7_sse2 -fftw_codelet_n1fv_8_avx -fftw_codelet_n1fv_8_sse2 -fftw_codelet_n1fv_9_avx -fftw_codelet_n1fv_9_sse2 -fftw_codelet_n2bv_10_avx -fftw_codelet_n2bv_10_sse2 -fftw_codelet_n2bv_12_avx -fftw_codelet_n2bv_12_sse2 -fftw_codelet_n2bv_14_avx -fftw_codelet_n2bv_14_sse2 -fftw_codelet_n2bv_16_avx -fftw_codelet_n2bv_16_sse2 -fftw_codelet_n2bv_20_avx -fftw_codelet_n2bv_20_sse2 -fftw_codelet_n2bv_2_avx -fftw_codelet_n2bv_2_sse2 -fftw_codelet_n2bv_32_avx -fftw_codelet_n2bv_32_sse2 -fftw_codelet_n2bv_4_avx -fftw_codelet_n2bv_4_sse2 -fftw_codelet_n2bv_64_avx -fftw_codelet_n2bv_64_sse2 -fftw_codelet_n2bv_6_avx -fftw_codelet_n2bv_6_sse2 -fftw_codelet_n2bv_8_avx -fftw_codelet_n2bv_8_sse2 -fftw_codelet_n2fv_10_avx -fftw_codelet_n2fv_10_sse2 -fftw_codelet_n2fv_12_avx -fftw_codelet_n2fv_12_sse2 -fftw_codelet_n2fv_14_avx -fftw_codelet_n2fv_14_sse2 -fftw_codelet_n2fv_16_avx -fftw_codelet_n2fv_16_sse2 -fftw_codelet_n2fv_20_avx -fftw_codelet_n2fv_20_sse2 -fftw_codelet_n2fv_2_avx -fftw_codelet_n2fv_2_sse2 -fftw_codelet_n2fv_32_avx -fftw_codelet_n2fv_32_sse2 -fftw_codelet_n2fv_4_avx -fftw_codelet_n2fv_4_sse2 -fftw_codelet_n2fv_64_avx -fftw_codelet_n2fv_64_sse2 -fftw_codelet_n2fv_6_avx -fftw_codelet_n2fv_6_sse2 -fftw_codelet_n2fv_8_avx -fftw_codelet_n2fv_8_sse2 -fftw_codelet_n2sv_16_avx -fftw_codelet_n2sv_16_sse2 -fftw_codelet_n2sv_32_avx -fftw_codelet_n2sv_32_sse2 -fftw_codelet_n2sv_4_avx -fftw_codelet_n2sv_4_sse2 -fftw_codelet_n2sv_64_avx -fftw_codelet_n2sv_64_sse2 -fftw_codelet_n2sv_8_avx -fftw_codelet_n2sv_8_sse2 -fftw_codelet_q1_2 -fftw_codelet_q1_3 -fftw_codelet_q1_4 -fftw_codelet_q1_5 -fftw_codelet_q1_6 -fftw_codelet_q1_8 -fftw_codelet_q1bv_2_avx -fftw_codelet_q1bv_2_sse2 -fftw_codelet_q1bv_4_avx -fftw_codelet_q1bv_4_sse2 -fftw_codelet_q1bv_5_avx -fftw_codelet_q1bv_5_sse2 -fftw_codelet_q1bv_8_avx -fftw_codelet_q1bv_8_sse2 -fftw_codelet_q1fv_2_avx -fftw_codelet_q1fv_2_sse2 -fftw_codelet_q1fv_4_avx -fftw_codelet_q1fv_4_sse2 -fftw_codelet_q1fv_5_avx -fftw_codelet_q1fv_5_sse2 -fftw_codelet_q1fv_8_avx -fftw_codelet_q1fv_8_sse2 -fftw_codelet_r2cb_10 -fftw_codelet_r2cb_11 -fftw_codelet_r2cb_12 -fftw_codelet_r2cb_128 -fftw_codelet_r2cb_13 -fftw_codelet_r2cb_14 -fftw_codelet_r2cb_15 -fftw_codelet_r2cb_16 -fftw_codelet_r2cb_2 -fftw_codelet_r2cb_20 -fftw_codelet_r2cb_25 -fftw_codelet_r2cb_3 -fftw_codelet_r2cb_32 -fftw_codelet_r2cb_4 -fftw_codelet_r2cb_5 -fftw_codelet_r2cb_6 -fftw_codelet_r2cb_64 -fftw_codelet_r2cb_7 -fftw_codelet_r2cb_8 -fftw_codelet_r2cb_9 -fftw_codelet_r2cbIII_10 -fftw_codelet_r2cbIII_12 -fftw_codelet_r2cbIII_15 -fftw_codelet_r2cbIII_16 -fftw_codelet_r2cbIII_2 -fftw_codelet_r2cbIII_20 -fftw_codelet_r2cbIII_25 -fftw_codelet_r2cbIII_3 -fftw_codelet_r2cbIII_32 -fftw_codelet_r2cbIII_4 -fftw_codelet_r2cbIII_5 -fftw_codelet_r2cbIII_6 -fftw_codelet_r2cbIII_64 -fftw_codelet_r2cbIII_7 -fftw_codelet_r2cbIII_8 -fftw_codelet_r2cbIII_9 -fftw_codelet_r2cf_10 -fftw_codelet_r2cf_11 -fftw_codelet_r2cf_12 -fftw_codelet_r2cf_128 -fftw_codelet_r2cf_13 -fftw_codelet_r2cf_14 -fftw_codelet_r2cf_15 -fftw_codelet_r2cf_16 -fftw_codelet_r2cf_2 -fftw_codelet_r2cf_20 -fftw_codelet_r2cf_25 -fftw_codelet_r2cf_3 -fftw_codelet_r2cf_32 -fftw_codelet_r2cf_4 -fftw_codelet_r2cf_5 -fftw_codelet_r2cf_6 -fftw_codelet_r2cf_64 -fftw_codelet_r2cf_7 -fftw_codelet_r2cf_8 -fftw_codelet_r2cf_9 -fftw_codelet_r2cfII_10 -fftw_codelet_r2cfII_12 -fftw_codelet_r2cfII_15 -fftw_codelet_r2cfII_16 -fftw_codelet_r2cfII_2 -fftw_codelet_r2cfII_20 -fftw_codelet_r2cfII_25 -fftw_codelet_r2cfII_3 -fftw_codelet_r2cfII_32 -fftw_codelet_r2cfII_4 -fftw_codelet_r2cfII_5 -fftw_codelet_r2cfII_6 -fftw_codelet_r2cfII_64 -fftw_codelet_r2cfII_7 -fftw_codelet_r2cfII_8 -fftw_codelet_r2cfII_9 -fftw_codelet_t1_10 -fftw_codelet_t1_12 -fftw_codelet_t1_15 -fftw_codelet_t1_16 -fftw_codelet_t1_2 -fftw_codelet_t1_20 -fftw_codelet_t1_25 -fftw_codelet_t1_3 -fftw_codelet_t1_32 -fftw_codelet_t1_4 -fftw_codelet_t1_5 -fftw_codelet_t1_6 -fftw_codelet_t1_64 -fftw_codelet_t1_7 -fftw_codelet_t1_8 -fftw_codelet_t1_9 -fftw_codelet_t1buv_10_avx -fftw_codelet_t1buv_10_sse2 -fftw_codelet_t1buv_2_avx -fftw_codelet_t1buv_2_sse2 -fftw_codelet_t1buv_3_avx -fftw_codelet_t1buv_3_sse2 -fftw_codelet_t1buv_4_avx -fftw_codelet_t1buv_4_sse2 -fftw_codelet_t1buv_5_avx -fftw_codelet_t1buv_5_sse2 -fftw_codelet_t1buv_6_avx -fftw_codelet_t1buv_6_sse2 -fftw_codelet_t1buv_7_avx -fftw_codelet_t1buv_7_sse2 -fftw_codelet_t1buv_8_avx -fftw_codelet_t1buv_8_sse2 -fftw_codelet_t1buv_9_avx -fftw_codelet_t1buv_9_sse2 -fftw_codelet_t1bv_10_avx -fftw_codelet_t1bv_10_sse2 -fftw_codelet_t1bv_12_avx -fftw_codelet_t1bv_12_sse2 -fftw_codelet_t1bv_15_avx -fftw_codelet_t1bv_15_sse2 -fftw_codelet_t1bv_16_avx -fftw_codelet_t1bv_16_sse2 -fftw_codelet_t1bv_20_avx -fftw_codelet_t1bv_20_sse2 -fftw_codelet_t1bv_25_avx -fftw_codelet_t1bv_25_sse2 -fftw_codelet_t1bv_2_avx -fftw_codelet_t1bv_2_sse2 -fftw_codelet_t1bv_32_avx -fftw_codelet_t1bv_32_sse2 -fftw_codelet_t1bv_3_avx -fftw_codelet_t1bv_3_sse2 -fftw_codelet_t1bv_4_avx -fftw_codelet_t1bv_4_sse2 -fftw_codelet_t1bv_5_avx -fftw_codelet_t1bv_5_sse2 -fftw_codelet_t1bv_64_avx -fftw_codelet_t1bv_64_sse2 -fftw_codelet_t1bv_6_avx -fftw_codelet_t1bv_6_sse2 -fftw_codelet_t1bv_7_avx -fftw_codelet_t1bv_7_sse2 -fftw_codelet_t1bv_8_avx -fftw_codelet_t1bv_8_sse2 -fftw_codelet_t1bv_9_avx -fftw_codelet_t1bv_9_sse2 -fftw_codelet_t1fuv_10_avx -fftw_codelet_t1fuv_10_sse2 -fftw_codelet_t1fuv_2_avx -fftw_codelet_t1fuv_2_sse2 -fftw_codelet_t1fuv_3_avx -fftw_codelet_t1fuv_3_sse2 -fftw_codelet_t1fuv_4_avx -fftw_codelet_t1fuv_4_sse2 -fftw_codelet_t1fuv_5_avx -fftw_codelet_t1fuv_5_sse2 -fftw_codelet_t1fuv_6_avx -fftw_codelet_t1fuv_6_sse2 -fftw_codelet_t1fuv_7_avx -fftw_codelet_t1fuv_7_sse2 -fftw_codelet_t1fuv_8_avx -fftw_codelet_t1fuv_8_sse2 -fftw_codelet_t1fuv_9_avx -fftw_codelet_t1fuv_9_sse2 -fftw_codelet_t1fv_10_avx -fftw_codelet_t1fv_10_sse2 -fftw_codelet_t1fv_12_avx -fftw_codelet_t1fv_12_sse2 -fftw_codelet_t1fv_15_avx -fftw_codelet_t1fv_15_sse2 -fftw_codelet_t1fv_16_avx -fftw_codelet_t1fv_16_sse2 -fftw_codelet_t1fv_20_avx -fftw_codelet_t1fv_20_sse2 -fftw_codelet_t1fv_25_avx -fftw_codelet_t1fv_25_sse2 -fftw_codelet_t1fv_2_avx -fftw_codelet_t1fv_2_sse2 -fftw_codelet_t1fv_32_avx -fftw_codelet_t1fv_32_sse2 -fftw_codelet_t1fv_3_avx -fftw_codelet_t1fv_3_sse2 -fftw_codelet_t1fv_4_avx -fftw_codelet_t1fv_4_sse2 -fftw_codelet_t1fv_5_avx -fftw_codelet_t1fv_5_sse2 -fftw_codelet_t1fv_64_avx -fftw_codelet_t1fv_64_sse2 -fftw_codelet_t1fv_6_avx -fftw_codelet_t1fv_6_sse2 -fftw_codelet_t1fv_7_avx -fftw_codelet_t1fv_7_sse2 -fftw_codelet_t1fv_8_avx -fftw_codelet_t1fv_8_sse2 -fftw_codelet_t1fv_9_avx -fftw_codelet_t1fv_9_sse2 -fftw_codelet_t1sv_16_avx -fftw_codelet_t1sv_16_sse2 -fftw_codelet_t1sv_2_avx -fftw_codelet_t1sv_2_sse2 -fftw_codelet_t1sv_32_avx -fftw_codelet_t1sv_32_sse2 -fftw_codelet_t1sv_4_avx -fftw_codelet_t1sv_4_sse2 -fftw_codelet_t1sv_8_avx -fftw_codelet_t1sv_8_sse2 -fftw_codelet_t2_10 -fftw_codelet_t2_16 -fftw_codelet_t2_20 -fftw_codelet_t2_25 -fftw_codelet_t2_32 -fftw_codelet_t2_4 -fftw_codelet_t2_5 -fftw_codelet_t2_64 -fftw_codelet_t2_8 -fftw_codelet_t2bv_10_avx -fftw_codelet_t2bv_10_sse2 -fftw_codelet_t2bv_16_avx -fftw_codelet_t2bv_16_sse2 -fftw_codelet_t2bv_20_avx -fftw_codelet_t2bv_20_sse2 -fftw_codelet_t2bv_25_avx -fftw_codelet_t2bv_25_sse2 -fftw_codelet_t2bv_2_avx -fftw_codelet_t2bv_2_sse2 -fftw_codelet_t2bv_32_avx -fftw_codelet_t2bv_32_sse2 -fftw_codelet_t2bv_4_avx -fftw_codelet_t2bv_4_sse2 -fftw_codelet_t2bv_5_avx -fftw_codelet_t2bv_5_sse2 -fftw_codelet_t2bv_64_avx -fftw_codelet_t2bv_64_sse2 -fftw_codelet_t2bv_8_avx -fftw_codelet_t2bv_8_sse2 -fftw_codelet_t2fv_10_avx -fftw_codelet_t2fv_10_sse2 -fftw_codelet_t2fv_16_avx -fftw_codelet_t2fv_16_sse2 -fftw_codelet_t2fv_20_avx -fftw_codelet_t2fv_20_sse2 -fftw_codelet_t2fv_25_avx -fftw_codelet_t2fv_25_sse2 -fftw_codelet_t2fv_2_avx -fftw_codelet_t2fv_2_sse2 -fftw_codelet_t2fv_32_avx -fftw_codelet_t2fv_32_sse2 -fftw_codelet_t2fv_4_avx -fftw_codelet_t2fv_4_sse2 -fftw_codelet_t2fv_5_avx -fftw_codelet_t2fv_5_sse2 -fftw_codelet_t2fv_64_avx -fftw_codelet_t2fv_64_sse2 -fftw_codelet_t2fv_8_avx -fftw_codelet_t2fv_8_sse2 -fftw_codelet_t2sv_16_avx -fftw_codelet_t2sv_16_sse2 -fftw_codelet_t2sv_32_avx -fftw_codelet_t2sv_32_sse2 -fftw_codelet_t2sv_4_avx -fftw_codelet_t2sv_4_sse2 -fftw_codelet_t2sv_8_avx -fftw_codelet_t2sv_8_sse2 -fftw_codelet_t3bv_10_avx -fftw_codelet_t3bv_10_sse2 -fftw_codelet_t3bv_16_avx -fftw_codelet_t3bv_16_sse2 -fftw_codelet_t3bv_20_avx -fftw_codelet_t3bv_20_sse2 -fftw_codelet_t3bv_25_avx -fftw_codelet_t3bv_25_sse2 -fftw_codelet_t3bv_32_avx -fftw_codelet_t3bv_32_sse2 -fftw_codelet_t3bv_4_avx -fftw_codelet_t3bv_4_sse2 -fftw_codelet_t3bv_5_avx -fftw_codelet_t3bv_5_sse2 -fftw_codelet_t3bv_8_avx -fftw_codelet_t3bv_8_sse2 -fftw_codelet_t3fv_10_avx -fftw_codelet_t3fv_10_sse2 -fftw_codelet_t3fv_16_avx -fftw_codelet_t3fv_16_sse2 -fftw_codelet_t3fv_20_avx -fftw_codelet_t3fv_20_sse2 -fftw_codelet_t3fv_25_avx -fftw_codelet_t3fv_25_sse2 -fftw_codelet_t3fv_32_avx -fftw_codelet_t3fv_32_sse2 -fftw_codelet_t3fv_4_avx -fftw_codelet_t3fv_4_sse2 -fftw_codelet_t3fv_5_avx -fftw_codelet_t3fv_5_sse2 -fftw_codelet_t3fv_8_avx -fftw_codelet_t3fv_8_sse2 -fftw_compute_tilesz -fftw_configure_planner -fftw_cost -fftw_cpy1d -fftw_cpy2d -fftw_cpy2d_ci -fftw_cpy2d_co -fftw_cpy2d_pair -fftw_cpy2d_pair_ci -fftw_cpy2d_pair_co -fftw_cpy2d_tiled -fftw_cpy2d_tiledbuf -fftw_ct_applicable -fftw_ct_genericbuf_register -fftw_ct_generic_register -fftw_ct_uglyp -fftw_destroy_plan -fftw_dft_bluestein_register -fftw_dft_buffered_register -fftw_dft_conf_standard -fftw_dft_generic_register -fftw_dft_indirect_register -fftw_dft_indirect_transpose_register -fftw_dft_nop_register -fftw_dft_r2hc_register -fftw_dft_rader_register -fftw_dft_rank_geq2_register -fftw_dft_solve -fftw_dft_thr_vrank_geq1_register -fftw_dft_vrank_geq1_register -fftw_dft_zerotens -fftw_dht_r2hc_register -fftw_dht_rader_register -fftw_dimcmp -fftw_elapsed_since -fftw_estimate_cost -fftw_execute -fftw_execute_dft -fftw_execute_dft_c2r -fftw_execute_dft_r2c -fftw_execute_r2r -fftw_execute_split_dft -fftw_execute_split_dft_c2r -fftw_execute_split_dft_r2c -fftw_export_wisdom -fftw_export_wisdom_to_file -fftw_export_wisdom_to_filename -fftw_export_wisdom_to_string -fftw_extract_reim -fftw_factors_into -fftw_factors_into_small_primes -fftw_find_generator -fftw_first_divisor -fftw_flops -fftw_forget_wisdom -fftw_fprint_plan -fftw_free -fftw_get_crude_time -fftw_guru64_kosherp -fftw_guru_kosherp -fftw_hash -fftw_have_simd_avx -fftw_have_simd_sse2 -fftw_hc2hc_applicable -fftw_hc2hc_generic_register -fftw_iabs -fftw_ialignment_of -fftw_iestimate_cost -fftw_ifree -fftw_ifree0 -fftw_imax -fftw_imin -fftw_import_system_wisdom -fftw_import_wisdom -fftw_import_wisdom_from_file -fftw_import_wisdom_from_filename -fftw_import_wisdom_from_string -fftw_init_threads -fftw_is_prime -fftw_isqrt -fftw_ithreads_init -fftw_join_taint -fftw_kdft_dif_register -fftw_kdft_difsq_register -fftw_kdft_dit_register -fftw_kdft_register -fftw_kernel_free -fftw_kernel_malloc -fftw_khc2c_register -fftw_khc2hc_register -fftw_kr2c_register -fftw_kr2r_register -fftw_make_planner_thread_safe -fftw_malloc -fftw_malloc_plain -fftw_many_kosherp -fftw_mapflags -fftw_map_r2r_kind -fftw_md5begin -fftw_md5end -fftw_md5int -fftw_md5INT -fftw_md5putb -fftw_md5putc -fftw_md5puts -fftw_md5unsigned -fftw_measure_execution_time -fftw_mkapiplan -fftw_mkplan -fftw_mkplan_d -fftw_mkplan_dft -fftw_mkplan_dftw -fftw_mkplan_f_d -fftw_mkplan_hc2c -fftw_mkplan_hc2hc -fftw_mkplanner -fftw_mkplan_rdft -fftw_mkplan_rdft2 -fftw_mkprinter -fftw_mkprinter_cnt -fftw_mkprinter_file -fftw_mkprinter_str -fftw_mkproblem -fftw_mkproblem_dft -fftw_mkproblem_dft_d -fftw_mkproblem_rdft -fftw_mkproblem_rdft_0_d -fftw_mkproblem_rdft_1 -fftw_mkproblem_rdft_1_d -fftw_mkproblem_rdft2 -fftw_mkproblem_rdft2_d -fftw_mkproblem_rdft2_d_3pointers -fftw_mkproblem_rdft_d -fftw_mkproblem_unsolvable -fftw_mkscanner -fftw_mksolver -fftw_mksolver_ct -fftw_mksolver_ct_threads -fftw_mksolver_dft_direct -fftw_mksolver_dft_directbuf -fftw_mksolver_hc2c -fftw_mksolver_hc2hc -fftw_mksolver_hc2hc_threads -fftw_mksolver_rdft2_direct -fftw_mksolver_rdft_r2c_direct -fftw_mksolver_rdft_r2c_directbuf -fftw_mksolver_rdft_r2r_direct -fftw_mkstride -fftw_mktensor -fftw_mktensor_0d -fftw_mktensor_1d -fftw_mktensor_2d -fftw_mktensor_3d -fftw_mktensor_4d -fftw_mktensor_5d -fftw_mktensor_iodims -fftw_mktensor_iodims64 -fftw_mktensor_rowmajor -fftw_mktriggen -fftw_modulo -fftw_nbuf -fftw_nbuf_redundant -fftw_next_prime -fftw_null_awake -fftw_ops_add -fftw_ops_add2 -fftw_ops_cpy -fftw_ops_madd -fftw_ops_madd2 -fftw_ops_other -fftw_ops_zero -fftw_pickdim -fftw_plan_awake -fftw_plan_destroy_internal -fftw_plan_dft -fftw_plan_dft_1d -fftw_plan_dft_2d -fftw_plan_dft_3d -fftw_plan_dft_c2r -fftw_plan_dft_c2r_1d -fftw_plan_dft_c2r_2d -fftw_plan_dft_c2r_3d -fftw_plan_dft_r2c -fftw_plan_dft_r2c_1d -fftw_plan_dft_r2c_2d -fftw_plan_dft_r2c_3d -fftw_plan_guru64_dft -fftw_plan_guru64_dft_c2r -fftw_plan_guru64_dft_r2c -fftw_plan_guru64_r2r -fftw_plan_guru64_split_dft -fftw_plan_guru64_split_dft_c2r -fftw_plan_guru64_split_dft_r2c -fftw_plan_guru_dft -fftw_plan_guru_dft_c2r -fftw_plan_guru_dft_r2c -fftw_plan_guru_r2r -fftw_plan_guru_split_dft -fftw_plan_guru_split_dft_c2r -fftw_plan_guru_split_dft_r2c -fftw_plan_many_dft -fftw_plan_many_dft_c2r -fftw_plan_many_dft_r2c -fftw_plan_many_r2r -fftw_planner_destroy -fftw_plan_null_destroy -fftw_plan_r2r -fftw_plan_r2r_1d -fftw_plan_r2r_2d -fftw_plan_r2r_3d -fftw_plan_with_nthreads -fftw_power_mod -fftw_printer_destroy -fftw_print_plan -fftw_problem_destroy -fftw_rader_tl_delete -fftw_rader_tl_find -fftw_rader_tl_insert -fftw_rdft2_buffered_register -fftw_rdft2_complex_n -fftw_rdft2_inplace_strides -fftw_rdft2_nop_register -fftw_rdft2_pad -fftw_rdft2_rank0_register -fftw_rdft2_rank_geq2_register -fftw_rdft2_rdft_register -fftw_rdft2_solve -fftw_rdft2_strides -fftw_rdft2_tensor_max_index -fftw_rdft2_thr_vrank_geq1_register -fftw_rdft2_vrank_geq1_register -fftw_rdft_buffered_register -fftw_rdft_conf_standard -fftw_rdft_dht_register -fftw_rdft_generic_register -fftw_rdft_indirect_register -fftw_rdft_kind_str -fftw_rdft_nop_register -fftw_rdft_rank0_register -fftw_rdft_rank_geq2_register -fftw_rdft_solve -fftw_rdft_thr_vrank_geq1_register -fftw_rdft_vrank3_transpose_register -fftw_rdft_vrank_geq1_register -fftw_rdft_zerotens -fftw_redft00e_r2hc_pad_register -fftw_regsolver_ct_directw -fftw_regsolver_ct_directwsq -fftw_regsolver_hc2c_direct -fftw_regsolver_hc2hc_direct -fftw_reodft00e_splitradix_register -fftw_reodft010e_r2hc_register -fftw_reodft11e_r2hc_odd_register -fftw_reodft11e_radix2_r2hc_register -fftw_reodft_conf_standard -fftw_rodft00e_r2hc_pad_register -fftw_safe_mulmod -fftw_scanner_destroy -fftw_set_planner_hooks -fftw_set_timelimit -fftw_solver_destroy -fftw_solver_register -fftw_solver_use -fftw_solvtab_exec -fftw_spawn_loop -fftw_sprint_plan -fftw_stride_destroy -fftw_taint -fftw_tensor_append -fftw_tensor_compress -fftw_tensor_compress_contiguous -fftw_tensor_copy -fftw_tensor_copy_except -fftw_tensor_copy_inplace -fftw_tensor_copy_sub -fftw_tensor_destroy -fftw_tensor_destroy2 -fftw_tensor_destroy4 -fftw_tensor_equal -fftw_tensor_inplace_locations -fftw_tensor_inplace_strides -fftw_tensor_inplace_strides2 -fftw_tensor_kosherp -fftw_tensor_max_index -fftw_tensor_md5 -fftw_tensor_min_istride -fftw_tensor_min_ostride -fftw_tensor_min_stride -fftw_tensor_print -fftw_tensor_split -fftw_tensor_strides_decrease -fftw_tensor_sz -fftw_tensor_tornk1 -fftw_the_planner -fftw_threads_cleanup -fftw_threads_conf_standard -fftw_threads_register_planner_hooks -fftw_tile2d -fftw_toobig -fftw_transpose -fftw_transpose_tiled -fftw_transpose_tiledbuf -fftw_triggen_destroy -fftw_twiddle_awake -fftw_twiddle_length -fftw_zero1d_pair diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.exp b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.exp deleted file mode 100644 index 9ab00ba19..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.lib b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.lib deleted file mode 100644 index 48c4af947..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.def b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.def deleted file mode 100644 index d61a2c36c..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.def +++ /dev/null @@ -1,1017 +0,0 @@ -LIBRARY libfftw3f-3.dll -EXPORTS -fftwf_alignment_of -fftwf_alloc_complex -fftwf_alloc_real -fftwf_assertion_failed -fftwf_bufdist -fftwf_check_alignment_of_sse2_pm -fftwf_choose_radix -fftwf_cleanup -fftwf_cleanup_threads -fftwf_codelet_e01_8 -fftwf_codelet_e10_8 -fftwf_codelet_hb_10 -fftwf_codelet_hb_12 -fftwf_codelet_hb_15 -fftwf_codelet_hb_16 -fftwf_codelet_hb_2 -fftwf_codelet_hb_20 -fftwf_codelet_hb2_16 -fftwf_codelet_hb2_20 -fftwf_codelet_hb2_25 -fftwf_codelet_hb2_32 -fftwf_codelet_hb2_4 -fftwf_codelet_hb_25 -fftwf_codelet_hb2_5 -fftwf_codelet_hb2_8 -fftwf_codelet_hb_3 -fftwf_codelet_hb_32 -fftwf_codelet_hb_4 -fftwf_codelet_hb_5 -fftwf_codelet_hb_6 -fftwf_codelet_hb_64 -fftwf_codelet_hb_7 -fftwf_codelet_hb_8 -fftwf_codelet_hb_9 -fftwf_codelet_hc2cb_10 -fftwf_codelet_hc2cb_12 -fftwf_codelet_hc2cb_16 -fftwf_codelet_hc2cb_2 -fftwf_codelet_hc2cb_20 -fftwf_codelet_hc2cb2_16 -fftwf_codelet_hc2cb2_20 -fftwf_codelet_hc2cb2_32 -fftwf_codelet_hc2cb2_4 -fftwf_codelet_hc2cb2_8 -fftwf_codelet_hc2cb_32 -fftwf_codelet_hc2cb_4 -fftwf_codelet_hc2cb_6 -fftwf_codelet_hc2cb_8 -fftwf_codelet_hc2cbdft_10 -fftwf_codelet_hc2cbdft_12 -fftwf_codelet_hc2cbdft_16 -fftwf_codelet_hc2cbdft_2 -fftwf_codelet_hc2cbdft_20 -fftwf_codelet_hc2cbdft2_16 -fftwf_codelet_hc2cbdft2_20 -fftwf_codelet_hc2cbdft2_32 -fftwf_codelet_hc2cbdft2_4 -fftwf_codelet_hc2cbdft2_8 -fftwf_codelet_hc2cbdft_32 -fftwf_codelet_hc2cbdft_4 -fftwf_codelet_hc2cbdft_6 -fftwf_codelet_hc2cbdft_8 -fftwf_codelet_hc2cbdftv_10_avx -fftwf_codelet_hc2cbdftv_10_sse2 -fftwf_codelet_hc2cbdftv_12_avx -fftwf_codelet_hc2cbdftv_12_sse2 -fftwf_codelet_hc2cbdftv_16_avx -fftwf_codelet_hc2cbdftv_16_sse2 -fftwf_codelet_hc2cbdftv_20_avx -fftwf_codelet_hc2cbdftv_20_sse2 -fftwf_codelet_hc2cbdftv_2_avx -fftwf_codelet_hc2cbdftv_2_sse2 -fftwf_codelet_hc2cbdftv_32_avx -fftwf_codelet_hc2cbdftv_32_sse2 -fftwf_codelet_hc2cbdftv_4_avx -fftwf_codelet_hc2cbdftv_4_sse2 -fftwf_codelet_hc2cbdftv_6_avx -fftwf_codelet_hc2cbdftv_6_sse2 -fftwf_codelet_hc2cbdftv_8_avx -fftwf_codelet_hc2cbdftv_8_sse2 -fftwf_codelet_hc2cf_10 -fftwf_codelet_hc2cf_12 -fftwf_codelet_hc2cf_16 -fftwf_codelet_hc2cf_2 -fftwf_codelet_hc2cf_20 -fftwf_codelet_hc2cf2_16 -fftwf_codelet_hc2cf2_20 -fftwf_codelet_hc2cf2_32 -fftwf_codelet_hc2cf2_4 -fftwf_codelet_hc2cf2_8 -fftwf_codelet_hc2cf_32 -fftwf_codelet_hc2cf_4 -fftwf_codelet_hc2cf_6 -fftwf_codelet_hc2cf_8 -fftwf_codelet_hc2cfdft_10 -fftwf_codelet_hc2cfdft_12 -fftwf_codelet_hc2cfdft_16 -fftwf_codelet_hc2cfdft_2 -fftwf_codelet_hc2cfdft_20 -fftwf_codelet_hc2cfdft2_16 -fftwf_codelet_hc2cfdft2_20 -fftwf_codelet_hc2cfdft2_32 -fftwf_codelet_hc2cfdft2_4 -fftwf_codelet_hc2cfdft2_8 -fftwf_codelet_hc2cfdft_32 -fftwf_codelet_hc2cfdft_4 -fftwf_codelet_hc2cfdft_6 -fftwf_codelet_hc2cfdft_8 -fftwf_codelet_hc2cfdftv_10_avx -fftwf_codelet_hc2cfdftv_10_sse2 -fftwf_codelet_hc2cfdftv_12_avx -fftwf_codelet_hc2cfdftv_12_sse2 -fftwf_codelet_hc2cfdftv_16_avx -fftwf_codelet_hc2cfdftv_16_sse2 -fftwf_codelet_hc2cfdftv_20_avx -fftwf_codelet_hc2cfdftv_20_sse2 -fftwf_codelet_hc2cfdftv_2_avx -fftwf_codelet_hc2cfdftv_2_sse2 -fftwf_codelet_hc2cfdftv_32_avx -fftwf_codelet_hc2cfdftv_32_sse2 -fftwf_codelet_hc2cfdftv_4_avx -fftwf_codelet_hc2cfdftv_4_sse2 -fftwf_codelet_hc2cfdftv_6_avx -fftwf_codelet_hc2cfdftv_6_sse2 -fftwf_codelet_hc2cfdftv_8_avx -fftwf_codelet_hc2cfdftv_8_sse2 -fftwf_codelet_hf_10 -fftwf_codelet_hf_12 -fftwf_codelet_hf_15 -fftwf_codelet_hf_16 -fftwf_codelet_hf_2 -fftwf_codelet_hf_20 -fftwf_codelet_hf2_16 -fftwf_codelet_hf2_20 -fftwf_codelet_hf2_25 -fftwf_codelet_hf2_32 -fftwf_codelet_hf2_4 -fftwf_codelet_hf_25 -fftwf_codelet_hf2_5 -fftwf_codelet_hf2_8 -fftwf_codelet_hf_3 -fftwf_codelet_hf_32 -fftwf_codelet_hf_4 -fftwf_codelet_hf_5 -fftwf_codelet_hf_6 -fftwf_codelet_hf_64 -fftwf_codelet_hf_7 -fftwf_codelet_hf_8 -fftwf_codelet_hf_9 -fftwf_codelet_n1_10 -fftwf_codelet_n1_11 -fftwf_codelet_n1_12 -fftwf_codelet_n1_13 -fftwf_codelet_n1_14 -fftwf_codelet_n1_15 -fftwf_codelet_n1_16 -fftwf_codelet_n1_2 -fftwf_codelet_n1_20 -fftwf_codelet_n1_25 -fftwf_codelet_n1_3 -fftwf_codelet_n1_32 -fftwf_codelet_n1_4 -fftwf_codelet_n1_5 -fftwf_codelet_n1_6 -fftwf_codelet_n1_64 -fftwf_codelet_n1_7 -fftwf_codelet_n1_8 -fftwf_codelet_n1_9 -fftwf_codelet_n1bv_10_avx -fftwf_codelet_n1bv_10_sse2 -fftwf_codelet_n1bv_11_avx -fftwf_codelet_n1bv_11_sse2 -fftwf_codelet_n1bv_128_avx -fftwf_codelet_n1bv_128_sse2 -fftwf_codelet_n1bv_12_avx -fftwf_codelet_n1bv_12_sse2 -fftwf_codelet_n1bv_13_avx -fftwf_codelet_n1bv_13_sse2 -fftwf_codelet_n1bv_14_avx -fftwf_codelet_n1bv_14_sse2 -fftwf_codelet_n1bv_15_avx -fftwf_codelet_n1bv_15_sse2 -fftwf_codelet_n1bv_16_avx -fftwf_codelet_n1bv_16_sse2 -fftwf_codelet_n1bv_20_avx -fftwf_codelet_n1bv_20_sse2 -fftwf_codelet_n1bv_25_avx -fftwf_codelet_n1bv_25_sse2 -fftwf_codelet_n1bv_2_avx -fftwf_codelet_n1bv_2_sse2 -fftwf_codelet_n1bv_32_avx -fftwf_codelet_n1bv_32_sse2 -fftwf_codelet_n1bv_3_avx -fftwf_codelet_n1bv_3_sse2 -fftwf_codelet_n1bv_4_avx -fftwf_codelet_n1bv_4_sse2 -fftwf_codelet_n1bv_5_avx -fftwf_codelet_n1bv_5_sse2 -fftwf_codelet_n1bv_64_avx -fftwf_codelet_n1bv_64_sse2 -fftwf_codelet_n1bv_6_avx -fftwf_codelet_n1bv_6_sse2 -fftwf_codelet_n1bv_7_avx -fftwf_codelet_n1bv_7_sse2 -fftwf_codelet_n1bv_8_avx -fftwf_codelet_n1bv_8_sse2 -fftwf_codelet_n1bv_9_avx -fftwf_codelet_n1bv_9_sse2 -fftwf_codelet_n1fv_10_avx -fftwf_codelet_n1fv_10_sse2 -fftwf_codelet_n1fv_11_avx -fftwf_codelet_n1fv_11_sse2 -fftwf_codelet_n1fv_128_avx -fftwf_codelet_n1fv_128_sse2 -fftwf_codelet_n1fv_12_avx -fftwf_codelet_n1fv_12_sse2 -fftwf_codelet_n1fv_13_avx -fftwf_codelet_n1fv_13_sse2 -fftwf_codelet_n1fv_14_avx -fftwf_codelet_n1fv_14_sse2 -fftwf_codelet_n1fv_15_avx -fftwf_codelet_n1fv_15_sse2 -fftwf_codelet_n1fv_16_avx -fftwf_codelet_n1fv_16_sse2 -fftwf_codelet_n1fv_20_avx -fftwf_codelet_n1fv_20_sse2 -fftwf_codelet_n1fv_25_avx -fftwf_codelet_n1fv_25_sse2 -fftwf_codelet_n1fv_2_avx -fftwf_codelet_n1fv_2_sse2 -fftwf_codelet_n1fv_32_avx -fftwf_codelet_n1fv_32_sse2 -fftwf_codelet_n1fv_3_avx -fftwf_codelet_n1fv_3_sse2 -fftwf_codelet_n1fv_4_avx -fftwf_codelet_n1fv_4_sse2 -fftwf_codelet_n1fv_5_avx -fftwf_codelet_n1fv_5_sse2 -fftwf_codelet_n1fv_64_avx -fftwf_codelet_n1fv_64_sse2 -fftwf_codelet_n1fv_6_avx -fftwf_codelet_n1fv_6_sse2 -fftwf_codelet_n1fv_7_avx -fftwf_codelet_n1fv_7_sse2 -fftwf_codelet_n1fv_8_avx -fftwf_codelet_n1fv_8_sse2 -fftwf_codelet_n1fv_9_avx -fftwf_codelet_n1fv_9_sse2 -fftwf_codelet_n2bv_10_avx -fftwf_codelet_n2bv_10_sse2 -fftwf_codelet_n2bv_12_avx -fftwf_codelet_n2bv_12_sse2 -fftwf_codelet_n2bv_14_avx -fftwf_codelet_n2bv_14_sse2 -fftwf_codelet_n2bv_16_avx -fftwf_codelet_n2bv_16_sse2 -fftwf_codelet_n2bv_20_avx -fftwf_codelet_n2bv_20_sse2 -fftwf_codelet_n2bv_2_avx -fftwf_codelet_n2bv_2_sse2 -fftwf_codelet_n2bv_32_avx -fftwf_codelet_n2bv_32_sse2 -fftwf_codelet_n2bv_4_avx -fftwf_codelet_n2bv_4_sse2 -fftwf_codelet_n2bv_64_avx -fftwf_codelet_n2bv_64_sse2 -fftwf_codelet_n2bv_6_avx -fftwf_codelet_n2bv_6_sse2 -fftwf_codelet_n2bv_8_avx -fftwf_codelet_n2bv_8_sse2 -fftwf_codelet_n2fv_10_avx -fftwf_codelet_n2fv_10_sse2 -fftwf_codelet_n2fv_12_avx -fftwf_codelet_n2fv_12_sse2 -fftwf_codelet_n2fv_14_avx -fftwf_codelet_n2fv_14_sse2 -fftwf_codelet_n2fv_16_avx -fftwf_codelet_n2fv_16_sse2 -fftwf_codelet_n2fv_20_avx -fftwf_codelet_n2fv_20_sse2 -fftwf_codelet_n2fv_2_avx -fftwf_codelet_n2fv_2_sse2 -fftwf_codelet_n2fv_32_avx -fftwf_codelet_n2fv_32_sse2 -fftwf_codelet_n2fv_4_avx -fftwf_codelet_n2fv_4_sse2 -fftwf_codelet_n2fv_64_avx -fftwf_codelet_n2fv_64_sse2 -fftwf_codelet_n2fv_6_avx -fftwf_codelet_n2fv_6_sse2 -fftwf_codelet_n2fv_8_avx -fftwf_codelet_n2fv_8_sse2 -fftwf_codelet_n2sv_16_avx -fftwf_codelet_n2sv_16_sse2 -fftwf_codelet_n2sv_32_avx -fftwf_codelet_n2sv_32_sse2 -fftwf_codelet_n2sv_4_avx -fftwf_codelet_n2sv_4_sse2 -fftwf_codelet_n2sv_64_avx -fftwf_codelet_n2sv_64_sse2 -fftwf_codelet_n2sv_8_avx -fftwf_codelet_n2sv_8_sse2 -fftwf_codelet_q1_2 -fftwf_codelet_q1_3 -fftwf_codelet_q1_4 -fftwf_codelet_q1_5 -fftwf_codelet_q1_6 -fftwf_codelet_q1_8 -fftwf_codelet_q1bv_2_avx -fftwf_codelet_q1bv_2_sse2 -fftwf_codelet_q1bv_4_avx -fftwf_codelet_q1bv_4_sse2 -fftwf_codelet_q1bv_5_avx -fftwf_codelet_q1bv_5_sse2 -fftwf_codelet_q1bv_8_avx -fftwf_codelet_q1bv_8_sse2 -fftwf_codelet_q1fv_2_avx -fftwf_codelet_q1fv_2_sse2 -fftwf_codelet_q1fv_4_avx -fftwf_codelet_q1fv_4_sse2 -fftwf_codelet_q1fv_5_avx -fftwf_codelet_q1fv_5_sse2 -fftwf_codelet_q1fv_8_avx -fftwf_codelet_q1fv_8_sse2 -fftwf_codelet_r2cb_10 -fftwf_codelet_r2cb_11 -fftwf_codelet_r2cb_12 -fftwf_codelet_r2cb_128 -fftwf_codelet_r2cb_13 -fftwf_codelet_r2cb_14 -fftwf_codelet_r2cb_15 -fftwf_codelet_r2cb_16 -fftwf_codelet_r2cb_2 -fftwf_codelet_r2cb_20 -fftwf_codelet_r2cb_25 -fftwf_codelet_r2cb_3 -fftwf_codelet_r2cb_32 -fftwf_codelet_r2cb_4 -fftwf_codelet_r2cb_5 -fftwf_codelet_r2cb_6 -fftwf_codelet_r2cb_64 -fftwf_codelet_r2cb_7 -fftwf_codelet_r2cb_8 -fftwf_codelet_r2cb_9 -fftwf_codelet_r2cbIII_10 -fftwf_codelet_r2cbIII_12 -fftwf_codelet_r2cbIII_15 -fftwf_codelet_r2cbIII_16 -fftwf_codelet_r2cbIII_2 -fftwf_codelet_r2cbIII_20 -fftwf_codelet_r2cbIII_25 -fftwf_codelet_r2cbIII_3 -fftwf_codelet_r2cbIII_32 -fftwf_codelet_r2cbIII_4 -fftwf_codelet_r2cbIII_5 -fftwf_codelet_r2cbIII_6 -fftwf_codelet_r2cbIII_64 -fftwf_codelet_r2cbIII_7 -fftwf_codelet_r2cbIII_8 -fftwf_codelet_r2cbIII_9 -fftwf_codelet_r2cf_10 -fftwf_codelet_r2cf_11 -fftwf_codelet_r2cf_12 -fftwf_codelet_r2cf_128 -fftwf_codelet_r2cf_13 -fftwf_codelet_r2cf_14 -fftwf_codelet_r2cf_15 -fftwf_codelet_r2cf_16 -fftwf_codelet_r2cf_2 -fftwf_codelet_r2cf_20 -fftwf_codelet_r2cf_25 -fftwf_codelet_r2cf_3 -fftwf_codelet_r2cf_32 -fftwf_codelet_r2cf_4 -fftwf_codelet_r2cf_5 -fftwf_codelet_r2cf_6 -fftwf_codelet_r2cf_64 -fftwf_codelet_r2cf_7 -fftwf_codelet_r2cf_8 -fftwf_codelet_r2cf_9 -fftwf_codelet_r2cfII_10 -fftwf_codelet_r2cfII_12 -fftwf_codelet_r2cfII_15 -fftwf_codelet_r2cfII_16 -fftwf_codelet_r2cfII_2 -fftwf_codelet_r2cfII_20 -fftwf_codelet_r2cfII_25 -fftwf_codelet_r2cfII_3 -fftwf_codelet_r2cfII_32 -fftwf_codelet_r2cfII_4 -fftwf_codelet_r2cfII_5 -fftwf_codelet_r2cfII_6 -fftwf_codelet_r2cfII_64 -fftwf_codelet_r2cfII_7 -fftwf_codelet_r2cfII_8 -fftwf_codelet_r2cfII_9 -fftwf_codelet_t1_10 -fftwf_codelet_t1_12 -fftwf_codelet_t1_15 -fftwf_codelet_t1_16 -fftwf_codelet_t1_2 -fftwf_codelet_t1_20 -fftwf_codelet_t1_25 -fftwf_codelet_t1_3 -fftwf_codelet_t1_32 -fftwf_codelet_t1_4 -fftwf_codelet_t1_5 -fftwf_codelet_t1_6 -fftwf_codelet_t1_64 -fftwf_codelet_t1_7 -fftwf_codelet_t1_8 -fftwf_codelet_t1_9 -fftwf_codelet_t1buv_10_avx -fftwf_codelet_t1buv_10_sse2 -fftwf_codelet_t1buv_2_avx -fftwf_codelet_t1buv_2_sse2 -fftwf_codelet_t1buv_3_avx -fftwf_codelet_t1buv_3_sse2 -fftwf_codelet_t1buv_4_avx -fftwf_codelet_t1buv_4_sse2 -fftwf_codelet_t1buv_5_avx -fftwf_codelet_t1buv_5_sse2 -fftwf_codelet_t1buv_6_avx -fftwf_codelet_t1buv_6_sse2 -fftwf_codelet_t1buv_7_avx -fftwf_codelet_t1buv_7_sse2 -fftwf_codelet_t1buv_8_avx -fftwf_codelet_t1buv_8_sse2 -fftwf_codelet_t1buv_9_avx -fftwf_codelet_t1buv_9_sse2 -fftwf_codelet_t1bv_10_avx -fftwf_codelet_t1bv_10_sse2 -fftwf_codelet_t1bv_12_avx -fftwf_codelet_t1bv_12_sse2 -fftwf_codelet_t1bv_15_avx -fftwf_codelet_t1bv_15_sse2 -fftwf_codelet_t1bv_16_avx -fftwf_codelet_t1bv_16_sse2 -fftwf_codelet_t1bv_20_avx -fftwf_codelet_t1bv_20_sse2 -fftwf_codelet_t1bv_25_avx -fftwf_codelet_t1bv_25_sse2 -fftwf_codelet_t1bv_2_avx -fftwf_codelet_t1bv_2_sse2 -fftwf_codelet_t1bv_32_avx -fftwf_codelet_t1bv_32_sse2 -fftwf_codelet_t1bv_3_avx -fftwf_codelet_t1bv_3_sse2 -fftwf_codelet_t1bv_4_avx -fftwf_codelet_t1bv_4_sse2 -fftwf_codelet_t1bv_5_avx -fftwf_codelet_t1bv_5_sse2 -fftwf_codelet_t1bv_64_avx -fftwf_codelet_t1bv_64_sse2 -fftwf_codelet_t1bv_6_avx -fftwf_codelet_t1bv_6_sse2 -fftwf_codelet_t1bv_7_avx -fftwf_codelet_t1bv_7_sse2 -fftwf_codelet_t1bv_8_avx -fftwf_codelet_t1bv_8_sse2 -fftwf_codelet_t1bv_9_avx -fftwf_codelet_t1bv_9_sse2 -fftwf_codelet_t1fuv_10_avx -fftwf_codelet_t1fuv_10_sse2 -fftwf_codelet_t1fuv_2_avx -fftwf_codelet_t1fuv_2_sse2 -fftwf_codelet_t1fuv_3_avx -fftwf_codelet_t1fuv_3_sse2 -fftwf_codelet_t1fuv_4_avx -fftwf_codelet_t1fuv_4_sse2 -fftwf_codelet_t1fuv_5_avx -fftwf_codelet_t1fuv_5_sse2 -fftwf_codelet_t1fuv_6_avx -fftwf_codelet_t1fuv_6_sse2 -fftwf_codelet_t1fuv_7_avx -fftwf_codelet_t1fuv_7_sse2 -fftwf_codelet_t1fuv_8_avx -fftwf_codelet_t1fuv_8_sse2 -fftwf_codelet_t1fuv_9_avx -fftwf_codelet_t1fuv_9_sse2 -fftwf_codelet_t1fv_10_avx -fftwf_codelet_t1fv_10_sse2 -fftwf_codelet_t1fv_12_avx -fftwf_codelet_t1fv_12_sse2 -fftwf_codelet_t1fv_15_avx -fftwf_codelet_t1fv_15_sse2 -fftwf_codelet_t1fv_16_avx -fftwf_codelet_t1fv_16_sse2 -fftwf_codelet_t1fv_20_avx -fftwf_codelet_t1fv_20_sse2 -fftwf_codelet_t1fv_25_avx -fftwf_codelet_t1fv_25_sse2 -fftwf_codelet_t1fv_2_avx -fftwf_codelet_t1fv_2_sse2 -fftwf_codelet_t1fv_32_avx -fftwf_codelet_t1fv_32_sse2 -fftwf_codelet_t1fv_3_avx -fftwf_codelet_t1fv_3_sse2 -fftwf_codelet_t1fv_4_avx -fftwf_codelet_t1fv_4_sse2 -fftwf_codelet_t1fv_5_avx -fftwf_codelet_t1fv_5_sse2 -fftwf_codelet_t1fv_64_avx -fftwf_codelet_t1fv_64_sse2 -fftwf_codelet_t1fv_6_avx -fftwf_codelet_t1fv_6_sse2 -fftwf_codelet_t1fv_7_avx -fftwf_codelet_t1fv_7_sse2 -fftwf_codelet_t1fv_8_avx -fftwf_codelet_t1fv_8_sse2 -fftwf_codelet_t1fv_9_avx -fftwf_codelet_t1fv_9_sse2 -fftwf_codelet_t1sv_16_avx -fftwf_codelet_t1sv_16_sse2 -fftwf_codelet_t1sv_2_avx -fftwf_codelet_t1sv_2_sse2 -fftwf_codelet_t1sv_32_avx -fftwf_codelet_t1sv_32_sse2 -fftwf_codelet_t1sv_4_avx -fftwf_codelet_t1sv_4_sse2 -fftwf_codelet_t1sv_8_avx -fftwf_codelet_t1sv_8_sse2 -fftwf_codelet_t2_10 -fftwf_codelet_t2_16 -fftwf_codelet_t2_20 -fftwf_codelet_t2_25 -fftwf_codelet_t2_32 -fftwf_codelet_t2_4 -fftwf_codelet_t2_5 -fftwf_codelet_t2_64 -fftwf_codelet_t2_8 -fftwf_codelet_t2bv_10_avx -fftwf_codelet_t2bv_10_sse2 -fftwf_codelet_t2bv_16_avx -fftwf_codelet_t2bv_16_sse2 -fftwf_codelet_t2bv_20_avx -fftwf_codelet_t2bv_20_sse2 -fftwf_codelet_t2bv_25_avx -fftwf_codelet_t2bv_25_sse2 -fftwf_codelet_t2bv_2_avx -fftwf_codelet_t2bv_2_sse2 -fftwf_codelet_t2bv_32_avx -fftwf_codelet_t2bv_32_sse2 -fftwf_codelet_t2bv_4_avx -fftwf_codelet_t2bv_4_sse2 -fftwf_codelet_t2bv_5_avx -fftwf_codelet_t2bv_5_sse2 -fftwf_codelet_t2bv_64_avx -fftwf_codelet_t2bv_64_sse2 -fftwf_codelet_t2bv_8_avx -fftwf_codelet_t2bv_8_sse2 -fftwf_codelet_t2fv_10_avx -fftwf_codelet_t2fv_10_sse2 -fftwf_codelet_t2fv_16_avx -fftwf_codelet_t2fv_16_sse2 -fftwf_codelet_t2fv_20_avx -fftwf_codelet_t2fv_20_sse2 -fftwf_codelet_t2fv_25_avx -fftwf_codelet_t2fv_25_sse2 -fftwf_codelet_t2fv_2_avx -fftwf_codelet_t2fv_2_sse2 -fftwf_codelet_t2fv_32_avx -fftwf_codelet_t2fv_32_sse2 -fftwf_codelet_t2fv_4_avx -fftwf_codelet_t2fv_4_sse2 -fftwf_codelet_t2fv_5_avx -fftwf_codelet_t2fv_5_sse2 -fftwf_codelet_t2fv_64_avx -fftwf_codelet_t2fv_64_sse2 -fftwf_codelet_t2fv_8_avx -fftwf_codelet_t2fv_8_sse2 -fftwf_codelet_t2sv_16_avx -fftwf_codelet_t2sv_16_sse2 -fftwf_codelet_t2sv_32_avx -fftwf_codelet_t2sv_32_sse2 -fftwf_codelet_t2sv_4_avx -fftwf_codelet_t2sv_4_sse2 -fftwf_codelet_t2sv_8_avx -fftwf_codelet_t2sv_8_sse2 -fftwf_codelet_t3bv_10_avx -fftwf_codelet_t3bv_10_sse2 -fftwf_codelet_t3bv_16_avx -fftwf_codelet_t3bv_16_sse2 -fftwf_codelet_t3bv_20_avx -fftwf_codelet_t3bv_20_sse2 -fftwf_codelet_t3bv_25_avx -fftwf_codelet_t3bv_25_sse2 -fftwf_codelet_t3bv_32_avx -fftwf_codelet_t3bv_32_sse2 -fftwf_codelet_t3bv_4_avx -fftwf_codelet_t3bv_4_sse2 -fftwf_codelet_t3bv_5_avx -fftwf_codelet_t3bv_5_sse2 -fftwf_codelet_t3bv_8_avx -fftwf_codelet_t3bv_8_sse2 -fftwf_codelet_t3fv_10_avx -fftwf_codelet_t3fv_10_sse2 -fftwf_codelet_t3fv_16_avx -fftwf_codelet_t3fv_16_sse2 -fftwf_codelet_t3fv_20_avx -fftwf_codelet_t3fv_20_sse2 -fftwf_codelet_t3fv_25_avx -fftwf_codelet_t3fv_25_sse2 -fftwf_codelet_t3fv_32_avx -fftwf_codelet_t3fv_32_sse2 -fftwf_codelet_t3fv_4_avx -fftwf_codelet_t3fv_4_sse2 -fftwf_codelet_t3fv_5_avx -fftwf_codelet_t3fv_5_sse2 -fftwf_codelet_t3fv_8_avx -fftwf_codelet_t3fv_8_sse2 -fftwf_compute_tilesz -fftwf_configure_planner -fftwf_cost -fftwf_cpy1d -fftwf_cpy2d -fftwf_cpy2d_ci -fftwf_cpy2d_co -fftwf_cpy2d_pair -fftwf_cpy2d_pair_ci -fftwf_cpy2d_pair_co -fftwf_cpy2d_tiled -fftwf_cpy2d_tiledbuf -fftwf_ct_applicable -fftwf_ct_genericbuf_register -fftwf_ct_generic_register -fftwf_ct_uglyp -fftwf_destroy_plan -fftwf_dft_bluestein_register -fftwf_dft_buffered_register -fftwf_dft_conf_standard -fftwf_dft_generic_register -fftwf_dft_indirect_register -fftwf_dft_indirect_transpose_register -fftwf_dft_nop_register -fftwf_dft_r2hc_register -fftwf_dft_rader_register -fftwf_dft_rank_geq2_register -fftwf_dft_solve -fftwf_dft_thr_vrank_geq1_register -fftwf_dft_vrank_geq1_register -fftwf_dft_zerotens -fftwf_dht_r2hc_register -fftwf_dht_rader_register -fftwf_dimcmp -fftwf_elapsed_since -fftwf_estimate_cost -fftwf_execute -fftwf_execute_dft -fftwf_execute_dft_c2r -fftwf_execute_dft_r2c -fftwf_execute_r2r -fftwf_execute_split_dft -fftwf_execute_split_dft_c2r -fftwf_execute_split_dft_r2c -fftwf_export_wisdom -fftwf_export_wisdom_to_file -fftwf_export_wisdom_to_filename -fftwf_export_wisdom_to_string -fftwf_extract_reim -fftwf_factors_into -fftwf_factors_into_small_primes -fftwf_find_generator -fftwf_first_divisor -fftwf_flops -fftwf_forget_wisdom -fftwf_fprint_plan -fftwf_free -fftwf_get_crude_time -fftwf_guru64_kosherp -fftwf_guru_kosherp -fftwf_hash -fftwf_have_simd_avx -fftwf_have_simd_sse2 -fftwf_hc2hc_applicable -fftwf_hc2hc_generic_register -fftwf_iabs -fftwf_ialignment_of -fftwf_iestimate_cost -fftwf_ifree -fftwf_ifree0 -fftwf_imax -fftwf_imin -fftwf_import_system_wisdom -fftwf_import_wisdom -fftwf_import_wisdom_from_file -fftwf_import_wisdom_from_filename -fftwf_import_wisdom_from_string -fftwf_init_threads -fftwf_is_prime -fftwf_isqrt -fftwf_ithreads_init -fftwf_join_taint -fftwf_kdft_dif_register -fftwf_kdft_difsq_register -fftwf_kdft_dit_register -fftwf_kdft_register -fftwf_kernel_free -fftwf_kernel_malloc -fftwf_khc2c_register -fftwf_khc2hc_register -fftwf_kr2c_register -fftwf_kr2r_register -fftwf_make_planner_thread_safe -fftwf_malloc -fftwf_malloc_plain -fftwf_many_kosherp -fftwf_mapflags -fftwf_map_r2r_kind -fftwf_md5begin -fftwf_md5end -fftwf_md5int -fftwf_md5INT -fftwf_md5putb -fftwf_md5putc -fftwf_md5puts -fftwf_md5unsigned -fftwf_measure_execution_time -fftwf_mkapiplan -fftwf_mkplan -fftwf_mkplan_d -fftwf_mkplan_dft -fftwf_mkplan_dftw -fftwf_mkplan_f_d -fftwf_mkplan_hc2c -fftwf_mkplan_hc2hc -fftwf_mkplanner -fftwf_mkplan_rdft -fftwf_mkplan_rdft2 -fftwf_mkprinter -fftwf_mkprinter_cnt -fftwf_mkprinter_file -fftwf_mkprinter_str -fftwf_mkproblem -fftwf_mkproblem_dft -fftwf_mkproblem_dft_d -fftwf_mkproblem_rdft -fftwf_mkproblem_rdft_0_d -fftwf_mkproblem_rdft_1 -fftwf_mkproblem_rdft_1_d -fftwf_mkproblem_rdft2 -fftwf_mkproblem_rdft2_d -fftwf_mkproblem_rdft2_d_3pointers -fftwf_mkproblem_rdft_d -fftwf_mkproblem_unsolvable -fftwf_mkscanner -fftwf_mksolver -fftwf_mksolver_ct -fftwf_mksolver_ct_threads -fftwf_mksolver_dft_direct -fftwf_mksolver_dft_directbuf -fftwf_mksolver_hc2c -fftwf_mksolver_hc2hc -fftwf_mksolver_hc2hc_threads -fftwf_mksolver_rdft2_direct -fftwf_mksolver_rdft_r2c_direct -fftwf_mksolver_rdft_r2c_directbuf -fftwf_mksolver_rdft_r2r_direct -fftwf_mkstride -fftwf_mktensor -fftwf_mktensor_0d -fftwf_mktensor_1d -fftwf_mktensor_2d -fftwf_mktensor_3d -fftwf_mktensor_4d -fftwf_mktensor_5d -fftwf_mktensor_iodims -fftwf_mktensor_iodims64 -fftwf_mktensor_rowmajor -fftwf_mktriggen -fftwf_modulo -fftwf_nbuf -fftwf_nbuf_redundant -fftwf_next_prime -fftwf_null_awake -fftwf_ops_add -fftwf_ops_add2 -fftwf_ops_cpy -fftwf_ops_madd -fftwf_ops_madd2 -fftwf_ops_other -fftwf_ops_zero -fftwf_pickdim -fftwf_plan_awake -fftwf_plan_destroy_internal -fftwf_plan_dft -fftwf_plan_dft_1d -fftwf_plan_dft_2d -fftwf_plan_dft_3d -fftwf_plan_dft_c2r -fftwf_plan_dft_c2r_1d -fftwf_plan_dft_c2r_2d -fftwf_plan_dft_c2r_3d -fftwf_plan_dft_r2c -fftwf_plan_dft_r2c_1d -fftwf_plan_dft_r2c_2d -fftwf_plan_dft_r2c_3d -fftwf_plan_guru64_dft -fftwf_plan_guru64_dft_c2r -fftwf_plan_guru64_dft_r2c -fftwf_plan_guru64_r2r -fftwf_plan_guru64_split_dft -fftwf_plan_guru64_split_dft_c2r -fftwf_plan_guru64_split_dft_r2c -fftwf_plan_guru_dft -fftwf_plan_guru_dft_c2r -fftwf_plan_guru_dft_r2c -fftwf_plan_guru_r2r -fftwf_plan_guru_split_dft -fftwf_plan_guru_split_dft_c2r -fftwf_plan_guru_split_dft_r2c -fftwf_plan_many_dft -fftwf_plan_many_dft_c2r -fftwf_plan_many_dft_r2c -fftwf_plan_many_r2r -fftwf_planner_destroy -fftwf_plan_null_destroy -fftwf_plan_r2r -fftwf_plan_r2r_1d -fftwf_plan_r2r_2d -fftwf_plan_r2r_3d -fftwf_plan_with_nthreads -fftwf_power_mod -fftwf_printer_destroy -fftwf_print_plan -fftwf_problem_destroy -fftwf_rader_tl_delete -fftwf_rader_tl_find -fftwf_rader_tl_insert -fftwf_rdft2_buffered_register -fftwf_rdft2_complex_n -fftwf_rdft2_inplace_strides -fftwf_rdft2_nop_register -fftwf_rdft2_pad -fftwf_rdft2_rank0_register -fftwf_rdft2_rank_geq2_register -fftwf_rdft2_rdft_register -fftwf_rdft2_solve -fftwf_rdft2_strides -fftwf_rdft2_tensor_max_index -fftwf_rdft2_thr_vrank_geq1_register -fftwf_rdft2_vrank_geq1_register -fftwf_rdft_buffered_register -fftwf_rdft_conf_standard -fftwf_rdft_dht_register -fftwf_rdft_generic_register -fftwf_rdft_indirect_register -fftwf_rdft_kind_str -fftwf_rdft_nop_register -fftwf_rdft_rank0_register -fftwf_rdft_rank_geq2_register -fftwf_rdft_solve -fftwf_rdft_thr_vrank_geq1_register -fftwf_rdft_vrank3_transpose_register -fftwf_rdft_vrank_geq1_register -fftwf_rdft_zerotens -fftwf_redft00e_r2hc_pad_register -fftwf_regsolver_ct_directw -fftwf_regsolver_ct_directwsq -fftwf_regsolver_hc2c_direct -fftwf_regsolver_hc2hc_direct -fftwf_reodft00e_splitradix_register -fftwf_reodft010e_r2hc_register -fftwf_reodft11e_r2hc_odd_register -fftwf_reodft11e_radix2_r2hc_register -fftwf_reodft_conf_standard -fftwf_rodft00e_r2hc_pad_register -fftwf_safe_mulmod -fftwf_scanner_destroy -fftwf_set_planner_hooks -fftwf_set_timelimit -fftwf_solver_destroy -fftwf_solver_register -fftwf_solver_use -fftwf_solvtab_exec -fftwf_spawn_loop -fftwf_sprint_plan -fftwf_stride_destroy -fftwf_taint -fftwf_tensor_append -fftwf_tensor_compress -fftwf_tensor_compress_contiguous -fftwf_tensor_copy -fftwf_tensor_copy_except -fftwf_tensor_copy_inplace -fftwf_tensor_copy_sub -fftwf_tensor_destroy -fftwf_tensor_destroy2 -fftwf_tensor_destroy4 -fftwf_tensor_equal -fftwf_tensor_inplace_locations -fftwf_tensor_inplace_strides -fftwf_tensor_inplace_strides2 -fftwf_tensor_kosherp -fftwf_tensor_max_index -fftwf_tensor_md5 -fftwf_tensor_min_istride -fftwf_tensor_min_ostride -fftwf_tensor_min_stride -fftwf_tensor_print -fftwf_tensor_split -fftwf_tensor_strides_decrease -fftwf_tensor_sz -fftwf_tensor_tornk1 -fftwf_the_planner -fftwf_threads_cleanup -fftwf_threads_conf_standard -fftwf_threads_register_planner_hooks -fftwf_tile2d -fftwf_toobig -fftwf_transpose -fftwf_transpose_tiled -fftwf_transpose_tiledbuf -fftwf_triggen_destroy -fftwf_twiddle_awake -fftwf_twiddle_length -fftwf_zero1d_pair -sfftw_cleanup_ -sfftw_cleanup__ -sfftw_cleanup_threads_ -sfftw_cleanup_threads__ -sfftw_cost_ -sfftw_cost__ -sfftw_destroy_plan_ -sfftw_destroy_plan__ -sfftw_estimate_cost_ -sfftw_estimate_cost__ -sfftw_execute_ -sfftw_execute__ -sfftw_execute_dft_ -sfftw_execute_dft__ -sfftw_execute_dft_c2r_ -sfftw_execute_dft_c2r__ -sfftw_execute_dft_r2c_ -sfftw_execute_dft_r2c__ -sfftw_execute_r2r_ -sfftw_execute_r2r__ -sfftw_execute_split_dft_ -sfftw_execute_split_dft__ -sfftw_execute_split_dft_c2r_ -sfftw_execute_split_dft_c2r__ -sfftw_execute_split_dft_r2c_ -sfftw_execute_split_dft_r2c__ -sfftw_export_wisdom_ -sfftw_export_wisdom__ -sfftw_flops_ -sfftw_flops__ -sfftw_forget_wisdom_ -sfftw_forget_wisdom__ -sfftw_import_system_wisdom_ -sfftw_import_system_wisdom__ -sfftw_import_wisdom_ -sfftw_import_wisdom__ -sfftw_init_threads_ -sfftw_init_threads__ -sfftw_plan_dft_ -sfftw_plan_dft__ -sfftw_plan_dft_1d_ -sfftw_plan_dft_1d__ -sfftw_plan_dft_2d_ -sfftw_plan_dft_2d__ -sfftw_plan_dft_3d_ -sfftw_plan_dft_3d__ -sfftw_plan_dft_c2r_ -sfftw_plan_dft_c2r__ -sfftw_plan_dft_c2r_1d_ -sfftw_plan_dft_c2r_1d__ -sfftw_plan_dft_c2r_2d_ -sfftw_plan_dft_c2r_2d__ -sfftw_plan_dft_c2r_3d_ -sfftw_plan_dft_c2r_3d__ -sfftw_plan_dft_r2c_ -sfftw_plan_dft_r2c__ -sfftw_plan_dft_r2c_1d_ -sfftw_plan_dft_r2c_1d__ -sfftw_plan_dft_r2c_2d_ -sfftw_plan_dft_r2c_2d__ -sfftw_plan_dft_r2c_3d_ -sfftw_plan_dft_r2c_3d__ -sfftw_plan_guru_dft_ -sfftw_plan_guru_dft__ -sfftw_plan_guru_dft_c2r_ -sfftw_plan_guru_dft_c2r__ -sfftw_plan_guru_dft_r2c_ -sfftw_plan_guru_dft_r2c__ -sfftw_plan_guru_r2r_ -sfftw_plan_guru_r2r__ -sfftw_plan_guru_split_dft_ -sfftw_plan_guru_split_dft__ -sfftw_plan_guru_split_dft_c2r_ -sfftw_plan_guru_split_dft_c2r__ -sfftw_plan_guru_split_dft_r2c_ -sfftw_plan_guru_split_dft_r2c__ -sfftw_plan_many_dft_ -sfftw_plan_many_dft__ -sfftw_plan_many_dft_c2r_ -sfftw_plan_many_dft_c2r__ -sfftw_plan_many_dft_r2c_ -sfftw_plan_many_dft_r2c__ -sfftw_plan_many_r2r_ -sfftw_plan_many_r2r__ -sfftw_plan_r2r_ -sfftw_plan_r2r__ -sfftw_plan_r2r_1d_ -sfftw_plan_r2r_1d__ -sfftw_plan_r2r_2d_ -sfftw_plan_r2r_2d__ -sfftw_plan_r2r_3d_ -sfftw_plan_r2r_3d__ -sfftw_plan_with_nthreads_ -sfftw_plan_with_nthreads__ -sfftw_print_plan_ -sfftw_print_plan__ -sfftw_set_timelimit_ -sfftw_set_timelimit__ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.exp b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.exp deleted file mode 100644 index 65b880624..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.lib b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.lib deleted file mode 100644 index e8f03ddf7..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3f-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.def b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.def deleted file mode 100644 index 62a5e4231..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.def +++ /dev/null @@ -1,634 +0,0 @@ -LIBRARY libfftw3l-3.dll -EXPORTS -fftwl_alignment_of -fftwl_alloc_complex -fftwl_alloc_real -fftwl_assertion_failed -fftwl_bufdist -fftwl_choose_radix -fftwl_cleanup -fftwl_cleanup_threads -fftwl_codelet_e01_8 -fftwl_codelet_e10_8 -fftwl_codelet_hb_10 -fftwl_codelet_hb_12 -fftwl_codelet_hb_15 -fftwl_codelet_hb_16 -fftwl_codelet_hb_2 -fftwl_codelet_hb_20 -fftwl_codelet_hb2_16 -fftwl_codelet_hb2_20 -fftwl_codelet_hb2_25 -fftwl_codelet_hb2_32 -fftwl_codelet_hb2_4 -fftwl_codelet_hb_25 -fftwl_codelet_hb2_5 -fftwl_codelet_hb2_8 -fftwl_codelet_hb_3 -fftwl_codelet_hb_32 -fftwl_codelet_hb_4 -fftwl_codelet_hb_5 -fftwl_codelet_hb_6 -fftwl_codelet_hb_64 -fftwl_codelet_hb_7 -fftwl_codelet_hb_8 -fftwl_codelet_hb_9 -fftwl_codelet_hc2cb_10 -fftwl_codelet_hc2cb_12 -fftwl_codelet_hc2cb_16 -fftwl_codelet_hc2cb_2 -fftwl_codelet_hc2cb_20 -fftwl_codelet_hc2cb2_16 -fftwl_codelet_hc2cb2_20 -fftwl_codelet_hc2cb2_32 -fftwl_codelet_hc2cb2_4 -fftwl_codelet_hc2cb2_8 -fftwl_codelet_hc2cb_32 -fftwl_codelet_hc2cb_4 -fftwl_codelet_hc2cb_6 -fftwl_codelet_hc2cb_8 -fftwl_codelet_hc2cbdft_10 -fftwl_codelet_hc2cbdft_12 -fftwl_codelet_hc2cbdft_16 -fftwl_codelet_hc2cbdft_2 -fftwl_codelet_hc2cbdft_20 -fftwl_codelet_hc2cbdft2_16 -fftwl_codelet_hc2cbdft2_20 -fftwl_codelet_hc2cbdft2_32 -fftwl_codelet_hc2cbdft2_4 -fftwl_codelet_hc2cbdft2_8 -fftwl_codelet_hc2cbdft_32 -fftwl_codelet_hc2cbdft_4 -fftwl_codelet_hc2cbdft_6 -fftwl_codelet_hc2cbdft_8 -fftwl_codelet_hc2cf_10 -fftwl_codelet_hc2cf_12 -fftwl_codelet_hc2cf_16 -fftwl_codelet_hc2cf_2 -fftwl_codelet_hc2cf_20 -fftwl_codelet_hc2cf2_16 -fftwl_codelet_hc2cf2_20 -fftwl_codelet_hc2cf2_32 -fftwl_codelet_hc2cf2_4 -fftwl_codelet_hc2cf2_8 -fftwl_codelet_hc2cf_32 -fftwl_codelet_hc2cf_4 -fftwl_codelet_hc2cf_6 -fftwl_codelet_hc2cf_8 -fftwl_codelet_hc2cfdft_10 -fftwl_codelet_hc2cfdft_12 -fftwl_codelet_hc2cfdft_16 -fftwl_codelet_hc2cfdft_2 -fftwl_codelet_hc2cfdft_20 -fftwl_codelet_hc2cfdft2_16 -fftwl_codelet_hc2cfdft2_20 -fftwl_codelet_hc2cfdft2_32 -fftwl_codelet_hc2cfdft2_4 -fftwl_codelet_hc2cfdft2_8 -fftwl_codelet_hc2cfdft_32 -fftwl_codelet_hc2cfdft_4 -fftwl_codelet_hc2cfdft_6 -fftwl_codelet_hc2cfdft_8 -fftwl_codelet_hf_10 -fftwl_codelet_hf_12 -fftwl_codelet_hf_15 -fftwl_codelet_hf_16 -fftwl_codelet_hf_2 -fftwl_codelet_hf_20 -fftwl_codelet_hf2_16 -fftwl_codelet_hf2_20 -fftwl_codelet_hf2_25 -fftwl_codelet_hf2_32 -fftwl_codelet_hf2_4 -fftwl_codelet_hf_25 -fftwl_codelet_hf2_5 -fftwl_codelet_hf2_8 -fftwl_codelet_hf_3 -fftwl_codelet_hf_32 -fftwl_codelet_hf_4 -fftwl_codelet_hf_5 -fftwl_codelet_hf_6 -fftwl_codelet_hf_64 -fftwl_codelet_hf_7 -fftwl_codelet_hf_8 -fftwl_codelet_hf_9 -fftwl_codelet_n1_10 -fftwl_codelet_n1_11 -fftwl_codelet_n1_12 -fftwl_codelet_n1_13 -fftwl_codelet_n1_14 -fftwl_codelet_n1_15 -fftwl_codelet_n1_16 -fftwl_codelet_n1_2 -fftwl_codelet_n1_20 -fftwl_codelet_n1_25 -fftwl_codelet_n1_3 -fftwl_codelet_n1_32 -fftwl_codelet_n1_4 -fftwl_codelet_n1_5 -fftwl_codelet_n1_6 -fftwl_codelet_n1_64 -fftwl_codelet_n1_7 -fftwl_codelet_n1_8 -fftwl_codelet_n1_9 -fftwl_codelet_q1_2 -fftwl_codelet_q1_3 -fftwl_codelet_q1_4 -fftwl_codelet_q1_5 -fftwl_codelet_q1_6 -fftwl_codelet_q1_8 -fftwl_codelet_r2cb_10 -fftwl_codelet_r2cb_11 -fftwl_codelet_r2cb_12 -fftwl_codelet_r2cb_128 -fftwl_codelet_r2cb_13 -fftwl_codelet_r2cb_14 -fftwl_codelet_r2cb_15 -fftwl_codelet_r2cb_16 -fftwl_codelet_r2cb_2 -fftwl_codelet_r2cb_20 -fftwl_codelet_r2cb_25 -fftwl_codelet_r2cb_3 -fftwl_codelet_r2cb_32 -fftwl_codelet_r2cb_4 -fftwl_codelet_r2cb_5 -fftwl_codelet_r2cb_6 -fftwl_codelet_r2cb_64 -fftwl_codelet_r2cb_7 -fftwl_codelet_r2cb_8 -fftwl_codelet_r2cb_9 -fftwl_codelet_r2cbIII_10 -fftwl_codelet_r2cbIII_12 -fftwl_codelet_r2cbIII_15 -fftwl_codelet_r2cbIII_16 -fftwl_codelet_r2cbIII_2 -fftwl_codelet_r2cbIII_20 -fftwl_codelet_r2cbIII_25 -fftwl_codelet_r2cbIII_3 -fftwl_codelet_r2cbIII_32 -fftwl_codelet_r2cbIII_4 -fftwl_codelet_r2cbIII_5 -fftwl_codelet_r2cbIII_6 -fftwl_codelet_r2cbIII_64 -fftwl_codelet_r2cbIII_7 -fftwl_codelet_r2cbIII_8 -fftwl_codelet_r2cbIII_9 -fftwl_codelet_r2cf_10 -fftwl_codelet_r2cf_11 -fftwl_codelet_r2cf_12 -fftwl_codelet_r2cf_128 -fftwl_codelet_r2cf_13 -fftwl_codelet_r2cf_14 -fftwl_codelet_r2cf_15 -fftwl_codelet_r2cf_16 -fftwl_codelet_r2cf_2 -fftwl_codelet_r2cf_20 -fftwl_codelet_r2cf_25 -fftwl_codelet_r2cf_3 -fftwl_codelet_r2cf_32 -fftwl_codelet_r2cf_4 -fftwl_codelet_r2cf_5 -fftwl_codelet_r2cf_6 -fftwl_codelet_r2cf_64 -fftwl_codelet_r2cf_7 -fftwl_codelet_r2cf_8 -fftwl_codelet_r2cf_9 -fftwl_codelet_r2cfII_10 -fftwl_codelet_r2cfII_12 -fftwl_codelet_r2cfII_15 -fftwl_codelet_r2cfII_16 -fftwl_codelet_r2cfII_2 -fftwl_codelet_r2cfII_20 -fftwl_codelet_r2cfII_25 -fftwl_codelet_r2cfII_3 -fftwl_codelet_r2cfII_32 -fftwl_codelet_r2cfII_4 -fftwl_codelet_r2cfII_5 -fftwl_codelet_r2cfII_6 -fftwl_codelet_r2cfII_64 -fftwl_codelet_r2cfII_7 -fftwl_codelet_r2cfII_8 -fftwl_codelet_r2cfII_9 -fftwl_codelet_t1_10 -fftwl_codelet_t1_12 -fftwl_codelet_t1_15 -fftwl_codelet_t1_16 -fftwl_codelet_t1_2 -fftwl_codelet_t1_20 -fftwl_codelet_t1_25 -fftwl_codelet_t1_3 -fftwl_codelet_t1_32 -fftwl_codelet_t1_4 -fftwl_codelet_t1_5 -fftwl_codelet_t1_6 -fftwl_codelet_t1_64 -fftwl_codelet_t1_7 -fftwl_codelet_t1_8 -fftwl_codelet_t1_9 -fftwl_codelet_t2_10 -fftwl_codelet_t2_16 -fftwl_codelet_t2_20 -fftwl_codelet_t2_25 -fftwl_codelet_t2_32 -fftwl_codelet_t2_4 -fftwl_codelet_t2_5 -fftwl_codelet_t2_64 -fftwl_codelet_t2_8 -fftwl_compute_tilesz -fftwl_configure_planner -fftwl_cost -fftwl_cpy1d -fftwl_cpy2d -fftwl_cpy2d_ci -fftwl_cpy2d_co -fftwl_cpy2d_pair -fftwl_cpy2d_pair_ci -fftwl_cpy2d_pair_co -fftwl_cpy2d_tiled -fftwl_cpy2d_tiledbuf -fftwl_ct_applicable -fftwl_ct_genericbuf_register -fftwl_ct_generic_register -fftwl_ct_uglyp -fftwl_destroy_plan -fftwl_dft_bluestein_register -fftwl_dft_buffered_register -fftwl_dft_conf_standard -fftwl_dft_generic_register -fftwl_dft_indirect_register -fftwl_dft_indirect_transpose_register -fftwl_dft_nop_register -fftwl_dft_r2hc_register -fftwl_dft_rader_register -fftwl_dft_rank_geq2_register -fftwl_dft_solve -fftwl_dft_thr_vrank_geq1_register -fftwl_dft_vrank_geq1_register -fftwl_dft_zerotens -fftwl_dht_r2hc_register -fftwl_dht_rader_register -fftwl_dimcmp -fftwl_elapsed_since -fftwl_estimate_cost -fftwl_execute -fftwl_execute_dft -fftwl_execute_dft_c2r -fftwl_execute_dft_r2c -fftwl_execute_r2r -fftwl_execute_split_dft -fftwl_execute_split_dft_c2r -fftwl_execute_split_dft_r2c -fftwl_export_wisdom -fftwl_export_wisdom_to_file -fftwl_export_wisdom_to_filename -fftwl_export_wisdom_to_string -fftwl_extract_reim -fftwl_factors_into -fftwl_factors_into_small_primes -fftwl_find_generator -fftwl_first_divisor -fftwl_flops -fftwl_forget_wisdom -fftwl_fprint_plan -fftwl_free -fftwl_get_crude_time -fftwl_guru64_kosherp -fftwl_guru_kosherp -fftwl_hash -fftwl_hc2hc_applicable -fftwl_hc2hc_generic_register -fftwl_iabs -fftwl_ialignment_of -fftwl_iestimate_cost -fftwl_ifree -fftwl_ifree0 -fftwl_imax -fftwl_imin -fftwl_import_system_wisdom -fftwl_import_wisdom -fftwl_import_wisdom_from_file -fftwl_import_wisdom_from_filename -fftwl_import_wisdom_from_string -fftwl_init_threads -fftwl_is_prime -fftwl_isqrt -fftwl_ithreads_init -fftwl_kdft_dif_register -fftwl_kdft_difsq_register -fftwl_kdft_dit_register -fftwl_kdft_register -fftwl_kernel_free -fftwl_kernel_malloc -fftwl_khc2c_register -fftwl_khc2hc_register -fftwl_kr2c_register -fftwl_kr2r_register -fftwl_make_planner_thread_safe -fftwl_malloc -fftwl_malloc_plain -fftwl_many_kosherp -fftwl_mapflags -fftwl_map_r2r_kind -fftwl_md5begin -fftwl_md5end -fftwl_md5int -fftwl_md5INT -fftwl_md5putb -fftwl_md5putc -fftwl_md5puts -fftwl_md5unsigned -fftwl_measure_execution_time -fftwl_mkapiplan -fftwl_mkplan -fftwl_mkplan_d -fftwl_mkplan_dft -fftwl_mkplan_dftw -fftwl_mkplan_f_d -fftwl_mkplan_hc2c -fftwl_mkplan_hc2hc -fftwl_mkplanner -fftwl_mkplan_rdft -fftwl_mkplan_rdft2 -fftwl_mkprinter -fftwl_mkprinter_cnt -fftwl_mkprinter_file -fftwl_mkprinter_str -fftwl_mkproblem -fftwl_mkproblem_dft -fftwl_mkproblem_dft_d -fftwl_mkproblem_rdft -fftwl_mkproblem_rdft_0_d -fftwl_mkproblem_rdft_1 -fftwl_mkproblem_rdft_1_d -fftwl_mkproblem_rdft2 -fftwl_mkproblem_rdft2_d -fftwl_mkproblem_rdft2_d_3pointers -fftwl_mkproblem_rdft_d -fftwl_mkproblem_unsolvable -fftwl_mkscanner -fftwl_mksolver -fftwl_mksolver_ct -fftwl_mksolver_ct_threads -fftwl_mksolver_dft_direct -fftwl_mksolver_dft_directbuf -fftwl_mksolver_hc2c -fftwl_mksolver_hc2hc -fftwl_mksolver_hc2hc_threads -fftwl_mksolver_rdft2_direct -fftwl_mksolver_rdft_r2c_direct -fftwl_mksolver_rdft_r2c_directbuf -fftwl_mksolver_rdft_r2r_direct -fftwl_mktensor -fftwl_mktensor_0d -fftwl_mktensor_1d -fftwl_mktensor_2d -fftwl_mktensor_3d -fftwl_mktensor_4d -fftwl_mktensor_5d -fftwl_mktensor_iodims -fftwl_mktensor_iodims64 -fftwl_mktensor_rowmajor -fftwl_mktriggen -fftwl_modulo -fftwl_nbuf -fftwl_nbuf_redundant -fftwl_next_prime -fftwl_null_awake -fftwl_ops_add -fftwl_ops_add2 -fftwl_ops_cpy -fftwl_ops_madd -fftwl_ops_madd2 -fftwl_ops_other -fftwl_ops_zero -fftwl_pickdim -fftwl_plan_awake -fftwl_plan_destroy_internal -fftwl_plan_dft -fftwl_plan_dft_1d -fftwl_plan_dft_2d -fftwl_plan_dft_3d -fftwl_plan_dft_c2r -fftwl_plan_dft_c2r_1d -fftwl_plan_dft_c2r_2d -fftwl_plan_dft_c2r_3d -fftwl_plan_dft_r2c -fftwl_plan_dft_r2c_1d -fftwl_plan_dft_r2c_2d -fftwl_plan_dft_r2c_3d -fftwl_plan_guru64_dft -fftwl_plan_guru64_dft_c2r -fftwl_plan_guru64_dft_r2c -fftwl_plan_guru64_r2r -fftwl_plan_guru64_split_dft -fftwl_plan_guru64_split_dft_c2r -fftwl_plan_guru64_split_dft_r2c -fftwl_plan_guru_dft -fftwl_plan_guru_dft_c2r -fftwl_plan_guru_dft_r2c -fftwl_plan_guru_r2r -fftwl_plan_guru_split_dft -fftwl_plan_guru_split_dft_c2r -fftwl_plan_guru_split_dft_r2c -fftwl_plan_many_dft -fftwl_plan_many_dft_c2r -fftwl_plan_many_dft_r2c -fftwl_plan_many_r2r -fftwl_planner_destroy -fftwl_plan_null_destroy -fftwl_plan_r2r -fftwl_plan_r2r_1d -fftwl_plan_r2r_2d -fftwl_plan_r2r_3d -fftwl_plan_with_nthreads -fftwl_power_mod -fftwl_printer_destroy -fftwl_print_plan -fftwl_problem_destroy -fftwl_rader_tl_delete -fftwl_rader_tl_find -fftwl_rader_tl_insert -fftwl_rdft2_buffered_register -fftwl_rdft2_complex_n -fftwl_rdft2_inplace_strides -fftwl_rdft2_nop_register -fftwl_rdft2_pad -fftwl_rdft2_rank0_register -fftwl_rdft2_rank_geq2_register -fftwl_rdft2_rdft_register -fftwl_rdft2_solve -fftwl_rdft2_strides -fftwl_rdft2_tensor_max_index -fftwl_rdft2_thr_vrank_geq1_register -fftwl_rdft2_vrank_geq1_register -fftwl_rdft_buffered_register -fftwl_rdft_conf_standard -fftwl_rdft_dht_register -fftwl_rdft_generic_register -fftwl_rdft_indirect_register -fftwl_rdft_kind_str -fftwl_rdft_nop_register -fftwl_rdft_rank0_register -fftwl_rdft_rank_geq2_register -fftwl_rdft_solve -fftwl_rdft_thr_vrank_geq1_register -fftwl_rdft_vrank3_transpose_register -fftwl_rdft_vrank_geq1_register -fftwl_rdft_zerotens -fftwl_redft00e_r2hc_pad_register -fftwl_regsolver_ct_directw -fftwl_regsolver_ct_directwsq -fftwl_regsolver_hc2c_direct -fftwl_regsolver_hc2hc_direct -fftwl_reodft00e_splitradix_register -fftwl_reodft010e_r2hc_register -fftwl_reodft11e_r2hc_odd_register -fftwl_reodft11e_radix2_r2hc_register -fftwl_reodft_conf_standard -fftwl_rodft00e_r2hc_pad_register -fftwl_safe_mulmod -fftwl_scanner_destroy -fftwl_set_planner_hooks -fftwl_set_timelimit -fftwl_solver_destroy -fftwl_solver_register -fftwl_solver_use -fftwl_solvtab_exec -fftwl_spawn_loop -fftwl_sprint_plan -fftwl_tensor_append -fftwl_tensor_compress -fftwl_tensor_compress_contiguous -fftwl_tensor_copy -fftwl_tensor_copy_except -fftwl_tensor_copy_inplace -fftwl_tensor_copy_sub -fftwl_tensor_destroy -fftwl_tensor_destroy2 -fftwl_tensor_destroy4 -fftwl_tensor_equal -fftwl_tensor_inplace_locations -fftwl_tensor_inplace_strides -fftwl_tensor_inplace_strides2 -fftwl_tensor_kosherp -fftwl_tensor_max_index -fftwl_tensor_md5 -fftwl_tensor_min_istride -fftwl_tensor_min_ostride -fftwl_tensor_min_stride -fftwl_tensor_print -fftwl_tensor_split -fftwl_tensor_strides_decrease -fftwl_tensor_sz -fftwl_tensor_tornk1 -fftwl_the_planner -fftwl_threads_cleanup -fftwl_threads_conf_standard -fftwl_threads_register_planner_hooks -fftwl_tile2d -fftwl_toobig -fftwl_transpose -fftwl_transpose_tiled -fftwl_transpose_tiledbuf -fftwl_triggen_destroy -fftwl_twiddle_awake -fftwl_twiddle_length -fftwl_zero1d_pair -lfftw_cleanup_ -lfftw_cleanup__ -lfftw_cleanup_threads_ -lfftw_cleanup_threads__ -lfftw_cost_ -lfftw_cost__ -lfftw_destroy_plan_ -lfftw_destroy_plan__ -lfftw_estimate_cost_ -lfftw_estimate_cost__ -lfftw_execute_ -lfftw_execute__ -lfftw_execute_dft_ -lfftw_execute_dft__ -lfftw_execute_dft_c2r_ -lfftw_execute_dft_c2r__ -lfftw_execute_dft_r2c_ -lfftw_execute_dft_r2c__ -lfftw_execute_r2r_ -lfftw_execute_r2r__ -lfftw_execute_split_dft_ -lfftw_execute_split_dft__ -lfftw_execute_split_dft_c2r_ -lfftw_execute_split_dft_c2r__ -lfftw_execute_split_dft_r2c_ -lfftw_execute_split_dft_r2c__ -lfftw_export_wisdom_ -lfftw_export_wisdom__ -lfftw_flops_ -lfftw_flops__ -lfftw_forget_wisdom_ -lfftw_forget_wisdom__ -lfftw_import_system_wisdom_ -lfftw_import_system_wisdom__ -lfftw_import_wisdom_ -lfftw_import_wisdom__ -lfftw_init_threads_ -lfftw_init_threads__ -lfftw_plan_dft_ -lfftw_plan_dft__ -lfftw_plan_dft_1d_ -lfftw_plan_dft_1d__ -lfftw_plan_dft_2d_ -lfftw_plan_dft_2d__ -lfftw_plan_dft_3d_ -lfftw_plan_dft_3d__ -lfftw_plan_dft_c2r_ -lfftw_plan_dft_c2r__ -lfftw_plan_dft_c2r_1d_ -lfftw_plan_dft_c2r_1d__ -lfftw_plan_dft_c2r_2d_ -lfftw_plan_dft_c2r_2d__ -lfftw_plan_dft_c2r_3d_ -lfftw_plan_dft_c2r_3d__ -lfftw_plan_dft_r2c_ -lfftw_plan_dft_r2c__ -lfftw_plan_dft_r2c_1d_ -lfftw_plan_dft_r2c_1d__ -lfftw_plan_dft_r2c_2d_ -lfftw_plan_dft_r2c_2d__ -lfftw_plan_dft_r2c_3d_ -lfftw_plan_dft_r2c_3d__ -lfftw_plan_guru_dft_ -lfftw_plan_guru_dft__ -lfftw_plan_guru_dft_c2r_ -lfftw_plan_guru_dft_c2r__ -lfftw_plan_guru_dft_r2c_ -lfftw_plan_guru_dft_r2c__ -lfftw_plan_guru_r2r_ -lfftw_plan_guru_r2r__ -lfftw_plan_guru_split_dft_ -lfftw_plan_guru_split_dft__ -lfftw_plan_guru_split_dft_c2r_ -lfftw_plan_guru_split_dft_c2r__ -lfftw_plan_guru_split_dft_r2c_ -lfftw_plan_guru_split_dft_r2c__ -lfftw_plan_many_dft_ -lfftw_plan_many_dft__ -lfftw_plan_many_dft_c2r_ -lfftw_plan_many_dft_c2r__ -lfftw_plan_many_dft_r2c_ -lfftw_plan_many_dft_r2c__ -lfftw_plan_many_r2r_ -lfftw_plan_many_r2r__ -lfftw_plan_r2r_ -lfftw_plan_r2r__ -lfftw_plan_r2r_1d_ -lfftw_plan_r2r_1d__ -lfftw_plan_r2r_2d_ -lfftw_plan_r2r_2d__ -lfftw_plan_r2r_3d_ -lfftw_plan_r2r_3d__ -lfftw_plan_with_nthreads_ -lfftw_plan_with_nthreads__ -lfftw_print_plan_ -lfftw_print_plan__ -lfftw_set_timelimit_ -lfftw_set_timelimit__ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.exp b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.exp deleted file mode 100644 index 1c98b3ac1..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.lib b/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.lib deleted file mode 100644 index 3661f5aae..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/libfftw3l-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x64/onnxruntime.lib b/funasr/runtime/onnxruntime/win/lib/x64/onnxruntime.lib deleted file mode 100644 index b1a314c3a..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x64/onnxruntime.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.def b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.def deleted file mode 100644 index 4b50ecd41..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.def +++ /dev/null @@ -1,1017 +0,0 @@ -LIBRARY libfftw3-3.dll -EXPORTS -dfftw_cleanup_ -dfftw_cleanup__ -dfftw_cleanup_threads_ -dfftw_cleanup_threads__ -dfftw_cost_ -dfftw_cost__ -dfftw_destroy_plan_ -dfftw_destroy_plan__ -dfftw_estimate_cost_ -dfftw_estimate_cost__ -dfftw_execute_ -dfftw_execute__ -dfftw_execute_dft_ -dfftw_execute_dft__ -dfftw_execute_dft_c2r_ -dfftw_execute_dft_c2r__ -dfftw_execute_dft_r2c_ -dfftw_execute_dft_r2c__ -dfftw_execute_r2r_ -dfftw_execute_r2r__ -dfftw_execute_split_dft_ -dfftw_execute_split_dft__ -dfftw_execute_split_dft_c2r_ -dfftw_execute_split_dft_c2r__ -dfftw_execute_split_dft_r2c_ -dfftw_execute_split_dft_r2c__ -dfftw_export_wisdom_ -dfftw_export_wisdom__ -dfftw_flops_ -dfftw_flops__ -dfftw_forget_wisdom_ -dfftw_forget_wisdom__ -dfftw_import_system_wisdom_ -dfftw_import_system_wisdom__ -dfftw_import_wisdom_ -dfftw_import_wisdom__ -dfftw_init_threads_ -dfftw_init_threads__ -dfftw_plan_dft_ -dfftw_plan_dft__ -dfftw_plan_dft_1d_ -dfftw_plan_dft_1d__ -dfftw_plan_dft_2d_ -dfftw_plan_dft_2d__ -dfftw_plan_dft_3d_ -dfftw_plan_dft_3d__ -dfftw_plan_dft_c2r_ -dfftw_plan_dft_c2r__ -dfftw_plan_dft_c2r_1d_ -dfftw_plan_dft_c2r_1d__ -dfftw_plan_dft_c2r_2d_ -dfftw_plan_dft_c2r_2d__ -dfftw_plan_dft_c2r_3d_ -dfftw_plan_dft_c2r_3d__ -dfftw_plan_dft_r2c_ -dfftw_plan_dft_r2c__ -dfftw_plan_dft_r2c_1d_ -dfftw_plan_dft_r2c_1d__ -dfftw_plan_dft_r2c_2d_ -dfftw_plan_dft_r2c_2d__ -dfftw_plan_dft_r2c_3d_ -dfftw_plan_dft_r2c_3d__ -dfftw_plan_guru_dft_ -dfftw_plan_guru_dft__ -dfftw_plan_guru_dft_c2r_ -dfftw_plan_guru_dft_c2r__ -dfftw_plan_guru_dft_r2c_ -dfftw_plan_guru_dft_r2c__ -dfftw_plan_guru_r2r_ -dfftw_plan_guru_r2r__ -dfftw_plan_guru_split_dft_ -dfftw_plan_guru_split_dft__ -dfftw_plan_guru_split_dft_c2r_ -dfftw_plan_guru_split_dft_c2r__ -dfftw_plan_guru_split_dft_r2c_ -dfftw_plan_guru_split_dft_r2c__ -dfftw_plan_many_dft_ -dfftw_plan_many_dft__ -dfftw_plan_many_dft_c2r_ -dfftw_plan_many_dft_c2r__ -dfftw_plan_many_dft_r2c_ -dfftw_plan_many_dft_r2c__ -dfftw_plan_many_r2r_ -dfftw_plan_many_r2r__ -dfftw_plan_r2r_ -dfftw_plan_r2r__ -dfftw_plan_r2r_1d_ -dfftw_plan_r2r_1d__ -dfftw_plan_r2r_2d_ -dfftw_plan_r2r_2d__ -dfftw_plan_r2r_3d_ -dfftw_plan_r2r_3d__ -dfftw_plan_with_nthreads_ -dfftw_plan_with_nthreads__ -dfftw_print_plan_ -dfftw_print_plan__ -dfftw_set_timelimit_ -dfftw_set_timelimit__ -fftw_alignment_of -fftw_alloc_complex -fftw_alloc_real -fftw_assertion_failed -fftw_bufdist -fftw_check_alignment_of_sse2_pm -fftw_choose_radix -fftw_cleanup -fftw_cleanup_threads -fftw_codelet_e01_8 -fftw_codelet_e10_8 -fftw_codelet_hb_10 -fftw_codelet_hb_12 -fftw_codelet_hb_15 -fftw_codelet_hb_16 -fftw_codelet_hb_2 -fftw_codelet_hb_20 -fftw_codelet_hb2_16 -fftw_codelet_hb2_20 -fftw_codelet_hb2_25 -fftw_codelet_hb2_32 -fftw_codelet_hb2_4 -fftw_codelet_hb_25 -fftw_codelet_hb2_5 -fftw_codelet_hb2_8 -fftw_codelet_hb_3 -fftw_codelet_hb_32 -fftw_codelet_hb_4 -fftw_codelet_hb_5 -fftw_codelet_hb_6 -fftw_codelet_hb_64 -fftw_codelet_hb_7 -fftw_codelet_hb_8 -fftw_codelet_hb_9 -fftw_codelet_hc2cb_10 -fftw_codelet_hc2cb_12 -fftw_codelet_hc2cb_16 -fftw_codelet_hc2cb_2 -fftw_codelet_hc2cb_20 -fftw_codelet_hc2cb2_16 -fftw_codelet_hc2cb2_20 -fftw_codelet_hc2cb2_32 -fftw_codelet_hc2cb2_4 -fftw_codelet_hc2cb2_8 -fftw_codelet_hc2cb_32 -fftw_codelet_hc2cb_4 -fftw_codelet_hc2cb_6 -fftw_codelet_hc2cb_8 -fftw_codelet_hc2cbdft_10 -fftw_codelet_hc2cbdft_12 -fftw_codelet_hc2cbdft_16 -fftw_codelet_hc2cbdft_2 -fftw_codelet_hc2cbdft_20 -fftw_codelet_hc2cbdft2_16 -fftw_codelet_hc2cbdft2_20 -fftw_codelet_hc2cbdft2_32 -fftw_codelet_hc2cbdft2_4 -fftw_codelet_hc2cbdft2_8 -fftw_codelet_hc2cbdft_32 -fftw_codelet_hc2cbdft_4 -fftw_codelet_hc2cbdft_6 -fftw_codelet_hc2cbdft_8 -fftw_codelet_hc2cbdftv_10_avx -fftw_codelet_hc2cbdftv_10_sse2 -fftw_codelet_hc2cbdftv_12_avx -fftw_codelet_hc2cbdftv_12_sse2 -fftw_codelet_hc2cbdftv_16_avx -fftw_codelet_hc2cbdftv_16_sse2 -fftw_codelet_hc2cbdftv_20_avx -fftw_codelet_hc2cbdftv_20_sse2 -fftw_codelet_hc2cbdftv_2_avx -fftw_codelet_hc2cbdftv_2_sse2 -fftw_codelet_hc2cbdftv_32_avx -fftw_codelet_hc2cbdftv_32_sse2 -fftw_codelet_hc2cbdftv_4_avx -fftw_codelet_hc2cbdftv_4_sse2 -fftw_codelet_hc2cbdftv_6_avx -fftw_codelet_hc2cbdftv_6_sse2 -fftw_codelet_hc2cbdftv_8_avx -fftw_codelet_hc2cbdftv_8_sse2 -fftw_codelet_hc2cf_10 -fftw_codelet_hc2cf_12 -fftw_codelet_hc2cf_16 -fftw_codelet_hc2cf_2 -fftw_codelet_hc2cf_20 -fftw_codelet_hc2cf2_16 -fftw_codelet_hc2cf2_20 -fftw_codelet_hc2cf2_32 -fftw_codelet_hc2cf2_4 -fftw_codelet_hc2cf2_8 -fftw_codelet_hc2cf_32 -fftw_codelet_hc2cf_4 -fftw_codelet_hc2cf_6 -fftw_codelet_hc2cf_8 -fftw_codelet_hc2cfdft_10 -fftw_codelet_hc2cfdft_12 -fftw_codelet_hc2cfdft_16 -fftw_codelet_hc2cfdft_2 -fftw_codelet_hc2cfdft_20 -fftw_codelet_hc2cfdft2_16 -fftw_codelet_hc2cfdft2_20 -fftw_codelet_hc2cfdft2_32 -fftw_codelet_hc2cfdft2_4 -fftw_codelet_hc2cfdft2_8 -fftw_codelet_hc2cfdft_32 -fftw_codelet_hc2cfdft_4 -fftw_codelet_hc2cfdft_6 -fftw_codelet_hc2cfdft_8 -fftw_codelet_hc2cfdftv_10_avx -fftw_codelet_hc2cfdftv_10_sse2 -fftw_codelet_hc2cfdftv_12_avx -fftw_codelet_hc2cfdftv_12_sse2 -fftw_codelet_hc2cfdftv_16_avx -fftw_codelet_hc2cfdftv_16_sse2 -fftw_codelet_hc2cfdftv_20_avx -fftw_codelet_hc2cfdftv_20_sse2 -fftw_codelet_hc2cfdftv_2_avx -fftw_codelet_hc2cfdftv_2_sse2 -fftw_codelet_hc2cfdftv_32_avx -fftw_codelet_hc2cfdftv_32_sse2 -fftw_codelet_hc2cfdftv_4_avx -fftw_codelet_hc2cfdftv_4_sse2 -fftw_codelet_hc2cfdftv_6_avx -fftw_codelet_hc2cfdftv_6_sse2 -fftw_codelet_hc2cfdftv_8_avx -fftw_codelet_hc2cfdftv_8_sse2 -fftw_codelet_hf_10 -fftw_codelet_hf_12 -fftw_codelet_hf_15 -fftw_codelet_hf_16 -fftw_codelet_hf_2 -fftw_codelet_hf_20 -fftw_codelet_hf2_16 -fftw_codelet_hf2_20 -fftw_codelet_hf2_25 -fftw_codelet_hf2_32 -fftw_codelet_hf2_4 -fftw_codelet_hf_25 -fftw_codelet_hf2_5 -fftw_codelet_hf2_8 -fftw_codelet_hf_3 -fftw_codelet_hf_32 -fftw_codelet_hf_4 -fftw_codelet_hf_5 -fftw_codelet_hf_6 -fftw_codelet_hf_64 -fftw_codelet_hf_7 -fftw_codelet_hf_8 -fftw_codelet_hf_9 -fftw_codelet_n1_10 -fftw_codelet_n1_11 -fftw_codelet_n1_12 -fftw_codelet_n1_13 -fftw_codelet_n1_14 -fftw_codelet_n1_15 -fftw_codelet_n1_16 -fftw_codelet_n1_2 -fftw_codelet_n1_20 -fftw_codelet_n1_25 -fftw_codelet_n1_3 -fftw_codelet_n1_32 -fftw_codelet_n1_4 -fftw_codelet_n1_5 -fftw_codelet_n1_6 -fftw_codelet_n1_64 -fftw_codelet_n1_7 -fftw_codelet_n1_8 -fftw_codelet_n1_9 -fftw_codelet_n1bv_10_avx -fftw_codelet_n1bv_10_sse2 -fftw_codelet_n1bv_11_avx -fftw_codelet_n1bv_11_sse2 -fftw_codelet_n1bv_128_avx -fftw_codelet_n1bv_128_sse2 -fftw_codelet_n1bv_12_avx -fftw_codelet_n1bv_12_sse2 -fftw_codelet_n1bv_13_avx -fftw_codelet_n1bv_13_sse2 -fftw_codelet_n1bv_14_avx -fftw_codelet_n1bv_14_sse2 -fftw_codelet_n1bv_15_avx -fftw_codelet_n1bv_15_sse2 -fftw_codelet_n1bv_16_avx -fftw_codelet_n1bv_16_sse2 -fftw_codelet_n1bv_20_avx -fftw_codelet_n1bv_20_sse2 -fftw_codelet_n1bv_25_avx -fftw_codelet_n1bv_25_sse2 -fftw_codelet_n1bv_2_avx -fftw_codelet_n1bv_2_sse2 -fftw_codelet_n1bv_32_avx -fftw_codelet_n1bv_32_sse2 -fftw_codelet_n1bv_3_avx -fftw_codelet_n1bv_3_sse2 -fftw_codelet_n1bv_4_avx -fftw_codelet_n1bv_4_sse2 -fftw_codelet_n1bv_5_avx -fftw_codelet_n1bv_5_sse2 -fftw_codelet_n1bv_64_avx -fftw_codelet_n1bv_64_sse2 -fftw_codelet_n1bv_6_avx -fftw_codelet_n1bv_6_sse2 -fftw_codelet_n1bv_7_avx -fftw_codelet_n1bv_7_sse2 -fftw_codelet_n1bv_8_avx -fftw_codelet_n1bv_8_sse2 -fftw_codelet_n1bv_9_avx -fftw_codelet_n1bv_9_sse2 -fftw_codelet_n1fv_10_avx -fftw_codelet_n1fv_10_sse2 -fftw_codelet_n1fv_11_avx -fftw_codelet_n1fv_11_sse2 -fftw_codelet_n1fv_128_avx -fftw_codelet_n1fv_128_sse2 -fftw_codelet_n1fv_12_avx -fftw_codelet_n1fv_12_sse2 -fftw_codelet_n1fv_13_avx -fftw_codelet_n1fv_13_sse2 -fftw_codelet_n1fv_14_avx -fftw_codelet_n1fv_14_sse2 -fftw_codelet_n1fv_15_avx -fftw_codelet_n1fv_15_sse2 -fftw_codelet_n1fv_16_avx -fftw_codelet_n1fv_16_sse2 -fftw_codelet_n1fv_20_avx -fftw_codelet_n1fv_20_sse2 -fftw_codelet_n1fv_25_avx -fftw_codelet_n1fv_25_sse2 -fftw_codelet_n1fv_2_avx -fftw_codelet_n1fv_2_sse2 -fftw_codelet_n1fv_32_avx -fftw_codelet_n1fv_32_sse2 -fftw_codelet_n1fv_3_avx -fftw_codelet_n1fv_3_sse2 -fftw_codelet_n1fv_4_avx -fftw_codelet_n1fv_4_sse2 -fftw_codelet_n1fv_5_avx -fftw_codelet_n1fv_5_sse2 -fftw_codelet_n1fv_64_avx -fftw_codelet_n1fv_64_sse2 -fftw_codelet_n1fv_6_avx -fftw_codelet_n1fv_6_sse2 -fftw_codelet_n1fv_7_avx -fftw_codelet_n1fv_7_sse2 -fftw_codelet_n1fv_8_avx -fftw_codelet_n1fv_8_sse2 -fftw_codelet_n1fv_9_avx -fftw_codelet_n1fv_9_sse2 -fftw_codelet_n2bv_10_avx -fftw_codelet_n2bv_10_sse2 -fftw_codelet_n2bv_12_avx -fftw_codelet_n2bv_12_sse2 -fftw_codelet_n2bv_14_avx -fftw_codelet_n2bv_14_sse2 -fftw_codelet_n2bv_16_avx -fftw_codelet_n2bv_16_sse2 -fftw_codelet_n2bv_20_avx -fftw_codelet_n2bv_20_sse2 -fftw_codelet_n2bv_2_avx -fftw_codelet_n2bv_2_sse2 -fftw_codelet_n2bv_32_avx -fftw_codelet_n2bv_32_sse2 -fftw_codelet_n2bv_4_avx -fftw_codelet_n2bv_4_sse2 -fftw_codelet_n2bv_64_avx -fftw_codelet_n2bv_64_sse2 -fftw_codelet_n2bv_6_avx -fftw_codelet_n2bv_6_sse2 -fftw_codelet_n2bv_8_avx -fftw_codelet_n2bv_8_sse2 -fftw_codelet_n2fv_10_avx -fftw_codelet_n2fv_10_sse2 -fftw_codelet_n2fv_12_avx -fftw_codelet_n2fv_12_sse2 -fftw_codelet_n2fv_14_avx -fftw_codelet_n2fv_14_sse2 -fftw_codelet_n2fv_16_avx -fftw_codelet_n2fv_16_sse2 -fftw_codelet_n2fv_20_avx -fftw_codelet_n2fv_20_sse2 -fftw_codelet_n2fv_2_avx -fftw_codelet_n2fv_2_sse2 -fftw_codelet_n2fv_32_avx -fftw_codelet_n2fv_32_sse2 -fftw_codelet_n2fv_4_avx -fftw_codelet_n2fv_4_sse2 -fftw_codelet_n2fv_64_avx -fftw_codelet_n2fv_64_sse2 -fftw_codelet_n2fv_6_avx -fftw_codelet_n2fv_6_sse2 -fftw_codelet_n2fv_8_avx -fftw_codelet_n2fv_8_sse2 -fftw_codelet_n2sv_16_avx -fftw_codelet_n2sv_16_sse2 -fftw_codelet_n2sv_32_avx -fftw_codelet_n2sv_32_sse2 -fftw_codelet_n2sv_4_avx -fftw_codelet_n2sv_4_sse2 -fftw_codelet_n2sv_64_avx -fftw_codelet_n2sv_64_sse2 -fftw_codelet_n2sv_8_avx -fftw_codelet_n2sv_8_sse2 -fftw_codelet_q1_2 -fftw_codelet_q1_3 -fftw_codelet_q1_4 -fftw_codelet_q1_5 -fftw_codelet_q1_6 -fftw_codelet_q1_8 -fftw_codelet_q1bv_2_avx -fftw_codelet_q1bv_2_sse2 -fftw_codelet_q1bv_4_avx -fftw_codelet_q1bv_4_sse2 -fftw_codelet_q1bv_5_avx -fftw_codelet_q1bv_5_sse2 -fftw_codelet_q1bv_8_avx -fftw_codelet_q1bv_8_sse2 -fftw_codelet_q1fv_2_avx -fftw_codelet_q1fv_2_sse2 -fftw_codelet_q1fv_4_avx -fftw_codelet_q1fv_4_sse2 -fftw_codelet_q1fv_5_avx -fftw_codelet_q1fv_5_sse2 -fftw_codelet_q1fv_8_avx -fftw_codelet_q1fv_8_sse2 -fftw_codelet_r2cb_10 -fftw_codelet_r2cb_11 -fftw_codelet_r2cb_12 -fftw_codelet_r2cb_128 -fftw_codelet_r2cb_13 -fftw_codelet_r2cb_14 -fftw_codelet_r2cb_15 -fftw_codelet_r2cb_16 -fftw_codelet_r2cb_2 -fftw_codelet_r2cb_20 -fftw_codelet_r2cb_25 -fftw_codelet_r2cb_3 -fftw_codelet_r2cb_32 -fftw_codelet_r2cb_4 -fftw_codelet_r2cb_5 -fftw_codelet_r2cb_6 -fftw_codelet_r2cb_64 -fftw_codelet_r2cb_7 -fftw_codelet_r2cb_8 -fftw_codelet_r2cb_9 -fftw_codelet_r2cbIII_10 -fftw_codelet_r2cbIII_12 -fftw_codelet_r2cbIII_15 -fftw_codelet_r2cbIII_16 -fftw_codelet_r2cbIII_2 -fftw_codelet_r2cbIII_20 -fftw_codelet_r2cbIII_25 -fftw_codelet_r2cbIII_3 -fftw_codelet_r2cbIII_32 -fftw_codelet_r2cbIII_4 -fftw_codelet_r2cbIII_5 -fftw_codelet_r2cbIII_6 -fftw_codelet_r2cbIII_64 -fftw_codelet_r2cbIII_7 -fftw_codelet_r2cbIII_8 -fftw_codelet_r2cbIII_9 -fftw_codelet_r2cf_10 -fftw_codelet_r2cf_11 -fftw_codelet_r2cf_12 -fftw_codelet_r2cf_128 -fftw_codelet_r2cf_13 -fftw_codelet_r2cf_14 -fftw_codelet_r2cf_15 -fftw_codelet_r2cf_16 -fftw_codelet_r2cf_2 -fftw_codelet_r2cf_20 -fftw_codelet_r2cf_25 -fftw_codelet_r2cf_3 -fftw_codelet_r2cf_32 -fftw_codelet_r2cf_4 -fftw_codelet_r2cf_5 -fftw_codelet_r2cf_6 -fftw_codelet_r2cf_64 -fftw_codelet_r2cf_7 -fftw_codelet_r2cf_8 -fftw_codelet_r2cf_9 -fftw_codelet_r2cfII_10 -fftw_codelet_r2cfII_12 -fftw_codelet_r2cfII_15 -fftw_codelet_r2cfII_16 -fftw_codelet_r2cfII_2 -fftw_codelet_r2cfII_20 -fftw_codelet_r2cfII_25 -fftw_codelet_r2cfII_3 -fftw_codelet_r2cfII_32 -fftw_codelet_r2cfII_4 -fftw_codelet_r2cfII_5 -fftw_codelet_r2cfII_6 -fftw_codelet_r2cfII_64 -fftw_codelet_r2cfII_7 -fftw_codelet_r2cfII_8 -fftw_codelet_r2cfII_9 -fftw_codelet_t1_10 -fftw_codelet_t1_12 -fftw_codelet_t1_15 -fftw_codelet_t1_16 -fftw_codelet_t1_2 -fftw_codelet_t1_20 -fftw_codelet_t1_25 -fftw_codelet_t1_3 -fftw_codelet_t1_32 -fftw_codelet_t1_4 -fftw_codelet_t1_5 -fftw_codelet_t1_6 -fftw_codelet_t1_64 -fftw_codelet_t1_7 -fftw_codelet_t1_8 -fftw_codelet_t1_9 -fftw_codelet_t1buv_10_avx -fftw_codelet_t1buv_10_sse2 -fftw_codelet_t1buv_2_avx -fftw_codelet_t1buv_2_sse2 -fftw_codelet_t1buv_3_avx -fftw_codelet_t1buv_3_sse2 -fftw_codelet_t1buv_4_avx -fftw_codelet_t1buv_4_sse2 -fftw_codelet_t1buv_5_avx -fftw_codelet_t1buv_5_sse2 -fftw_codelet_t1buv_6_avx -fftw_codelet_t1buv_6_sse2 -fftw_codelet_t1buv_7_avx -fftw_codelet_t1buv_7_sse2 -fftw_codelet_t1buv_8_avx -fftw_codelet_t1buv_8_sse2 -fftw_codelet_t1buv_9_avx -fftw_codelet_t1buv_9_sse2 -fftw_codelet_t1bv_10_avx -fftw_codelet_t1bv_10_sse2 -fftw_codelet_t1bv_12_avx -fftw_codelet_t1bv_12_sse2 -fftw_codelet_t1bv_15_avx -fftw_codelet_t1bv_15_sse2 -fftw_codelet_t1bv_16_avx -fftw_codelet_t1bv_16_sse2 -fftw_codelet_t1bv_20_avx -fftw_codelet_t1bv_20_sse2 -fftw_codelet_t1bv_25_avx -fftw_codelet_t1bv_25_sse2 -fftw_codelet_t1bv_2_avx -fftw_codelet_t1bv_2_sse2 -fftw_codelet_t1bv_32_avx -fftw_codelet_t1bv_32_sse2 -fftw_codelet_t1bv_3_avx -fftw_codelet_t1bv_3_sse2 -fftw_codelet_t1bv_4_avx -fftw_codelet_t1bv_4_sse2 -fftw_codelet_t1bv_5_avx -fftw_codelet_t1bv_5_sse2 -fftw_codelet_t1bv_64_avx -fftw_codelet_t1bv_64_sse2 -fftw_codelet_t1bv_6_avx -fftw_codelet_t1bv_6_sse2 -fftw_codelet_t1bv_7_avx -fftw_codelet_t1bv_7_sse2 -fftw_codelet_t1bv_8_avx -fftw_codelet_t1bv_8_sse2 -fftw_codelet_t1bv_9_avx -fftw_codelet_t1bv_9_sse2 -fftw_codelet_t1fuv_10_avx -fftw_codelet_t1fuv_10_sse2 -fftw_codelet_t1fuv_2_avx -fftw_codelet_t1fuv_2_sse2 -fftw_codelet_t1fuv_3_avx -fftw_codelet_t1fuv_3_sse2 -fftw_codelet_t1fuv_4_avx -fftw_codelet_t1fuv_4_sse2 -fftw_codelet_t1fuv_5_avx -fftw_codelet_t1fuv_5_sse2 -fftw_codelet_t1fuv_6_avx -fftw_codelet_t1fuv_6_sse2 -fftw_codelet_t1fuv_7_avx -fftw_codelet_t1fuv_7_sse2 -fftw_codelet_t1fuv_8_avx -fftw_codelet_t1fuv_8_sse2 -fftw_codelet_t1fuv_9_avx -fftw_codelet_t1fuv_9_sse2 -fftw_codelet_t1fv_10_avx -fftw_codelet_t1fv_10_sse2 -fftw_codelet_t1fv_12_avx -fftw_codelet_t1fv_12_sse2 -fftw_codelet_t1fv_15_avx -fftw_codelet_t1fv_15_sse2 -fftw_codelet_t1fv_16_avx -fftw_codelet_t1fv_16_sse2 -fftw_codelet_t1fv_20_avx -fftw_codelet_t1fv_20_sse2 -fftw_codelet_t1fv_25_avx -fftw_codelet_t1fv_25_sse2 -fftw_codelet_t1fv_2_avx -fftw_codelet_t1fv_2_sse2 -fftw_codelet_t1fv_32_avx -fftw_codelet_t1fv_32_sse2 -fftw_codelet_t1fv_3_avx -fftw_codelet_t1fv_3_sse2 -fftw_codelet_t1fv_4_avx -fftw_codelet_t1fv_4_sse2 -fftw_codelet_t1fv_5_avx -fftw_codelet_t1fv_5_sse2 -fftw_codelet_t1fv_64_avx -fftw_codelet_t1fv_64_sse2 -fftw_codelet_t1fv_6_avx -fftw_codelet_t1fv_6_sse2 -fftw_codelet_t1fv_7_avx -fftw_codelet_t1fv_7_sse2 -fftw_codelet_t1fv_8_avx -fftw_codelet_t1fv_8_sse2 -fftw_codelet_t1fv_9_avx -fftw_codelet_t1fv_9_sse2 -fftw_codelet_t1sv_16_avx -fftw_codelet_t1sv_16_sse2 -fftw_codelet_t1sv_2_avx -fftw_codelet_t1sv_2_sse2 -fftw_codelet_t1sv_32_avx -fftw_codelet_t1sv_32_sse2 -fftw_codelet_t1sv_4_avx -fftw_codelet_t1sv_4_sse2 -fftw_codelet_t1sv_8_avx -fftw_codelet_t1sv_8_sse2 -fftw_codelet_t2_10 -fftw_codelet_t2_16 -fftw_codelet_t2_20 -fftw_codelet_t2_25 -fftw_codelet_t2_32 -fftw_codelet_t2_4 -fftw_codelet_t2_5 -fftw_codelet_t2_64 -fftw_codelet_t2_8 -fftw_codelet_t2bv_10_avx -fftw_codelet_t2bv_10_sse2 -fftw_codelet_t2bv_16_avx -fftw_codelet_t2bv_16_sse2 -fftw_codelet_t2bv_20_avx -fftw_codelet_t2bv_20_sse2 -fftw_codelet_t2bv_25_avx -fftw_codelet_t2bv_25_sse2 -fftw_codelet_t2bv_2_avx -fftw_codelet_t2bv_2_sse2 -fftw_codelet_t2bv_32_avx -fftw_codelet_t2bv_32_sse2 -fftw_codelet_t2bv_4_avx -fftw_codelet_t2bv_4_sse2 -fftw_codelet_t2bv_5_avx -fftw_codelet_t2bv_5_sse2 -fftw_codelet_t2bv_64_avx -fftw_codelet_t2bv_64_sse2 -fftw_codelet_t2bv_8_avx -fftw_codelet_t2bv_8_sse2 -fftw_codelet_t2fv_10_avx -fftw_codelet_t2fv_10_sse2 -fftw_codelet_t2fv_16_avx -fftw_codelet_t2fv_16_sse2 -fftw_codelet_t2fv_20_avx -fftw_codelet_t2fv_20_sse2 -fftw_codelet_t2fv_25_avx -fftw_codelet_t2fv_25_sse2 -fftw_codelet_t2fv_2_avx -fftw_codelet_t2fv_2_sse2 -fftw_codelet_t2fv_32_avx -fftw_codelet_t2fv_32_sse2 -fftw_codelet_t2fv_4_avx -fftw_codelet_t2fv_4_sse2 -fftw_codelet_t2fv_5_avx -fftw_codelet_t2fv_5_sse2 -fftw_codelet_t2fv_64_avx -fftw_codelet_t2fv_64_sse2 -fftw_codelet_t2fv_8_avx -fftw_codelet_t2fv_8_sse2 -fftw_codelet_t2sv_16_avx -fftw_codelet_t2sv_16_sse2 -fftw_codelet_t2sv_32_avx -fftw_codelet_t2sv_32_sse2 -fftw_codelet_t2sv_4_avx -fftw_codelet_t2sv_4_sse2 -fftw_codelet_t2sv_8_avx -fftw_codelet_t2sv_8_sse2 -fftw_codelet_t3bv_10_avx -fftw_codelet_t3bv_10_sse2 -fftw_codelet_t3bv_16_avx -fftw_codelet_t3bv_16_sse2 -fftw_codelet_t3bv_20_avx -fftw_codelet_t3bv_20_sse2 -fftw_codelet_t3bv_25_avx -fftw_codelet_t3bv_25_sse2 -fftw_codelet_t3bv_32_avx -fftw_codelet_t3bv_32_sse2 -fftw_codelet_t3bv_4_avx -fftw_codelet_t3bv_4_sse2 -fftw_codelet_t3bv_5_avx -fftw_codelet_t3bv_5_sse2 -fftw_codelet_t3bv_8_avx -fftw_codelet_t3bv_8_sse2 -fftw_codelet_t3fv_10_avx -fftw_codelet_t3fv_10_sse2 -fftw_codelet_t3fv_16_avx -fftw_codelet_t3fv_16_sse2 -fftw_codelet_t3fv_20_avx -fftw_codelet_t3fv_20_sse2 -fftw_codelet_t3fv_25_avx -fftw_codelet_t3fv_25_sse2 -fftw_codelet_t3fv_32_avx -fftw_codelet_t3fv_32_sse2 -fftw_codelet_t3fv_4_avx -fftw_codelet_t3fv_4_sse2 -fftw_codelet_t3fv_5_avx -fftw_codelet_t3fv_5_sse2 -fftw_codelet_t3fv_8_avx -fftw_codelet_t3fv_8_sse2 -fftw_compute_tilesz -fftw_configure_planner -fftw_cost -fftw_cpy1d -fftw_cpy2d -fftw_cpy2d_ci -fftw_cpy2d_co -fftw_cpy2d_pair -fftw_cpy2d_pair_ci -fftw_cpy2d_pair_co -fftw_cpy2d_tiled -fftw_cpy2d_tiledbuf -fftw_ct_applicable -fftw_ct_genericbuf_register -fftw_ct_generic_register -fftw_ct_uglyp -fftw_destroy_plan -fftw_dft_bluestein_register -fftw_dft_buffered_register -fftw_dft_conf_standard -fftw_dft_generic_register -fftw_dft_indirect_register -fftw_dft_indirect_transpose_register -fftw_dft_nop_register -fftw_dft_r2hc_register -fftw_dft_rader_register -fftw_dft_rank_geq2_register -fftw_dft_solve -fftw_dft_thr_vrank_geq1_register -fftw_dft_vrank_geq1_register -fftw_dft_zerotens -fftw_dht_r2hc_register -fftw_dht_rader_register -fftw_dimcmp -fftw_elapsed_since -fftw_estimate_cost -fftw_execute -fftw_execute_dft -fftw_execute_dft_c2r -fftw_execute_dft_r2c -fftw_execute_r2r -fftw_execute_split_dft -fftw_execute_split_dft_c2r -fftw_execute_split_dft_r2c -fftw_export_wisdom -fftw_export_wisdom_to_file -fftw_export_wisdom_to_filename -fftw_export_wisdom_to_string -fftw_extract_reim -fftw_factors_into -fftw_factors_into_small_primes -fftw_find_generator -fftw_first_divisor -fftw_flops -fftw_forget_wisdom -fftw_fprint_plan -fftw_free -fftw_get_crude_time -fftw_guru64_kosherp -fftw_guru_kosherp -fftw_hash -fftw_have_simd_avx -fftw_have_simd_sse2 -fftw_hc2hc_applicable -fftw_hc2hc_generic_register -fftw_iabs -fftw_ialignment_of -fftw_iestimate_cost -fftw_ifree -fftw_ifree0 -fftw_imax -fftw_imin -fftw_import_system_wisdom -fftw_import_wisdom -fftw_import_wisdom_from_file -fftw_import_wisdom_from_filename -fftw_import_wisdom_from_string -fftw_init_threads -fftw_is_prime -fftw_isqrt -fftw_ithreads_init -fftw_join_taint -fftw_kdft_dif_register -fftw_kdft_difsq_register -fftw_kdft_dit_register -fftw_kdft_register -fftw_kernel_free -fftw_kernel_malloc -fftw_khc2c_register -fftw_khc2hc_register -fftw_kr2c_register -fftw_kr2r_register -fftw_make_planner_thread_safe -fftw_malloc -fftw_malloc_plain -fftw_many_kosherp -fftw_mapflags -fftw_map_r2r_kind -fftw_md5begin -fftw_md5end -fftw_md5int -fftw_md5INT -fftw_md5putb -fftw_md5putc -fftw_md5puts -fftw_md5unsigned -fftw_measure_execution_time -fftw_mkapiplan -fftw_mkplan -fftw_mkplan_d -fftw_mkplan_dft -fftw_mkplan_dftw -fftw_mkplan_f_d -fftw_mkplan_hc2c -fftw_mkplan_hc2hc -fftw_mkplanner -fftw_mkplan_rdft -fftw_mkplan_rdft2 -fftw_mkprinter -fftw_mkprinter_cnt -fftw_mkprinter_file -fftw_mkprinter_str -fftw_mkproblem -fftw_mkproblem_dft -fftw_mkproblem_dft_d -fftw_mkproblem_rdft -fftw_mkproblem_rdft_0_d -fftw_mkproblem_rdft_1 -fftw_mkproblem_rdft_1_d -fftw_mkproblem_rdft2 -fftw_mkproblem_rdft2_d -fftw_mkproblem_rdft2_d_3pointers -fftw_mkproblem_rdft_d -fftw_mkproblem_unsolvable -fftw_mkscanner -fftw_mksolver -fftw_mksolver_ct -fftw_mksolver_ct_threads -fftw_mksolver_dft_direct -fftw_mksolver_dft_directbuf -fftw_mksolver_hc2c -fftw_mksolver_hc2hc -fftw_mksolver_hc2hc_threads -fftw_mksolver_rdft2_direct -fftw_mksolver_rdft_r2c_direct -fftw_mksolver_rdft_r2c_directbuf -fftw_mksolver_rdft_r2r_direct -fftw_mkstride -fftw_mktensor -fftw_mktensor_0d -fftw_mktensor_1d -fftw_mktensor_2d -fftw_mktensor_3d -fftw_mktensor_4d -fftw_mktensor_5d -fftw_mktensor_iodims -fftw_mktensor_iodims64 -fftw_mktensor_rowmajor -fftw_mktriggen -fftw_modulo -fftw_nbuf -fftw_nbuf_redundant -fftw_next_prime -fftw_null_awake -fftw_ops_add -fftw_ops_add2 -fftw_ops_cpy -fftw_ops_madd -fftw_ops_madd2 -fftw_ops_other -fftw_ops_zero -fftw_pickdim -fftw_plan_awake -fftw_plan_destroy_internal -fftw_plan_dft -fftw_plan_dft_1d -fftw_plan_dft_2d -fftw_plan_dft_3d -fftw_plan_dft_c2r -fftw_plan_dft_c2r_1d -fftw_plan_dft_c2r_2d -fftw_plan_dft_c2r_3d -fftw_plan_dft_r2c -fftw_plan_dft_r2c_1d -fftw_plan_dft_r2c_2d -fftw_plan_dft_r2c_3d -fftw_plan_guru64_dft -fftw_plan_guru64_dft_c2r -fftw_plan_guru64_dft_r2c -fftw_plan_guru64_r2r -fftw_plan_guru64_split_dft -fftw_plan_guru64_split_dft_c2r -fftw_plan_guru64_split_dft_r2c -fftw_plan_guru_dft -fftw_plan_guru_dft_c2r -fftw_plan_guru_dft_r2c -fftw_plan_guru_r2r -fftw_plan_guru_split_dft -fftw_plan_guru_split_dft_c2r -fftw_plan_guru_split_dft_r2c -fftw_plan_many_dft -fftw_plan_many_dft_c2r -fftw_plan_many_dft_r2c -fftw_plan_many_r2r -fftw_planner_destroy -fftw_plan_null_destroy -fftw_plan_r2r -fftw_plan_r2r_1d -fftw_plan_r2r_2d -fftw_plan_r2r_3d -fftw_plan_with_nthreads -fftw_power_mod -fftw_printer_destroy -fftw_print_plan -fftw_problem_destroy -fftw_rader_tl_delete -fftw_rader_tl_find -fftw_rader_tl_insert -fftw_rdft2_buffered_register -fftw_rdft2_complex_n -fftw_rdft2_inplace_strides -fftw_rdft2_nop_register -fftw_rdft2_pad -fftw_rdft2_rank0_register -fftw_rdft2_rank_geq2_register -fftw_rdft2_rdft_register -fftw_rdft2_solve -fftw_rdft2_strides -fftw_rdft2_tensor_max_index -fftw_rdft2_thr_vrank_geq1_register -fftw_rdft2_vrank_geq1_register -fftw_rdft_buffered_register -fftw_rdft_conf_standard -fftw_rdft_dht_register -fftw_rdft_generic_register -fftw_rdft_indirect_register -fftw_rdft_kind_str -fftw_rdft_nop_register -fftw_rdft_rank0_register -fftw_rdft_rank_geq2_register -fftw_rdft_solve -fftw_rdft_thr_vrank_geq1_register -fftw_rdft_vrank3_transpose_register -fftw_rdft_vrank_geq1_register -fftw_rdft_zerotens -fftw_redft00e_r2hc_pad_register -fftw_regsolver_ct_directw -fftw_regsolver_ct_directwsq -fftw_regsolver_hc2c_direct -fftw_regsolver_hc2hc_direct -fftw_reodft00e_splitradix_register -fftw_reodft010e_r2hc_register -fftw_reodft11e_r2hc_odd_register -fftw_reodft11e_radix2_r2hc_register -fftw_reodft_conf_standard -fftw_rodft00e_r2hc_pad_register -fftw_safe_mulmod -fftw_scanner_destroy -fftw_set_planner_hooks -fftw_set_timelimit -fftw_solver_destroy -fftw_solver_register -fftw_solver_use -fftw_solvtab_exec -fftw_spawn_loop -fftw_sprint_plan -fftw_stride_destroy -fftw_taint -fftw_tensor_append -fftw_tensor_compress -fftw_tensor_compress_contiguous -fftw_tensor_copy -fftw_tensor_copy_except -fftw_tensor_copy_inplace -fftw_tensor_copy_sub -fftw_tensor_destroy -fftw_tensor_destroy2 -fftw_tensor_destroy4 -fftw_tensor_equal -fftw_tensor_inplace_locations -fftw_tensor_inplace_strides -fftw_tensor_inplace_strides2 -fftw_tensor_kosherp -fftw_tensor_max_index -fftw_tensor_md5 -fftw_tensor_min_istride -fftw_tensor_min_ostride -fftw_tensor_min_stride -fftw_tensor_print -fftw_tensor_split -fftw_tensor_strides_decrease -fftw_tensor_sz -fftw_tensor_tornk1 -fftw_the_planner -fftw_threads_cleanup -fftw_threads_conf_standard -fftw_threads_register_planner_hooks -fftw_tile2d -fftw_toobig -fftw_transpose -fftw_transpose_tiled -fftw_transpose_tiledbuf -fftw_triggen_destroy -fftw_twiddle_awake -fftw_twiddle_length -fftw_zero1d_pair diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.exp b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.exp deleted file mode 100644 index 5048009f2..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.lib b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.lib deleted file mode 100644 index 7103673bf..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.def b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.def deleted file mode 100644 index d61a2c36c..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.def +++ /dev/null @@ -1,1017 +0,0 @@ -LIBRARY libfftw3f-3.dll -EXPORTS -fftwf_alignment_of -fftwf_alloc_complex -fftwf_alloc_real -fftwf_assertion_failed -fftwf_bufdist -fftwf_check_alignment_of_sse2_pm -fftwf_choose_radix -fftwf_cleanup -fftwf_cleanup_threads -fftwf_codelet_e01_8 -fftwf_codelet_e10_8 -fftwf_codelet_hb_10 -fftwf_codelet_hb_12 -fftwf_codelet_hb_15 -fftwf_codelet_hb_16 -fftwf_codelet_hb_2 -fftwf_codelet_hb_20 -fftwf_codelet_hb2_16 -fftwf_codelet_hb2_20 -fftwf_codelet_hb2_25 -fftwf_codelet_hb2_32 -fftwf_codelet_hb2_4 -fftwf_codelet_hb_25 -fftwf_codelet_hb2_5 -fftwf_codelet_hb2_8 -fftwf_codelet_hb_3 -fftwf_codelet_hb_32 -fftwf_codelet_hb_4 -fftwf_codelet_hb_5 -fftwf_codelet_hb_6 -fftwf_codelet_hb_64 -fftwf_codelet_hb_7 -fftwf_codelet_hb_8 -fftwf_codelet_hb_9 -fftwf_codelet_hc2cb_10 -fftwf_codelet_hc2cb_12 -fftwf_codelet_hc2cb_16 -fftwf_codelet_hc2cb_2 -fftwf_codelet_hc2cb_20 -fftwf_codelet_hc2cb2_16 -fftwf_codelet_hc2cb2_20 -fftwf_codelet_hc2cb2_32 -fftwf_codelet_hc2cb2_4 -fftwf_codelet_hc2cb2_8 -fftwf_codelet_hc2cb_32 -fftwf_codelet_hc2cb_4 -fftwf_codelet_hc2cb_6 -fftwf_codelet_hc2cb_8 -fftwf_codelet_hc2cbdft_10 -fftwf_codelet_hc2cbdft_12 -fftwf_codelet_hc2cbdft_16 -fftwf_codelet_hc2cbdft_2 -fftwf_codelet_hc2cbdft_20 -fftwf_codelet_hc2cbdft2_16 -fftwf_codelet_hc2cbdft2_20 -fftwf_codelet_hc2cbdft2_32 -fftwf_codelet_hc2cbdft2_4 -fftwf_codelet_hc2cbdft2_8 -fftwf_codelet_hc2cbdft_32 -fftwf_codelet_hc2cbdft_4 -fftwf_codelet_hc2cbdft_6 -fftwf_codelet_hc2cbdft_8 -fftwf_codelet_hc2cbdftv_10_avx -fftwf_codelet_hc2cbdftv_10_sse2 -fftwf_codelet_hc2cbdftv_12_avx -fftwf_codelet_hc2cbdftv_12_sse2 -fftwf_codelet_hc2cbdftv_16_avx -fftwf_codelet_hc2cbdftv_16_sse2 -fftwf_codelet_hc2cbdftv_20_avx -fftwf_codelet_hc2cbdftv_20_sse2 -fftwf_codelet_hc2cbdftv_2_avx -fftwf_codelet_hc2cbdftv_2_sse2 -fftwf_codelet_hc2cbdftv_32_avx -fftwf_codelet_hc2cbdftv_32_sse2 -fftwf_codelet_hc2cbdftv_4_avx -fftwf_codelet_hc2cbdftv_4_sse2 -fftwf_codelet_hc2cbdftv_6_avx -fftwf_codelet_hc2cbdftv_6_sse2 -fftwf_codelet_hc2cbdftv_8_avx -fftwf_codelet_hc2cbdftv_8_sse2 -fftwf_codelet_hc2cf_10 -fftwf_codelet_hc2cf_12 -fftwf_codelet_hc2cf_16 -fftwf_codelet_hc2cf_2 -fftwf_codelet_hc2cf_20 -fftwf_codelet_hc2cf2_16 -fftwf_codelet_hc2cf2_20 -fftwf_codelet_hc2cf2_32 -fftwf_codelet_hc2cf2_4 -fftwf_codelet_hc2cf2_8 -fftwf_codelet_hc2cf_32 -fftwf_codelet_hc2cf_4 -fftwf_codelet_hc2cf_6 -fftwf_codelet_hc2cf_8 -fftwf_codelet_hc2cfdft_10 -fftwf_codelet_hc2cfdft_12 -fftwf_codelet_hc2cfdft_16 -fftwf_codelet_hc2cfdft_2 -fftwf_codelet_hc2cfdft_20 -fftwf_codelet_hc2cfdft2_16 -fftwf_codelet_hc2cfdft2_20 -fftwf_codelet_hc2cfdft2_32 -fftwf_codelet_hc2cfdft2_4 -fftwf_codelet_hc2cfdft2_8 -fftwf_codelet_hc2cfdft_32 -fftwf_codelet_hc2cfdft_4 -fftwf_codelet_hc2cfdft_6 -fftwf_codelet_hc2cfdft_8 -fftwf_codelet_hc2cfdftv_10_avx -fftwf_codelet_hc2cfdftv_10_sse2 -fftwf_codelet_hc2cfdftv_12_avx -fftwf_codelet_hc2cfdftv_12_sse2 -fftwf_codelet_hc2cfdftv_16_avx -fftwf_codelet_hc2cfdftv_16_sse2 -fftwf_codelet_hc2cfdftv_20_avx -fftwf_codelet_hc2cfdftv_20_sse2 -fftwf_codelet_hc2cfdftv_2_avx -fftwf_codelet_hc2cfdftv_2_sse2 -fftwf_codelet_hc2cfdftv_32_avx -fftwf_codelet_hc2cfdftv_32_sse2 -fftwf_codelet_hc2cfdftv_4_avx -fftwf_codelet_hc2cfdftv_4_sse2 -fftwf_codelet_hc2cfdftv_6_avx -fftwf_codelet_hc2cfdftv_6_sse2 -fftwf_codelet_hc2cfdftv_8_avx -fftwf_codelet_hc2cfdftv_8_sse2 -fftwf_codelet_hf_10 -fftwf_codelet_hf_12 -fftwf_codelet_hf_15 -fftwf_codelet_hf_16 -fftwf_codelet_hf_2 -fftwf_codelet_hf_20 -fftwf_codelet_hf2_16 -fftwf_codelet_hf2_20 -fftwf_codelet_hf2_25 -fftwf_codelet_hf2_32 -fftwf_codelet_hf2_4 -fftwf_codelet_hf_25 -fftwf_codelet_hf2_5 -fftwf_codelet_hf2_8 -fftwf_codelet_hf_3 -fftwf_codelet_hf_32 -fftwf_codelet_hf_4 -fftwf_codelet_hf_5 -fftwf_codelet_hf_6 -fftwf_codelet_hf_64 -fftwf_codelet_hf_7 -fftwf_codelet_hf_8 -fftwf_codelet_hf_9 -fftwf_codelet_n1_10 -fftwf_codelet_n1_11 -fftwf_codelet_n1_12 -fftwf_codelet_n1_13 -fftwf_codelet_n1_14 -fftwf_codelet_n1_15 -fftwf_codelet_n1_16 -fftwf_codelet_n1_2 -fftwf_codelet_n1_20 -fftwf_codelet_n1_25 -fftwf_codelet_n1_3 -fftwf_codelet_n1_32 -fftwf_codelet_n1_4 -fftwf_codelet_n1_5 -fftwf_codelet_n1_6 -fftwf_codelet_n1_64 -fftwf_codelet_n1_7 -fftwf_codelet_n1_8 -fftwf_codelet_n1_9 -fftwf_codelet_n1bv_10_avx -fftwf_codelet_n1bv_10_sse2 -fftwf_codelet_n1bv_11_avx -fftwf_codelet_n1bv_11_sse2 -fftwf_codelet_n1bv_128_avx -fftwf_codelet_n1bv_128_sse2 -fftwf_codelet_n1bv_12_avx -fftwf_codelet_n1bv_12_sse2 -fftwf_codelet_n1bv_13_avx -fftwf_codelet_n1bv_13_sse2 -fftwf_codelet_n1bv_14_avx -fftwf_codelet_n1bv_14_sse2 -fftwf_codelet_n1bv_15_avx -fftwf_codelet_n1bv_15_sse2 -fftwf_codelet_n1bv_16_avx -fftwf_codelet_n1bv_16_sse2 -fftwf_codelet_n1bv_20_avx -fftwf_codelet_n1bv_20_sse2 -fftwf_codelet_n1bv_25_avx -fftwf_codelet_n1bv_25_sse2 -fftwf_codelet_n1bv_2_avx -fftwf_codelet_n1bv_2_sse2 -fftwf_codelet_n1bv_32_avx -fftwf_codelet_n1bv_32_sse2 -fftwf_codelet_n1bv_3_avx -fftwf_codelet_n1bv_3_sse2 -fftwf_codelet_n1bv_4_avx -fftwf_codelet_n1bv_4_sse2 -fftwf_codelet_n1bv_5_avx -fftwf_codelet_n1bv_5_sse2 -fftwf_codelet_n1bv_64_avx -fftwf_codelet_n1bv_64_sse2 -fftwf_codelet_n1bv_6_avx -fftwf_codelet_n1bv_6_sse2 -fftwf_codelet_n1bv_7_avx -fftwf_codelet_n1bv_7_sse2 -fftwf_codelet_n1bv_8_avx -fftwf_codelet_n1bv_8_sse2 -fftwf_codelet_n1bv_9_avx -fftwf_codelet_n1bv_9_sse2 -fftwf_codelet_n1fv_10_avx -fftwf_codelet_n1fv_10_sse2 -fftwf_codelet_n1fv_11_avx -fftwf_codelet_n1fv_11_sse2 -fftwf_codelet_n1fv_128_avx -fftwf_codelet_n1fv_128_sse2 -fftwf_codelet_n1fv_12_avx -fftwf_codelet_n1fv_12_sse2 -fftwf_codelet_n1fv_13_avx -fftwf_codelet_n1fv_13_sse2 -fftwf_codelet_n1fv_14_avx -fftwf_codelet_n1fv_14_sse2 -fftwf_codelet_n1fv_15_avx -fftwf_codelet_n1fv_15_sse2 -fftwf_codelet_n1fv_16_avx -fftwf_codelet_n1fv_16_sse2 -fftwf_codelet_n1fv_20_avx -fftwf_codelet_n1fv_20_sse2 -fftwf_codelet_n1fv_25_avx -fftwf_codelet_n1fv_25_sse2 -fftwf_codelet_n1fv_2_avx -fftwf_codelet_n1fv_2_sse2 -fftwf_codelet_n1fv_32_avx -fftwf_codelet_n1fv_32_sse2 -fftwf_codelet_n1fv_3_avx -fftwf_codelet_n1fv_3_sse2 -fftwf_codelet_n1fv_4_avx -fftwf_codelet_n1fv_4_sse2 -fftwf_codelet_n1fv_5_avx -fftwf_codelet_n1fv_5_sse2 -fftwf_codelet_n1fv_64_avx -fftwf_codelet_n1fv_64_sse2 -fftwf_codelet_n1fv_6_avx -fftwf_codelet_n1fv_6_sse2 -fftwf_codelet_n1fv_7_avx -fftwf_codelet_n1fv_7_sse2 -fftwf_codelet_n1fv_8_avx -fftwf_codelet_n1fv_8_sse2 -fftwf_codelet_n1fv_9_avx -fftwf_codelet_n1fv_9_sse2 -fftwf_codelet_n2bv_10_avx -fftwf_codelet_n2bv_10_sse2 -fftwf_codelet_n2bv_12_avx -fftwf_codelet_n2bv_12_sse2 -fftwf_codelet_n2bv_14_avx -fftwf_codelet_n2bv_14_sse2 -fftwf_codelet_n2bv_16_avx -fftwf_codelet_n2bv_16_sse2 -fftwf_codelet_n2bv_20_avx -fftwf_codelet_n2bv_20_sse2 -fftwf_codelet_n2bv_2_avx -fftwf_codelet_n2bv_2_sse2 -fftwf_codelet_n2bv_32_avx -fftwf_codelet_n2bv_32_sse2 -fftwf_codelet_n2bv_4_avx -fftwf_codelet_n2bv_4_sse2 -fftwf_codelet_n2bv_64_avx -fftwf_codelet_n2bv_64_sse2 -fftwf_codelet_n2bv_6_avx -fftwf_codelet_n2bv_6_sse2 -fftwf_codelet_n2bv_8_avx -fftwf_codelet_n2bv_8_sse2 -fftwf_codelet_n2fv_10_avx -fftwf_codelet_n2fv_10_sse2 -fftwf_codelet_n2fv_12_avx -fftwf_codelet_n2fv_12_sse2 -fftwf_codelet_n2fv_14_avx -fftwf_codelet_n2fv_14_sse2 -fftwf_codelet_n2fv_16_avx -fftwf_codelet_n2fv_16_sse2 -fftwf_codelet_n2fv_20_avx -fftwf_codelet_n2fv_20_sse2 -fftwf_codelet_n2fv_2_avx -fftwf_codelet_n2fv_2_sse2 -fftwf_codelet_n2fv_32_avx -fftwf_codelet_n2fv_32_sse2 -fftwf_codelet_n2fv_4_avx -fftwf_codelet_n2fv_4_sse2 -fftwf_codelet_n2fv_64_avx -fftwf_codelet_n2fv_64_sse2 -fftwf_codelet_n2fv_6_avx -fftwf_codelet_n2fv_6_sse2 -fftwf_codelet_n2fv_8_avx -fftwf_codelet_n2fv_8_sse2 -fftwf_codelet_n2sv_16_avx -fftwf_codelet_n2sv_16_sse2 -fftwf_codelet_n2sv_32_avx -fftwf_codelet_n2sv_32_sse2 -fftwf_codelet_n2sv_4_avx -fftwf_codelet_n2sv_4_sse2 -fftwf_codelet_n2sv_64_avx -fftwf_codelet_n2sv_64_sse2 -fftwf_codelet_n2sv_8_avx -fftwf_codelet_n2sv_8_sse2 -fftwf_codelet_q1_2 -fftwf_codelet_q1_3 -fftwf_codelet_q1_4 -fftwf_codelet_q1_5 -fftwf_codelet_q1_6 -fftwf_codelet_q1_8 -fftwf_codelet_q1bv_2_avx -fftwf_codelet_q1bv_2_sse2 -fftwf_codelet_q1bv_4_avx -fftwf_codelet_q1bv_4_sse2 -fftwf_codelet_q1bv_5_avx -fftwf_codelet_q1bv_5_sse2 -fftwf_codelet_q1bv_8_avx -fftwf_codelet_q1bv_8_sse2 -fftwf_codelet_q1fv_2_avx -fftwf_codelet_q1fv_2_sse2 -fftwf_codelet_q1fv_4_avx -fftwf_codelet_q1fv_4_sse2 -fftwf_codelet_q1fv_5_avx -fftwf_codelet_q1fv_5_sse2 -fftwf_codelet_q1fv_8_avx -fftwf_codelet_q1fv_8_sse2 -fftwf_codelet_r2cb_10 -fftwf_codelet_r2cb_11 -fftwf_codelet_r2cb_12 -fftwf_codelet_r2cb_128 -fftwf_codelet_r2cb_13 -fftwf_codelet_r2cb_14 -fftwf_codelet_r2cb_15 -fftwf_codelet_r2cb_16 -fftwf_codelet_r2cb_2 -fftwf_codelet_r2cb_20 -fftwf_codelet_r2cb_25 -fftwf_codelet_r2cb_3 -fftwf_codelet_r2cb_32 -fftwf_codelet_r2cb_4 -fftwf_codelet_r2cb_5 -fftwf_codelet_r2cb_6 -fftwf_codelet_r2cb_64 -fftwf_codelet_r2cb_7 -fftwf_codelet_r2cb_8 -fftwf_codelet_r2cb_9 -fftwf_codelet_r2cbIII_10 -fftwf_codelet_r2cbIII_12 -fftwf_codelet_r2cbIII_15 -fftwf_codelet_r2cbIII_16 -fftwf_codelet_r2cbIII_2 -fftwf_codelet_r2cbIII_20 -fftwf_codelet_r2cbIII_25 -fftwf_codelet_r2cbIII_3 -fftwf_codelet_r2cbIII_32 -fftwf_codelet_r2cbIII_4 -fftwf_codelet_r2cbIII_5 -fftwf_codelet_r2cbIII_6 -fftwf_codelet_r2cbIII_64 -fftwf_codelet_r2cbIII_7 -fftwf_codelet_r2cbIII_8 -fftwf_codelet_r2cbIII_9 -fftwf_codelet_r2cf_10 -fftwf_codelet_r2cf_11 -fftwf_codelet_r2cf_12 -fftwf_codelet_r2cf_128 -fftwf_codelet_r2cf_13 -fftwf_codelet_r2cf_14 -fftwf_codelet_r2cf_15 -fftwf_codelet_r2cf_16 -fftwf_codelet_r2cf_2 -fftwf_codelet_r2cf_20 -fftwf_codelet_r2cf_25 -fftwf_codelet_r2cf_3 -fftwf_codelet_r2cf_32 -fftwf_codelet_r2cf_4 -fftwf_codelet_r2cf_5 -fftwf_codelet_r2cf_6 -fftwf_codelet_r2cf_64 -fftwf_codelet_r2cf_7 -fftwf_codelet_r2cf_8 -fftwf_codelet_r2cf_9 -fftwf_codelet_r2cfII_10 -fftwf_codelet_r2cfII_12 -fftwf_codelet_r2cfII_15 -fftwf_codelet_r2cfII_16 -fftwf_codelet_r2cfII_2 -fftwf_codelet_r2cfII_20 -fftwf_codelet_r2cfII_25 -fftwf_codelet_r2cfII_3 -fftwf_codelet_r2cfII_32 -fftwf_codelet_r2cfII_4 -fftwf_codelet_r2cfII_5 -fftwf_codelet_r2cfII_6 -fftwf_codelet_r2cfII_64 -fftwf_codelet_r2cfII_7 -fftwf_codelet_r2cfII_8 -fftwf_codelet_r2cfII_9 -fftwf_codelet_t1_10 -fftwf_codelet_t1_12 -fftwf_codelet_t1_15 -fftwf_codelet_t1_16 -fftwf_codelet_t1_2 -fftwf_codelet_t1_20 -fftwf_codelet_t1_25 -fftwf_codelet_t1_3 -fftwf_codelet_t1_32 -fftwf_codelet_t1_4 -fftwf_codelet_t1_5 -fftwf_codelet_t1_6 -fftwf_codelet_t1_64 -fftwf_codelet_t1_7 -fftwf_codelet_t1_8 -fftwf_codelet_t1_9 -fftwf_codelet_t1buv_10_avx -fftwf_codelet_t1buv_10_sse2 -fftwf_codelet_t1buv_2_avx -fftwf_codelet_t1buv_2_sse2 -fftwf_codelet_t1buv_3_avx -fftwf_codelet_t1buv_3_sse2 -fftwf_codelet_t1buv_4_avx -fftwf_codelet_t1buv_4_sse2 -fftwf_codelet_t1buv_5_avx -fftwf_codelet_t1buv_5_sse2 -fftwf_codelet_t1buv_6_avx -fftwf_codelet_t1buv_6_sse2 -fftwf_codelet_t1buv_7_avx -fftwf_codelet_t1buv_7_sse2 -fftwf_codelet_t1buv_8_avx -fftwf_codelet_t1buv_8_sse2 -fftwf_codelet_t1buv_9_avx -fftwf_codelet_t1buv_9_sse2 -fftwf_codelet_t1bv_10_avx -fftwf_codelet_t1bv_10_sse2 -fftwf_codelet_t1bv_12_avx -fftwf_codelet_t1bv_12_sse2 -fftwf_codelet_t1bv_15_avx -fftwf_codelet_t1bv_15_sse2 -fftwf_codelet_t1bv_16_avx -fftwf_codelet_t1bv_16_sse2 -fftwf_codelet_t1bv_20_avx -fftwf_codelet_t1bv_20_sse2 -fftwf_codelet_t1bv_25_avx -fftwf_codelet_t1bv_25_sse2 -fftwf_codelet_t1bv_2_avx -fftwf_codelet_t1bv_2_sse2 -fftwf_codelet_t1bv_32_avx -fftwf_codelet_t1bv_32_sse2 -fftwf_codelet_t1bv_3_avx -fftwf_codelet_t1bv_3_sse2 -fftwf_codelet_t1bv_4_avx -fftwf_codelet_t1bv_4_sse2 -fftwf_codelet_t1bv_5_avx -fftwf_codelet_t1bv_5_sse2 -fftwf_codelet_t1bv_64_avx -fftwf_codelet_t1bv_64_sse2 -fftwf_codelet_t1bv_6_avx -fftwf_codelet_t1bv_6_sse2 -fftwf_codelet_t1bv_7_avx -fftwf_codelet_t1bv_7_sse2 -fftwf_codelet_t1bv_8_avx -fftwf_codelet_t1bv_8_sse2 -fftwf_codelet_t1bv_9_avx -fftwf_codelet_t1bv_9_sse2 -fftwf_codelet_t1fuv_10_avx -fftwf_codelet_t1fuv_10_sse2 -fftwf_codelet_t1fuv_2_avx -fftwf_codelet_t1fuv_2_sse2 -fftwf_codelet_t1fuv_3_avx -fftwf_codelet_t1fuv_3_sse2 -fftwf_codelet_t1fuv_4_avx -fftwf_codelet_t1fuv_4_sse2 -fftwf_codelet_t1fuv_5_avx -fftwf_codelet_t1fuv_5_sse2 -fftwf_codelet_t1fuv_6_avx -fftwf_codelet_t1fuv_6_sse2 -fftwf_codelet_t1fuv_7_avx -fftwf_codelet_t1fuv_7_sse2 -fftwf_codelet_t1fuv_8_avx -fftwf_codelet_t1fuv_8_sse2 -fftwf_codelet_t1fuv_9_avx -fftwf_codelet_t1fuv_9_sse2 -fftwf_codelet_t1fv_10_avx -fftwf_codelet_t1fv_10_sse2 -fftwf_codelet_t1fv_12_avx -fftwf_codelet_t1fv_12_sse2 -fftwf_codelet_t1fv_15_avx -fftwf_codelet_t1fv_15_sse2 -fftwf_codelet_t1fv_16_avx -fftwf_codelet_t1fv_16_sse2 -fftwf_codelet_t1fv_20_avx -fftwf_codelet_t1fv_20_sse2 -fftwf_codelet_t1fv_25_avx -fftwf_codelet_t1fv_25_sse2 -fftwf_codelet_t1fv_2_avx -fftwf_codelet_t1fv_2_sse2 -fftwf_codelet_t1fv_32_avx -fftwf_codelet_t1fv_32_sse2 -fftwf_codelet_t1fv_3_avx -fftwf_codelet_t1fv_3_sse2 -fftwf_codelet_t1fv_4_avx -fftwf_codelet_t1fv_4_sse2 -fftwf_codelet_t1fv_5_avx -fftwf_codelet_t1fv_5_sse2 -fftwf_codelet_t1fv_64_avx -fftwf_codelet_t1fv_64_sse2 -fftwf_codelet_t1fv_6_avx -fftwf_codelet_t1fv_6_sse2 -fftwf_codelet_t1fv_7_avx -fftwf_codelet_t1fv_7_sse2 -fftwf_codelet_t1fv_8_avx -fftwf_codelet_t1fv_8_sse2 -fftwf_codelet_t1fv_9_avx -fftwf_codelet_t1fv_9_sse2 -fftwf_codelet_t1sv_16_avx -fftwf_codelet_t1sv_16_sse2 -fftwf_codelet_t1sv_2_avx -fftwf_codelet_t1sv_2_sse2 -fftwf_codelet_t1sv_32_avx -fftwf_codelet_t1sv_32_sse2 -fftwf_codelet_t1sv_4_avx -fftwf_codelet_t1sv_4_sse2 -fftwf_codelet_t1sv_8_avx -fftwf_codelet_t1sv_8_sse2 -fftwf_codelet_t2_10 -fftwf_codelet_t2_16 -fftwf_codelet_t2_20 -fftwf_codelet_t2_25 -fftwf_codelet_t2_32 -fftwf_codelet_t2_4 -fftwf_codelet_t2_5 -fftwf_codelet_t2_64 -fftwf_codelet_t2_8 -fftwf_codelet_t2bv_10_avx -fftwf_codelet_t2bv_10_sse2 -fftwf_codelet_t2bv_16_avx -fftwf_codelet_t2bv_16_sse2 -fftwf_codelet_t2bv_20_avx -fftwf_codelet_t2bv_20_sse2 -fftwf_codelet_t2bv_25_avx -fftwf_codelet_t2bv_25_sse2 -fftwf_codelet_t2bv_2_avx -fftwf_codelet_t2bv_2_sse2 -fftwf_codelet_t2bv_32_avx -fftwf_codelet_t2bv_32_sse2 -fftwf_codelet_t2bv_4_avx -fftwf_codelet_t2bv_4_sse2 -fftwf_codelet_t2bv_5_avx -fftwf_codelet_t2bv_5_sse2 -fftwf_codelet_t2bv_64_avx -fftwf_codelet_t2bv_64_sse2 -fftwf_codelet_t2bv_8_avx -fftwf_codelet_t2bv_8_sse2 -fftwf_codelet_t2fv_10_avx -fftwf_codelet_t2fv_10_sse2 -fftwf_codelet_t2fv_16_avx -fftwf_codelet_t2fv_16_sse2 -fftwf_codelet_t2fv_20_avx -fftwf_codelet_t2fv_20_sse2 -fftwf_codelet_t2fv_25_avx -fftwf_codelet_t2fv_25_sse2 -fftwf_codelet_t2fv_2_avx -fftwf_codelet_t2fv_2_sse2 -fftwf_codelet_t2fv_32_avx -fftwf_codelet_t2fv_32_sse2 -fftwf_codelet_t2fv_4_avx -fftwf_codelet_t2fv_4_sse2 -fftwf_codelet_t2fv_5_avx -fftwf_codelet_t2fv_5_sse2 -fftwf_codelet_t2fv_64_avx -fftwf_codelet_t2fv_64_sse2 -fftwf_codelet_t2fv_8_avx -fftwf_codelet_t2fv_8_sse2 -fftwf_codelet_t2sv_16_avx -fftwf_codelet_t2sv_16_sse2 -fftwf_codelet_t2sv_32_avx -fftwf_codelet_t2sv_32_sse2 -fftwf_codelet_t2sv_4_avx -fftwf_codelet_t2sv_4_sse2 -fftwf_codelet_t2sv_8_avx -fftwf_codelet_t2sv_8_sse2 -fftwf_codelet_t3bv_10_avx -fftwf_codelet_t3bv_10_sse2 -fftwf_codelet_t3bv_16_avx -fftwf_codelet_t3bv_16_sse2 -fftwf_codelet_t3bv_20_avx -fftwf_codelet_t3bv_20_sse2 -fftwf_codelet_t3bv_25_avx -fftwf_codelet_t3bv_25_sse2 -fftwf_codelet_t3bv_32_avx -fftwf_codelet_t3bv_32_sse2 -fftwf_codelet_t3bv_4_avx -fftwf_codelet_t3bv_4_sse2 -fftwf_codelet_t3bv_5_avx -fftwf_codelet_t3bv_5_sse2 -fftwf_codelet_t3bv_8_avx -fftwf_codelet_t3bv_8_sse2 -fftwf_codelet_t3fv_10_avx -fftwf_codelet_t3fv_10_sse2 -fftwf_codelet_t3fv_16_avx -fftwf_codelet_t3fv_16_sse2 -fftwf_codelet_t3fv_20_avx -fftwf_codelet_t3fv_20_sse2 -fftwf_codelet_t3fv_25_avx -fftwf_codelet_t3fv_25_sse2 -fftwf_codelet_t3fv_32_avx -fftwf_codelet_t3fv_32_sse2 -fftwf_codelet_t3fv_4_avx -fftwf_codelet_t3fv_4_sse2 -fftwf_codelet_t3fv_5_avx -fftwf_codelet_t3fv_5_sse2 -fftwf_codelet_t3fv_8_avx -fftwf_codelet_t3fv_8_sse2 -fftwf_compute_tilesz -fftwf_configure_planner -fftwf_cost -fftwf_cpy1d -fftwf_cpy2d -fftwf_cpy2d_ci -fftwf_cpy2d_co -fftwf_cpy2d_pair -fftwf_cpy2d_pair_ci -fftwf_cpy2d_pair_co -fftwf_cpy2d_tiled -fftwf_cpy2d_tiledbuf -fftwf_ct_applicable -fftwf_ct_genericbuf_register -fftwf_ct_generic_register -fftwf_ct_uglyp -fftwf_destroy_plan -fftwf_dft_bluestein_register -fftwf_dft_buffered_register -fftwf_dft_conf_standard -fftwf_dft_generic_register -fftwf_dft_indirect_register -fftwf_dft_indirect_transpose_register -fftwf_dft_nop_register -fftwf_dft_r2hc_register -fftwf_dft_rader_register -fftwf_dft_rank_geq2_register -fftwf_dft_solve -fftwf_dft_thr_vrank_geq1_register -fftwf_dft_vrank_geq1_register -fftwf_dft_zerotens -fftwf_dht_r2hc_register -fftwf_dht_rader_register -fftwf_dimcmp -fftwf_elapsed_since -fftwf_estimate_cost -fftwf_execute -fftwf_execute_dft -fftwf_execute_dft_c2r -fftwf_execute_dft_r2c -fftwf_execute_r2r -fftwf_execute_split_dft -fftwf_execute_split_dft_c2r -fftwf_execute_split_dft_r2c -fftwf_export_wisdom -fftwf_export_wisdom_to_file -fftwf_export_wisdom_to_filename -fftwf_export_wisdom_to_string -fftwf_extract_reim -fftwf_factors_into -fftwf_factors_into_small_primes -fftwf_find_generator -fftwf_first_divisor -fftwf_flops -fftwf_forget_wisdom -fftwf_fprint_plan -fftwf_free -fftwf_get_crude_time -fftwf_guru64_kosherp -fftwf_guru_kosherp -fftwf_hash -fftwf_have_simd_avx -fftwf_have_simd_sse2 -fftwf_hc2hc_applicable -fftwf_hc2hc_generic_register -fftwf_iabs -fftwf_ialignment_of -fftwf_iestimate_cost -fftwf_ifree -fftwf_ifree0 -fftwf_imax -fftwf_imin -fftwf_import_system_wisdom -fftwf_import_wisdom -fftwf_import_wisdom_from_file -fftwf_import_wisdom_from_filename -fftwf_import_wisdom_from_string -fftwf_init_threads -fftwf_is_prime -fftwf_isqrt -fftwf_ithreads_init -fftwf_join_taint -fftwf_kdft_dif_register -fftwf_kdft_difsq_register -fftwf_kdft_dit_register -fftwf_kdft_register -fftwf_kernel_free -fftwf_kernel_malloc -fftwf_khc2c_register -fftwf_khc2hc_register -fftwf_kr2c_register -fftwf_kr2r_register -fftwf_make_planner_thread_safe -fftwf_malloc -fftwf_malloc_plain -fftwf_many_kosherp -fftwf_mapflags -fftwf_map_r2r_kind -fftwf_md5begin -fftwf_md5end -fftwf_md5int -fftwf_md5INT -fftwf_md5putb -fftwf_md5putc -fftwf_md5puts -fftwf_md5unsigned -fftwf_measure_execution_time -fftwf_mkapiplan -fftwf_mkplan -fftwf_mkplan_d -fftwf_mkplan_dft -fftwf_mkplan_dftw -fftwf_mkplan_f_d -fftwf_mkplan_hc2c -fftwf_mkplan_hc2hc -fftwf_mkplanner -fftwf_mkplan_rdft -fftwf_mkplan_rdft2 -fftwf_mkprinter -fftwf_mkprinter_cnt -fftwf_mkprinter_file -fftwf_mkprinter_str -fftwf_mkproblem -fftwf_mkproblem_dft -fftwf_mkproblem_dft_d -fftwf_mkproblem_rdft -fftwf_mkproblem_rdft_0_d -fftwf_mkproblem_rdft_1 -fftwf_mkproblem_rdft_1_d -fftwf_mkproblem_rdft2 -fftwf_mkproblem_rdft2_d -fftwf_mkproblem_rdft2_d_3pointers -fftwf_mkproblem_rdft_d -fftwf_mkproblem_unsolvable -fftwf_mkscanner -fftwf_mksolver -fftwf_mksolver_ct -fftwf_mksolver_ct_threads -fftwf_mksolver_dft_direct -fftwf_mksolver_dft_directbuf -fftwf_mksolver_hc2c -fftwf_mksolver_hc2hc -fftwf_mksolver_hc2hc_threads -fftwf_mksolver_rdft2_direct -fftwf_mksolver_rdft_r2c_direct -fftwf_mksolver_rdft_r2c_directbuf -fftwf_mksolver_rdft_r2r_direct -fftwf_mkstride -fftwf_mktensor -fftwf_mktensor_0d -fftwf_mktensor_1d -fftwf_mktensor_2d -fftwf_mktensor_3d -fftwf_mktensor_4d -fftwf_mktensor_5d -fftwf_mktensor_iodims -fftwf_mktensor_iodims64 -fftwf_mktensor_rowmajor -fftwf_mktriggen -fftwf_modulo -fftwf_nbuf -fftwf_nbuf_redundant -fftwf_next_prime -fftwf_null_awake -fftwf_ops_add -fftwf_ops_add2 -fftwf_ops_cpy -fftwf_ops_madd -fftwf_ops_madd2 -fftwf_ops_other -fftwf_ops_zero -fftwf_pickdim -fftwf_plan_awake -fftwf_plan_destroy_internal -fftwf_plan_dft -fftwf_plan_dft_1d -fftwf_plan_dft_2d -fftwf_plan_dft_3d -fftwf_plan_dft_c2r -fftwf_plan_dft_c2r_1d -fftwf_plan_dft_c2r_2d -fftwf_plan_dft_c2r_3d -fftwf_plan_dft_r2c -fftwf_plan_dft_r2c_1d -fftwf_plan_dft_r2c_2d -fftwf_plan_dft_r2c_3d -fftwf_plan_guru64_dft -fftwf_plan_guru64_dft_c2r -fftwf_plan_guru64_dft_r2c -fftwf_plan_guru64_r2r -fftwf_plan_guru64_split_dft -fftwf_plan_guru64_split_dft_c2r -fftwf_plan_guru64_split_dft_r2c -fftwf_plan_guru_dft -fftwf_plan_guru_dft_c2r -fftwf_plan_guru_dft_r2c -fftwf_plan_guru_r2r -fftwf_plan_guru_split_dft -fftwf_plan_guru_split_dft_c2r -fftwf_plan_guru_split_dft_r2c -fftwf_plan_many_dft -fftwf_plan_many_dft_c2r -fftwf_plan_many_dft_r2c -fftwf_plan_many_r2r -fftwf_planner_destroy -fftwf_plan_null_destroy -fftwf_plan_r2r -fftwf_plan_r2r_1d -fftwf_plan_r2r_2d -fftwf_plan_r2r_3d -fftwf_plan_with_nthreads -fftwf_power_mod -fftwf_printer_destroy -fftwf_print_plan -fftwf_problem_destroy -fftwf_rader_tl_delete -fftwf_rader_tl_find -fftwf_rader_tl_insert -fftwf_rdft2_buffered_register -fftwf_rdft2_complex_n -fftwf_rdft2_inplace_strides -fftwf_rdft2_nop_register -fftwf_rdft2_pad -fftwf_rdft2_rank0_register -fftwf_rdft2_rank_geq2_register -fftwf_rdft2_rdft_register -fftwf_rdft2_solve -fftwf_rdft2_strides -fftwf_rdft2_tensor_max_index -fftwf_rdft2_thr_vrank_geq1_register -fftwf_rdft2_vrank_geq1_register -fftwf_rdft_buffered_register -fftwf_rdft_conf_standard -fftwf_rdft_dht_register -fftwf_rdft_generic_register -fftwf_rdft_indirect_register -fftwf_rdft_kind_str -fftwf_rdft_nop_register -fftwf_rdft_rank0_register -fftwf_rdft_rank_geq2_register -fftwf_rdft_solve -fftwf_rdft_thr_vrank_geq1_register -fftwf_rdft_vrank3_transpose_register -fftwf_rdft_vrank_geq1_register -fftwf_rdft_zerotens -fftwf_redft00e_r2hc_pad_register -fftwf_regsolver_ct_directw -fftwf_regsolver_ct_directwsq -fftwf_regsolver_hc2c_direct -fftwf_regsolver_hc2hc_direct -fftwf_reodft00e_splitradix_register -fftwf_reodft010e_r2hc_register -fftwf_reodft11e_r2hc_odd_register -fftwf_reodft11e_radix2_r2hc_register -fftwf_reodft_conf_standard -fftwf_rodft00e_r2hc_pad_register -fftwf_safe_mulmod -fftwf_scanner_destroy -fftwf_set_planner_hooks -fftwf_set_timelimit -fftwf_solver_destroy -fftwf_solver_register -fftwf_solver_use -fftwf_solvtab_exec -fftwf_spawn_loop -fftwf_sprint_plan -fftwf_stride_destroy -fftwf_taint -fftwf_tensor_append -fftwf_tensor_compress -fftwf_tensor_compress_contiguous -fftwf_tensor_copy -fftwf_tensor_copy_except -fftwf_tensor_copy_inplace -fftwf_tensor_copy_sub -fftwf_tensor_destroy -fftwf_tensor_destroy2 -fftwf_tensor_destroy4 -fftwf_tensor_equal -fftwf_tensor_inplace_locations -fftwf_tensor_inplace_strides -fftwf_tensor_inplace_strides2 -fftwf_tensor_kosherp -fftwf_tensor_max_index -fftwf_tensor_md5 -fftwf_tensor_min_istride -fftwf_tensor_min_ostride -fftwf_tensor_min_stride -fftwf_tensor_print -fftwf_tensor_split -fftwf_tensor_strides_decrease -fftwf_tensor_sz -fftwf_tensor_tornk1 -fftwf_the_planner -fftwf_threads_cleanup -fftwf_threads_conf_standard -fftwf_threads_register_planner_hooks -fftwf_tile2d -fftwf_toobig -fftwf_transpose -fftwf_transpose_tiled -fftwf_transpose_tiledbuf -fftwf_triggen_destroy -fftwf_twiddle_awake -fftwf_twiddle_length -fftwf_zero1d_pair -sfftw_cleanup_ -sfftw_cleanup__ -sfftw_cleanup_threads_ -sfftw_cleanup_threads__ -sfftw_cost_ -sfftw_cost__ -sfftw_destroy_plan_ -sfftw_destroy_plan__ -sfftw_estimate_cost_ -sfftw_estimate_cost__ -sfftw_execute_ -sfftw_execute__ -sfftw_execute_dft_ -sfftw_execute_dft__ -sfftw_execute_dft_c2r_ -sfftw_execute_dft_c2r__ -sfftw_execute_dft_r2c_ -sfftw_execute_dft_r2c__ -sfftw_execute_r2r_ -sfftw_execute_r2r__ -sfftw_execute_split_dft_ -sfftw_execute_split_dft__ -sfftw_execute_split_dft_c2r_ -sfftw_execute_split_dft_c2r__ -sfftw_execute_split_dft_r2c_ -sfftw_execute_split_dft_r2c__ -sfftw_export_wisdom_ -sfftw_export_wisdom__ -sfftw_flops_ -sfftw_flops__ -sfftw_forget_wisdom_ -sfftw_forget_wisdom__ -sfftw_import_system_wisdom_ -sfftw_import_system_wisdom__ -sfftw_import_wisdom_ -sfftw_import_wisdom__ -sfftw_init_threads_ -sfftw_init_threads__ -sfftw_plan_dft_ -sfftw_plan_dft__ -sfftw_plan_dft_1d_ -sfftw_plan_dft_1d__ -sfftw_plan_dft_2d_ -sfftw_plan_dft_2d__ -sfftw_plan_dft_3d_ -sfftw_plan_dft_3d__ -sfftw_plan_dft_c2r_ -sfftw_plan_dft_c2r__ -sfftw_plan_dft_c2r_1d_ -sfftw_plan_dft_c2r_1d__ -sfftw_plan_dft_c2r_2d_ -sfftw_plan_dft_c2r_2d__ -sfftw_plan_dft_c2r_3d_ -sfftw_plan_dft_c2r_3d__ -sfftw_plan_dft_r2c_ -sfftw_plan_dft_r2c__ -sfftw_plan_dft_r2c_1d_ -sfftw_plan_dft_r2c_1d__ -sfftw_plan_dft_r2c_2d_ -sfftw_plan_dft_r2c_2d__ -sfftw_plan_dft_r2c_3d_ -sfftw_plan_dft_r2c_3d__ -sfftw_plan_guru_dft_ -sfftw_plan_guru_dft__ -sfftw_plan_guru_dft_c2r_ -sfftw_plan_guru_dft_c2r__ -sfftw_plan_guru_dft_r2c_ -sfftw_plan_guru_dft_r2c__ -sfftw_plan_guru_r2r_ -sfftw_plan_guru_r2r__ -sfftw_plan_guru_split_dft_ -sfftw_plan_guru_split_dft__ -sfftw_plan_guru_split_dft_c2r_ -sfftw_plan_guru_split_dft_c2r__ -sfftw_plan_guru_split_dft_r2c_ -sfftw_plan_guru_split_dft_r2c__ -sfftw_plan_many_dft_ -sfftw_plan_many_dft__ -sfftw_plan_many_dft_c2r_ -sfftw_plan_many_dft_c2r__ -sfftw_plan_many_dft_r2c_ -sfftw_plan_many_dft_r2c__ -sfftw_plan_many_r2r_ -sfftw_plan_many_r2r__ -sfftw_plan_r2r_ -sfftw_plan_r2r__ -sfftw_plan_r2r_1d_ -sfftw_plan_r2r_1d__ -sfftw_plan_r2r_2d_ -sfftw_plan_r2r_2d__ -sfftw_plan_r2r_3d_ -sfftw_plan_r2r_3d__ -sfftw_plan_with_nthreads_ -sfftw_plan_with_nthreads__ -sfftw_print_plan_ -sfftw_print_plan__ -sfftw_set_timelimit_ -sfftw_set_timelimit__ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.exp b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.exp deleted file mode 100644 index c2380657c..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.lib b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.lib deleted file mode 100644 index 55fd55015..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3f-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.def b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.def deleted file mode 100644 index 62a5e4231..000000000 --- a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.def +++ /dev/null @@ -1,634 +0,0 @@ -LIBRARY libfftw3l-3.dll -EXPORTS -fftwl_alignment_of -fftwl_alloc_complex -fftwl_alloc_real -fftwl_assertion_failed -fftwl_bufdist -fftwl_choose_radix -fftwl_cleanup -fftwl_cleanup_threads -fftwl_codelet_e01_8 -fftwl_codelet_e10_8 -fftwl_codelet_hb_10 -fftwl_codelet_hb_12 -fftwl_codelet_hb_15 -fftwl_codelet_hb_16 -fftwl_codelet_hb_2 -fftwl_codelet_hb_20 -fftwl_codelet_hb2_16 -fftwl_codelet_hb2_20 -fftwl_codelet_hb2_25 -fftwl_codelet_hb2_32 -fftwl_codelet_hb2_4 -fftwl_codelet_hb_25 -fftwl_codelet_hb2_5 -fftwl_codelet_hb2_8 -fftwl_codelet_hb_3 -fftwl_codelet_hb_32 -fftwl_codelet_hb_4 -fftwl_codelet_hb_5 -fftwl_codelet_hb_6 -fftwl_codelet_hb_64 -fftwl_codelet_hb_7 -fftwl_codelet_hb_8 -fftwl_codelet_hb_9 -fftwl_codelet_hc2cb_10 -fftwl_codelet_hc2cb_12 -fftwl_codelet_hc2cb_16 -fftwl_codelet_hc2cb_2 -fftwl_codelet_hc2cb_20 -fftwl_codelet_hc2cb2_16 -fftwl_codelet_hc2cb2_20 -fftwl_codelet_hc2cb2_32 -fftwl_codelet_hc2cb2_4 -fftwl_codelet_hc2cb2_8 -fftwl_codelet_hc2cb_32 -fftwl_codelet_hc2cb_4 -fftwl_codelet_hc2cb_6 -fftwl_codelet_hc2cb_8 -fftwl_codelet_hc2cbdft_10 -fftwl_codelet_hc2cbdft_12 -fftwl_codelet_hc2cbdft_16 -fftwl_codelet_hc2cbdft_2 -fftwl_codelet_hc2cbdft_20 -fftwl_codelet_hc2cbdft2_16 -fftwl_codelet_hc2cbdft2_20 -fftwl_codelet_hc2cbdft2_32 -fftwl_codelet_hc2cbdft2_4 -fftwl_codelet_hc2cbdft2_8 -fftwl_codelet_hc2cbdft_32 -fftwl_codelet_hc2cbdft_4 -fftwl_codelet_hc2cbdft_6 -fftwl_codelet_hc2cbdft_8 -fftwl_codelet_hc2cf_10 -fftwl_codelet_hc2cf_12 -fftwl_codelet_hc2cf_16 -fftwl_codelet_hc2cf_2 -fftwl_codelet_hc2cf_20 -fftwl_codelet_hc2cf2_16 -fftwl_codelet_hc2cf2_20 -fftwl_codelet_hc2cf2_32 -fftwl_codelet_hc2cf2_4 -fftwl_codelet_hc2cf2_8 -fftwl_codelet_hc2cf_32 -fftwl_codelet_hc2cf_4 -fftwl_codelet_hc2cf_6 -fftwl_codelet_hc2cf_8 -fftwl_codelet_hc2cfdft_10 -fftwl_codelet_hc2cfdft_12 -fftwl_codelet_hc2cfdft_16 -fftwl_codelet_hc2cfdft_2 -fftwl_codelet_hc2cfdft_20 -fftwl_codelet_hc2cfdft2_16 -fftwl_codelet_hc2cfdft2_20 -fftwl_codelet_hc2cfdft2_32 -fftwl_codelet_hc2cfdft2_4 -fftwl_codelet_hc2cfdft2_8 -fftwl_codelet_hc2cfdft_32 -fftwl_codelet_hc2cfdft_4 -fftwl_codelet_hc2cfdft_6 -fftwl_codelet_hc2cfdft_8 -fftwl_codelet_hf_10 -fftwl_codelet_hf_12 -fftwl_codelet_hf_15 -fftwl_codelet_hf_16 -fftwl_codelet_hf_2 -fftwl_codelet_hf_20 -fftwl_codelet_hf2_16 -fftwl_codelet_hf2_20 -fftwl_codelet_hf2_25 -fftwl_codelet_hf2_32 -fftwl_codelet_hf2_4 -fftwl_codelet_hf_25 -fftwl_codelet_hf2_5 -fftwl_codelet_hf2_8 -fftwl_codelet_hf_3 -fftwl_codelet_hf_32 -fftwl_codelet_hf_4 -fftwl_codelet_hf_5 -fftwl_codelet_hf_6 -fftwl_codelet_hf_64 -fftwl_codelet_hf_7 -fftwl_codelet_hf_8 -fftwl_codelet_hf_9 -fftwl_codelet_n1_10 -fftwl_codelet_n1_11 -fftwl_codelet_n1_12 -fftwl_codelet_n1_13 -fftwl_codelet_n1_14 -fftwl_codelet_n1_15 -fftwl_codelet_n1_16 -fftwl_codelet_n1_2 -fftwl_codelet_n1_20 -fftwl_codelet_n1_25 -fftwl_codelet_n1_3 -fftwl_codelet_n1_32 -fftwl_codelet_n1_4 -fftwl_codelet_n1_5 -fftwl_codelet_n1_6 -fftwl_codelet_n1_64 -fftwl_codelet_n1_7 -fftwl_codelet_n1_8 -fftwl_codelet_n1_9 -fftwl_codelet_q1_2 -fftwl_codelet_q1_3 -fftwl_codelet_q1_4 -fftwl_codelet_q1_5 -fftwl_codelet_q1_6 -fftwl_codelet_q1_8 -fftwl_codelet_r2cb_10 -fftwl_codelet_r2cb_11 -fftwl_codelet_r2cb_12 -fftwl_codelet_r2cb_128 -fftwl_codelet_r2cb_13 -fftwl_codelet_r2cb_14 -fftwl_codelet_r2cb_15 -fftwl_codelet_r2cb_16 -fftwl_codelet_r2cb_2 -fftwl_codelet_r2cb_20 -fftwl_codelet_r2cb_25 -fftwl_codelet_r2cb_3 -fftwl_codelet_r2cb_32 -fftwl_codelet_r2cb_4 -fftwl_codelet_r2cb_5 -fftwl_codelet_r2cb_6 -fftwl_codelet_r2cb_64 -fftwl_codelet_r2cb_7 -fftwl_codelet_r2cb_8 -fftwl_codelet_r2cb_9 -fftwl_codelet_r2cbIII_10 -fftwl_codelet_r2cbIII_12 -fftwl_codelet_r2cbIII_15 -fftwl_codelet_r2cbIII_16 -fftwl_codelet_r2cbIII_2 -fftwl_codelet_r2cbIII_20 -fftwl_codelet_r2cbIII_25 -fftwl_codelet_r2cbIII_3 -fftwl_codelet_r2cbIII_32 -fftwl_codelet_r2cbIII_4 -fftwl_codelet_r2cbIII_5 -fftwl_codelet_r2cbIII_6 -fftwl_codelet_r2cbIII_64 -fftwl_codelet_r2cbIII_7 -fftwl_codelet_r2cbIII_8 -fftwl_codelet_r2cbIII_9 -fftwl_codelet_r2cf_10 -fftwl_codelet_r2cf_11 -fftwl_codelet_r2cf_12 -fftwl_codelet_r2cf_128 -fftwl_codelet_r2cf_13 -fftwl_codelet_r2cf_14 -fftwl_codelet_r2cf_15 -fftwl_codelet_r2cf_16 -fftwl_codelet_r2cf_2 -fftwl_codelet_r2cf_20 -fftwl_codelet_r2cf_25 -fftwl_codelet_r2cf_3 -fftwl_codelet_r2cf_32 -fftwl_codelet_r2cf_4 -fftwl_codelet_r2cf_5 -fftwl_codelet_r2cf_6 -fftwl_codelet_r2cf_64 -fftwl_codelet_r2cf_7 -fftwl_codelet_r2cf_8 -fftwl_codelet_r2cf_9 -fftwl_codelet_r2cfII_10 -fftwl_codelet_r2cfII_12 -fftwl_codelet_r2cfII_15 -fftwl_codelet_r2cfII_16 -fftwl_codelet_r2cfII_2 -fftwl_codelet_r2cfII_20 -fftwl_codelet_r2cfII_25 -fftwl_codelet_r2cfII_3 -fftwl_codelet_r2cfII_32 -fftwl_codelet_r2cfII_4 -fftwl_codelet_r2cfII_5 -fftwl_codelet_r2cfII_6 -fftwl_codelet_r2cfII_64 -fftwl_codelet_r2cfII_7 -fftwl_codelet_r2cfII_8 -fftwl_codelet_r2cfII_9 -fftwl_codelet_t1_10 -fftwl_codelet_t1_12 -fftwl_codelet_t1_15 -fftwl_codelet_t1_16 -fftwl_codelet_t1_2 -fftwl_codelet_t1_20 -fftwl_codelet_t1_25 -fftwl_codelet_t1_3 -fftwl_codelet_t1_32 -fftwl_codelet_t1_4 -fftwl_codelet_t1_5 -fftwl_codelet_t1_6 -fftwl_codelet_t1_64 -fftwl_codelet_t1_7 -fftwl_codelet_t1_8 -fftwl_codelet_t1_9 -fftwl_codelet_t2_10 -fftwl_codelet_t2_16 -fftwl_codelet_t2_20 -fftwl_codelet_t2_25 -fftwl_codelet_t2_32 -fftwl_codelet_t2_4 -fftwl_codelet_t2_5 -fftwl_codelet_t2_64 -fftwl_codelet_t2_8 -fftwl_compute_tilesz -fftwl_configure_planner -fftwl_cost -fftwl_cpy1d -fftwl_cpy2d -fftwl_cpy2d_ci -fftwl_cpy2d_co -fftwl_cpy2d_pair -fftwl_cpy2d_pair_ci -fftwl_cpy2d_pair_co -fftwl_cpy2d_tiled -fftwl_cpy2d_tiledbuf -fftwl_ct_applicable -fftwl_ct_genericbuf_register -fftwl_ct_generic_register -fftwl_ct_uglyp -fftwl_destroy_plan -fftwl_dft_bluestein_register -fftwl_dft_buffered_register -fftwl_dft_conf_standard -fftwl_dft_generic_register -fftwl_dft_indirect_register -fftwl_dft_indirect_transpose_register -fftwl_dft_nop_register -fftwl_dft_r2hc_register -fftwl_dft_rader_register -fftwl_dft_rank_geq2_register -fftwl_dft_solve -fftwl_dft_thr_vrank_geq1_register -fftwl_dft_vrank_geq1_register -fftwl_dft_zerotens -fftwl_dht_r2hc_register -fftwl_dht_rader_register -fftwl_dimcmp -fftwl_elapsed_since -fftwl_estimate_cost -fftwl_execute -fftwl_execute_dft -fftwl_execute_dft_c2r -fftwl_execute_dft_r2c -fftwl_execute_r2r -fftwl_execute_split_dft -fftwl_execute_split_dft_c2r -fftwl_execute_split_dft_r2c -fftwl_export_wisdom -fftwl_export_wisdom_to_file -fftwl_export_wisdom_to_filename -fftwl_export_wisdom_to_string -fftwl_extract_reim -fftwl_factors_into -fftwl_factors_into_small_primes -fftwl_find_generator -fftwl_first_divisor -fftwl_flops -fftwl_forget_wisdom -fftwl_fprint_plan -fftwl_free -fftwl_get_crude_time -fftwl_guru64_kosherp -fftwl_guru_kosherp -fftwl_hash -fftwl_hc2hc_applicable -fftwl_hc2hc_generic_register -fftwl_iabs -fftwl_ialignment_of -fftwl_iestimate_cost -fftwl_ifree -fftwl_ifree0 -fftwl_imax -fftwl_imin -fftwl_import_system_wisdom -fftwl_import_wisdom -fftwl_import_wisdom_from_file -fftwl_import_wisdom_from_filename -fftwl_import_wisdom_from_string -fftwl_init_threads -fftwl_is_prime -fftwl_isqrt -fftwl_ithreads_init -fftwl_kdft_dif_register -fftwl_kdft_difsq_register -fftwl_kdft_dit_register -fftwl_kdft_register -fftwl_kernel_free -fftwl_kernel_malloc -fftwl_khc2c_register -fftwl_khc2hc_register -fftwl_kr2c_register -fftwl_kr2r_register -fftwl_make_planner_thread_safe -fftwl_malloc -fftwl_malloc_plain -fftwl_many_kosherp -fftwl_mapflags -fftwl_map_r2r_kind -fftwl_md5begin -fftwl_md5end -fftwl_md5int -fftwl_md5INT -fftwl_md5putb -fftwl_md5putc -fftwl_md5puts -fftwl_md5unsigned -fftwl_measure_execution_time -fftwl_mkapiplan -fftwl_mkplan -fftwl_mkplan_d -fftwl_mkplan_dft -fftwl_mkplan_dftw -fftwl_mkplan_f_d -fftwl_mkplan_hc2c -fftwl_mkplan_hc2hc -fftwl_mkplanner -fftwl_mkplan_rdft -fftwl_mkplan_rdft2 -fftwl_mkprinter -fftwl_mkprinter_cnt -fftwl_mkprinter_file -fftwl_mkprinter_str -fftwl_mkproblem -fftwl_mkproblem_dft -fftwl_mkproblem_dft_d -fftwl_mkproblem_rdft -fftwl_mkproblem_rdft_0_d -fftwl_mkproblem_rdft_1 -fftwl_mkproblem_rdft_1_d -fftwl_mkproblem_rdft2 -fftwl_mkproblem_rdft2_d -fftwl_mkproblem_rdft2_d_3pointers -fftwl_mkproblem_rdft_d -fftwl_mkproblem_unsolvable -fftwl_mkscanner -fftwl_mksolver -fftwl_mksolver_ct -fftwl_mksolver_ct_threads -fftwl_mksolver_dft_direct -fftwl_mksolver_dft_directbuf -fftwl_mksolver_hc2c -fftwl_mksolver_hc2hc -fftwl_mksolver_hc2hc_threads -fftwl_mksolver_rdft2_direct -fftwl_mksolver_rdft_r2c_direct -fftwl_mksolver_rdft_r2c_directbuf -fftwl_mksolver_rdft_r2r_direct -fftwl_mktensor -fftwl_mktensor_0d -fftwl_mktensor_1d -fftwl_mktensor_2d -fftwl_mktensor_3d -fftwl_mktensor_4d -fftwl_mktensor_5d -fftwl_mktensor_iodims -fftwl_mktensor_iodims64 -fftwl_mktensor_rowmajor -fftwl_mktriggen -fftwl_modulo -fftwl_nbuf -fftwl_nbuf_redundant -fftwl_next_prime -fftwl_null_awake -fftwl_ops_add -fftwl_ops_add2 -fftwl_ops_cpy -fftwl_ops_madd -fftwl_ops_madd2 -fftwl_ops_other -fftwl_ops_zero -fftwl_pickdim -fftwl_plan_awake -fftwl_plan_destroy_internal -fftwl_plan_dft -fftwl_plan_dft_1d -fftwl_plan_dft_2d -fftwl_plan_dft_3d -fftwl_plan_dft_c2r -fftwl_plan_dft_c2r_1d -fftwl_plan_dft_c2r_2d -fftwl_plan_dft_c2r_3d -fftwl_plan_dft_r2c -fftwl_plan_dft_r2c_1d -fftwl_plan_dft_r2c_2d -fftwl_plan_dft_r2c_3d -fftwl_plan_guru64_dft -fftwl_plan_guru64_dft_c2r -fftwl_plan_guru64_dft_r2c -fftwl_plan_guru64_r2r -fftwl_plan_guru64_split_dft -fftwl_plan_guru64_split_dft_c2r -fftwl_plan_guru64_split_dft_r2c -fftwl_plan_guru_dft -fftwl_plan_guru_dft_c2r -fftwl_plan_guru_dft_r2c -fftwl_plan_guru_r2r -fftwl_plan_guru_split_dft -fftwl_plan_guru_split_dft_c2r -fftwl_plan_guru_split_dft_r2c -fftwl_plan_many_dft -fftwl_plan_many_dft_c2r -fftwl_plan_many_dft_r2c -fftwl_plan_many_r2r -fftwl_planner_destroy -fftwl_plan_null_destroy -fftwl_plan_r2r -fftwl_plan_r2r_1d -fftwl_plan_r2r_2d -fftwl_plan_r2r_3d -fftwl_plan_with_nthreads -fftwl_power_mod -fftwl_printer_destroy -fftwl_print_plan -fftwl_problem_destroy -fftwl_rader_tl_delete -fftwl_rader_tl_find -fftwl_rader_tl_insert -fftwl_rdft2_buffered_register -fftwl_rdft2_complex_n -fftwl_rdft2_inplace_strides -fftwl_rdft2_nop_register -fftwl_rdft2_pad -fftwl_rdft2_rank0_register -fftwl_rdft2_rank_geq2_register -fftwl_rdft2_rdft_register -fftwl_rdft2_solve -fftwl_rdft2_strides -fftwl_rdft2_tensor_max_index -fftwl_rdft2_thr_vrank_geq1_register -fftwl_rdft2_vrank_geq1_register -fftwl_rdft_buffered_register -fftwl_rdft_conf_standard -fftwl_rdft_dht_register -fftwl_rdft_generic_register -fftwl_rdft_indirect_register -fftwl_rdft_kind_str -fftwl_rdft_nop_register -fftwl_rdft_rank0_register -fftwl_rdft_rank_geq2_register -fftwl_rdft_solve -fftwl_rdft_thr_vrank_geq1_register -fftwl_rdft_vrank3_transpose_register -fftwl_rdft_vrank_geq1_register -fftwl_rdft_zerotens -fftwl_redft00e_r2hc_pad_register -fftwl_regsolver_ct_directw -fftwl_regsolver_ct_directwsq -fftwl_regsolver_hc2c_direct -fftwl_regsolver_hc2hc_direct -fftwl_reodft00e_splitradix_register -fftwl_reodft010e_r2hc_register -fftwl_reodft11e_r2hc_odd_register -fftwl_reodft11e_radix2_r2hc_register -fftwl_reodft_conf_standard -fftwl_rodft00e_r2hc_pad_register -fftwl_safe_mulmod -fftwl_scanner_destroy -fftwl_set_planner_hooks -fftwl_set_timelimit -fftwl_solver_destroy -fftwl_solver_register -fftwl_solver_use -fftwl_solvtab_exec -fftwl_spawn_loop -fftwl_sprint_plan -fftwl_tensor_append -fftwl_tensor_compress -fftwl_tensor_compress_contiguous -fftwl_tensor_copy -fftwl_tensor_copy_except -fftwl_tensor_copy_inplace -fftwl_tensor_copy_sub -fftwl_tensor_destroy -fftwl_tensor_destroy2 -fftwl_tensor_destroy4 -fftwl_tensor_equal -fftwl_tensor_inplace_locations -fftwl_tensor_inplace_strides -fftwl_tensor_inplace_strides2 -fftwl_tensor_kosherp -fftwl_tensor_max_index -fftwl_tensor_md5 -fftwl_tensor_min_istride -fftwl_tensor_min_ostride -fftwl_tensor_min_stride -fftwl_tensor_print -fftwl_tensor_split -fftwl_tensor_strides_decrease -fftwl_tensor_sz -fftwl_tensor_tornk1 -fftwl_the_planner -fftwl_threads_cleanup -fftwl_threads_conf_standard -fftwl_threads_register_planner_hooks -fftwl_tile2d -fftwl_toobig -fftwl_transpose -fftwl_transpose_tiled -fftwl_transpose_tiledbuf -fftwl_triggen_destroy -fftwl_twiddle_awake -fftwl_twiddle_length -fftwl_zero1d_pair -lfftw_cleanup_ -lfftw_cleanup__ -lfftw_cleanup_threads_ -lfftw_cleanup_threads__ -lfftw_cost_ -lfftw_cost__ -lfftw_destroy_plan_ -lfftw_destroy_plan__ -lfftw_estimate_cost_ -lfftw_estimate_cost__ -lfftw_execute_ -lfftw_execute__ -lfftw_execute_dft_ -lfftw_execute_dft__ -lfftw_execute_dft_c2r_ -lfftw_execute_dft_c2r__ -lfftw_execute_dft_r2c_ -lfftw_execute_dft_r2c__ -lfftw_execute_r2r_ -lfftw_execute_r2r__ -lfftw_execute_split_dft_ -lfftw_execute_split_dft__ -lfftw_execute_split_dft_c2r_ -lfftw_execute_split_dft_c2r__ -lfftw_execute_split_dft_r2c_ -lfftw_execute_split_dft_r2c__ -lfftw_export_wisdom_ -lfftw_export_wisdom__ -lfftw_flops_ -lfftw_flops__ -lfftw_forget_wisdom_ -lfftw_forget_wisdom__ -lfftw_import_system_wisdom_ -lfftw_import_system_wisdom__ -lfftw_import_wisdom_ -lfftw_import_wisdom__ -lfftw_init_threads_ -lfftw_init_threads__ -lfftw_plan_dft_ -lfftw_plan_dft__ -lfftw_plan_dft_1d_ -lfftw_plan_dft_1d__ -lfftw_plan_dft_2d_ -lfftw_plan_dft_2d__ -lfftw_plan_dft_3d_ -lfftw_plan_dft_3d__ -lfftw_plan_dft_c2r_ -lfftw_plan_dft_c2r__ -lfftw_plan_dft_c2r_1d_ -lfftw_plan_dft_c2r_1d__ -lfftw_plan_dft_c2r_2d_ -lfftw_plan_dft_c2r_2d__ -lfftw_plan_dft_c2r_3d_ -lfftw_plan_dft_c2r_3d__ -lfftw_plan_dft_r2c_ -lfftw_plan_dft_r2c__ -lfftw_plan_dft_r2c_1d_ -lfftw_plan_dft_r2c_1d__ -lfftw_plan_dft_r2c_2d_ -lfftw_plan_dft_r2c_2d__ -lfftw_plan_dft_r2c_3d_ -lfftw_plan_dft_r2c_3d__ -lfftw_plan_guru_dft_ -lfftw_plan_guru_dft__ -lfftw_plan_guru_dft_c2r_ -lfftw_plan_guru_dft_c2r__ -lfftw_plan_guru_dft_r2c_ -lfftw_plan_guru_dft_r2c__ -lfftw_plan_guru_r2r_ -lfftw_plan_guru_r2r__ -lfftw_plan_guru_split_dft_ -lfftw_plan_guru_split_dft__ -lfftw_plan_guru_split_dft_c2r_ -lfftw_plan_guru_split_dft_c2r__ -lfftw_plan_guru_split_dft_r2c_ -lfftw_plan_guru_split_dft_r2c__ -lfftw_plan_many_dft_ -lfftw_plan_many_dft__ -lfftw_plan_many_dft_c2r_ -lfftw_plan_many_dft_c2r__ -lfftw_plan_many_dft_r2c_ -lfftw_plan_many_dft_r2c__ -lfftw_plan_many_r2r_ -lfftw_plan_many_r2r__ -lfftw_plan_r2r_ -lfftw_plan_r2r__ -lfftw_plan_r2r_1d_ -lfftw_plan_r2r_1d__ -lfftw_plan_r2r_2d_ -lfftw_plan_r2r_2d__ -lfftw_plan_r2r_3d_ -lfftw_plan_r2r_3d__ -lfftw_plan_with_nthreads_ -lfftw_plan_with_nthreads__ -lfftw_print_plan_ -lfftw_print_plan__ -lfftw_set_timelimit_ -lfftw_set_timelimit__ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.exp b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.exp deleted file mode 100644 index cc66aff00..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.exp and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.lib b/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.lib deleted file mode 100644 index bdceb321a..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/libfftw3l-3.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/lib/x86/onnxruntime.lib b/funasr/runtime/onnxruntime/win/lib/x86/onnxruntime.lib deleted file mode 100644 index b00709f54..000000000 Binary files a/funasr/runtime/onnxruntime/win/lib/x86/onnxruntime.lib and /dev/null differ diff --git a/funasr/runtime/onnxruntime/win/readme.md b/funasr/runtime/onnxruntime/win/readme.md deleted file mode 100644 index 8b1378917..000000000 --- a/funasr/runtime/onnxruntime/win/readme.md +++ /dev/null @@ -1 +0,0 @@ -