├── .gitignore ├── LICENSE ├── README.md ├── SConstruct ├── cost-model ├── SConscript ├── include │ ├── abstract-hardware-model │ │ ├── AHW-pe-array.hpp │ │ ├── AHW-pe-model.hpp │ │ ├── AHW_Accelerator.hpp │ │ └── AHW_noc-model.hpp │ ├── base │ │ ├── BASE_base-objects.hpp │ │ ├── BASE_constants.hpp │ │ └── BASE_maestro-class.hpp │ ├── cost-analysis │ │ ├── CA_analysis-types.hpp │ │ ├── CA_cost-analysis-engine.hpp │ │ ├── CA_cost-analysis-results.hpp │ │ ├── CA_iterations.hpp │ │ └── CA_reuse-analysis.hpp │ ├── dataflow-analysis │ │ ├── DFA_analysis-output.hpp │ │ ├── DFA_cluster-analysis.hpp │ │ ├── DFA_cluster-table.hpp │ │ ├── DFA_cluster-unit.hpp │ │ ├── DFA_dimension-overlap-info-table.hpp │ │ ├── DFA_dimension-table.hpp │ │ ├── DFA_directive-table.hpp │ │ ├── DFA_directives.hpp │ │ ├── DFA_iteration-analysis.hpp │ │ ├── DFA_iteration-status.hpp │ │ ├── DFA_layer.hpp │ │ ├── DFA_neural-network.hpp │ │ ├── DFA_tensor-table.hpp │ │ └── DFA_tensor.hpp │ ├── dataflow-specification-language │ │ ├── DFSL_hw-parser.hpp │ │ ├── DFSL_parser.hpp │ │ └── DFSL_syntax_tokens.hpp │ ├── design-space-exploration │ │ ├── DSE_config.hpp │ │ ├── DSE_cost-database.hpp │ │ ├── DSE_csv_writer.hpp │ │ ├── DSE_design-options.hpp │ │ ├── DSE_design_point.hpp │ │ ├── DSE_engine.hpp │ │ ├── DSE_hardware_modules.hpp │ │ └── DSE_scaling-coefficients.hpp │ ├── maestro-marvel.h │ ├── option.hpp │ ├── tools │ │ ├── TL_analysis-results-csv-writer.hpp │ │ ├── TL_error-handler.hpp │ │ ├── TL_generic-csv-writer.hpp │ │ └── TL_message-printer.hpp │ └── user-api │ │ ├── API_configuration.hpp │ │ ├── API_user-interface-v2.hpp │ │ └── API_user-interface.hpp └── src │ ├── BASE_base-objects.cpp │ └── maestro-marvel.cpp ├── data ├── hw │ └── accelerator_1.m ├── mapping │ ├── GEMM_Example.m │ ├── MobileNetV2_kcp_ws.m │ ├── MobileNetV2_xp_ws.m │ ├── MobileNetV2_yxp_os.m │ ├── ResNeXt50_kcp_ws.m │ ├── ResNeXt50_nlr.m │ ├── ResNeXt50_rs.m │ ├── ResNeXt50_xp_ws.m │ ├── ResNeXt50_yxp_os.m │ ├── Resnet50_kcp_ws.m │ ├── Resnet50_nlr.m │ ├── Resnet50_rs.m │ ├── Resnet50_xp_ws.m │ ├── Resnet50_yxp_os.m │ ├── Transformer_Complete.m │ ├── Transformer_Layers.m │ ├── UNet_RS.m │ ├── UNet_kcp_ws.m │ ├── UNet_nlr.m │ ├── UNet_xp_ws.m │ ├── UNet_yxp_os.m │ ├── example.m │ ├── gnmt_nmk.m │ ├── googlenet_kcp_ws.m │ ├── googlenet_rs.m │ ├── googlenet_xp_ws.m │ ├── googlenet_ykp_os.m │ ├── mnasnet_kcp_ws.m │ ├── mnasnet_rs.m │ ├── mnasnet_xp_ws.m │ ├── mnasnet_ykp_os.m │ ├── ncf_nmk.m │ ├── squeezenet1_0_kcp_ws.m │ ├── squeezenet1_0_rs.m │ ├── squeezenet1_0_xp_ws.m │ ├── squeezenet1_0_ykp_os.m │ ├── vgg16_ckp_ws.m │ ├── vgg16_nlr.m │ ├── vgg16_rs.m │ ├── vgg16_xp_ws.m │ └── vgg16_yxp_os.m └── model │ ├── MobileNetV2_model.m │ ├── ResNeXt50_model.m │ ├── Resnet50_model.m │ ├── Transformer_Complete_model.m │ ├── Transformer_Layers_model.m │ ├── UNet_model.m │ ├── dnn_model.m │ ├── gnmt_model.m │ ├── googlenet_model.m │ ├── mnasnet_model.m │ ├── ncf_model.m │ ├── squeezenet1_0_model.m │ └── vgg16_model.m ├── docs └── frontend_tutorial.md ├── maestro-top.cpp ├── requirements.txt ├── run_eval.sh ├── run_example.sh ├── run_example2.sh ├── tools ├── frontend │ ├── dataflow │ │ ├── dpt.m │ │ ├── kcp_ws.m │ │ ├── maeri.m │ │ ├── rs.m │ │ ├── xp_ws.m │ │ └── ykp_os.m │ ├── frameworks_to_modelfile_maestro.py │ ├── helpers │ │ ├── keras_helper.py │ │ ├── keras_maestro_summary.py │ │ ├── torch_maestro_summary.py │ │ └── torch_to_maestro.py │ ├── keras-example │ │ ├── alexnet.py │ │ └── my_model.py │ ├── mapping_to_modelfile.py │ ├── modelfile_to_mapping.py │ └── run_frontend.sh └── jupyter_notebook │ ├── README.md │ ├── __init__.py │ ├── data │ ├── MobileNetV2_kcp_ws_pe256.csv │ ├── Resnet50_kcp_ws_pe1024.csv │ ├── Resnet50_kcp_ws_pe256.csv │ └── Resnet50_rs_pe256.csv │ ├── graph_util.py │ ├── maestro_output_analysis.ipynb │ └── requirements.txt └── validation ├── eyeriss ├── alexnet_rs_validation.m └── run_eval_alexnet_rs.sh └── maeri ├── run_eval_Resnet50_maeri.sh ├── run_eval_vgg16_maeri.sh └── vgg16_maeri.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Excutable 35 | maestro 36 | 37 | # Generated datasets 38 | *.csv 39 | !tools/jupyter_notebook/data/*.csv 40 | 41 | # SCONS temp files 42 | .sconsign* 43 | 44 | # OSX file system 45 | .DS_Store 46 | 47 | *.pyc 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 GT Synergy Lab 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MAESTRO: An Open-source Infrastructure for Modeling Dataflows within Deep Learning Accelerators 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) 3 | 4 | # What is MAESTRO? 5 | MAESTRO is an open-source tool for modeling and evaluating the performance and energy-efficiency of different dataflows. MAESTRO is actively developed by the [Synergy Lab](https://synergy.ece.gatech.edu/) at [Georgia Institute of Technology](https://www.gatech.edu/). For more details about MAESTRO, please visit the following links. 6 | 7 | - [MAESTRO Website](http://maestro.ece.gatech.edu/) 8 | - [MAESTRO Docs](http://maestro.ece.gatech.edu/docs/build/html/index.html) 9 | 10 | 11 | # Codebase 12 | 13 | ## Updates 14 | ### May 26th, 2021 15 | 16 | We updated the hardware description file, added off-chip bandwidth added as constraint. 17 | 18 | We added a validation folder with data for Eyeriss and MAERI from MICRO 2019 paper. 19 | 20 | ### Oct 13th, 2020 21 | 22 | We added a direct support for GEMM layers. For more information, please take a look at [here](http://maestro.ece.gatech.edu/docs/build/html/layer_supported.html). 23 | 24 | ### May 13th, 2020 25 | 26 | We updated the naming convention of mappings and the directory structure of data folder. 27 | 28 | ### Oct 14th, 2019 29 | 30 | Latest codebase released along with MAESTRO MICRO 2019 paper. 31 | 32 | 33 | ## Maintainers 34 | - Felix (Sheng-Chun) Kao (felix@gatech.edu) 35 | - Geonhwa Jeong (geonhwa.jeong@gatech.edu) 36 | - Tushar Krishna (tushar@ece.gatech.edu) 37 | 38 | 39 | ## Technical Contributors 40 | - Hyoukjun Kwon (Georgia Tech, now at Facebook Reality Labs): Main developer (core framework and functionalities) 41 | - Prasanth Chatarasi (Georgia Tech, now at IBM Research): APIs + interface to mapping optimizers. 42 | - Felix (Sheng-Chun) Kao (Georgia Tech): Pytorch frontend + updates to cost-model/interface + GAMMA mapper 43 | - Geonhwa Jeong (Georgia Tech): Keras frontend + debugging + website maintainer. 44 | - Saurabh Malik (Georgia Tech, now at Microsoft): Jupyter Notebooks demo + website. 45 | 46 | # Citations ### 47 | ``` 48 | @inproceedings{maestro_micro2019, 49 | author = {Hyoukjun Kwon and 50 | Prasanth Chatarasi and 51 | Michael Pellauer and 52 | Angshuman Parashar and 53 | Vivek Sarkar and 54 | Tushar Krishna}, 55 | title = {Understanding Reuse, Performance, and Hardware Cost of {DNN} Dataflow: 56 | {A} Data-Centric Approach}, 57 | booktitle = {Proceedings of the 52nd Annual {IEEE/ACM} International Symposium 58 | on Microarchitecture, {MICRO}}, 59 | pages = {754--768}, 60 | publisher = {{ACM}}, 61 | year = {2019}, 62 | } 63 | 64 | ``` 65 | ``` 66 | @article{maestro_toppicks2020, 67 | author = {Hyoukjun Kwon and 68 | Prasanth Chatarasi and 69 | Vivek Sarkar and 70 | Tushar Krishna and 71 | Michael Pellauer and 72 | Angshuman Parashar}, 73 | title = {{MAESTRO:} {A} Data-Centric Approach to Understand Reuse, Performance, 74 | and Hardware Cost of {DNN} Mappings}, 75 | journal = {{IEEE} Micro}, 76 | volume = {40}, 77 | number = {3}, 78 | pages = {20--29}, 79 | year = {2020}, 80 | } 81 | ``` 82 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | 2 | env = Environment() 3 | 4 | includes = ''' 5 | . 6 | ./cost-model/include 7 | ./cost-model/include/base 8 | ./cost-model/include/tools 9 | ./cost-model/include/user-api 10 | ./cost-model/include/dataflow-analysis 11 | ./cost-model/include/dataflow-specification-language 12 | ./cost-model/include/design-space-exploration 13 | ./cost-model/include/cost-analysis 14 | ./cost-model/include/abstract-hardware-model 15 | ./cost-model/src 16 | ''' 17 | env.Append(LINKFLAGS=['-lboost_program_options', '-lboost_filesystem', '-lboost_system']) 18 | env.Append(CXXFLAGS=['-std=c++17', '-lboost_program_options', '-lboost_filesystem', '-lboost_system']) 19 | env.Append(LIBS=['-lboost_program_options', '-lboost_filesystem', '-lboost_system' ]) 20 | 21 | env.Append(CPPPATH = Split(includes)) 22 | #env.Program("maestro-top.cpp") 23 | #env.Program('maestro', ['maestro-top.cpp', 'lib/src/maestro_v3.cpp', 'lib/src/BASE_base-objects.cpp' ]) 24 | env.Program('maestro', ['maestro-top.cpp', 'cost-model/src/BASE_base-objects.cpp' ]) 25 | #env.Library('maestro', ['maestro-top.cpp', 'lib/src/maestro_v3.cpp', 'lib/src/BASE_base-objects.cpp' ]) 26 | 27 | -------------------------------------------------------------------------------- /cost-model/SConscript: -------------------------------------------------------------------------------- 1 | 2 | Import ('env') 3 | 4 | env.Append(CPPPATH = ['./lib/include/', 5 | './lib/include/DFSL', 6 | './lib/include/DSE', 7 | './lib/include/DFA', 8 | './lib/include/AHW-model', 9 | './lib/src/']) 10 | 11 | #env.Append(CXXFLAGS=['-std=c++17', '-lboost_program_options' ]) 12 | env.Append(CXXFLAGS=['-std=c++17']) 13 | #env.Append(LINKFLAGS=['-lboost_program_options']) 14 | 15 | print "cc" 16 | -------------------------------------------------------------------------------- /cost-model/include/abstract-hardware-model/AHW-pe-array.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_AHW_PE_ARRAY_HPP_ 24 | #define MAESTRO_AHW_PE_ARRAY_HPP_ 25 | 26 | #include 27 | 28 | #include "../abstract-hardware-model/AHW-pe-model.hpp" 29 | 30 | namespace maestro { 31 | 32 | namespace AHW { 33 | class ProcessingElementArray { 34 | public: 35 | ProcessingElementArray(int num_pes, std::shared_ptr pe_model) : 36 | num_pes_(num_pes), pe_model_(pe_model) { 37 | 38 | } 39 | 40 | int GetNumPEs () { 41 | return num_pes_; 42 | } 43 | 44 | std::shared_ptr GetPEModel() { 45 | return pe_model_; 46 | } 47 | 48 | protected: 49 | int num_pes_; 50 | std::shared_ptr pe_model_; 51 | 52 | }; 53 | 54 | }; // End of namespace abstract_hw 55 | }; // End of namespace maestro 56 | #endif 57 | -------------------------------------------------------------------------------- /cost-model/include/abstract-hardware-model/AHW-pe-model.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_AHW_PE_MODEL_HPP_ 24 | #define MAESTRO_AHW_PE_MODEL_HPP_ 25 | 26 | namespace maestro { 27 | namespace AHW { 28 | 29 | enum class Precision {FP8, FP16, FP32, INT8, INT16, INT32}; 30 | 31 | class ProcessingElement { 32 | public: 33 | ProcessingElement(int l1_size, int vector_width, Precision mult_precision, Precision add_precision) : 34 | l1_size_(l1_size), vector_width_(vector_width), mult_precision_(mult_precision), add_precision_(add_precision) { 35 | } 36 | 37 | int GetL1Size() { 38 | return l1_size_; 39 | } 40 | 41 | int GetVectorWidth() { 42 | return vector_width_; 43 | } 44 | 45 | Precision GetMultPrecision() { 46 | return mult_precision_; 47 | } 48 | 49 | Precision GetAddPrecision() { 50 | return add_precision_; 51 | } 52 | 53 | protected: 54 | int l1_size_; 55 | int vector_width_; 56 | Precision mult_precision_; 57 | Precision add_precision_; 58 | }; 59 | 60 | }; // End of namespace abstract_hw 61 | }; // End of namespace maestro 62 | #endif 63 | -------------------------------------------------------------------------------- /cost-model/include/abstract-hardware-model/AHW_Accelerator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_AHW_ACCELERATOR_HPP_ 2 | #define MAESTRO_AHW_ACCELERATOR_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | #include "DSE_design-options.hpp" 8 | 9 | namespace maestro { 10 | 11 | namespace AHW { 12 | 13 | class Accelerator { 14 | public: 15 | 16 | 17 | protected: 18 | int num_pes_; 19 | int pe_vector_width_; 20 | DSE::OpType mult_op_type_; 21 | int mult_precision_; 22 | DSE::OpType add_op_type_; 23 | int add_precision_; 24 | 25 | std::vector buffer_name_; 26 | std::vector buffer_sizes_; 27 | std::vector noc_name_; 28 | std::vector noc_bandwidth_; 29 | std::vector noc_latency_; 30 | 31 | 32 | }; // End of class Accelerator 33 | 34 | 35 | }; // End of namespace AHW 36 | }; // End of namespace maestro 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /cost-model/include/abstract-hardware-model/AHW_noc-model.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #ifndef MAESTRO_AHW_NOC_MODEL_HPP_ 23 | #define MAESTRO_AHW_NOC_MODEL_HPP_ 24 | 25 | namespace maestro { 26 | 27 | namespace AHW { 28 | 29 | class NetworkOnChipModel { 30 | public: 31 | NetworkOnChipModel(int bw, int hops, int hop_latency ,bool mc) : 32 | bandwidth_(bw), num_average_hops_(hops), latency_per_hops_(hop_latency), multicast_support_(mc) { 33 | } 34 | 35 | int GetBandwidth() { 36 | return bandwidth_; 37 | } 38 | 39 | bool IsMulticastSupported() { 40 | return multicast_support_; 41 | } 42 | 43 | void SetBandwidth(int bw) { 44 | bandwidth_ = bw; 45 | } 46 | 47 | long GetOutStandingDelay(long data_amount) { 48 | long delay; 49 | 50 | long num_sends; 51 | if(data_amount % bandwidth_ != 0) { 52 | num_sends = data_amount / bandwidth_ + 1; 53 | } 54 | else { 55 | num_sends = data_amount / bandwidth_; 56 | } 57 | 58 | long avg_zero_load_delay = num_average_hops_ * latency_per_hops_; 59 | 60 | delay = avg_zero_load_delay // Head delay 61 | + (num_sends-1); // Pipeline delay 62 | 63 | return delay; 64 | } // End of GetOutStandingDelay 65 | 66 | protected: 67 | int bandwidth_; 68 | int num_average_hops_; 69 | int latency_per_hops_; 70 | bool multicast_support_; 71 | 72 | }; // End of class NetworkOnChipModel 73 | }; // End of namespace abstract_hw 74 | }; // End of namespace maestro 75 | #endif 76 | -------------------------------------------------------------------------------- /cost-model/include/base/BASE_base-objects.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_BASE_BASE_OBJECTS_HPP_ 24 | #define MAESTRO_BASE_BASE_OBJECTS_HPP_ 25 | 26 | #include 27 | #include "TL_error-handler.hpp" 28 | #include "TL_message-printer.hpp" 29 | 30 | namespace maestro { 31 | 32 | extern std::shared_ptr error_handler; 33 | extern std::shared_ptr message_printer; 34 | 35 | extern int printout_level; 36 | 37 | void InitializeBaseObjects(int print_lv = 256); 38 | void SetPrintOutLevel(int new_lv); 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /cost-model/include/base/BASE_constants.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef BASE_CONSTANTS_HPP_ 24 | #define BASE_CONSTANTS_HPP_ 25 | 26 | 27 | #include 28 | 29 | namespace maestro{ 30 | const std::string init_dim = "Init"; 31 | const std::string wgt_init_dim = "Init"; 32 | const std::string ipt_init_dim = "Init"; 33 | 34 | 35 | 36 | enum class DataClass{Input, Weight, Output, NumDataClasses}; 37 | const double l1_energy_multiplier = 1.68; 38 | const double l2_energy_multiplier = 18.61; 39 | 40 | 41 | }; // End of namespace maestro 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /cost-model/include/base/BASE_maestro-class.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_BASE_MAESTRO_CLASS_HPP_ 24 | #define MAESTRO_BASE_MAESTRO_CLASS_HPP_ 25 | 26 | #include 27 | 28 | #include "BASE_base-objects.hpp" 29 | #include "TL_error-handler.hpp" 30 | 31 | namespace maestro { 32 | class MAESTROClass { 33 | public: 34 | 35 | MAESTROClass() : 36 | instance_name_("class"), 37 | error_handler_(error_handler), 38 | message_printer_(message_printer) { 39 | } 40 | 41 | MAESTROClass(std::string instance_name) : 42 | instance_name_(instance_name), 43 | error_handler_(error_handler), 44 | message_printer_(message_printer) { 45 | } 46 | 47 | std::string GetName() { 48 | return instance_name_; 49 | } 50 | 51 | void ToString() { 52 | std::cout << "Base class" << std::endl;; 53 | } 54 | 55 | protected: 56 | std::string instance_name_; 57 | std::shared_ptr error_handler_; 58 | std::shared_ptr message_printer_; 59 | }; 60 | }; 61 | #endif 62 | -------------------------------------------------------------------------------- /cost-model/include/cost-analysis/CA_analysis-types.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_CA_ANALYSIS_TYPES_HPP_ 2 | #define MAESTRO_CA_ANALYSIS_TYPES_HPP_ 3 | 4 | 5 | namespace maestro { 6 | namespace CA { 7 | 8 | enum class IterationStatus {Init, Steady, Edge, Unroll, InitEdge, InitUnroll, InitEdgeSpEdge, EdgeSpEdge, NumIterStatus}; 9 | enum class EstimationType {Min, Max, Exact, NumEstimationTypes}; 10 | const int num_iter_status = 3; 11 | 12 | }; 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /cost-model/include/cost-analysis/CA_iterations.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #ifndef MAESTRO_CA_ITERATION_HPP_ 23 | #define MAESTRO_CA_ITERATION_HPP_ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "BASE_maestro-class.hpp" 34 | 35 | #include "DFA_directives.hpp" 36 | #include "DFA_tensor.hpp" 37 | 38 | #include "CA_analysis-types.hpp" 39 | 40 | namespace maestro { 41 | namespace CA { 42 | 43 | 44 | class IterationStatusInfo : public MAESTROClass { 45 | public: 46 | IterationStatusInfo() : 47 | MAESTROClass("IterationStatusInfo") { 48 | } 49 | 50 | void AddIterationInfo(std::pair>> iteration_info) { 51 | possible_status_.push_back(iteration_info); 52 | } 53 | 54 | protected: 55 | std::vector>>> possible_status_; 56 | 57 | }; 58 | 59 | 60 | class IterationStatusInstance : public MAESTROClass { 61 | public: 62 | IterationStatusInstance() : 63 | MAESTROClass("IterationStatusInstance") { 64 | } 65 | 66 | 67 | 68 | protected: 69 | std::map status_; 70 | 71 | }; 72 | 73 | 74 | class UnitIterationAnalysis { 75 | public: 76 | UnitIterationAnalysis(std::shared_ptr dataflow_directive, int dim_bound, int num_clusters) 77 | : dataflow_directive_(dataflow_directive), dimension_bound_(dim_bound), num_targ_clusters_(num_clusters) { 78 | } 79 | 80 | int GetNumTemporalIteration() { 81 | int ret = 1; 82 | if(dataflow_directive_->GetClass() == DFA::directive::DirectiveClass::TemporalMap) { 83 | ret = ceil(static_cast(dimension_bound_ - dataflow_directive_->GetSize() +1 ) / static_cast(dataflow_directive_->GetOfs())); 84 | } 85 | return ret; 86 | } 87 | 88 | int GetNumSpatialIteration() { 89 | int ret = 1; 90 | if(dataflow_directive_->GetClass() == DFA::directive::DirectiveClass::SpatialMap) { 91 | ret = ceil(static_cast(dimension_bound_ - dataflow_directive_->GetSize() +1 ) / static_cast(dataflow_directive_->GetOfs() * num_targ_clusters_)); 92 | } 93 | return ret; 94 | } 95 | 96 | int GetNumSpatialEdgeClusters() { 97 | return (dimension_bound_ - dataflow_directive_->GetSize() +1 ) % (dataflow_directive_->GetOfs() * num_targ_clusters_); 98 | } 99 | 100 | protected: 101 | std::shared_ptr dataflow_directive_; 102 | int dimension_bound_; 103 | int num_targ_clusters_; 104 | }; // End of class UnitIterationAnalysis 105 | 106 | 107 | }; // End of namespace CA 108 | }; // End of namespace maestro 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_analysis-output.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_ANALYSIS_OUTPUT_HPP_ 24 | #define MAESTRO_DFA_ANALYSIS_OUTPUT_HPP_ 25 | 26 | namespace maestro { 27 | namespace DFA { 28 | 29 | class BufferAnalysis { 30 | public: 31 | BufferAnalysis() { 32 | } 33 | 34 | void AddSizeReq(int size_req) { 35 | size_req_.push_back(size_req); 36 | } 37 | 38 | void AddAccessCounts(int counts) { 39 | access_counts_.push_back(counts); 40 | } 41 | 42 | protected: 43 | std::vector size_req_; 44 | std::vector access_counts_; 45 | }; 46 | 47 | 48 | }; // End of namespace DFA 49 | }; // End of namespace maestro 50 | 51 | #endif /* MAESTRO_V2_LIB_INCLUDE_DATAFLOW_ANALYSIS_DFA_ANALYSIS_OUTPUT_HPP_ */ 52 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_cluster-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_CLUSTER_TABLE_HPP_ 24 | #define MAESTRO_DFA_CLUSTER_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_maestro-class.hpp" 30 | #include "TL_error-handler.hpp" 31 | 32 | #include "DFA_layer.hpp" 33 | #include "DFA_analysis-output.hpp" 34 | #include "DFA_cluster-unit.hpp" 35 | 36 | namespace maestro { 37 | namespace DFA { 38 | class ClusterTable: public MAESTROClass { 39 | public: 40 | 41 | /* 42 | * Custom iterator to support "for-each" loop over this data structure 43 | */ 44 | class iterator { 45 | private: 46 | std::shared_ptr>> iter_clusters_; 47 | public: 48 | 49 | int curr_idx_; 50 | 51 | iterator(std::shared_ptr>> ptr, int idx) : 52 | iter_clusters_(ptr), curr_idx_(idx) { 53 | } 54 | 55 | iterator operator++() { 56 | this->curr_idx_++; 57 | iterator iter = *this; 58 | return iter; 59 | } 60 | 61 | iterator operator--() { 62 | if(this->curr_idx_ != 0) { 63 | this->curr_idx_--; 64 | } 65 | iterator iter = *this; 66 | return iter; 67 | } 68 | 69 | std::shared_ptr& operator*() { 70 | return iter_clusters_->at(curr_idx_); 71 | } 72 | 73 | bool operator==(const iterator& rhs) { 74 | return (this->curr_idx_ == rhs.curr_idx_); 75 | } 76 | 77 | bool operator!=(const iterator& rhs) { 78 | return (this->curr_idx_ != rhs.curr_idx_); 79 | } 80 | 81 | }; // End of class iterator for class Directive_table 82 | 83 | iterator begin() { 84 | iterator iter(clusters_, 0); 85 | return iter; 86 | } 87 | 88 | iterator end() { 89 | iterator iter(clusters_, clusters_->size()); 90 | return iter; 91 | } 92 | /***********************************************************************************************/ 93 | 94 | ClusterTable(LayerType layer_type) : 95 | layer_type_(layer_type), 96 | MAESTROClass("ClusterTable") { 97 | clusters_ = std::make_shared>>(); 98 | } 99 | 100 | int size() { 101 | return clusters_->size(); 102 | } 103 | 104 | void PutCluster(std::shared_ptr new_cluster) { 105 | clusters_->push_back(new_cluster); 106 | } 107 | 108 | std::shared_ptr GetCluster(int lv) { 109 | if(lv < clusters_->size()) { 110 | return clusters_->at(lv); 111 | } 112 | else { 113 | error_handler_->PrintErrorMsg(TL::ErrorCode::InvalidClusterLevel, std::to_string(lv), instance_name_); 114 | return nullptr; 115 | } 116 | } 117 | 118 | LayerType GetLayerType() { 119 | return layer_type_; 120 | } 121 | 122 | protected: 123 | LayerType layer_type_; 124 | std::shared_ptr>> clusters_; 125 | 126 | }; // End of class ClusterTable 127 | }; // End of namespace DFA 128 | };// End of namespace maestro 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_dimension-overlap-info-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIMENSION_OVERLAP_INFO_HPP_ 24 | #define MAESTRO_DFA_DIMENSION_OVERLAP_INFO_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | namespace maestro { 33 | namespace DFA { 34 | 35 | class DimensionOverlapInfoTable { 36 | public: 37 | DimensionOverlapInfoTable() { 38 | overlapping_dimensions_ = std::make_unique>>>(); 39 | } 40 | 41 | void AddOverlapDimension(std::string reference_dim, std::string sliding_dim) { 42 | auto new_overlap_info = std::make_shared>(reference_dim, sliding_dim); 43 | overlapping_dimensions_->push_back(new_overlap_info); 44 | } 45 | 46 | void AddOverlapDimensions(std::shared_ptr>>> overlap_dim_list) { 47 | for(auto& it: *overlap_dim_list) { 48 | overlapping_dimensions_->push_back(it); 49 | } 50 | } 51 | 52 | bool IsOverlapped(std::string dim) { 53 | bool ret = false; 54 | 55 | for(auto& it: *overlapping_dimensions_) { 56 | auto ref_dim = it->first; 57 | auto sliding_dim = it->second; 58 | if(dim == ref_dim || dim == sliding_dim) { 59 | ret = true; 60 | break; 61 | } 62 | } 63 | 64 | return ret; 65 | } 66 | 67 | bool IsSlidingDim(std::string dim) { 68 | bool ret = false; 69 | 70 | for(auto& it: *overlapping_dimensions_) { 71 | auto sliding_dim = it->second; 72 | if(dim == sliding_dim) { 73 | ret = true; 74 | } 75 | } 76 | 77 | return ret; 78 | } 79 | 80 | std::string GetCounterPart(std::string dim) { 81 | std::string ret = ""; 82 | 83 | for(auto& it: *overlapping_dimensions_) { 84 | auto reference_dim = it->first; 85 | auto sliding_dim = it->second; 86 | if(dim == sliding_dim) { 87 | ret = reference_dim; 88 | } 89 | else if(dim == reference_dim) { 90 | ret = sliding_dim; 91 | } 92 | } 93 | 94 | return ret; 95 | } 96 | 97 | protected: 98 | std::unique_ptr>>> overlapping_dimensions_; 99 | 100 | }; // End of class DiemensionOverlapInfoTable 101 | 102 | 103 | }; // End of namespace DFA 104 | }; // End of namespace maestro 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_dimension-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIMENSION_TABLE_HPP_ 24 | #define MAESTRO_DFA_DIMENSION_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "BASE_maestro-class.hpp" 31 | #include "TL_error-handler.hpp" 32 | 33 | #include "DFA_layer.hpp" 34 | #include "DFA_dimension-overlap-info-table.hpp" 35 | 36 | namespace maestro { 37 | namespace DFA { 38 | 39 | const int invalid_size = -1; 40 | 41 | class DimensionTable : public MAESTROClass { 42 | public: 43 | class iterator { 44 | private: 45 | std::map>* map_ptr_; 46 | std::map>::iterator map_iterator_; 47 | public: 48 | 49 | iterator(std::map>* ptr_layerdim_map) : 50 | map_ptr_(ptr_layerdim_map) { 51 | map_iterator_ = ptr_layerdim_map->begin(); 52 | } 53 | 54 | iterator operator++() { 55 | map_iterator_++; 56 | return *this; 57 | /* 58 | this->curr_idx_++; 59 | iterator iter = *this; 60 | return iter; 61 | */ 62 | } 63 | 64 | std::shared_ptr& operator*() { 65 | return map_iterator_->second; 66 | } 67 | 68 | bool operator==(const iterator& rhs) { 69 | return (this->map_iterator_ == rhs.map_iterator_); 70 | } 71 | 72 | bool operator!=(const iterator& rhs) { 73 | return (this->map_iterator_ != rhs.map_iterator_); 74 | } 75 | 76 | void set_end () { 77 | map_iterator_ = map_ptr_->end(); 78 | } 79 | }; // End of class iterator for class Directive_table 80 | 81 | iterator begin() { 82 | iterator iter(&dim_table_); 83 | return iter; 84 | } 85 | 86 | iterator end() { 87 | iterator iter(&dim_table_); 88 | iter.set_end(); 89 | return iter; 90 | } 91 | 92 | 93 | DimensionTable() : 94 | MAESTROClass("Dimension Table") { 95 | dim_overlap_table_ = std::make_shared(); 96 | } 97 | 98 | // Not a good way to use std::map; will remove after update deprecated code 99 | std::shared_ptr at (int idx) { 100 | int count = 0; 101 | 102 | for(auto iter = dim_table_.begin(); iter != dim_table_.end(); iter++) { 103 | if(count == idx) { 104 | return iter->second; 105 | } 106 | count ++; 107 | } 108 | return nullptr; 109 | } 110 | 111 | std::shared_ptr operator[] (int idx) { 112 | return this->at(idx); 113 | } 114 | 115 | bool HasVar(std::string targ) { 116 | return (dim_table_.find(targ) != dim_table_.end()); 117 | } 118 | 119 | int GetSize(std::string targ) { 120 | 121 | if(!this->HasVar(targ)) { 122 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 123 | error_handler_->TerminateProgram(); 124 | } 125 | 126 | return dim_table_[targ]->GetSize(); 127 | } 128 | 129 | int GetOuterStride(std::string targ) { 130 | 131 | if(!this->HasVar(targ)) { 132 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 133 | error_handler_->TerminateProgram(); 134 | } 135 | 136 | return dim_table_[targ]->GetOuterStride(); 137 | 138 | } 139 | 140 | int GetInnerStride(std::string targ) { 141 | 142 | if(!this->HasVar(targ)) { 143 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 144 | error_handler_->TerminateProgram(); 145 | } 146 | 147 | return dim_table_[targ]->GetInnerStride(); 148 | 149 | } 150 | 151 | 152 | void AddDimension(std::shared_ptr new_dimension) { 153 | dim_table_.insert(std::make_pair(new_dimension->GetName(), new_dimension)); 154 | } 155 | 156 | void AddOverlapDimension(std::string reference_dim, std::string sliding_dim) { 157 | dim_overlap_table_->AddOverlapDimension(reference_dim, sliding_dim); 158 | } 159 | 160 | void AddOverlapDimensions(std::shared_ptr>>> overlap_dim_list) { 161 | dim_overlap_table_->AddOverlapDimensions(overlap_dim_list); 162 | } 163 | 164 | void SetOverlapTable (std::shared_ptr new_table) { 165 | dim_overlap_table_ = new_table; 166 | } 167 | 168 | bool IsOverlapped(std::string dim) { 169 | return dim_overlap_table_->IsOverlapped(dim); 170 | } 171 | 172 | bool IsSlidingDim(std::string dim) { 173 | return dim_overlap_table_->IsSlidingDim(dim); 174 | } 175 | 176 | std::string GetOverlappingDim(std::string dim) { 177 | std::string ret; 178 | 179 | ret = dim_overlap_table_->GetCounterPart(dim); 180 | 181 | return ret; 182 | } 183 | 184 | std::shared_ptr GetOverlapTable() { 185 | return dim_overlap_table_; 186 | } 187 | 188 | std::string ToString() { 189 | std::string ret = "Dimension Table contents\n"; 190 | for(auto& it : dim_table_) { 191 | ret += it.second->ToString(); 192 | ret += "\n"; 193 | } 194 | return ret; 195 | } 196 | 197 | protected: 198 | std::map> dim_table_; 199 | 200 | std::shared_ptr dim_overlap_table_; 201 | 202 | }; 203 | }; 204 | }; 205 | #endif 206 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_directive-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIRECTIVE_TABLE_HPP_ 24 | #define MAESTRO_DFA_DIRECTIVE_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "DFA_analysis-output.hpp" 32 | #include "DFA_directives.hpp" 33 | #include "DFSL_syntax_tokens.hpp" 34 | 35 | namespace maestro { 36 | namespace DFA { 37 | 38 | class DirectiveTable { 39 | public: 40 | 41 | class iterator { 42 | private: 43 | std::shared_ptr>> iter_directives_; 44 | public: 45 | 46 | int curr_idx_; 47 | 48 | iterator(std::shared_ptr>> ptr, int idx) : 49 | iter_directives_(ptr), 50 | curr_idx_(idx) { 51 | 52 | } 53 | 54 | iterator operator++() { 55 | this->curr_idx_++; 56 | iterator iter = *this; 57 | return iter; 58 | } 59 | 60 | std::shared_ptr& operator*() { 61 | return iter_directives_->at(curr_idx_); 62 | } 63 | 64 | bool operator==(const iterator& rhs) { 65 | return (this->curr_idx_ == rhs.curr_idx_); 66 | } 67 | 68 | bool operator!=(const iterator& rhs) { 69 | return (this->curr_idx_ != rhs.curr_idx_); 70 | } 71 | 72 | }; // End of class iterator for class Directive_table 73 | 74 | iterator begin() { 75 | iterator iter(directives_, 0); 76 | return iter; 77 | } 78 | 79 | iterator end() { 80 | iterator iter(directives_, directives_->size()); 81 | return iter; 82 | } 83 | 84 | DirectiveTable() { 85 | directives_ = std::make_shared>>(); 86 | } 87 | 88 | std::shared_ptr at (int idx) { 89 | if(idx < directives_->size()) { 90 | return directives_->at(idx); 91 | } 92 | else { 93 | return nullptr; 94 | } 95 | } 96 | 97 | std::shared_ptr operator[] (int idx) { 98 | return this->at(idx); 99 | } 100 | 101 | void ConvertToInputCentric() { 102 | 103 | int size_S, size_R = 0; 104 | 105 | for(auto& directive : *directives_) { 106 | if(directive->GetVariable() == DFSL::layer_dim_weight_width_) { 107 | size_S = directive->GetSize(); 108 | } 109 | else if(directive->GetVariable() == DFSL::layer_dim_weight_height_) { 110 | size_R = directive->GetSize(); 111 | } 112 | } 113 | 114 | for(auto& directive : *directives_) { 115 | if(directive->GetVariable() == DFSL::layer_dim_output_width_) { 116 | directive->SetVariable(DFSL::layer_dim_input_width_); 117 | directive->SetSize(directive->GetSize() + size_S -1); 118 | } 119 | else if(directive->GetVariable() == DFSL::layer_dim_output_height_) { 120 | directive->SetVariable(DFSL::layer_dim_input_height_); 121 | directive->SetSize(directive->GetSize() + size_R -1); 122 | } 123 | } 124 | } 125 | 126 | std::shared_ptr FindDirective (std::string var) { 127 | std::shared_ptr ret = nullptr; 128 | 129 | for(auto directive : *directives_) { 130 | if(directive->GetVariable() == var) { 131 | return directive; 132 | } 133 | } 134 | 135 | return ret; 136 | } 137 | 138 | int GetDirectiveIdx (std::string var) { 139 | int idx = 0; 140 | for(auto directive : *directives_) { 141 | if(directive->GetVariable() == var) { 142 | return idx; 143 | } 144 | idx++; 145 | } 146 | return idx; 147 | } 148 | 149 | int GetTemporalMapIdx (std::string var) { 150 | int idx = 0; 151 | for(auto directive : *directives_) { 152 | if(directive->GetVariable() == var) { 153 | return idx; 154 | } 155 | if(directive->GetClass() == DFA::directive::DirectiveClass::TemporalMap) { 156 | idx++; 157 | } 158 | } 159 | return idx; 160 | } 161 | 162 | void AddDirectiveFront(std::shared_ptr new_directive) { 163 | directives_->insert(directives_->begin(), new_directive); 164 | } 165 | 166 | 167 | void AddDirective(std::shared_ptr new_directive) { 168 | directives_->push_back(new_directive); 169 | } 170 | 171 | void DeleteDirectives(){ 172 | directives_->erase(directives_->begin(), 173 | directives_->begin() + directives_->size()); 174 | } 175 | 176 | void ReverseDirectives() { 177 | std::reverse(std::begin(*directives_), std::end(*directives_)); 178 | } 179 | 180 | int size() { 181 | return directives_->size(); 182 | } 183 | 184 | std::string ToString() { 185 | std::string ret = ""; 186 | for(auto& it : *directives_) { 187 | ret = ret + it->ToString(); 188 | ret = ret + "\n"; 189 | } 190 | 191 | return ret; 192 | } 193 | 194 | protected: 195 | std::shared_ptr>> directives_; 196 | 197 | }; // End of class DirectiveTable 198 | 199 | }; // End of namespace DFA 200 | }; // End of namesapce maestro 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_neural-network.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_NEURAL_NETWORK_HPP_ 24 | #define MAESTRO_DFA_NEURAL_NETWORK_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "DFA_layer.hpp" 31 | 32 | namespace maestro{ 33 | namespace DFA { 34 | 35 | class NeuralNetwork { 36 | public: 37 | 38 | class iterator { 39 | private: 40 | std::shared_ptr>> iter_layers_; 41 | public: 42 | 43 | int curr_idx_; 44 | 45 | iterator(std::shared_ptr>> ptr, int idx) : 46 | iter_layers_(ptr), 47 | curr_idx_(idx) { 48 | 49 | } 50 | 51 | iterator operator++() { 52 | this->curr_idx_++; 53 | iterator iter = *this; 54 | return iter; 55 | } 56 | 57 | std::shared_ptr& operator*() { 58 | return iter_layers_->at(curr_idx_); 59 | } 60 | 61 | bool operator==(const iterator& rhs) { 62 | return (this->curr_idx_ == rhs.curr_idx_); 63 | } 64 | 65 | bool operator!=(const iterator& rhs) { 66 | return (this->curr_idx_ != rhs.curr_idx_); 67 | } 68 | 69 | 70 | }; // End of class iterator for class NeuralNetwork 71 | 72 | iterator begin() { 73 | return iterator(layers_, 0); 74 | } 75 | 76 | iterator end() { 77 | return iterator(layers_, layers_->size()); 78 | } 79 | 80 | std::shared_ptr operator [](int idx) { 81 | return GetLayer(idx); 82 | } 83 | 84 | std::shared_ptr at (int idx) { 85 | return GetLayer(idx); 86 | } 87 | 88 | NeuralNetwork() { 89 | layers_ = std::make_shared>>(); 90 | } 91 | 92 | NeuralNetwork(std::string name) : 93 | name_(name) { 94 | layers_ = std::make_shared>>(); 95 | } 96 | 97 | std::string GetName() { 98 | return name_; 99 | } 100 | 101 | void SetName(std::string name) { 102 | name_ = name; 103 | } 104 | 105 | void AddLayer(std::shared_ptr new_layer) { 106 | if(new_layer == nullptr) { 107 | std::cout << "Warning: Adding a null ptr" << std::endl; 108 | } 109 | layers_->push_back(new_layer); 110 | } 111 | 112 | 113 | 114 | protected: 115 | std::string name_; 116 | std::shared_ptr>> layers_; 117 | 118 | private: 119 | std::shared_ptr GetLayer(int idx) { 120 | if(idx < layers_->size()) { 121 | return layers_->at(idx); 122 | } 123 | else { 124 | return nullptr; 125 | } 126 | } 127 | }; // End of class NeuralNetwork 128 | 129 | }; // End of namespace DFA 130 | }; // End of namespace maestro 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_tensor-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_TENSOR_TABLE_HPP_ 24 | #define MAESTRO_DFA_TENSOR_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_maestro-class.hpp" 30 | #include "TL_error-handler.hpp" 31 | 32 | #include "DFA_tensor.hpp" 33 | 34 | namespace maestro { 35 | namespace DFA { 36 | class TensorTable : public MAESTROClass { 37 | public: 38 | /* 39 | * Custom iterator to support "for-each" loop over this data structure 40 | */ 41 | class iterator { 42 | private: 43 | std::shared_ptr>> iter_tensors_; 44 | public: 45 | 46 | int curr_idx_; 47 | 48 | iterator(std::shared_ptr>> ptr, int idx) : 49 | iter_tensors_(ptr), curr_idx_(idx) { 50 | } 51 | 52 | iterator operator++() { 53 | this->curr_idx_++; 54 | iterator iter = *this; 55 | return iter; 56 | } 57 | 58 | std::shared_ptr& operator*() { 59 | return iter_tensors_->at(curr_idx_); 60 | } 61 | 62 | bool operator==(const iterator& rhs) { 63 | return (this->curr_idx_ == rhs.curr_idx_); 64 | } 65 | 66 | bool operator!=(const iterator& rhs) { 67 | return (this->curr_idx_ != rhs.curr_idx_); 68 | } 69 | 70 | }; // End of class iterator for class Directive_table 71 | 72 | iterator begin() { 73 | iterator iter(tensors_, 0); 74 | return iter; 75 | } 76 | 77 | iterator end() { 78 | iterator iter(tensors_, tensors_->size()); 79 | return iter; 80 | } 81 | /***********************************************************************************************/ 82 | 83 | 84 | TensorTable() { 85 | tensors_ = std::make_shared>>(); 86 | } 87 | 88 | std::shared_ptr at (int idx) { 89 | if(idx < tensors_->size()) { 90 | return tensors_->at(idx); 91 | } 92 | else { 93 | return nullptr; 94 | } 95 | } 96 | 97 | std::shared_ptr operator[] (int idx) { 98 | return this->at(idx); 99 | } 100 | 101 | void AddTensor(std::shared_ptr new_tensor) { 102 | tensors_->push_back(new_tensor); 103 | } 104 | 105 | 106 | void AddTensor(std::string tensor_name, DFA::TensorClass tensor_class, DataClass data_class, std::vector correlated_varaibles) { 107 | 108 | std::shared_ptr> corr_vars_to_be_added = std::make_shared>(); 109 | 110 | for(auto var : correlated_varaibles) { 111 | corr_vars_to_be_added->push_back(var); 112 | } 113 | 114 | auto new_tensor = std::make_shared(tensor_name, tensor_class, data_class, corr_vars_to_be_added); 115 | tensors_->push_back(new_tensor); 116 | } 117 | 118 | std::shared_ptr FindTensor(std::string tensor_name) { 119 | std::shared_ptr ret = nullptr; 120 | 121 | for(auto tensor : *tensors_) { 122 | if(tensor->GetTensorName() == tensor_name) { 123 | ret = tensor; 124 | } 125 | } 126 | 127 | return ret; 128 | } 129 | 130 | std::shared_ptr> GetTensorVarsInClass(DFA::TensorClass tensor_class) { 131 | std::shared_ptr> ret = std::make_shared>(); 132 | 133 | for(auto& tensor : *tensors_) { 134 | if(tensor->GetTensorClass() == tensor_class) { 135 | auto corr_var_list = tensor->GetCoupledVariables(); 136 | for(auto var : *corr_var_list) { 137 | ret->push_back(var); 138 | } 139 | } 140 | } 141 | 142 | ret->sort(); 143 | ret->unique(); 144 | 145 | return ret; 146 | } 147 | 148 | std::shared_ptr>> GetTensorsInClass(DFA::TensorClass tensor_class) { 149 | std::shared_ptr>> ret = std::make_shared>>(); 150 | 151 | for(auto& tensor : *tensors_) { 152 | if(tensor->GetTensorClass() == tensor_class) { 153 | ret->push_back(tensor); 154 | } 155 | } 156 | 157 | return ret; 158 | } 159 | 160 | 161 | 162 | protected: 163 | std::shared_ptr>> tensors_; 164 | 165 | }; // End of class TensorTable 166 | }; // End of namespace DFA 167 | }; // End of namespace maestro 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-analysis/DFA_tensor.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_TENSOR_HPP_ 24 | #define MAESTRO_DFA_TENSOR_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_constants.hpp" 30 | 31 | namespace maestro { 32 | namespace DFA { 33 | 34 | enum class TensorClass {InputTensor, OutputTensor}; 35 | 36 | class Tensor { 37 | public: 38 | Tensor(std::string name, 39 | TensorClass tensor_class, 40 | DataClass data_class, 41 | std::shared_ptr> correlated_variables) : 42 | tensor_name_(name), 43 | tensor_class_(tensor_class), 44 | data_class_(data_class), 45 | coupled_variables_(correlated_variables) { 46 | } 47 | 48 | std::string GetTensorName() { 49 | return tensor_name_; 50 | } 51 | 52 | TensorClass GetTensorClass() { 53 | return tensor_class_; 54 | } 55 | 56 | DataClass GetDataClass() { 57 | return data_class_; 58 | } 59 | 60 | std::shared_ptr> GetCoupledVariables() { 61 | return coupled_variables_; 62 | } 63 | 64 | bool HasVariable(std::string search_var) { 65 | bool ret =false; 66 | for(auto& var : *coupled_variables_) { 67 | if(var == search_var) { 68 | ret = true; 69 | break; 70 | } 71 | } 72 | return ret; 73 | } 74 | 75 | protected: 76 | TensorClass tensor_class_; 77 | DataClass data_class_; 78 | std::string tensor_name_; 79 | std::shared_ptr> coupled_variables_; 80 | }; // End of class Tensor 81 | 82 | }; // End of namespace DFA 83 | }; // End of namespace maestro 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-specification-language/DFSL_hw-parser.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFSL_HW_PARSER_HPP_ 24 | #define MAESTRO_DFSL_HW_PARSER_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #include "BASE_maestro-class.hpp" 38 | #include "DFSL_syntax_tokens.hpp" 39 | #include "DFSL_parser.hpp" 40 | 41 | 42 | namespace maestro { 43 | namespace DFSL { 44 | 45 | //Indentation shows the structure of the state machine in HWParser. 46 | enum class HWParserState {Idle, 47 | NumPEsIdentifier, 48 | NumPEsValue, 49 | L1SizeIdentifier, 50 | L1SizeValue, 51 | L2SizeIdentifier, 52 | L2SizeValue, 53 | NoCBWIdentifier, 54 | NoCBWValue, 55 | NoCNumHopsIdentifier, 56 | NoCNumHopsValue, 57 | //felix 58 | OffChipBWIdentifier, 59 | OffChipBWValue 60 | }; 61 | 62 | class HWConfig : public MAESTROClass { 63 | public: 64 | int num_pes_ = 1; 65 | int l1_size_ = INT_MAX; 66 | int l2_size_ = INT_MAX; 67 | int noc_bw_ = INT_MAX; 68 | int noc_hops_ = 1; 69 | //felix 70 | int off_chip_bw_ = INT_MAX; 71 | }; 72 | 73 | class HWParser : public InputParser { 74 | public: 75 | HWParser(std::string file_name) : InputParser(file_name) { 76 | } 77 | 78 | std::shared_ptr ParseHW() { 79 | std::string line; 80 | boost::char_separator sep(" ,->():\t;"); 81 | int line_number = 1; 82 | auto ret = std::make_shared(); 83 | while(std::getline(in_file_, line)) { 84 | boost::tokenizer> tokn(line, sep); 85 | 86 | for(auto &tkn : tokn) { 87 | 88 | if(tkn.size() >= 2 && tkn.substr(0,2) == DFSL::comments_) { 89 | line_number++; 90 | break; 91 | } 92 | 93 | switch(state_) { 94 | case HWParserState::Idle: { 95 | if(tkn == DFSL::tmp_num_pes_decl_) { 96 | state_ = HWParserState::NumPEsIdentifier; 97 | } 98 | else if(tkn == DFSL::tmp_l1size_decl_) { 99 | state_ = HWParserState::L1SizeIdentifier; 100 | } 101 | else if(tkn == DFSL::tmp_l2size_decl_) { 102 | state_ = HWParserState::L2SizeIdentifier; 103 | } 104 | else if(tkn == DFSL::tmp_noc_bw_decl_) { 105 | state_ = HWParserState::NoCBWIdentifier; 106 | } 107 | else if(tkn == DFSL::tmp_noc_hops_decl_) { 108 | state_ = HWParserState::NoCNumHopsIdentifier; 109 | } 110 | //felix 111 | else if(tkn == DFSL::tmp_offchip_bw_decl_) { 112 | state_ = HWParserState::OffChipBWIdentifier; 113 | } 114 | else { 115 | ParseError(line_number); 116 | } 117 | break; 118 | } 119 | 120 | case HWParserState::NumPEsIdentifier: { 121 | ret->num_pes_ = std::atoi(tkn.c_str()); 122 | state_ = HWParserState::Idle; 123 | break; 124 | } 125 | 126 | case HWParserState::L1SizeIdentifier: { 127 | std::cout << "" << std::endl; 128 | ret->l1_size_ = std::atoi(tkn.c_str()); 129 | state_ = HWParserState::Idle; 130 | break; 131 | } 132 | 133 | case HWParserState::L2SizeIdentifier: { 134 | ret->l2_size_ = std::atoi(tkn.c_str()); 135 | state_ = HWParserState::Idle; 136 | break; 137 | } 138 | 139 | case HWParserState::NoCBWIdentifier: { 140 | ret->noc_bw_ = std::atoi(tkn.c_str()); 141 | state_ = HWParserState::Idle; 142 | break; 143 | } 144 | 145 | case HWParserState::NoCNumHopsIdentifier: { 146 | ret->noc_hops_ = std::atoi(tkn.c_str()); 147 | state_ = HWParserState::Idle; 148 | break; 149 | } 150 | //felix 151 | case HWParserState::OffChipBWIdentifier: { 152 | ret->off_chip_bw_ = std::atoi(tkn.c_str()); 153 | state_ = HWParserState::Idle; 154 | break; 155 | } 156 | 157 | default: { 158 | ParseError(line_number); 159 | break; 160 | } 161 | } // End of switch(state_) 162 | } // End of for(tkn) 163 | 164 | line_number++; 165 | 166 | } // End of while(getline(...)) 167 | 168 | if(state_ != HWParserState::Idle) { 169 | ParseError(line_number); 170 | } 171 | 172 | return ret; 173 | 174 | } // End of ParseHW 175 | 176 | protected: 177 | HWParserState state_ = HWParserState::Idle; 178 | 179 | }; 180 | }; // End of namespace DFSL 181 | }; // End of namespace maestro 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /cost-model/include/dataflow-specification-language/DFSL_syntax_tokens.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSL_SYNTAX_TOKENS_HPP_ 24 | #define MAESTRO_DSL_SYNTAX_TOKENS_HPP_ 25 | 26 | #include 27 | 28 | namespace maestro { 29 | 30 | 31 | namespace DFSL { 32 | 33 | /* Common tokens */ 34 | const std::string brace_open_ = "{"; 35 | const std::string brace_close_ = "}"; 36 | const std::string bracket_open_ = "["; 37 | const std::string bracket_close_ = "]"; 38 | 39 | const std::string separator_ = ";"; 40 | const std::string comments_ = "//"; 41 | 42 | /* Constant definition */ 43 | const std::string constant_decl_ = "Constant"; 44 | 45 | /* Neural network and layer Description */ 46 | const std::string network_decl_ = "Network"; 47 | const std::string layer_decl_ = "Layer"; 48 | const std::string layer_type_decl_ = "Type"; 49 | const std::string layer_type_conv_ = "CONV"; 50 | const std::string layer_type_residual_ = "RESIDUAL_IDENTITY"; 51 | const std::string layer_type_fc_ = "FC"; 52 | const std::string layer_type_pool_ = "POOL"; 53 | const std::string layer_type_dsconv_ = "DSCONV"; 54 | const std::string layer_type_trconv_ = "TRCONV"; 55 | const std::string layer_type_ngconv_ = "NGCONV"; // Nested grouped convolution (ResNeXt) 56 | const std::string layer_type_lstm_ = "LSTM"; 57 | const std::string layer_type_gemm_ = "GEMM"; 58 | const std::string layer_stride_decl_ = "Stride"; 59 | 60 | const std::string layer_dim_decl_ = "Dimensions"; 61 | const std::string layer_dim_input_batch_ = "N"; 62 | const std::string layer_dim_group_ = "G"; 63 | const std::string layer_dim_output_channel_ = "K"; 64 | const std::string layer_dim_input_channel_ = "C"; 65 | const std::string layer_dim_weight_height_ = "R"; 66 | const std::string layer_dim_weight_width_ = "S"; 67 | const std::string layer_dim_input_height_ = "Y"; 68 | const std::string layer_dim_input_width_ = "X"; 69 | const std::string layer_dim_output_height_ = "Y'"; 70 | const std::string layer_dim_output_width_ = "X'"; 71 | 72 | 73 | const std::string layer_expansion_factor_decl_ = "ExpansionSize"; 74 | const std::string layer_pooling_size_decl_ = "PoolSize"; 75 | const std::string layer_stride_size_decl_ = "Stride"; 76 | 77 | const std::string layer_dataflow_decl_ = "Dataflow"; 78 | const std::string dataflow_temporal_map_ = "TemporalMap"; 79 | const std::string dataflow_spatial_map_ = "SpatialMap"; 80 | const std::string dataflow_cluster_ = "Cluster"; 81 | 82 | const std::string dataflow_dim_size_indicatior_ = "Sz"; 83 | 84 | const std::string dataflow_cluster_type_logical_ = "L"; 85 | const std::string dataflow_cluster_type_physical_ = "P"; 86 | 87 | /* Tmp HW parser */ 88 | const std::string tmp_num_pes_decl_ = "num_pes"; 89 | const std::string tmp_l1size_decl_ = "l1_size_cstr"; 90 | const std::string tmp_l2size_decl_ = "l2_size_cstr"; 91 | const std::string tmp_noc_bw_decl_ = "noc_bw_cstr"; 92 | const std::string tmp_noc_hops_decl_ = "NoC_NumHops"; 93 | //felix 94 | const std::string tmp_offchip_bw_decl_ = "offchip_bw_cstr"; 95 | //==== 96 | 97 | /* Hardware Resource Description */ 98 | const std::string accelerator_decl_ = "Accelerator"; 99 | const std::string compute_cluster_decl_ = "ComputeUnitCluster"; 100 | const std::string compute_cluster_level_decl_ = "Level"; 101 | const std::string compute_cluster_counts_ = "NumInstances"; 102 | const std::string compute_cluster_size_decl_ = "NumSubClusters"; 103 | 104 | // NoC Description 105 | const std::string noc_decl_ = "DistributionNoC"; 106 | const std::string noc_bandwidth_decl_ = "Bandwidth"; 107 | const std::string noc_latency_per_hop_decl_ = "LatencyPerHop"; 108 | const std::string noc_tensor_decl_ = "Tensor"; 109 | const std::string noc_avg_num_hops_decl_ = "AvgNumHops"; 110 | const std::string noc_type_decl_ = "Type"; 111 | const std::string dist_noc_type_bus_ = "Bus"; 112 | const std::string dist_noc_type_tree_ = "Tree"; 113 | const std::string dist_noc_type_crossbar_ = "Crossbar"; 114 | const std::string dist_noc_type_systolic_ = "Systolic"; 115 | const std::string dist_noc_type_mesh_ = "Mesh"; 116 | 117 | const std::string redc_noc_decl_ = "ReductionNoC"; 118 | const std::string redc_noc_type_adder_tree_ = "AdderTree"; 119 | const std::string redc_noc_type_systolic_ = "Systolic"; 120 | 121 | 122 | // PE Description 123 | const std::string pe_decl_ = "PE"; 124 | const std::string num_pe_decl_ = "NumPEs"; 125 | const std::string vector_width_decl_ = "VectorWidth"; 126 | 127 | const std::string mult_precision_decl_ = "MultPrecision"; 128 | const std::string add_precision_decl_ = "AddPrecision"; 129 | const std::string bfloat_precision_type = "BFLOAT"; 130 | const std::string float_precision_type = "FLOAT"; 131 | const std::string fixed_precision_type = "INT"; 132 | 133 | const std::string fp4_precision = "FP4"; 134 | const std::string fp8_precision = "FP8"; 135 | const std::string fp16_precision = "FP16"; 136 | const std::string fp32_precision = "FP32"; 137 | 138 | const std::string int4_precision = "INT4"; 139 | const std::string int8_precision = "INT8"; 140 | const std::string int16_precision = "INT16"; 141 | const std::string int32_precision = "INT32"; 142 | 143 | 144 | // Buffer Description 145 | const std::string buffer_decl_ = "Buffer"; 146 | const std::string buffer_tensor_decl_ = "Tensor"; 147 | const std::string buffer_size_decl_ = "Size"; 148 | const std::string buffer_type_decl_ = "Type"; 149 | const std::string buffer_type_fifo_ = "FIFO"; 150 | const std::string buffer_type_circular_fifo_ = "CFIFO"; 151 | const std::string buffer_type_scratchpad_ = "ScratchPad"; 152 | const std::string buffer_type_buffet_ = "Buffet"; 153 | 154 | }; 155 | 156 | } 157 | ; 158 | // End of name space maestro 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /cost-model/include/design-space-exploration/DSE_config.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_CONFIG_HPP_ 24 | #define MAESTRO_DSE_CONFIG_HPP_ 25 | 26 | namespace maestro { 27 | 28 | namespace DSE { 29 | 30 | enum class OptimizationTarget {Runtime, Energy, PerformancePerWatt}; 31 | 32 | }; // End of namespace DSE 33 | }; // End of namesapce maestro 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /cost-model/include/design-space-exploration/DSE_cost-database.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_COST_DATABASE_HPP_ 24 | #define MAESTRO_DSE_COST_DATABASE_HPP_ 25 | 26 | //namespace maestro { 27 | // namespace DSE { 28 | // namespace cost { 29 | // /* Embedded scaling model */ 30 | // 31 | // const double mac_area = 4470.9014; 32 | // const double mac_power = 1.2223; 33 | // const double mac_energy = 0.904; // nJ; Caution, it's from external source! 34 | // 35 | // const double sram_unit_size_64 = 64; 36 | // const double sram_area_64 = 4505.1889; 37 | // const double sram_power_64 = 0.2208; 38 | // 39 | // const double sram_unit_size_32768 = 32768; 40 | // const double sram_area_32768 = 4161.536; 41 | // const double sram_power_32768 = 4; 42 | // 43 | // const double bus_unit_area = 101.7938; 44 | // const double bus_unit_power = 0.8; 45 | // 46 | // const double arbiter_unit_area = 395.473; 47 | // const double arbiter_unit_power = 0.34; 48 | // 49 | // }; // End of namespace scaling_model 50 | // }; // End of namespace DSE 51 | //}; // End of namespace maestro 52 | 53 | 54 | //Felix 55 | // ref:"https://www.tomshardware.com/news/bfloat16-deep-dive-arm-bf16-support-armv8-a,40305.html" 56 | // ref:"https://cacm.acm.org/magazines/2020/7/245701-domain-specific-hardware-accelerators/fulltext" 57 | namespace maestro { 58 | namespace DSE { 59 | namespace cost { 60 | /* Embedded scaling model */ 61 | 62 | const double mac_area = 283; 63 | const double mac_power = 1.2223; 64 | const double mac_energy = 0.00023; // nJ; Caution, it's from external source! 65 | 66 | const double sram_unit_size_64 = 1; 67 | const double sram_area_64 = 0.104; 68 | const double sram_power_64 = 0.00345; 69 | 70 | const double sram_unit_size_32768 = 1; 71 | const double sram_area_32768 = 0.104; 72 | const double sram_power_32768 = 0.00345; 73 | 74 | const double bus_unit_area = 101.7938; 75 | const double bus_unit_power = 0.8; 76 | 77 | const double arbiter_unit_area = 395.473; 78 | const double arbiter_unit_power = 0.34; 79 | 80 | }; // End of namespace scaling_model 81 | }; // End of namespace DSE 82 | }; // End of namespace maestro 83 | // 84 | 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /cost-model/include/design-space-exploration/DSE_design-options.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_DSE_DESIGN_OPTIONS_HPP_ 2 | #define MAESTRO_DSE_DESIGN_OPTIONS_HPP_ 3 | 4 | namespace maestro { 5 | 6 | namespace DSE { 7 | 8 | enum class OpType{FloatPoint, FixedPoint}; 9 | }; // End of namespace DSE 10 | }; // End of namesapce maestro 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /cost-model/include/design-space-exploration/DSE_design_point.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_DESIGN_POINT_HPP_ 24 | #define MAESTRO_DSE_DESIGN_POINT_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "DSE_config.hpp" 31 | 32 | namespace maestro { 33 | namespace DSE { 34 | 35 | class DesignPoint { 36 | public: 37 | 38 | OptimizationTarget target_ = OptimizationTarget::Runtime; 39 | long runtime_ = 0; 40 | double energy_ = 0; 41 | long double performance_per_energy_ = 0; 42 | double area_ = 0; 43 | double power_ = 0; 44 | int num_pes_ = 1; 45 | int noc_bw_ = 16; 46 | int vector_width_ = 1; 47 | int l2_sram_sz = 1; 48 | int l1_sram_sz = 1; 49 | std::shared_ptr>> multicasting_factors_; 50 | 51 | DesignPoint(OptimizationTarget optimization_target, long runtime, 52 | double energy, long double performance_per_energy, double area, 53 | double power, int num_pes, int noc_bw, int vector_width, 54 | int l2_size, int l1_size) : 55 | target_(optimization_target), runtime_(runtime), energy_(energy), performance_per_energy_( 56 | performance_per_energy), area_(area), power_(power), num_pes_( 57 | num_pes), noc_bw_(noc_bw), vector_width_(vector_width), l2_sram_sz( 58 | l2_size), l1_sram_sz(l1_size) { 59 | multicasting_factors_ = std::make_shared< 60 | std::list>>(); 61 | } 62 | 63 | bool operator<(std::shared_ptr dp) { 64 | bool ret = false; 65 | if (dp != nullptr) { 66 | switch (target_) { 67 | case OptimizationTarget::Runtime: 68 | ret = runtime_ < dp->runtime_; 69 | break; 70 | case OptimizationTarget::Energy: 71 | ret = energy_ < dp->energy_; 72 | break; 73 | case OptimizationTarget::PerformancePerWatt: 74 | ret = performance_per_energy_ > dp->performance_per_energy_; 75 | break; 76 | } 77 | } 78 | return ret; 79 | } 80 | 81 | void PutMulticastingFactor(std::string dataclass, double factor) { 82 | multicasting_factors_->push_back(std::make_pair(dataclass, factor)); 83 | } 84 | 85 | double GetMulticastingFactor(std::string dataclass) { 86 | double ret = -1; 87 | for(auto& it : *multicasting_factors_) { 88 | if(it.first == dataclass) { 89 | ret = it.second; 90 | break; 91 | } 92 | } 93 | return ret; 94 | } 95 | 96 | void Print() { 97 | std::cout << "" << std::endl; 98 | std::cout << "Estimated runtime: " << runtime_ << std::endl; 99 | std::cout << "Estimated energy: " << energy_ << std::endl; 100 | std::cout << "Estimated area: " << area_ << std::endl; 101 | std::cout << "Estimated power: " << power_ << std::endl; 102 | std::cout << "Number of PEs: " << num_pes_ << std::endl; 103 | std::cout << "NoC bandwidth: " << noc_bw_ << std::endl; 104 | std::cout << "PE vector width: " << vector_width_ << std::endl; 105 | std::cout << "L2 size: " << l2_sram_sz << std::endl; 106 | std::cout << "L1 size: " << l1_sram_sz << std::endl; 107 | } 108 | 109 | }; 110 | // End of class DesignPoint 111 | } 112 | ; 113 | // End of namespace DSE 114 | } 115 | ; 116 | // End of namespace maestro 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /cost-model/include/design-space-exploration/DSE_scaling-coefficients.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_SCALING_COEFFICIENTS_HPP_ 24 | #define MAESTRO_DSE_SCALING_COEFFICIENTS_HPP_ 25 | 26 | namespace maestro { 27 | namespace DSE { 28 | namespace scaling_model { 29 | /* Embedded scaling model */ 30 | // Based on 28nm technology 31 | const double matrix_arbiter_c2 = 1.2886; 32 | const double matrix_arbirter_c1 = 5.5814; 33 | const double matrix_arbiter_c0 = -23.711; 34 | 35 | const double bus_c1 = 14.662; 36 | const double bus_c0 = 28.895; 37 | 38 | }; // End of namespace scaling_model 39 | }; // End of namespace DSE 40 | }; // End of namespace maestro 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /cost-model/include/maestro-marvel.h: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_MARVEL_HPP_ 2 | #define MAESTRO_MARVEL_HPP_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | #include 11 | 12 | #include "BASE_base-objects.hpp" 13 | #include "option.hpp" 14 | 15 | #include "DFA_tensor.hpp" 16 | 17 | #include "AHW_noc-model.hpp" 18 | 19 | #include "CA_cost-analysis-results.hpp" 20 | 21 | #include "API_configuration.hpp" 22 | #include "API_user-interface.hpp" 23 | #include "API_user-interface-v2.hpp" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | std::map 32 | maestro_get_costs( 33 | int num_pes, 34 | int l1_buffer_size, 35 | int l2_buffer_size, 36 | int noc_bw, 37 | std::shared_ptr layer); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /cost-model/include/tools/TL_analysis-results-csv-writer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_ERROR_HANDLER_HPP_ 24 | #define MAESTRO_TL_ERROR_HANDLER_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | namespace maestro { 32 | namespace TL { 33 | class AnalysisResCSVWriter { 34 | public: 35 | AnalysisResCSVWriter(std::string file_name) { 36 | outfile_.open(file_name); 37 | 38 | } 39 | protected: 40 | std::ofstream outfile_; 41 | 42 | }; // End of class AnalysisResCSVWriter 43 | }; // End of namespace TL 44 | }; // End of namespace maestro 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /cost-model/include/tools/TL_error-handler.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_ERROR_HANDLER_HPP_ 24 | #define MAESTRO_TL_ERROR_HANDLER_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | namespace maestro { 30 | namespace TL { 31 | 32 | enum class ErrorCode { 33 | NoSpatialMap, 34 | MissingDimension, 35 | NotEnoughSpDim, 36 | DuplicatedDimDefinition, 37 | DoubleDimDefinition, 38 | InvalidCluster, 39 | InvalidClusterLevel, 40 | IllegalClusterConstruction, 41 | IllegalTemporalEdgeSp, 42 | InvalidTemporalEdgeSz, 43 | InvalidDirective, 44 | InvalidDimension, 45 | InvalidAnalysisCase, 46 | EdgeOnSpatialMap, 47 | NotEnoughL2Buffer, 48 | NotEnoughL1Buffer, 49 | MultiParallelismInSingleCluster, 50 | MissingNoCForCluster, 51 | NotSupportedLayerType 52 | }; 53 | 54 | class ErrorHandler { 55 | public: 56 | void PrintErrorMsg(ErrorCode error_code, std::string opt, std::string instance_name = "") { 57 | switch(error_code) { 58 | case ErrorCode::NoSpatialMap: { 59 | std::cout << "(Error@ " << instance_name << ") Cluster level: " << opt << ", No spatial map in a cluster" << std::endl; 60 | break; 61 | } 62 | case ErrorCode::MissingDimension: { 63 | std::cout << "(Error@ " << instance_name << ") Dimension " << opt << " not found" << std::endl; 64 | break; 65 | } 66 | case ErrorCode::NotEnoughSpDim: { 67 | std::cout << "(Error@ " << instance_name << ") Dimension " << opt << " is not sufficient for conv windows" << std::endl; 68 | break; 69 | } 70 | case ErrorCode::DuplicatedDimDefinition: { 71 | std::cout << "(Error@ " << instance_name << ") Trying to re-define the operator dimension " << opt << std::endl; 72 | break; 73 | } 74 | case ErrorCode::DoubleDimDefinition: { 75 | std::cout << "(Error@ " << instance_name << ") Both input- and output-centric dimension definition is used. " << opt << std::endl; 76 | break; 77 | } 78 | case ErrorCode::InvalidCluster: { 79 | std::cout << "(Error@ " << instance_name << ") Cluster level " << opt << " contains directives other than temporal and spatial map" << std::endl; 80 | break; 81 | } 82 | case ErrorCode::IllegalClusterConstruction: { 83 | std::cout << "(Error@ " << instance_name << ") Specified cluster does not cover entire number of PEs" << std::endl; 84 | break; 85 | } 86 | case ErrorCode::InvalidClusterLevel: { 87 | std::cout << "(Error@ " << instance_name << ") Cluster level " << opt << " does not exist" << std::endl; 88 | break; 89 | } 90 | case ErrorCode::IllegalTemporalEdgeSp: { 91 | std::cout << "(Error@ " << instance_name << ") variable " << opt << " is spatially mapped but temporal edge is set" << std::endl; 92 | break; 93 | } 94 | case ErrorCode::InvalidTemporalEdgeSz: { 95 | std::cout << "(Error@ " << instance_name << ") variable " << opt << " does not have edge" << std::endl; 96 | break; 97 | } 98 | case ErrorCode::InvalidDirective: { 99 | std::cout << "(Error@ " << instance_name << ") found an invalid directive on variable " << opt << "." << std::endl; 100 | break; 101 | } 102 | 103 | case ErrorCode::InvalidDimension: { 104 | std::cout << "(Error@ " << instance_name << ") encountered an invalid dimension " << opt << "." << std::endl; 105 | break; 106 | } 107 | 108 | case ErrorCode::InvalidAnalysisCase: { 109 | std::cout << "(Error@ " << instance_name << ") encountered an invalid analysis case. " << std::endl; 110 | break; 111 | } 112 | 113 | case ErrorCode::EdgeOnSpatialMap: { 114 | std::cout << "(Error@ " << instance_name << ") Dataflow cannot have edge on spatial map. Please check the mapping size of spatial map at cluter level " << opt << "." << std::endl; 115 | break; 116 | } 117 | 118 | case ErrorCode::NotEnoughL1Buffer: { 119 | std::cout << "(Error@ " << instance_name << ") The required L1 buffer size " << opt << " is larger than your L1 size. Reduce the L1 tile size by reducing mapping sizes." << std::endl; 120 | break; 121 | } 122 | 123 | case ErrorCode::NotEnoughL2Buffer: { 124 | std::cout << "(Error@ " << instance_name << ") The required L2 buffer size " << opt << " is larger than your L2 size. Reduce the L2 tile size by reducing mapping sizes." << std::endl; 125 | break; 126 | } 127 | 128 | 129 | case ErrorCode::MultiParallelismInSingleCluster: { 130 | std::cout << "(Error@ " << instance_name << ") Found too many spatial maps within a single cluster. Cluster level: " << opt << "." << std::endl; 131 | break; 132 | } 133 | 134 | case ErrorCode::MissingNoCForCluster: { 135 | std::cout << "(Error@ " << instance_name << ") NoC is not defined at cluster level " << opt << "." << std::endl; 136 | break; 137 | } 138 | 139 | case ErrorCode::NotSupportedLayerType: { 140 | std::cout << "(Error@ " << instance_name << ") Not supported layer type. " << std::endl; 141 | break; 142 | } 143 | 144 | default: { 145 | std::cout << "(Error) Error in class " << opt << std::endl; 146 | } 147 | } 148 | 149 | this->TerminateProgram(); 150 | } 151 | 152 | void TerminateProgram() { 153 | exit(-1); 154 | } 155 | 156 | protected: 157 | 158 | }; // End of class ErrorHandler 159 | 160 | }; // End of namespace DFA 161 | }; // End of namespace maestro 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /cost-model/include/tools/TL_generic-csv-writer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #include "BASE_maestro-class.hpp" 23 | 24 | namespace maestro { 25 | 26 | namespace TL { 27 | 28 | class GenericCSVWriter : public MAESTROClass { 29 | GenericCSVWriter() { 30 | 31 | } 32 | 33 | 34 | }; // End of class GenericCSVWriter 35 | 36 | 37 | }; // End of namespace TL (Tool) 38 | 39 | }; // End of namespace maestro 40 | -------------------------------------------------------------------------------- /cost-model/include/tools/TL_message-printer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_MESSAGE_PRINTER_HPP_ 24 | #define MAESTRO_TL_MESSAGE_PRINTER_HPP_ 25 | 26 | #include 27 | 28 | namespace maestro { 29 | namespace TL { 30 | class MessagePrinter { 31 | public: 32 | MessagePrinter(int target_lv) : print_lv_(target_lv) { 33 | } 34 | 35 | void PrintMsg(int lv, std::string msg, bool change_line = true) { 36 | if(lv <= print_lv_) { 37 | if(change_line) { 38 | std::cout << msg << std::endl; 39 | } 40 | else { 41 | std::cout << msg; 42 | } 43 | } 44 | } 45 | 46 | void SetPrintLv(int new_lv) { 47 | print_lv_ = new_lv; 48 | } 49 | 50 | protected: 51 | int print_lv_= 0; 52 | }; 53 | 54 | 55 | }; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /cost-model/include/user-api/API_configuration.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef API_CONFIGURATION_HPP_ 24 | #define API_CONFIGURATION_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | //#include "option.hpp" 30 | 31 | #include "BASE_base-objects.hpp" 32 | 33 | #include "DFA_tensor.hpp" 34 | #include "DFA_neural-network.hpp" 35 | #include "DFA_cluster-analysis.hpp" 36 | 37 | #include "DSE_hardware_modules.hpp" 38 | 39 | #include "AHW_noc-model.hpp" 40 | 41 | 42 | 43 | namespace maestro { 44 | 45 | class Configuration { 46 | 47 | public: 48 | Configuration(int num_pes, int vector_width, int top_noc_bw, int l1_sram_byte_size, int l2_sram_byte_size) 49 | : num_pes_(num_pes) { 50 | network_= std::make_shared(); 51 | tensors_ = std::make_shared(); 52 | nocs_ = std::make_shared>>(); 53 | cluster_analysis_= std::make_shared>>(); 54 | target_accelerator_ = std::make_shared 55 | (num_pes, vector_width, top_noc_bw, l1_sram_byte_size, l2_sram_byte_size); 56 | 57 | 58 | } 59 | /* 60 | Accelerator (int num_pes, int vector_width, int noc_bw, int l1_sram_byte_size, int l2_sram_byte_size) 61 | : num_pes_(num_pes), vector_width_(vector_width), noc_bw_(noc_bw) { 62 | ReconstructAccelerator(num_pes, vector_width, noc_bw, l1_sram_byte_size, l2_sram_byte_size); 63 | } 64 | */ 65 | std::shared_ptr network_; 66 | std::shared_ptr tensors_; 67 | std::shared_ptr>> cluster_analysis_; 68 | 69 | //Hardware 70 | std::shared_ptr target_accelerator_; 71 | std::shared_ptr>> nocs_; 72 | 73 | int num_pes_; 74 | }; // End of class Configuration 75 | 76 | class ConfigurationV2 { 77 | 78 | public: 79 | ConfigurationV2( 80 | std::string dfsl_file_name, 81 | std::string hw_file_name, 82 | std::shared_ptr> noc_bw, 83 | std::shared_ptr> noc_latency, 84 | std::shared_ptr> noc_multcast, 85 | int num_pes, 86 | int simd_width, 87 | int top_noc_bw, 88 | int l1_sram_byte_size, 89 | int l2_sram_byte_size, 90 | int offchip_bw) : 91 | dfsl_file_name_(dfsl_file_name), 92 | hw_file_name_(hw_file_name), 93 | noc_multcast_(noc_multcast), 94 | noc_latency_(noc_latency), 95 | noc_bw_(noc_bw), 96 | offchip_bw_(offchip_bw), 97 | num_pes_(num_pes), 98 | simd_width_(simd_width), 99 | l1_size_(l1_sram_byte_size), 100 | l2_size_(l2_sram_byte_size) { 101 | network_= std::make_shared(); 102 | tensors_ = std::make_shared>>(); 103 | nocs_ = std::make_shared>>(); 104 | cluster_analysis_= std::make_shared>>(); 105 | //TODO: Update NoC setup processes 106 | target_accelerator_ = std::make_shared 107 | (num_pes, simd_width, top_noc_bw, l1_sram_byte_size, l2_sram_byte_size); 108 | } 109 | 110 | std::string dfsl_file_name_; 111 | std::string hw_file_name_; 112 | 113 | 114 | std::shared_ptr network_; 115 | 116 | std::shared_ptr>> tensors_; 117 | std::shared_ptr>> cluster_analysis_; 118 | 119 | //Hardware 120 | std::shared_ptr target_accelerator_; 121 | std::shared_ptr>> nocs_; 122 | 123 | std::shared_ptr> noc_multcast_; 124 | std::shared_ptr> noc_latency_; 125 | std::shared_ptr> noc_bw_; 126 | 127 | int num_pes_; 128 | int simd_width_; 129 | int l1_size_; 130 | int l2_size_; 131 | int offchip_bw_; 132 | }; // End of class Configuration 133 | 134 | 135 | 136 | 137 | }; // End of namespace maestro 138 | 139 | 140 | #endif 141 | -------------------------------------------------------------------------------- /cost-model/src/BASE_base-objects.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #include 23 | 24 | #include "TL_error-handler.hpp" 25 | #include "TL_message-printer.hpp" 26 | 27 | namespace maestro { 28 | 29 | //Singleton objects for common functionalities 30 | std::shared_ptr error_handler; 31 | std::shared_ptr message_printer; 32 | int printout_level = 0; 33 | 34 | void InitializeBaseObjects(int print_lv = 0) { 35 | error_handler = std::make_shared(); 36 | message_printer = std::make_shared(print_lv); 37 | } 38 | 39 | void SetPrintOutLevel(int new_lv) { 40 | message_printer->SetPrintLv(new_lv); 41 | } 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /cost-model/src/maestro-marvel.cpp: -------------------------------------------------------------------------------- 1 | #include "maestro-marvel.h" 2 | 3 | 4 | void handler(int sig) { 5 | void *array[10]; 6 | size_t size; 7 | 8 | // get void*'s for all entries on the stack 9 | size = backtrace(array, 10); 10 | 11 | // print out all the frames to stderr 12 | fprintf(stderr, "Error: signal %d:\n", sig); 13 | backtrace_symbols_fd(array, size, STDERR_FILENO); 14 | exit(1); 15 | } 16 | 17 | 18 | 19 | /*std::vector maestro_get_costs_old( 20 | int num_pes, 21 | int l1_buffer_size, 22 | int l2_buffer_size, 23 | int noc_bw, 24 | std::shared_ptr layer) { 25 | 26 | signal(SIGSEGV, handler); 27 | 28 | maestro::Options option; 29 | option.np = num_pes; 30 | option.l1_size = l1_buffer_size; 31 | option.l2_size = l2_buffer_size; 32 | option.bw = noc_bw; 33 | option.hop_latency = 1; 34 | option.do_implicit_reduction = true; 35 | option.fg_sync = false; 36 | option.do_reduction = true; 37 | option.mc = true; 38 | 39 | maestro::InitializeBaseObjects(); 40 | 41 | auto maestro_config = std::make_shared( 42 | option.np, 1, 43 | option.bw, option.l1_size, option.l2_size); 44 | 45 | auto maestro_api = std::make_shared( 46 | maestro_config); 47 | 48 | maestro_api->CreateNetworkWithALayer(layer, false); 49 | 50 | *//* Construct the convolution problem *//* 51 | std::list input_correlated_vars = {"C", "Y", "X"}; 52 | std::list weight_correlated_vars = {"K", "C", "R", "S"}; 53 | std::list output_correlated_vars = {"K", "Y", "X"}; 54 | 55 | maestro_api->AddTensor("input", maestro::DFA::TensorClass::InputTensor, maestro::DataClass::Input, input_correlated_vars); 56 | maestro_api->AddTensor("weight", maestro::DFA::TensorClass::InputTensor, maestro::DataClass::Weight, weight_correlated_vars); 57 | maestro_api->AddTensor("output", maestro::DFA::TensorClass::OutputTensor, maestro::DataClass::Output, output_correlated_vars); 58 | 59 | //Applying different NoC for each cluster is also possible (add more nocs; 60 | //the following function add the noc to the next lower cluster level 61 | maestro_api->AddNoC(option.bw, option.hops, option.hop_latency, option.mc, false); 62 | maestro_api->AddNoC(option.bw, option.hops, option.hop_latency, option.mc, false); 63 | maestro_api->AddNoC(option.bw, option.hops, option.hop_latency, option.mc, false); 64 | maestro_api->AddNoC(option.bw, option.hops, option.hop_latency, option.mc, false); 65 | 66 | std::shared_ptr>>> overlap_dim_list = std::make_shared>>>(); 67 | auto output_column_overlap = std::make_shared>("X", "S"); 68 | auto output_row_overlap = std::make_shared>("Y", "R"); 69 | overlap_dim_list->push_back(output_column_overlap); 70 | overlap_dim_list->push_back(output_row_overlap); 71 | 72 | maestro_api->AnalyzeClusters(overlap_dim_list,false); 73 | 74 | auto analysis_result = maestro_api->AnalyzeNeuralNetwork(false); 75 | 76 | std::vector costs; 77 | for(auto& layer_res : *analysis_result) { 78 | int cluster_lv = 0; 79 | for(auto& cluster_res : *layer_res) { 80 | if(cluster_lv == layer_res->size()-1) { 81 | maestro_api->GetCostsFromAnalysisResultsSingleCluster( 82 | cluster_res, costs); 83 | } 84 | 85 | cluster_lv++; 86 | } 87 | } 88 | 89 | return costs; 90 | }*/ 91 | 92 | 93 | std::map 94 | maestro_get_costs( 95 | int num_pes, 96 | int l1_buffer_size, 97 | int l2_buffer_size, 98 | int noc_bw_value, 99 | std::shared_ptr layer) { 100 | 101 | signal(SIGSEGV, handler); 102 | 103 | maestro::Options option; 104 | option.np = num_pes; 105 | option.l1_size = l1_buffer_size; 106 | option.l2_size = l2_buffer_size; 107 | option.bw = noc_bw_value; 108 | option.num_simd_lanes = 1; 109 | option.hop_latency = 1; 110 | option.do_implicit_reduction = true; 111 | option.fg_sync = false; 112 | option.do_reduction = true; 113 | option.mc = true; 114 | 115 | maestro::InitializeBaseObjects(); 116 | 117 | maestro::SetPrintOutLevel(-1); 118 | 119 | std::shared_ptr> noc_multcast = std::make_shared>(); 120 | std::shared_ptr> noc_latency = std::make_shared>(); 121 | std::shared_ptr> noc_bw = std::make_shared>(); 122 | 123 | noc_bw->push_back(option.bw); 124 | noc_bw->push_back(option.bw); 125 | noc_bw->push_back(option.bw); 126 | 127 | noc_latency->push_back(option.hop_latency * option.hops); 128 | noc_latency->push_back(option.hop_latency * option.hops); 129 | noc_latency->push_back(option.hop_latency * option.hops); 130 | 131 | noc_multcast->push_back(true); 132 | noc_multcast->push_back(true); 133 | noc_multcast->push_back(true); 134 | 135 | 136 | auto config = std::make_shared( 137 | option.dfsl_file_name, 138 | noc_bw, 139 | noc_latency, 140 | noc_multcast, 141 | option.np, 142 | option.num_simd_lanes, 143 | option.bw, 144 | option.l1_size, 145 | option.l2_size 146 | ); 147 | 148 | 149 | auto api = std::make_shared(config, layer); 150 | 151 | auto analysis_result = api->AnalyzeNeuralNetwork(false, false); 152 | 153 | std::map costs; 154 | for(auto& layer_res : *analysis_result) { 155 | int cluster_lv = 0; 156 | for(auto& cluster_res : *layer_res) { 157 | if(cluster_lv == layer_res->size()-1) { 158 | api->GetCostsFromAnalysisResultsSingleCluster( 159 | cluster_res, costs); 160 | } 161 | 162 | cluster_lv++; 163 | } 164 | } 165 | 166 | return costs; 167 | } 168 | -------------------------------------------------------------------------------- /data/hw/accelerator_1.m: -------------------------------------------------------------------------------- 1 | num_pes: 256 2 | l1_size_cstr: 100 3 | l2_size_cstr: 3000 4 | noc_bw_cstr: 1000 5 | offchip_bw_cstr: 50 6 | -------------------------------------------------------------------------------- /data/mapping/GEMM_Example.m: -------------------------------------------------------------------------------- 1 | // BLAS 3 - Dense Matrix-Dense Matrix multiplication 2 | // Constants are in GEMM convention; (MxK matrix) x (KxN matrix) = (MxN matrix) 3 | Constant SzM 100; 4 | Constant SzN 100; 5 | Constant SzK 100; 6 | 7 | // Optimize for data reuse 8 | // Constant MTileSz 10; 9 | // Constant NTileSz 50; 10 | // Constant KTileSz 100; 11 | 12 | // Optimize for throughput 13 | Constant MTileSz 1; 14 | Constant NTileSz 1; 15 | Constant KTileSz 100; 16 | 17 | 18 | Network BLAS3 { 19 | Layer BLAS { 20 | Type: GEMM 21 | Dimensions { K: SzK, M: SzM, N: SzN } 22 | Dataflow { 23 | TemporalMap(NTileSz,NTileSz) N; 24 | SpatialMap(MTileSz,MTileSz) M; 25 | TemporalMap(KTileSz,KTileSz) K; 26 | Cluster(KTileSz, P); 27 | TemporalMap(NTileSz,NTileSz) N; 28 | TemporalMap(MTileSz,MTileSz) M; 29 | SpatialMap(1,1) K; 30 | } 31 | } 32 | } 33 | 34 | // Network BLAS3 { 35 | // Layer BLAS { 36 | // Type: CONV 37 | // Stride { X: 1, Y: 1 } 38 | // Dimensions { K: SzN, C: 1, R: 1, S: SzK, Y: SzM, X: SzK } 39 | // Dataflow { 40 | // TemporalMap(NTileSz,NTileSz) K; 41 | // SpatialMap(MTileSz,MTileSz) Y; 42 | // TemporalMap(SzK,SzK) X; 43 | // TemporalMap(SzK,SzK) S; 44 | // Cluster(1,P); 45 | // SpatialMap(KTileSz,KTileSz) X; 46 | // TemporalMap(KTileSz,KTileSz) S; 47 | // Cluster(KTileSz,P); 48 | // SpatialMap(1,1) X; 49 | // SpatialMap(1,1) S; 50 | // } 51 | // } 52 | // } -------------------------------------------------------------------------------- /data/mapping/Transformer_Layers.m: -------------------------------------------------------------------------------- 1 | //Make some assumptions 2 | // let's assume seq_len = 64 for now 3 | // N d_mod d_ff h dk dv 4 | // 6 512 2048 8 64 64 5 | Constant Seq_Len 128; 6 | 7 | Network Transformer { 8 | //Start encoder 9 | Layer MH_FC_DimReduce_VKQ_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 10 | Type: CONV 11 | Stride { X: 1, Y: 1 } // k = 3 * 512, one for each VKQ 12 | Dimensions { N: Seq_Len, K: 1536, C: 1, R: 1, S: 512, Y:1, X:512 } 13 | Dataflow { 14 | SpatialMap(1,1) K; 15 | TemporalMap(1,1) C; 16 | TemporalMap(Sz(R),Sz(R)) R; 17 | TemporalMap(Sz(S),Sz(S)) S; 18 | TemporalMap(Sz(R),1) Y; 19 | TemporalMap(Sz(S),1) X; 20 | Cluster(1, P); 21 | SpatialMap(1,1) C; 22 | TemporalMap(Sz(R),1) Y; 23 | TemporalMap(Sz(S),1) X; 24 | TemporalMap(Sz(R),Sz(R)) R; 25 | TemporalMap(Sz(S),Sz(S)) S; 26 | } 27 | } //good 28 | 29 | Layer SD_MatMul_QK_00 { //Mat mul, batch is 1 30 | Type: CONV //MatMul -> M(seql)xK(dv)xN(seql)-> filter = Kx1(m chans), input = KxN 31 | Stride { X: 1, Y: 1 } 32 | //N=1, K(conv)=M(matr), C=1, R(conv)=K(matr),S=1,Y(conv)=K(matr), X(conv)=N(matr) 33 | Dimensions { N: 1, K: Seq_Len, C: 1, R: 64, S: 1, Y:64, X:Seq_Len } 34 | Dataflow { 35 | SpatialMap(2,1) K; 36 | TemporalMap(1,1) C; 37 | TemporalMap(Sz(R),Sz(R)) R; 38 | TemporalMap(Sz(S),Sz(S)) S; 39 | TemporalMap(Sz(R),1) Y; 40 | TemporalMap(Sz(S),1) X; 41 | 42 | } 43 | } 44 | 45 | Layer SD_MatMul_V_00 { //Mat mul, batch is 1 46 | Type: CONV //MatMul -> M(seql)xK(seql)xN(dv)-> filter = Kx1(m chans), input = KxN 47 | Stride { X: 1, Y: 1 } 48 | //N=1, K(conv)=M(matr), C=1, R(conv)=K(matr),S=1,Y(conv)=K(matr), X(conv)=N(matr) 49 | Dimensions { N: 1, K: Seq_Len, C: 1, R: Seq_Len, S: 1, Y:Seq_Len, X:64 } 50 | Dataflow { 51 | SpatialMap(1,1) K; 52 | TemporalMap(1,1) C; 53 | TemporalMap(Sz(R),Sz(R)) R; 54 | TemporalMap(Sz(S),Sz(S)) S; 55 | TemporalMap(Sz(R),1) Y; 56 | TemporalMap(Sz(S),1) X; 57 | Cluster(1, P); 58 | SpatialMap(1,1) C; 59 | TemporalMap(Sz(R),1) Y; 60 | TemporalMap(Sz(S),1) X; 61 | TemporalMap(Sz(R),Sz(R)) R; 62 | TemporalMap(Sz(S),Sz(S)) S; 63 | } 64 | } 65 | 66 | // done with h parallel sd layers now 67 | Layer MH_FC_DimRecast_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 68 | Type: CONV 69 | Stride { X: 1, Y: 1 } // v,k,q have been combined 70 | Dimensions { N: Seq_Len, K: 512, C: 1, R: 1, S: 512, Y:1, X:512 } 71 | Dataflow { 72 | SpatialMap(1,1) K; 73 | TemporalMap(1,1) C; 74 | TemporalMap(Sz(R),Sz(R)) R; 75 | TemporalMap(Sz(S),Sz(S)) S; 76 | TemporalMap(Sz(R),1) Y; 77 | TemporalMap(Sz(S),1) X; 78 | Cluster(1, P); 79 | SpatialMap(1,1) C; 80 | TemporalMap(Sz(R),1) Y; 81 | TemporalMap(Sz(S),1) X; 82 | TemporalMap(Sz(R),Sz(R)) R; 83 | TemporalMap(Sz(S),Sz(S)) S; 84 | } 85 | } //good 86 | 87 | /// done with h parallel sd layers now 88 | Layer FF_A_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 89 | Type: CONV //2048 output neurons, 512->2048 90 | Stride { X: 1, Y: 1 } 91 | Dimensions { N: Seq_Len, K: 2048, C: 1, R: 1, S: 512, Y:1, X:512 } 92 | Dataflow { 93 | SpatialMap(1,1) K; 94 | TemporalMap(1,1) C; 95 | TemporalMap(Sz(R),Sz(R)) R; 96 | TemporalMap(Sz(S),Sz(S)) S; 97 | TemporalMap(Sz(R),1) Y; 98 | TemporalMap(Sz(S),1) X; 99 | Cluster(1, P); 100 | SpatialMap(1,1) C; 101 | TemporalMap(Sz(R),1) Y; 102 | TemporalMap(Sz(S),1) X; 103 | TemporalMap(Sz(R),Sz(R)) R; 104 | TemporalMap(Sz(S),Sz(S)) S; 105 | } 106 | } //good 107 | 108 | /// done with h parallel sd layers now 109 | Layer FF_B_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 110 | Type: CONV //2048 -> 512 111 | Stride { X: 1, Y: 1 } 112 | Dimensions { N: Seq_Len, K: 512, C: 1, R: 1, S: 2048, Y:1, X:2048 } 113 | Dataflow { 114 | SpatialMap(1,1) K; 115 | TemporalMap(1,1) C; 116 | TemporalMap(Sz(R),Sz(R)) R; 117 | TemporalMap(Sz(S),Sz(S)) S; 118 | TemporalMap(Sz(R),1) Y; 119 | TemporalMap(Sz(S),1) X; 120 | Cluster(1, P); 121 | SpatialMap(1,1) C; 122 | TemporalMap(Sz(R),1) Y; 123 | TemporalMap(Sz(S),1) X; 124 | TemporalMap(Sz(R),Sz(R)) R; 125 | TemporalMap(Sz(S),Sz(S)) S; 126 | } 127 | } //good 128 | 129 | 130 | } 131 | 132 | -------------------------------------------------------------------------------- /data/mapping/example.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | Network ResNeXt50 { 4 | Layer CONV1 { 5 | Type: CONV 6 | Stride { X: 1, Y: 1 } 7 | Dimensions { K: 64, C: 128, R: 3, S: 3, Y:224, X:224 } 8 | Dataflow { 9 | SpatialMap(1,1) K; 10 | TemporalMap(64,64) C; 11 | TemporalMap(Sz(R),Sz(R)) R; 12 | TemporalMap(Sz(S),Sz(S)) S; 13 | TemporalMap(Sz(R),1) Y; 14 | TemporalMap(Sz(S),1) X; 15 | Cluster(64, P); 16 | SpatialMap(1,1) C; 17 | TemporalMap(Sz(R),1) Y; 18 | TemporalMap(Sz(S),1) X; 19 | TemporalMap(Sz(R),Sz(R)) R; 20 | TemporalMap(Sz(S),Sz(S)) S; 21 | } 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /data/mapping/gnmt_nmk.m: -------------------------------------------------------------------------------- 1 | Constant MTileSz 1; 2 | Constant NTileSz 1; 3 | Constant KTileSz 100; 4 | Network gnmt_gemm { 5 | Layer GEMM0 { 6 | Type: GEMM 7 | Dimensions { N: 2048, K: 4096, M: 128 } 8 | Dataflow { 9 | TemporalMap(NTileSz,NTileSz) N; 10 | SpatialMap(MTileSz,MTileSz) M; 11 | TemporalMap(KTileSz,KTileSz) K; 12 | Cluster(KTileSz, P); 13 | TemporalMap(NTileSz,NTileSz) N; 14 | TemporalMap(MTileSz,MTileSz) M; 15 | SpatialMap(1,1) K; 16 | } 17 | } 18 | Layer GEMM1 { 19 | Type: GEMM 20 | Dimensions { N: 2048, K: 4096, M: 128 } 21 | Dataflow { 22 | TemporalMap(NTileSz,NTileSz) N; 23 | SpatialMap(MTileSz,MTileSz) M; 24 | TemporalMap(KTileSz,KTileSz) K; 25 | Cluster(KTileSz, P); 26 | TemporalMap(NTileSz,NTileSz) N; 27 | TemporalMap(MTileSz,MTileSz) M; 28 | SpatialMap(1,1) K; 29 | } 30 | } 31 | Layer GEMM2 { 32 | Type: GEMM 33 | Dimensions { N: 3072, K: 4096, M: 320 } 34 | Dataflow { 35 | TemporalMap(NTileSz,NTileSz) N; 36 | SpatialMap(MTileSz,MTileSz) M; 37 | TemporalMap(KTileSz,KTileSz) K; 38 | Cluster(KTileSz, P); 39 | TemporalMap(NTileSz,NTileSz) N; 40 | TemporalMap(MTileSz,MTileSz) M; 41 | SpatialMap(1,1) K; 42 | } 43 | } 44 | Layer GEMM3 { 45 | Type: GEMM 46 | Dimensions { N: 2048, K: 4096, M: 128 } 47 | Dataflow { 48 | TemporalMap(NTileSz,NTileSz) N; 49 | SpatialMap(MTileSz,MTileSz) M; 50 | TemporalMap(KTileSz,KTileSz) K; 51 | Cluster(KTileSz, P); 52 | TemporalMap(NTileSz,NTileSz) N; 53 | TemporalMap(MTileSz,MTileSz) M; 54 | SpatialMap(1,1) K; 55 | } 56 | } 57 | Layer GEMM4 { 58 | Type: GEMM 59 | Dimensions { N: 2048, K: 4096, M: 128 } 60 | Dataflow { 61 | TemporalMap(NTileSz,NTileSz) N; 62 | SpatialMap(MTileSz,MTileSz) M; 63 | TemporalMap(KTileSz,KTileSz) K; 64 | Cluster(KTileSz, P); 65 | TemporalMap(NTileSz,NTileSz) N; 66 | TemporalMap(MTileSz,MTileSz) M; 67 | SpatialMap(1,1) K; 68 | } 69 | } 70 | Layer GEMM5 { 71 | Type: GEMM 72 | Dimensions { N: 3072, K: 4096, M: 320 } 73 | Dataflow { 74 | TemporalMap(NTileSz,NTileSz) N; 75 | SpatialMap(MTileSz,MTileSz) M; 76 | TemporalMap(KTileSz,KTileSz) K; 77 | Cluster(KTileSz, P); 78 | TemporalMap(NTileSz,NTileSz) N; 79 | TemporalMap(MTileSz,MTileSz) M; 80 | SpatialMap(1,1) K; 81 | } 82 | } 83 | Layer GEMM6 { 84 | Type: GEMM 85 | Dimensions { N: 3072, K: 4096, M: 320 } 86 | Dataflow { 87 | TemporalMap(NTileSz,NTileSz) N; 88 | SpatialMap(MTileSz,MTileSz) M; 89 | TemporalMap(KTileSz,KTileSz) K; 90 | Cluster(KTileSz, P); 91 | TemporalMap(NTileSz,NTileSz) N; 92 | TemporalMap(MTileSz,MTileSz) M; 93 | SpatialMap(1,1) K; 94 | } 95 | } 96 | Layer GEMM7 { 97 | Type: GEMM 98 | Dimensions { N: 3072, K: 4096, M: 320 } 99 | Dataflow { 100 | TemporalMap(NTileSz,NTileSz) N; 101 | SpatialMap(MTileSz,MTileSz) M; 102 | TemporalMap(KTileSz,KTileSz) K; 103 | Cluster(KTileSz, P); 104 | TemporalMap(NTileSz,NTileSz) N; 105 | TemporalMap(MTileSz,MTileSz) M; 106 | SpatialMap(1,1) K; 107 | } 108 | } 109 | Layer GEMM8 { 110 | Type: GEMM 111 | Dimensions { N: 3072, K: 4096, M: 320 } 112 | Dataflow { 113 | TemporalMap(NTileSz,NTileSz) N; 114 | SpatialMap(MTileSz,MTileSz) M; 115 | TemporalMap(KTileSz,KTileSz) K; 116 | Cluster(KTileSz, P); 117 | TemporalMap(NTileSz,NTileSz) N; 118 | TemporalMap(MTileSz,MTileSz) M; 119 | SpatialMap(1,1) K; 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /data/mapping/ncf_nmk.m: -------------------------------------------------------------------------------- 1 | Constant MTileSz 1; 2 | Constant NTileSz 1; 3 | Constant KTileSz 100; 4 | 5 | Network ncf_gemm { 6 | Layer GEMM0 { 7 | Type: GEMM 8 | Dimensions { N: 128, K: 2048, M: 256 } 9 | Dataflow { 10 | TemporalMap(NTileSz,NTileSz) N; 11 | SpatialMap(MTileSz,MTileSz) M; 12 | TemporalMap(KTileSz,KTileSz) K; 13 | Cluster(KTileSz, P); 14 | TemporalMap(NTileSz,NTileSz) N; 15 | TemporalMap(MTileSz,MTileSz) M; 16 | SpatialMap(1,1) K; 17 | } 18 | } 19 | Layer GEMM1 { 20 | Type: GEMM 21 | Dimensions { N: 64, K: 2048, M: 128 } 22 | Dataflow { 23 | TemporalMap(NTileSz,NTileSz) N; 24 | SpatialMap(MTileSz,MTileSz) M; 25 | TemporalMap(KTileSz,KTileSz) K; 26 | Cluster(KTileSz, P); 27 | TemporalMap(NTileSz,NTileSz) N; 28 | TemporalMap(MTileSz,MTileSz) M; 29 | SpatialMap(1,1) K; 30 | } 31 | } 32 | Layer GEMM2 { 33 | Type: GEMM 34 | Dimensions { N: 256, K: 2048, M: 256 } 35 | Dataflow { 36 | TemporalMap(NTileSz,NTileSz) N; 37 | SpatialMap(MTileSz,MTileSz) M; 38 | TemporalMap(KTileSz,KTileSz) K; 39 | Cluster(KTileSz, P); 40 | TemporalMap(NTileSz,NTileSz) N; 41 | TemporalMap(MTileSz,MTileSz) M; 42 | SpatialMap(1,1) K; 43 | } 44 | } 45 | Layer GEMM3 { 46 | Type: GEMM 47 | Dimensions { N: 256, K: 256, M: 2048 } 48 | Dataflow { 49 | TemporalMap(NTileSz,NTileSz) N; 50 | SpatialMap(MTileSz,MTileSz) M; 51 | TemporalMap(KTileSz,KTileSz) K; 52 | Cluster(KTileSz, P); 53 | TemporalMap(NTileSz,NTileSz) N; 54 | TemporalMap(MTileSz,MTileSz) M; 55 | SpatialMap(1,1) K; 56 | } 57 | } 58 | Layer GEMM4 { 59 | Type: GEMM 60 | Dimensions { N: 256, K: 256, M: 2048 } 61 | Dataflow { 62 | TemporalMap(NTileSz,NTileSz) N; 63 | SpatialMap(MTileSz,MTileSz) M; 64 | TemporalMap(KTileSz,KTileSz) K; 65 | Cluster(KTileSz, P); 66 | TemporalMap(NTileSz,NTileSz) N; 67 | TemporalMap(MTileSz,MTileSz) M; 68 | SpatialMap(1,1) K; 69 | } 70 | } 71 | Layer GEMM5 { 72 | Type: GEMM 73 | Dimensions { N: 128, K: 256, M: 2048 } 74 | Dataflow { 75 | TemporalMap(NTileSz,NTileSz) N; 76 | SpatialMap(MTileSz,MTileSz) M; 77 | TemporalMap(KTileSz,KTileSz) K; 78 | Cluster(KTileSz, P); 79 | TemporalMap(NTileSz,NTileSz) N; 80 | TemporalMap(MTileSz,MTileSz) M; 81 | SpatialMap(1,1) K; 82 | } 83 | } 84 | Layer GEMM6 { 85 | Type: GEMM 86 | Dimensions { N: 256, K: 128, M: 2048 } 87 | Dataflow { 88 | TemporalMap(NTileSz,NTileSz) N; 89 | SpatialMap(MTileSz,MTileSz) M; 90 | TemporalMap(KTileSz,KTileSz) K; 91 | Cluster(KTileSz, P); 92 | TemporalMap(NTileSz,NTileSz) N; 93 | TemporalMap(MTileSz,MTileSz) M; 94 | SpatialMap(1,1) K; 95 | } 96 | } 97 | Layer GEMM7 { 98 | Type: GEMM 99 | Dimensions { N: 128, K: 64, M: 2048 } 100 | Dataflow { 101 | TemporalMap(NTileSz,NTileSz) N; 102 | SpatialMap(MTileSz,MTileSz) M; 103 | TemporalMap(KTileSz,KTileSz) K; 104 | Cluster(KTileSz, P); 105 | TemporalMap(NTileSz,NTileSz) N; 106 | TemporalMap(MTileSz,MTileSz) M; 107 | SpatialMap(1,1) K; 108 | } 109 | } 110 | Layer GEMM8 { 111 | Type: GEMM 112 | Dimensions { N: 64, K: 128, M: 2048 } 113 | Dataflow { 114 | TemporalMap(NTileSz,NTileSz) N; 115 | SpatialMap(MTileSz,MTileSz) M; 116 | TemporalMap(KTileSz,KTileSz) K; 117 | Cluster(KTileSz, P); 118 | TemporalMap(NTileSz,NTileSz) N; 119 | TemporalMap(MTileSz,MTileSz) M; 120 | SpatialMap(1,1) K; 121 | } 122 | } 123 | Layer GEMM9 { 124 | Type: GEMM 125 | Dimensions { N: 1, K: 2048, M: 128 } 126 | Dataflow { 127 | TemporalMap(NTileSz,NTileSz) N; 128 | SpatialMap(MTileSz,MTileSz) M; 129 | TemporalMap(KTileSz,KTileSz) K; 130 | Cluster(KTileSz, P); 131 | TemporalMap(NTileSz,NTileSz) N; 132 | TemporalMap(MTileSz,MTileSz) M; 133 | SpatialMap(1,1) K; 134 | } 135 | } 136 | Layer GEMM10 { 137 | Type: GEMM 138 | Dimensions { N: 1, K: 128, M: 2048 } 139 | Dataflow { 140 | TemporalMap(NTileSz,NTileSz) N; 141 | SpatialMap(MTileSz,MTileSz) M; 142 | TemporalMap(KTileSz,KTileSz) K; 143 | Cluster(KTileSz, P); 144 | TemporalMap(NTileSz,NTileSz) N; 145 | TemporalMap(MTileSz,MTileSz) M; 146 | SpatialMap(1,1) K; 147 | } 148 | } 149 | Layer GEMM11 { 150 | Type: GEMM 151 | Dimensions { N: 128, K: 1, M: 2048 } 152 | Dataflow { 153 | TemporalMap(NTileSz,NTileSz) N; 154 | SpatialMap(MTileSz,MTileSz) M; 155 | TemporalMap(KTileSz,KTileSz) K; 156 | Cluster(KTileSz, P); 157 | TemporalMap(NTileSz,NTileSz) N; 158 | TemporalMap(MTileSz,MTileSz) M; 159 | SpatialMap(1,1) K; 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /data/mapping/vgg16_ckp_ws.m: -------------------------------------------------------------------------------- 1 | Network vgg16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Dimensions { K 64,C 3,R 3,S 3,Y 224,X 224 } 5 | Dataflow { 6 | SpatialMap(1,1) C; 7 | TemporalMap(64,64) K; 8 | TemporalMap(3,3) R; 9 | TemporalMap(3,3) S; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(64, P); 13 | SpatialMap(1,1) K; 14 | TemporalMap(3,3) R; 15 | TemporalMap(3,3) S; 16 | } 17 | } 18 | 19 | Layer CONV2 { 20 | Type: CONV 21 | Dimensions { K 64,C 64,R 3,S 3,Y 224,X 224 } 22 | Dataflow { 23 | SpatialMap(1,1) C; 24 | TemporalMap(64,64) K; 25 | TemporalMap(3,3) R; 26 | TemporalMap(3,3) S; 27 | TemporalMap(1,1) Y'; 28 | TemporalMap(1,1) X'; 29 | Cluster(64, P); 30 | SpatialMap(1,1) K; 31 | TemporalMap(3,3) R; 32 | TemporalMap(3,3) S; 33 | } 34 | } 35 | 36 | Layer CONV3 { 37 | Type: CONV 38 | Dimensions { K 128,C 64,R 3,S 3,Y 112,X 112 } 39 | Dataflow { 40 | SpatialMap(1,1) C; 41 | TemporalMap(64,64) K; 42 | TemporalMap(3,3) R; 43 | TemporalMap(3,3) S; 44 | TemporalMap(1,1) Y'; 45 | TemporalMap(1,1) X'; 46 | Cluster(64, P); 47 | SpatialMap(1,1) K; 48 | TemporalMap(3,3) R; 49 | TemporalMap(3,3) S; 50 | } 51 | } 52 | 53 | Layer CONV4 { 54 | Type: CONV 55 | Dimensions { K 128,C 128,R 3,S 3,Y 112,X 112 } 56 | Dataflow { 57 | SpatialMap(1,1) C; 58 | TemporalMap(64,64) K; 59 | TemporalMap(3,3) R; 60 | TemporalMap(3,3) S; 61 | TemporalMap(1,1) Y'; 62 | TemporalMap(1,1) X'; 63 | Cluster(64, P); 64 | SpatialMap(1,1) K; 65 | TemporalMap(3,3) R; 66 | TemporalMap(3,3) S; 67 | } 68 | } 69 | 70 | Layer CONV5 { 71 | Type: CONV 72 | Dimensions { K 256,C 128,R 3,S 3,Y 56,X 56 } 73 | Dataflow { 74 | SpatialMap(1,1) C; 75 | TemporalMap(64,64) K; 76 | TemporalMap(3,3) R; 77 | TemporalMap(3,3) S; 78 | TemporalMap(1,1) Y'; 79 | TemporalMap(1,1) X'; 80 | Cluster(64, P); 81 | SpatialMap(1,1) K; 82 | TemporalMap(3,3) R; 83 | TemporalMap(3,3) S; 84 | } 85 | } 86 | 87 | Layer CONV6 { 88 | Type: CONV 89 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 90 | Dataflow { 91 | SpatialMap(1,1) C; 92 | TemporalMap(64,64) K; 93 | TemporalMap(3,3) R; 94 | TemporalMap(3,3) S; 95 | TemporalMap(1,1) Y'; 96 | TemporalMap(1,1) X'; 97 | Cluster(64, P); 98 | SpatialMap(1,1) K; 99 | TemporalMap(3,3) R; 100 | TemporalMap(3,3) S; 101 | } 102 | } 103 | 104 | Layer CONV7 { 105 | Type: CONV 106 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 107 | Dataflow { 108 | SpatialMap(1,1) C; 109 | TemporalMap(64,64) K; 110 | TemporalMap(3,3) R; 111 | TemporalMap(3,3) S; 112 | TemporalMap(1,1) Y'; 113 | TemporalMap(1,1) X'; 114 | Cluster(64, P); 115 | SpatialMap(1,1) K; 116 | TemporalMap(3,3) R; 117 | TemporalMap(3,3) S; 118 | } 119 | } 120 | 121 | Layer CONV8 { 122 | Type: CONV 123 | Dimensions { K 512,C 256,R 3,S 3,Y 28,X 28 } 124 | Dataflow { 125 | SpatialMap(1,1) C; 126 | TemporalMap(64,64) K; 127 | TemporalMap(3,3) R; 128 | TemporalMap(3,3) S; 129 | TemporalMap(1,1) Y'; 130 | TemporalMap(1,1) X'; 131 | Cluster(64, P); 132 | SpatialMap(1,1) K; 133 | TemporalMap(3,3) R; 134 | TemporalMap(3,3) S; 135 | } 136 | } 137 | 138 | Layer CONV9 { 139 | Type: CONV 140 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 141 | Dataflow { 142 | SpatialMap(1,1) C; 143 | TemporalMap(64,64) K; 144 | TemporalMap(3,3) R; 145 | TemporalMap(3,3) S; 146 | TemporalMap(1,1) Y'; 147 | TemporalMap(1,1) X'; 148 | Cluster(64, P); 149 | SpatialMap(1,1) K; 150 | TemporalMap(3,3) R; 151 | TemporalMap(3,3) S; 152 | } 153 | } 154 | 155 | Layer CONV10 { 156 | Type: CONV 157 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 158 | Dataflow { 159 | SpatialMap(1,1) C; 160 | TemporalMap(64,64) K; 161 | TemporalMap(3,3) R; 162 | TemporalMap(3,3) S; 163 | TemporalMap(1,1) Y'; 164 | TemporalMap(1,1) X'; 165 | Cluster(64, P); 166 | SpatialMap(1,1) K; 167 | TemporalMap(3,3) R; 168 | TemporalMap(3,3) S; 169 | } 170 | } 171 | 172 | Layer CONV11 { 173 | Type: CONV 174 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 175 | Dataflow { 176 | SpatialMap(1,1) C; 177 | TemporalMap(64,64) K; 178 | TemporalMap(3,3) R; 179 | TemporalMap(3,3) S; 180 | TemporalMap(1,1) Y'; 181 | TemporalMap(1,1) X'; 182 | Cluster(64, P); 183 | SpatialMap(1,1) K; 184 | TemporalMap(3,3) R; 185 | TemporalMap(3,3) S; 186 | } 187 | } 188 | 189 | Layer CONV12 { 190 | Type: CONV 191 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 192 | Dataflow { 193 | SpatialMap(1,1) C; 194 | TemporalMap(64,64) K; 195 | TemporalMap(3,3) R; 196 | TemporalMap(3,3) S; 197 | TemporalMap(1,1) Y'; 198 | TemporalMap(1,1) X'; 199 | Cluster(64, P); 200 | SpatialMap(1,1) K; 201 | TemporalMap(3,3) R; 202 | TemporalMap(3,3) S; 203 | } 204 | } 205 | 206 | Layer CONV13 { 207 | Type: CONV 208 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 209 | Dataflow { 210 | SpatialMap(1,1) C; 211 | TemporalMap(64,64) K; 212 | TemporalMap(3,3) R; 213 | TemporalMap(3,3) S; 214 | TemporalMap(1,1) Y'; 215 | TemporalMap(1,1) X'; 216 | Cluster(64, P); 217 | SpatialMap(1,1) K; 218 | TemporalMap(3,3) R; 219 | TemporalMap(3,3) S; 220 | } 221 | } 222 | 223 | 224 | } 225 | -------------------------------------------------------------------------------- /data/mapping/vgg16_nlr.m: -------------------------------------------------------------------------------- 1 | Network vgg16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Dimensions { K 64,C 3,R 3,S 3,Y 224,X 224 } 5 | Dataflow { 6 | TemporalMap (1,1) K; 7 | TemporalMap (Sz(R), 1) Y; 8 | TemporalMap (Sz(S), 1) X; 9 | TemporalMap (Sz(R), Sz(R)) R; 10 | TemporalMap (Sz(S), Sz(S)) S; 11 | SpatialMap (1,1) C; 12 | } 13 | } 14 | 15 | Layer CONV2 { 16 | Type: CONV 17 | Dimensions { K 64,C 64,R 3,S 3,Y 224,X 224 } 18 | Dataflow { 19 | TemporalMap (1,1) K; 20 | TemporalMap (Sz(R), 1) Y; 21 | TemporalMap (Sz(S), 1) X; 22 | TemporalMap (Sz(R), Sz(R)) R; 23 | TemporalMap (Sz(S), Sz(S)) S; 24 | SpatialMap (1,1) C; 25 | } 26 | } 27 | 28 | Layer CONV3 { 29 | Type: CONV 30 | Dimensions { K 128,C 64,R 3,S 3,Y 112,X 112 } 31 | Dataflow { 32 | TemporalMap (1,1) K; 33 | TemporalMap (Sz(R), 1) Y; 34 | TemporalMap (Sz(S), 1) X; 35 | TemporalMap (Sz(R), Sz(R)) R; 36 | TemporalMap (Sz(S), Sz(S)) S; 37 | SpatialMap (1,1) C; 38 | } 39 | } 40 | 41 | Layer CONV4 { 42 | Type: CONV 43 | Dimensions { K 128,C 128,R 3,S 3,Y 112,X 112 } 44 | Dataflow { 45 | TemporalMap (1,1) K; 46 | TemporalMap (Sz(R), 1) Y; 47 | TemporalMap (Sz(S), 1) X; 48 | TemporalMap (Sz(R), Sz(R)) R; 49 | TemporalMap (Sz(S), Sz(S)) S; 50 | SpatialMap (1,1) C; 51 | } 52 | } 53 | 54 | Layer CONV5 { 55 | Type: CONV 56 | Dimensions { K 256,C 128,R 3,S 3,Y 56,X 56 } 57 | Dataflow { 58 | TemporalMap (1,1) K; 59 | TemporalMap (Sz(R), 1) Y; 60 | TemporalMap (Sz(S), 1) X; 61 | TemporalMap (Sz(R), Sz(R)) R; 62 | TemporalMap (Sz(S), Sz(S)) S; 63 | SpatialMap (1,1) C; 64 | } 65 | } 66 | 67 | Layer CONV6 { 68 | Type: CONV 69 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 70 | Dataflow { 71 | TemporalMap (1,1) K; 72 | TemporalMap (Sz(R), 1) Y; 73 | TemporalMap (Sz(S), 1) X; 74 | TemporalMap (Sz(R), Sz(R)) R; 75 | TemporalMap (Sz(S), Sz(S)) S; 76 | SpatialMap (1,1) C; 77 | } 78 | } 79 | 80 | Layer CONV7 { 81 | Type: CONV 82 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 83 | Dataflow { 84 | TemporalMap (1,1) K; 85 | TemporalMap (Sz(R), 1) Y; 86 | TemporalMap (Sz(S), 1) X; 87 | TemporalMap (Sz(R), Sz(R)) R; 88 | TemporalMap (Sz(S), Sz(S)) S; 89 | SpatialMap (1,1) C; 90 | } 91 | } 92 | 93 | Layer CONV8 { 94 | Type: CONV 95 | Dimensions { K 512,C 256,R 3,S 3,Y 28,X 28 } 96 | Dataflow { 97 | TemporalMap (1,1) K; 98 | TemporalMap (Sz(R), 1) Y; 99 | TemporalMap (Sz(S), 1) X; 100 | TemporalMap (Sz(R), Sz(R)) R; 101 | TemporalMap (Sz(S), Sz(S)) S; 102 | SpatialMap (1,1) C; 103 | } 104 | } 105 | 106 | Layer CONV9 { 107 | Type: CONV 108 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 109 | Dataflow { 110 | TemporalMap (1,1) K; 111 | TemporalMap (Sz(R), 1) Y; 112 | TemporalMap (Sz(S), 1) X; 113 | TemporalMap (Sz(R), Sz(R)) R; 114 | TemporalMap (Sz(S), Sz(S)) S; 115 | SpatialMap (1,1) C; 116 | } 117 | } 118 | 119 | Layer CONV10 { 120 | Type: CONV 121 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 122 | Dataflow { 123 | TemporalMap (1,1) K; 124 | TemporalMap (Sz(R), 1) Y; 125 | TemporalMap (Sz(S), 1) X; 126 | TemporalMap (Sz(R), Sz(R)) R; 127 | TemporalMap (Sz(S), Sz(S)) S; 128 | SpatialMap (1,1) C; 129 | } 130 | } 131 | 132 | Layer CONV11 { 133 | Type: CONV 134 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 135 | Dataflow { 136 | TemporalMap (1,1) K; 137 | TemporalMap (Sz(R), 1) Y; 138 | TemporalMap (Sz(S), 1) X; 139 | TemporalMap (Sz(R), Sz(R)) R; 140 | TemporalMap (Sz(S), Sz(S)) S; 141 | SpatialMap (1,1) C; 142 | } 143 | } 144 | 145 | Layer CONV12 { 146 | Type: CONV 147 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 148 | Dataflow { 149 | TemporalMap (1,1) K; 150 | TemporalMap (Sz(R), 1) Y; 151 | TemporalMap (Sz(S), 1) X; 152 | TemporalMap (Sz(R), Sz(R)) R; 153 | TemporalMap (Sz(S), Sz(S)) S; 154 | SpatialMap (1,1) C; 155 | } 156 | } 157 | 158 | Layer CONV13 { 159 | Type: CONV 160 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 161 | Dataflow { 162 | TemporalMap (1,1) K; 163 | TemporalMap (Sz(R), 1) Y; 164 | TemporalMap (Sz(S), 1) X; 165 | TemporalMap (Sz(R), Sz(R)) R; 166 | TemporalMap (Sz(S), Sz(S)) S; 167 | SpatialMap (1,1) C; 168 | } 169 | } 170 | 171 | 172 | } 173 | -------------------------------------------------------------------------------- /data/mapping/vgg16_rs.m: -------------------------------------------------------------------------------- 1 | Network VGG16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Dimensions { K: 64, C:3, R: 3, S: 3, Y: 224, X: 224 } 5 | Dataflow { 6 | TemporalMap(2,2) K; 7 | TemporalMap(3,3) C; 8 | TemporalMap(3,3) R; 9 | SpatialMap(3,1) Y; 10 | TemporalMap(3,1) X; 11 | Cluster(3,P); 12 | SpatialMap(1,1) X; 13 | SpatialMap(1,1) R; 14 | TemporalMap(3,3) S; 15 | } 16 | } 17 | 18 | Layer CONV2 { 19 | Type: CONV 20 | Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 224, X: 224 } 21 | Dataflow { 22 | TemporalMap(2,2) K; 23 | TemporalMap(3,3) C; 24 | TemporalMap(3,3) R; 25 | SpatialMap(3,1) Y; 26 | TemporalMap(3,1) X; 27 | Cluster(3,P); 28 | SpatialMap(1,1) X; 29 | SpatialMap(1,1) R; 30 | TemporalMap(3,3) S; 31 | } 32 | } 33 | 34 | Layer CONV3 { 35 | Type: CONV 36 | Dimensions { K: 128, C: 64, R: 3, S: 3, Y: 112, X: 112 } 37 | Dataflow { 38 | TemporalMap(2,2) K; 39 | TemporalMap(3,3) C; 40 | TemporalMap(3,3) R; 41 | SpatialMap(3,1) Y; 42 | TemporalMap(3,1) X; 43 | Cluster(3,P); 44 | SpatialMap(1,1) X; 45 | SpatialMap(1,1) R; 46 | TemporalMap(3,3) S; 47 | } 48 | } 49 | 50 | Layer CONV4 { 51 | Type: CONV 52 | Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 112, X: 112 } 53 | Dataflow { 54 | TemporalMap(2,2) K; 55 | TemporalMap(3,3) C; 56 | TemporalMap(3,3) R; 57 | SpatialMap(3,1) Y; 58 | TemporalMap(3,1) X; 59 | Cluster(3,P); 60 | SpatialMap(1,1) X; 61 | SpatialMap(1,1) R; 62 | TemporalMap(3,3) S; 63 | } 64 | } 65 | 66 | 67 | Layer CONV5 { 68 | Type: CONV 69 | Dimensions { K: 256, C:128, R: 3, S: 3, Y: 56, X: 56 } 70 | Dataflow { 71 | TemporalMap(2,2) K; 72 | TemporalMap(3,3) C; 73 | TemporalMap(3,3) R; 74 | SpatialMap(3,1) Y; 75 | TemporalMap(3,1) X; 76 | Cluster(3,P); 77 | SpatialMap(1,1) X; 78 | SpatialMap(1,1) R; 79 | TemporalMap(3,3) S; 80 | } 81 | } 82 | 83 | Layer CONV6 { 84 | Type: CONV 85 | Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 56, X: 56 } 86 | Dataflow { 87 | TemporalMap(2,2) K; 88 | TemporalMap(3,3) C; 89 | TemporalMap(3,3) R; 90 | SpatialMap(3,1) Y; 91 | TemporalMap(3,1) X; 92 | Cluster(3,P); 93 | SpatialMap(1,1) X; 94 | SpatialMap(1,1) R; 95 | TemporalMap(3,3) S; 96 | } 97 | } 98 | 99 | Layer CONV7 { 100 | Type: CONV 101 | Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 56, X: 56 } 102 | Dataflow { 103 | TemporalMap(2,2) K; 104 | TemporalMap(3,3) C; 105 | TemporalMap(3,3) R; 106 | SpatialMap(3,1) Y; 107 | TemporalMap(3,1) X; 108 | Cluster(3,P); 109 | SpatialMap(1,1) X; 110 | SpatialMap(1,1) R; 111 | TemporalMap(3,3) S; 112 | } 113 | } 114 | 115 | Layer CONV8 { 116 | Type: CONV 117 | Dimensions { K: 512, C: 256, R: 3, S: 3, Y: 28, X: 28 } 118 | Dataflow { 119 | TemporalMap(2,2) K; 120 | TemporalMap(3,3) C; 121 | TemporalMap(3,3) R; 122 | SpatialMap(3,1) Y; 123 | TemporalMap(3,1) X; 124 | Cluster(3,P); 125 | SpatialMap(1,1) X; 126 | SpatialMap(1,1) R; 127 | TemporalMap(3,3) S; 128 | } 129 | } 130 | 131 | Layer CONV9 { 132 | Type: CONV 133 | Dimensions { K: 512, C:512, R: 3, S: 3, Y: 28, X: 28 } 134 | Dataflow { 135 | TemporalMap(2,2) K; 136 | TemporalMap(3,3) C; 137 | TemporalMap(3,3) R; 138 | SpatialMap(3,1) Y; 139 | TemporalMap(3,1) X; 140 | Cluster(3,P); 141 | SpatialMap(1,1) X; 142 | SpatialMap(1,1) R; 143 | TemporalMap(3,3) S; 144 | } 145 | } 146 | 147 | Layer CONV10 { 148 | Type: CONV 149 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 28, X: 28 } 150 | Dataflow { 151 | TemporalMap(2,2) K; 152 | TemporalMap(3,3) C; 153 | TemporalMap(3,3) R; 154 | SpatialMap(3,1) Y; 155 | TemporalMap(3,1) X; 156 | Cluster(3,P); 157 | SpatialMap(1,1) X; 158 | SpatialMap(1,1) R; 159 | TemporalMap(3,3) S; 160 | } 161 | } 162 | 163 | Layer CONV11 { 164 | Type: CONV 165 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 14, X: 14 } 166 | Dataflow { 167 | TemporalMap(2,2) K; 168 | TemporalMap(3,3) C; 169 | TemporalMap(3,3) R; 170 | SpatialMap(3,1) Y; 171 | TemporalMap(3,1) X; 172 | Cluster(3,P); 173 | SpatialMap(1,1) X; 174 | SpatialMap(1,1) R; 175 | TemporalMap(3,3) S; 176 | } 177 | } 178 | 179 | Layer CONV12 { 180 | Type: CONV 181 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 14, X: 14 } 182 | Dataflow { 183 | TemporalMap(2,2) K; 184 | TemporalMap(3,3) C; 185 | TemporalMap(3,3) R; 186 | SpatialMap(3,1) Y; 187 | TemporalMap(3,1) X; 188 | Cluster(3,P); 189 | SpatialMap(1,1) X; 190 | SpatialMap(1,1) R; 191 | TemporalMap(3,3) S; 192 | } 193 | } 194 | 195 | Layer CONV13 { 196 | Type: CONV 197 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 14, X: 14 } 198 | Dataflow { 199 | TemporalMap(2,2) K; 200 | TemporalMap(3,3) C; 201 | TemporalMap(3,3) R; 202 | SpatialMap(3,1) Y; 203 | TemporalMap(3,1) X; 204 | Cluster(3,P); 205 | SpatialMap(1,1) X; 206 | SpatialMap(1,1) R; 207 | TemporalMap(3,3) S; 208 | } 209 | } 210 | } 211 | 212 | 213 | //Accelerator { 214 | // PE { NumPEs: 128; VectorWidth: 4; MultPrecision: INT8, AddPrecision: INT16 } 215 | // Buffer { GlobalL2: 2048, LocalL1: 64} 216 | // NoC {Bandwidth: 64; AvgLatency: 2} 217 | //} 218 | -------------------------------------------------------------------------------- /data/mapping/vgg16_xp_ws.m: -------------------------------------------------------------------------------- 1 | Network vgg16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Dimensions { K 64,C 3,R 3,S 3,Y 224,X 224 } 5 | Dataflow { 6 | TemporalMap (1,1) K; 7 | TemporalMap (1,1) C; 8 | TemporalMap (3,1) Y; 9 | SpatialMap (3,1) X; 10 | TemporalMap (3,3) R; 11 | TemporalMap (3,3) S; 12 | } 13 | } 14 | 15 | Layer CONV2 { 16 | Type: CONV 17 | Dimensions { K 64,C 64,R 3,S 3,Y 224,X 224 } 18 | Dataflow { 19 | TemporalMap (1,1) K; 20 | TemporalMap (1,1) C; 21 | TemporalMap (3,1) Y; 22 | SpatialMap (3,1) X; 23 | TemporalMap (3,3) R; 24 | TemporalMap (3,3) S; 25 | } 26 | } 27 | 28 | Layer CONV3 { 29 | Type: CONV 30 | Dimensions { K 128,C 64,R 3,S 3,Y 112,X 112 } 31 | Dataflow { 32 | TemporalMap (1,1) K; 33 | TemporalMap (1,1) C; 34 | TemporalMap (3,1) Y; 35 | SpatialMap (3,1) X; 36 | TemporalMap (3,3) R; 37 | TemporalMap (3,3) S; 38 | } 39 | } 40 | 41 | Layer CONV4 { 42 | Type: CONV 43 | Dimensions { K 128,C 128,R 3,S 3,Y 112,X 112 } 44 | Dataflow { 45 | TemporalMap (1,1) K; 46 | TemporalMap (1,1) C; 47 | TemporalMap (3,1) Y; 48 | SpatialMap (3,1) X; 49 | TemporalMap (3,3) R; 50 | TemporalMap (3,3) S; 51 | } 52 | } 53 | 54 | Layer CONV5 { 55 | Type: CONV 56 | Dimensions { K 256,C 128,R 3,S 3,Y 56,X 56 } 57 | Dataflow { 58 | TemporalMap (1,1) K; 59 | TemporalMap (1,1) C; 60 | TemporalMap (3,1) Y; 61 | SpatialMap (3,1) X; 62 | TemporalMap (3,3) R; 63 | TemporalMap (3,3) S; 64 | } 65 | } 66 | 67 | Layer CONV6 { 68 | Type: CONV 69 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 70 | Dataflow { 71 | TemporalMap (1,1) K; 72 | TemporalMap (1,1) C; 73 | TemporalMap (3,1) Y; 74 | SpatialMap (3,1) X; 75 | TemporalMap (3,3) R; 76 | TemporalMap (3,3) S; 77 | } 78 | } 79 | 80 | Layer CONV7 { 81 | Type: CONV 82 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 83 | Dataflow { 84 | TemporalMap (1,1) K; 85 | TemporalMap (1,1) C; 86 | TemporalMap (3,1) Y; 87 | SpatialMap (3,1) X; 88 | TemporalMap (3,3) R; 89 | TemporalMap (3,3) S; 90 | } 91 | } 92 | 93 | Layer CONV8 { 94 | Type: CONV 95 | Dimensions { K 512,C 256,R 3,S 3,Y 28,X 28 } 96 | Dataflow { 97 | TemporalMap (1,1) K; 98 | TemporalMap (1,1) C; 99 | TemporalMap (3,1) Y; 100 | SpatialMap (3,1) X; 101 | TemporalMap (3,3) R; 102 | TemporalMap (3,3) S; 103 | } 104 | } 105 | 106 | Layer CONV9 { 107 | Type: CONV 108 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 109 | Dataflow { 110 | TemporalMap (1,1) K; 111 | TemporalMap (1,1) C; 112 | TemporalMap (3,1) Y; 113 | SpatialMap (3,1) X; 114 | TemporalMap (3,3) R; 115 | TemporalMap (3,3) S; 116 | } 117 | } 118 | 119 | Layer CONV10 { 120 | Type: CONV 121 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 122 | Dataflow { 123 | TemporalMap (1,1) K; 124 | TemporalMap (1,1) C; 125 | TemporalMap (3,1) Y; 126 | SpatialMap (3,1) X; 127 | TemporalMap (3,3) R; 128 | TemporalMap (3,3) S; 129 | } 130 | } 131 | 132 | Layer CONV11 { 133 | Type: CONV 134 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 135 | Dataflow { 136 | TemporalMap (1,1) K; 137 | TemporalMap (1,1) C; 138 | TemporalMap (3,1) Y; 139 | SpatialMap (3,1) X; 140 | TemporalMap (3,3) R; 141 | TemporalMap (3,3) S; 142 | } 143 | } 144 | 145 | 146 | Layer CONV12 { 147 | Type: CONV 148 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 149 | Dataflow { 150 | TemporalMap (1,1) K; 151 | TemporalMap (1,1) C; 152 | TemporalMap (3,1) Y; 153 | SpatialMap (3,1) X; 154 | TemporalMap (3,3) R; 155 | TemporalMap (3,3) S; 156 | } 157 | } 158 | 159 | Layer CONV13 { 160 | Type: CONV 161 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 162 | Dataflow { 163 | TemporalMap (1,1) K; 164 | TemporalMap (1,1) C; 165 | TemporalMap (3,1) Y; 166 | SpatialMap (3,1) X; 167 | TemporalMap (3,3) R; 168 | TemporalMap (3,3) S; 169 | } 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /data/mapping/vgg16_yxp_os.m: -------------------------------------------------------------------------------- 1 | Network vgg16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Stride { X: 1, Y: 1 } 5 | Dimensions { K 64,C 3,R 3,S 3,Y 224,X 224 } 6 | Dataflow { 7 | TemporalMap(1,1) K; 8 | TemporalMap(1,1) C; 9 | SpatialMap(Sz(R), 1) Y; 10 | TemporalMap(10,8) X; 11 | TemporalMap(Sz(R), Sz(R)) R; 12 | TemporalMap(Sz(R), Sz(R)) S; 13 | Cluster(8, P); 14 | SpatialMap(Sz(S), 1) X; 15 | TemporalMap(Sz(R), Sz(R)) S; 16 | } 17 | } 18 | 19 | Layer CONV2 { 20 | Type: CONV 21 | Dimensions { K 64,C 64,R 3,S 3,Y 224,X 224 } 22 | Dataflow { 23 | TemporalMap(1,1) K; 24 | TemporalMap(1,1) C; 25 | SpatialMap(Sz(R), 1) Y; 26 | TemporalMap(10,8) X; 27 | Cluster(8, P); 28 | SpatialMap(Sz(S), 1) X; 29 | TemporalMap(Sz(R), Sz(R)) R; 30 | TemporalMap(Sz(R), Sz(R)) S; 31 | } 32 | } 33 | 34 | Layer CONV3 { 35 | Type: CONV 36 | Dimensions { K 128,C 64,R 3,S 3,Y 112,X 112 } 37 | Dataflow { 38 | TemporalMap(1,1) K; 39 | TemporalMap(1,1) C; 40 | SpatialMap(Sz(R), 1) Y; 41 | TemporalMap(10,8) X; 42 | Cluster(8, P); 43 | SpatialMap(Sz(S), 1) X; 44 | TemporalMap(Sz(R), Sz(R)) R; 45 | TemporalMap(Sz(R), Sz(R)) S; 46 | } 47 | 48 | } 49 | 50 | Layer CONV4 { 51 | Type: CONV 52 | Dimensions { K 128,C 128,R 3,S 3,Y 112,X 112 } 53 | Dataflow { 54 | TemporalMap(1,1) K; 55 | TemporalMap(1,1) C; 56 | SpatialMap(Sz(R), 1) Y; 57 | TemporalMap(10,8) X; 58 | Cluster(8, P); 59 | SpatialMap(Sz(S), 1) X; 60 | TemporalMap(Sz(R), Sz(R)) R; 61 | TemporalMap(Sz(R), Sz(R)) S; 62 | } 63 | 64 | } 65 | 66 | Layer CONV5 { 67 | Type: CONV 68 | Dimensions { K 256,C 128,R 3,S 3,Y 56,X 56 } 69 | Dataflow { 70 | TemporalMap(1,1) K; 71 | TemporalMap(1,1) C; 72 | SpatialMap(Sz(R), 1) Y; 73 | TemporalMap(10,8) X; 74 | Cluster(8, P); 75 | SpatialMap(Sz(S), 1) X; 76 | TemporalMap(Sz(R), Sz(R)) R; 77 | TemporalMap(Sz(R), Sz(R)) S; 78 | } 79 | 80 | } 81 | 82 | Layer CONV6 { 83 | Type: CONV 84 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 85 | Dataflow { 86 | TemporalMap(1,1) K; 87 | TemporalMap(1,1) C; 88 | SpatialMap(Sz(R), 1) Y; 89 | TemporalMap(10,8) X; 90 | Cluster(8, P); 91 | SpatialMap(Sz(S), 1) X; 92 | TemporalMap(Sz(R), Sz(R)) R; 93 | TemporalMap(Sz(R), Sz(R)) S; 94 | } 95 | } 96 | 97 | Layer CONV7 { 98 | Type: CONV 99 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 100 | Dataflow { 101 | TemporalMap(1,1) K; 102 | TemporalMap(1,1) C; 103 | SpatialMap(Sz(R), 1) Y; 104 | TemporalMap(10,8) X; 105 | Cluster(8, P); 106 | SpatialMap(Sz(S), 1) X; 107 | TemporalMap(Sz(R), Sz(R)) R; 108 | TemporalMap(Sz(R), Sz(R)) S; 109 | } 110 | 111 | } 112 | 113 | Layer CONV8 { 114 | Type: CONV 115 | Dimensions { K 512,C 256,R 3,S 3,Y 28,X 28 } 116 | Dataflow { 117 | TemporalMap(1,1) K; 118 | TemporalMap(1,1) C; 119 | SpatialMap(Sz(R), 1) Y; 120 | TemporalMap(10,8) X; 121 | Cluster(8, P); 122 | SpatialMap(Sz(S), 1) X; 123 | TemporalMap(Sz(R), Sz(R)) R; 124 | TemporalMap(Sz(R), Sz(R)) S; 125 | } 126 | 127 | } 128 | 129 | Layer CONV9 { 130 | Type: CONV 131 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 132 | Dataflow { 133 | TemporalMap(1,1) K; 134 | TemporalMap(1,1) C; 135 | SpatialMap(Sz(R), 1) Y; 136 | TemporalMap(10,8) X; 137 | Cluster(8, P); 138 | SpatialMap(Sz(S), 1) X; 139 | TemporalMap(Sz(R), Sz(R)) R; 140 | TemporalMap(Sz(R), Sz(R)) S; 141 | } 142 | 143 | } 144 | 145 | Layer CONV10 { 146 | Type: CONV 147 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 148 | Dataflow { 149 | TemporalMap(1,1) K; 150 | TemporalMap(1,1) C; 151 | SpatialMap(Sz(R), 1) Y; 152 | TemporalMap(10,8) X; 153 | Cluster(8, P); 154 | SpatialMap(Sz(S), 1) X; 155 | TemporalMap(Sz(R), Sz(R)) R; 156 | TemporalMap(Sz(R), Sz(R)) S; 157 | } 158 | } 159 | 160 | Layer CONV11 { 161 | Type: CONV 162 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 163 | Dataflow { 164 | TemporalMap(1,1) K; 165 | TemporalMap(1,1) C; 166 | SpatialMap(Sz(R), 1) Y; 167 | TemporalMap(10,8) X; 168 | Cluster(8, P); 169 | SpatialMap(Sz(S), 1) X; 170 | TemporalMap(Sz(R), Sz(R)) R; 171 | TemporalMap(Sz(R), Sz(R)) S; 172 | } 173 | } 174 | 175 | 176 | Layer CONV12 { 177 | Type: CONV 178 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 179 | Dataflow { 180 | TemporalMap(1,1) K; 181 | TemporalMap(1,1) C; 182 | SpatialMap(Sz(R), 1) Y; 183 | TemporalMap(10,8) X; 184 | Cluster(8, P); 185 | SpatialMap(Sz(S), 1) X; 186 | TemporalMap(Sz(R), Sz(R)) R; 187 | TemporalMap(Sz(R), Sz(R)) S; 188 | } 189 | 190 | } 191 | 192 | Layer CONV13 { 193 | Type: CONV 194 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 195 | Dataflow { 196 | TemporalMap(1,1) K; 197 | TemporalMap(1,1) C; 198 | SpatialMap(Sz(R), 1) Y; 199 | TemporalMap(10,8) X; 200 | Cluster(8, P); 201 | SpatialMap(Sz(S), 1) X; 202 | TemporalMap(Sz(R), Sz(R)) R; 203 | TemporalMap(Sz(R), Sz(R)) S; 204 | } 205 | 206 | } 207 | 208 | 209 | } 210 | -------------------------------------------------------------------------------- /data/model/Transformer_Layers_model.m: -------------------------------------------------------------------------------- 1 | //Make some assumptions 2 | // let's assume seq_len = 64 for now 3 | // N d_mod d_ff h dk dv 4 | // 6 512 2048 8 64 64 5 | Constant Seq_Len 128; 6 | 7 | Network Transformer { 8 | //Start encoder 9 | Layer MH_FC_DimReduce_VKQ_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 10 | Type: CONV 11 | Stride { X: 1, Y: 1 } // k = 3 * 512, one for each VKQ 12 | Dimensions { N: Seq_Len, K: 1536, C: 1, R: 1, S: 512, Y:1, X:512 } 13 | } //good 14 | 15 | Layer SD_MatMul_QK_00 { //Mat mul, batch is 1 16 | Type: CONV //MatMul -> M(seql)xK(dv)xN(seql)-> filter = Kx1(m chans), input = KxN 17 | Stride { X: 1, Y: 1 } 18 | //N=1, K(conv)=M(matr), C=1, R(conv)=K(matr),S=1,Y(conv)=K(matr), X(conv)=N(matr) 19 | Dimensions { N: 1, K: Seq_Len, C: 1, R: 64, S: 1, Y:64, X:Seq_Len } 20 | } 21 | 22 | Layer SD_MatMul_V_00 { //Mat mul, batch is 1 23 | Type: CONV //MatMul -> M(seql)xK(seql)xN(dv)-> filter = Kx1(m chans), input = KxN 24 | Stride { X: 1, Y: 1 } 25 | //N=1, K(conv)=M(matr), C=1, R(conv)=K(matr),S=1,Y(conv)=K(matr), X(conv)=N(matr) 26 | Dimensions { N: 1, K: Seq_Len, C: 1, R: Seq_Len, S: 1, Y:Seq_Len, X:64 } 27 | } 28 | 29 | // done with h parallel sd layers now 30 | Layer MH_FC_DimRecast_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 31 | Type: CONV 32 | Stride { X: 1, Y: 1 } // v,k,q have been combined 33 | Dimensions { N: Seq_Len, K: 512, C: 1, R: 1, S: 512, Y:1, X:512 } 34 | } //good 35 | 36 | /// done with h parallel sd layers now 37 | Layer FF_A_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 38 | Type: CONV //2048 output neurons, 512->2048 39 | Stride { X: 1, Y: 1 } 40 | Dimensions { N: Seq_Len, K: 2048, C: 1, R: 1, S: 512, Y:1, X:512 } 41 | } //good 42 | 43 | /// done with h parallel sd layers now 44 | Layer FF_B_0 { //Batched FC layer, where seq_len is batch, input is d_model x 1 45 | Type: CONV //2048 -> 512 46 | Stride { X: 1, Y: 1 } 47 | Dimensions { N: Seq_Len, K: 512, C: 1, R: 1, S: 2048, Y:1, X:2048 } 48 | } //good 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /data/model/UNet_model.m: -------------------------------------------------------------------------------- 1 | Network UNet { 2 | Layer CONV1_1 { 3 | Type: CONV 4 | Dimensions { K: 64, C:1, R: 3, S: 3, Y: 572, X: 572 } 5 | 6 | } 7 | 8 | Layer CONV1_2 { 9 | Type: CONV 10 | Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 570, X: 570 } 11 | 12 | } 13 | 14 | Layer CONV2_1 { 15 | Type: CONV 16 | Dimensions { K: 128, C: 64, R: 3, S: 3, Y: 284, X: 284 } 17 | 18 | 19 | } 20 | 21 | Layer CONV2_2 { 22 | Type: CONV 23 | Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 282, X: 282 } 24 | 25 | 26 | } 27 | 28 | Layer CONV3_1 { 29 | Type: CONV 30 | Dimensions { K: 256, C: 128, R: 3, S: 3, Y: 140, X: 140 } 31 | } 32 | 33 | 34 | Layer CONV3_2 { 35 | Type: CONV 36 | Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 138, X: 138 } 37 | 38 | 39 | } 40 | 41 | Layer CONV4_1 { 42 | Type: CONV 43 | Dimensions { K: 512, C: 256, R: 3, S: 3, Y: 68, X: 68 } 44 | 45 | 46 | } 47 | 48 | 49 | Layer CONV4_2 { 50 | Type: CONV 51 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 66, X: 66 } 52 | 53 | 54 | } 55 | 56 | Layer CONV5_1 { 57 | Type: CONV 58 | Dimensions { K: 1024, C: 512, R: 3, S: 3, Y: 32, X: 32 } 59 | 60 | } 61 | 62 | 63 | Layer CONV5_2 { 64 | Type: CONV 65 | Dimensions { K: 1024, C: 1024, R: 3, S: 3, Y: 30, X: 30 } 66 | 67 | } 68 | 69 | Layer TRCONV1 { 70 | Type: TRCONV 71 | Dimensions { K: 512, C: 1024, R: 2, S: 2, Y: 28, X: 28 } 72 | 73 | 74 | } 75 | 76 | 77 | Layer CONV4_3 { 78 | Type: CONV 79 | Dimensions { K: 512, C: 1024, R: 3, S: 3, Y: 56, X: 56 } 80 | 81 | 82 | } 83 | 84 | Layer CONV4_4 { 85 | Type: CONV 86 | Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 54, X: 54 } 87 | } 88 | 89 | Layer TRCONV2 { 90 | Type: TRCONV 91 | Dimensions { K: 512, C: 512, R: 2, S: 2, Y: 52, X: 52 } 92 | } 93 | 94 | Layer CONV3_3 { 95 | Type: CONV 96 | Dimensions { K: 256, C: 512, R: 3, S: 3, Y: 104, X: 104 } 97 | } 98 | 99 | 100 | Layer CONV3_4 { 101 | Type: CONV 102 | Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 102, X: 102 } 103 | 104 | } 105 | 106 | Layer TRCONV3 { 107 | Type: TRCONV 108 | Dimensions { K: 128, C: 256, R: 2, S: 2, Y: 100, X: 100 } 109 | } 110 | 111 | 112 | Layer CONV2_3 { 113 | Type: CONV 114 | Dimensions { K: 128, C: 256, R: 3, S: 3, Y: 200, X: 200 } 115 | 116 | } 117 | 118 | Layer CONV2_4 { 119 | Type: CONV 120 | Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 198, X: 198 } 121 | } 122 | 123 | Layer TRCONV4 { 124 | Type: TRCONV 125 | Dimensions { K: 64, C: 128, R: 2, S: 2, Y: 196, X: 196 } 126 | 127 | } 128 | 129 | Layer CONV1_3 { 130 | Type: CONV 131 | Dimensions { K: 64, C: 128, R: 3, S: 3, Y: 392, X: 392 } 132 | 133 | } 134 | 135 | 136 | Layer CONV1_4 { 137 | Type: CONV 138 | Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 390, X: 390 } 139 | 140 | } 141 | 142 | Layer CONV1_5 { 143 | Type: CONV 144 | Dimensions { K: 2, C: 64, R: 1, S: 1, Y: 388, X: 388 } 145 | 146 | } 147 | } 148 | 149 | // Accelerator { 150 | // PE { NumPEs: 128; VectorWidth: 4; MultPrecision: INT8, AddPrecision: INT16 } 151 | // Buffer { GlobalL2: 2048, LocalL1: 64} 152 | // NoC {Bandwidth: 64; AvgLatency: 2} 153 | // } 154 | -------------------------------------------------------------------------------- /data/model/dnn_model.m: -------------------------------------------------------------------------------- 1 | Network sequential { 2 | Layer conv2d { 3 | Type: CONV 4 | Stride { X: 4, Y: 4 } 5 | Dimensions { K: 96, C: 3, R: 11, S: 11, Y: 224, X: 224 } 6 | } 7 | Layer conv2d_1 { 8 | Type: CONV 9 | Stride { X: 1, Y: 1 } 10 | Dimensions { K: 256, C: 96, R: 5, S: 5, Y: 26, X: 26 } 11 | } 12 | Layer conv2d_2 { 13 | Type: CONV 14 | Stride { X: 1, Y: 1 } 15 | Dimensions { K: 384, C: 256, R: 3, S: 3, Y: 10, X: 10 } 16 | } 17 | Layer conv2d_3 { 18 | Type: CONV 19 | Stride { X: 1, Y: 1 } 20 | Dimensions { K: 384, C: 384, R: 3, S: 3, Y: 8, X: 8 } 21 | } 22 | Layer conv2d_4 { 23 | Type: CONV 24 | Stride { X: 1, Y: 1 } 25 | Dimensions { K: 256, C: 384, R: 3, S: 3, Y: 6, X: 6 } 26 | } 27 | Layer dense { 28 | Type: CONV 29 | Dimensions { K: 4096, C: 256, R: 1, S: 1, Y: 1, X: 1 } 30 | } 31 | Layer dense_1 { 32 | Type: CONV 33 | Dimensions { K: 4096, C: 4096, R: 1, S: 1, Y: 1, X: 1 } 34 | } 35 | Layer dense_2 { 36 | Type: CONV 37 | Dimensions { K: 4096, C: 4096, R: 1, S: 1, Y: 1, X: 1 } 38 | } 39 | Layer dense_3 { 40 | Type: CONV 41 | Dimensions { K: 1, C: 4096, R: 1, S: 1, Y: 1, X: 1 } 42 | } 43 | } -------------------------------------------------------------------------------- /data/model/gnmt_model.m: -------------------------------------------------------------------------------- 1 | Network gnmt_gemm { 2 | Layer GEMM0 { 3 | Type: CONV 4 | Dimensions { K: 2048, C: 4096, Y: 128, X: 1, R: 1, S: 1 } 5 | 6 | 7 | } 8 | Layer GEMM1 { 9 | Type: CONV 10 | Dimensions { K: 2048, C: 4096, Y: 128, X: 1, R: 1, S: 1 } 11 | 12 | 13 | } 14 | Layer GEMM2 { 15 | Type: CONV 16 | Dimensions { K: 3072, C: 4096, Y: 320, X: 1, R: 1, S: 1 } 17 | 18 | 19 | } 20 | Layer GEMM3 { 21 | Type: CONV 22 | Dimensions { K: 2048, C: 4096, Y: 128, X: 1, R: 1, S: 1 } 23 | 24 | 25 | } 26 | Layer GEMM4 { 27 | Type: CONV 28 | Dimensions { K: 2048, C: 4096, Y: 128, X: 1, R: 1, S: 1 } 29 | 30 | 31 | } 32 | Layer GEMM5 { 33 | Type: CONV 34 | Dimensions { K: 3072, C: 4096, Y: 320, X: 1, R: 1, S: 1 } 35 | 36 | 37 | } 38 | Layer GEMM6 { 39 | Type: CONV 40 | Dimensions { K: 3072, C: 4096, Y: 320, X: 1, R: 1, S: 1 } 41 | 42 | 43 | } 44 | Layer GEMM7 { 45 | Type: CONV 46 | Dimensions { K: 3072, C: 4096, Y: 320, X: 1, R: 1, S: 1 } 47 | 48 | 49 | } 50 | Layer GEMM8 { 51 | Type: CONV 52 | Dimensions { K: 3072, C: 4096, Y: 320, X: 1, R: 1, S: 1 } 53 | 54 | 55 | } 56 | } -------------------------------------------------------------------------------- /data/model/mnasnet_model.m: -------------------------------------------------------------------------------- 1 | Network torchvision.models.mnasnet { 2 | Layer Conv2d-1 { 3 | Type: CONV 4 | Stride { X: 2, Y: 2 } 5 | Dimensions { K: 32, C: 3, R: 3, S: 3, Y: 224, X: 224 } 6 | } 7 | Layer Conv2d-2 { 8 | Type: DSCONV 9 | Stride { X: 1, Y: 1 } 10 | Dimensions { K: 1, C: 32, R: 3, S: 3, Y: 112, X: 112 } 11 | } 12 | Layer Conv2d-3 { 13 | Type: CONV 14 | Stride { X: 1, Y: 1 } 15 | Dimensions { K: 16, C: 32, R: 1, S: 1, Y: 112, X: 112 } 16 | } 17 | Layer Conv2d-4 { 18 | Type: CONV 19 | Stride { X: 1, Y: 1 } 20 | Dimensions { K: 48, C: 16, R: 1, S: 1, Y: 112, X: 112 } 21 | } 22 | Layer Conv2d-5 { 23 | Type: DSCONV 24 | Stride { X: 2, Y: 2 } 25 | Dimensions { K: 1, C: 48, R: 3, S: 3, Y: 112, X: 112 } 26 | } 27 | Layer Conv2d-6 { 28 | Type: CONV 29 | Stride { X: 1, Y: 1 } 30 | Dimensions { K: 24, C: 48, R: 1, S: 1, Y: 56, X: 56 } 31 | } 32 | Layer Conv2d-7 { 33 | Type: CONV 34 | Stride { X: 1, Y: 1 } 35 | Dimensions { K: 72, C: 24, R: 1, S: 1, Y: 56, X: 56 } 36 | } 37 | Layer Conv2d-8 { 38 | Type: DSCONV 39 | Stride { X: 1, Y: 1 } 40 | Dimensions { K: 1, C: 72, R: 3, S: 3, Y: 56, X: 56 } 41 | } 42 | Layer Conv2d-9 { 43 | Type: CONV 44 | Stride { X: 1, Y: 1 } 45 | Dimensions { K: 24, C: 72, R: 1, S: 1, Y: 56, X: 56 } 46 | } 47 | Layer Conv2d-10 { 48 | Type: CONV 49 | Stride { X: 1, Y: 1 } 50 | Dimensions { K: 72, C: 24, R: 1, S: 1, Y: 56, X: 56 } 51 | } 52 | Layer Conv2d-11 { 53 | Type: DSCONV 54 | Stride { X: 1, Y: 1 } 55 | Dimensions { K: 1, C: 72, R: 3, S: 3, Y: 56, X: 56 } 56 | } 57 | Layer Conv2d-12 { 58 | Type: CONV 59 | Stride { X: 1, Y: 1 } 60 | Dimensions { K: 24, C: 72, R: 1, S: 1, Y: 56, X: 56 } 61 | } 62 | Layer Conv2d-13 { 63 | Type: CONV 64 | Stride { X: 1, Y: 1 } 65 | Dimensions { K: 72, C: 24, R: 1, S: 1, Y: 56, X: 56 } 66 | } 67 | Layer Conv2d-14 { 68 | Type: DSCONV 69 | Stride { X: 2, Y: 2 } 70 | Dimensions { K: 1, C: 72, R: 5, S: 5, Y: 56, X: 56 } 71 | } 72 | Layer Conv2d-15 { 73 | Type: CONV 74 | Stride { X: 1, Y: 1 } 75 | Dimensions { K: 40, C: 72, R: 1, S: 1, Y: 28, X: 28 } 76 | } 77 | Layer Conv2d-16 { 78 | Type: CONV 79 | Stride { X: 1, Y: 1 } 80 | Dimensions { K: 120, C: 40, R: 1, S: 1, Y: 28, X: 28 } 81 | } 82 | Layer Conv2d-17 { 83 | Type: DSCONV 84 | Stride { X: 1, Y: 1 } 85 | Dimensions { K: 1, C: 120, R: 5, S: 5, Y: 28, X: 28 } 86 | } 87 | Layer Conv2d-18 { 88 | Type: CONV 89 | Stride { X: 1, Y: 1 } 90 | Dimensions { K: 40, C: 120, R: 1, S: 1, Y: 28, X: 28 } 91 | } 92 | Layer Conv2d-19 { 93 | Type: CONV 94 | Stride { X: 1, Y: 1 } 95 | Dimensions { K: 120, C: 40, R: 1, S: 1, Y: 28, X: 28 } 96 | } 97 | Layer Conv2d-20 { 98 | Type: DSCONV 99 | Stride { X: 1, Y: 1 } 100 | Dimensions { K: 1, C: 120, R: 5, S: 5, Y: 28, X: 28 } 101 | } 102 | Layer Conv2d-21 { 103 | Type: CONV 104 | Stride { X: 1, Y: 1 } 105 | Dimensions { K: 40, C: 120, R: 1, S: 1, Y: 28, X: 28 } 106 | } 107 | Layer Conv2d-22 { 108 | Type: CONV 109 | Stride { X: 1, Y: 1 } 110 | Dimensions { K: 240, C: 40, R: 1, S: 1, Y: 28, X: 28 } 111 | } 112 | Layer Conv2d-23 { 113 | Type: DSCONV 114 | Stride { X: 2, Y: 2 } 115 | Dimensions { K: 1, C: 240, R: 5, S: 5, Y: 28, X: 28 } 116 | } 117 | Layer Conv2d-24 { 118 | Type: CONV 119 | Stride { X: 1, Y: 1 } 120 | Dimensions { K: 80, C: 240, R: 1, S: 1, Y: 14, X: 14 } 121 | } 122 | Layer Conv2d-25 { 123 | Type: CONV 124 | Stride { X: 1, Y: 1 } 125 | Dimensions { K: 480, C: 80, R: 1, S: 1, Y: 14, X: 14 } 126 | } 127 | Layer Conv2d-26 { 128 | Type: DSCONV 129 | Stride { X: 1, Y: 1 } 130 | Dimensions { K: 1, C: 480, R: 5, S: 5, Y: 14, X: 14 } 131 | } 132 | Layer Conv2d-27 { 133 | Type: CONV 134 | Stride { X: 1, Y: 1 } 135 | Dimensions { K: 80, C: 480, R: 1, S: 1, Y: 14, X: 14 } 136 | } 137 | Layer Conv2d-28 { 138 | Type: CONV 139 | Stride { X: 1, Y: 1 } 140 | Dimensions { K: 480, C: 80, R: 1, S: 1, Y: 14, X: 14 } 141 | } 142 | Layer Conv2d-29 { 143 | Type: DSCONV 144 | Stride { X: 1, Y: 1 } 145 | Dimensions { K: 1, C: 480, R: 5, S: 5, Y: 14, X: 14 } 146 | } 147 | Layer Conv2d-30 { 148 | Type: CONV 149 | Stride { X: 1, Y: 1 } 150 | Dimensions { K: 80, C: 480, R: 1, S: 1, Y: 14, X: 14 } 151 | } 152 | Layer Conv2d-31 { 153 | Type: CONV 154 | Stride { X: 1, Y: 1 } 155 | Dimensions { K: 480, C: 80, R: 1, S: 1, Y: 14, X: 14 } 156 | } 157 | Layer Conv2d-32 { 158 | Type: DSCONV 159 | Stride { X: 1, Y: 1 } 160 | Dimensions { K: 1, C: 480, R: 3, S: 3, Y: 14, X: 14 } 161 | } 162 | Layer Conv2d-33 { 163 | Type: CONV 164 | Stride { X: 1, Y: 1 } 165 | Dimensions { K: 96, C: 480, R: 1, S: 1, Y: 14, X: 14 } 166 | } 167 | Layer Conv2d-34 { 168 | Type: CONV 169 | Stride { X: 1, Y: 1 } 170 | Dimensions { K: 576, C: 96, R: 1, S: 1, Y: 14, X: 14 } 171 | } 172 | Layer Conv2d-35 { 173 | Type: DSCONV 174 | Stride { X: 1, Y: 1 } 175 | Dimensions { K: 1, C: 576, R: 3, S: 3, Y: 14, X: 14 } 176 | } 177 | Layer Conv2d-36 { 178 | Type: CONV 179 | Stride { X: 1, Y: 1 } 180 | Dimensions { K: 96, C: 576, R: 1, S: 1, Y: 14, X: 14 } 181 | } 182 | Layer Conv2d-37 { 183 | Type: CONV 184 | Stride { X: 1, Y: 1 } 185 | Dimensions { K: 576, C: 96, R: 1, S: 1, Y: 14, X: 14 } 186 | } 187 | Layer Conv2d-38 { 188 | Type: DSCONV 189 | Stride { X: 2, Y: 2 } 190 | Dimensions { K: 1, C: 576, R: 5, S: 5, Y: 14, X: 14 } 191 | } 192 | Layer Conv2d-39 { 193 | Type: CONV 194 | Stride { X: 1, Y: 1 } 195 | Dimensions { K: 192, C: 576, R: 1, S: 1, Y: 7, X: 7 } 196 | } 197 | Layer Conv2d-40 { 198 | Type: CONV 199 | Stride { X: 1, Y: 1 } 200 | Dimensions { K: 1152, C: 192, R: 1, S: 1, Y: 7, X: 7 } 201 | } 202 | Layer Conv2d-41 { 203 | Type: DSCONV 204 | Stride { X: 1, Y: 1 } 205 | Dimensions { K: 1, C: 1152, R: 5, S: 5, Y: 7, X: 7 } 206 | } 207 | Layer Conv2d-42 { 208 | Type: CONV 209 | Stride { X: 1, Y: 1 } 210 | Dimensions { K: 192, C: 1152, R: 1, S: 1, Y: 7, X: 7 } 211 | } 212 | Layer Conv2d-43 { 213 | Type: CONV 214 | Stride { X: 1, Y: 1 } 215 | Dimensions { K: 1152, C: 192, R: 1, S: 1, Y: 7, X: 7 } 216 | } 217 | Layer Conv2d-44 { 218 | Type: DSCONV 219 | Stride { X: 1, Y: 1 } 220 | Dimensions { K: 1, C: 1152, R: 5, S: 5, Y: 7, X: 7 } 221 | } 222 | Layer Conv2d-45 { 223 | Type: CONV 224 | Stride { X: 1, Y: 1 } 225 | Dimensions { K: 192, C: 1152, R: 1, S: 1, Y: 7, X: 7 } 226 | } 227 | Layer Conv2d-46 { 228 | Type: CONV 229 | Stride { X: 1, Y: 1 } 230 | Dimensions { K: 1152, C: 192, R: 1, S: 1, Y: 7, X: 7 } 231 | } 232 | Layer Conv2d-47 { 233 | Type: DSCONV 234 | Stride { X: 1, Y: 1 } 235 | Dimensions { K: 1, C: 1152, R: 5, S: 5, Y: 7, X: 7 } 236 | } 237 | Layer Conv2d-48 { 238 | Type: CONV 239 | Stride { X: 1, Y: 1 } 240 | Dimensions { K: 192, C: 1152, R: 1, S: 1, Y: 7, X: 7 } 241 | } 242 | Layer Conv2d-49 { 243 | Type: CONV 244 | Stride { X: 1, Y: 1 } 245 | Dimensions { K: 1152, C: 192, R: 1, S: 1, Y: 7, X: 7 } 246 | } 247 | Layer Conv2d-50 { 248 | Type: DSCONV 249 | Stride { X: 1, Y: 1 } 250 | Dimensions { K: 1, C: 1152, R: 3, S: 3, Y: 7, X: 7 } 251 | } 252 | Layer Conv2d-51 { 253 | Type: CONV 254 | Stride { X: 1, Y: 1 } 255 | Dimensions { K: 320, C: 1152, R: 1, S: 1, Y: 7, X: 7 } 256 | } 257 | Layer Conv2d-52 { 258 | Type: CONV 259 | Stride { X: 1, Y: 1 } 260 | Dimensions { K: 1280, C: 320, R: 1, S: 1, Y: 7, X: 7 } 261 | } 262 | Layer Linear-53 { 263 | Type: CONV 264 | Dimensions { K: 1000, C: 1280, R: 1, S: 1, Y: 1, X: 1 } 265 | } 266 | } -------------------------------------------------------------------------------- /data/model/ncf_model.m: -------------------------------------------------------------------------------- 1 | Network ncf_gemm { 2 | Layer GEMM0 { 3 | Type: CONV 4 | Dimensions { K: 128, C: 2048, Y: 256, X: 1, R: 1, S: 1 } 5 | 6 | 7 | } 8 | Layer GEMM1 { 9 | Type: CONV 10 | Dimensions { K: 64, C: 2048, Y: 128, X: 1, R: 1, S: 1 } 11 | 12 | 13 | } 14 | Layer GEMM2 { 15 | Type: CONV 16 | Dimensions { K: 256, C: 2048, Y: 256, X: 1, R: 1, S: 1 } 17 | 18 | 19 | } 20 | Layer GEMM3 { 21 | Type: CONV 22 | Dimensions { K: 256, C: 256, Y: 2048, X: 1, R: 1, S: 1 } 23 | 24 | 25 | } 26 | Layer GEMM4 { 27 | Type: CONV 28 | Dimensions { K: 256, C: 256, Y: 2048, X: 1, R: 1, S: 1 } 29 | 30 | 31 | } 32 | Layer GEMM5 { 33 | Type: CONV 34 | Dimensions { K: 128, C: 256, Y: 2048, X: 1, R: 1, S: 1 } 35 | 36 | 37 | } 38 | Layer GEMM6 { 39 | Type: CONV 40 | Dimensions { K: 256, C: 128, Y: 2048, X: 1, R: 1, S: 1 } 41 | 42 | 43 | } 44 | Layer GEMM7 { 45 | Type: CONV 46 | Dimensions { K: 128, C: 64, Y: 2048, X: 1, R: 1, S: 1 } 47 | 48 | 49 | } 50 | Layer GEMM8 { 51 | Type: CONV 52 | Dimensions { K: 64, C: 128, Y: 2048, X: 1, R: 1, S: 1 } 53 | 54 | 55 | } 56 | Layer GEMM9 { 57 | Type: CONV 58 | Dimensions { K: 1, C: 2048, Y: 128, X: 1, R: 1, S: 1 } 59 | 60 | 61 | } 62 | Layer GEMM10 { 63 | Type: CONV 64 | Dimensions { K: 1, C: 128, Y: 2048, X: 1, R: 1, S: 1 } 65 | 66 | 67 | } 68 | Layer GEMM11 { 69 | Type: CONV 70 | Dimensions { K: 128, C: 1, Y: 2048, X: 1, R: 1, S: 1 } 71 | 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /data/model/squeezenet1_0_model.m: -------------------------------------------------------------------------------- 1 | Network torchvision.models.squeezenet { 2 | Layer Conv2d-1 { 3 | Type: CONV 4 | Stride { X: 2, Y: 2 } 5 | Dimensions { K: 96, C: 3, R: 7, S: 7, Y: 224, X: 224 } 6 | } 7 | Layer Conv2d-2 { 8 | Type: CONV 9 | Stride { X: 1, Y: 1 } 10 | Dimensions { K: 16, C: 96, R: 1, S: 1, Y: 54, X: 54 } 11 | } 12 | Layer Conv2d-3 { 13 | Type: CONV 14 | Stride { X: 1, Y: 1 } 15 | Dimensions { K: 64, C: 16, R: 1, S: 1, Y: 54, X: 54 } 16 | } 17 | Layer Conv2d-4 { 18 | Type: CONV 19 | Stride { X: 1, Y: 1 } 20 | Dimensions { K: 64, C: 16, R: 3, S: 3, Y: 54, X: 54 } 21 | } 22 | Layer Conv2d-5 { 23 | Type: CONV 24 | Stride { X: 1, Y: 1 } 25 | Dimensions { K: 16, C: 128, R: 1, S: 1, Y: 54, X: 54 } 26 | } 27 | Layer Conv2d-6 { 28 | Type: CONV 29 | Stride { X: 1, Y: 1 } 30 | Dimensions { K: 64, C: 16, R: 1, S: 1, Y: 54, X: 54 } 31 | } 32 | Layer Conv2d-7 { 33 | Type: CONV 34 | Stride { X: 1, Y: 1 } 35 | Dimensions { K: 64, C: 16, R: 3, S: 3, Y: 54, X: 54 } 36 | } 37 | Layer Conv2d-8 { 38 | Type: CONV 39 | Stride { X: 1, Y: 1 } 40 | Dimensions { K: 32, C: 128, R: 1, S: 1, Y: 54, X: 54 } 41 | } 42 | Layer Conv2d-9 { 43 | Type: CONV 44 | Stride { X: 1, Y: 1 } 45 | Dimensions { K: 128, C: 32, R: 1, S: 1, Y: 54, X: 54 } 46 | } 47 | Layer Conv2d-10 { 48 | Type: CONV 49 | Stride { X: 1, Y: 1 } 50 | Dimensions { K: 128, C: 32, R: 3, S: 3, Y: 54, X: 54 } 51 | } 52 | Layer Conv2d-11 { 53 | Type: CONV 54 | Stride { X: 1, Y: 1 } 55 | Dimensions { K: 32, C: 256, R: 1, S: 1, Y: 27, X: 27 } 56 | } 57 | Layer Conv2d-12 { 58 | Type: CONV 59 | Stride { X: 1, Y: 1 } 60 | Dimensions { K: 128, C: 32, R: 1, S: 1, Y: 27, X: 27 } 61 | } 62 | Layer Conv2d-13 { 63 | Type: CONV 64 | Stride { X: 1, Y: 1 } 65 | Dimensions { K: 128, C: 32, R: 3, S: 3, Y: 27, X: 27 } 66 | } 67 | Layer Conv2d-14 { 68 | Type: CONV 69 | Stride { X: 1, Y: 1 } 70 | Dimensions { K: 48, C: 256, R: 1, S: 1, Y: 27, X: 27 } 71 | } 72 | Layer Conv2d-15 { 73 | Type: CONV 74 | Stride { X: 1, Y: 1 } 75 | Dimensions { K: 192, C: 48, R: 1, S: 1, Y: 27, X: 27 } 76 | } 77 | Layer Conv2d-16 { 78 | Type: CONV 79 | Stride { X: 1, Y: 1 } 80 | Dimensions { K: 192, C: 48, R: 3, S: 3, Y: 27, X: 27 } 81 | } 82 | Layer Conv2d-17 { 83 | Type: CONV 84 | Stride { X: 1, Y: 1 } 85 | Dimensions { K: 48, C: 384, R: 1, S: 1, Y: 27, X: 27 } 86 | } 87 | Layer Conv2d-18 { 88 | Type: CONV 89 | Stride { X: 1, Y: 1 } 90 | Dimensions { K: 192, C: 48, R: 1, S: 1, Y: 27, X: 27 } 91 | } 92 | Layer Conv2d-19 { 93 | Type: CONV 94 | Stride { X: 1, Y: 1 } 95 | Dimensions { K: 192, C: 48, R: 3, S: 3, Y: 27, X: 27 } 96 | } 97 | Layer Conv2d-20 { 98 | Type: CONV 99 | Stride { X: 1, Y: 1 } 100 | Dimensions { K: 64, C: 384, R: 1, S: 1, Y: 27, X: 27 } 101 | } 102 | Layer Conv2d-21 { 103 | Type: CONV 104 | Stride { X: 1, Y: 1 } 105 | Dimensions { K: 256, C: 64, R: 1, S: 1, Y: 27, X: 27 } 106 | } 107 | Layer Conv2d-22 { 108 | Type: CONV 109 | Stride { X: 1, Y: 1 } 110 | Dimensions { K: 256, C: 64, R: 3, S: 3, Y: 27, X: 27 } 111 | } 112 | Layer Conv2d-23 { 113 | Type: CONV 114 | Stride { X: 1, Y: 1 } 115 | Dimensions { K: 64, C: 512, R: 1, S: 1, Y: 13, X: 13 } 116 | } 117 | Layer Conv2d-24 { 118 | Type: CONV 119 | Stride { X: 1, Y: 1 } 120 | Dimensions { K: 256, C: 64, R: 1, S: 1, Y: 13, X: 13 } 121 | } 122 | Layer Conv2d-25 { 123 | Type: CONV 124 | Stride { X: 1, Y: 1 } 125 | Dimensions { K: 256, C: 64, R: 3, S: 3, Y: 13, X: 13 } 126 | } 127 | Layer Conv2d-26 { 128 | Type: CONV 129 | Stride { X: 1, Y: 1 } 130 | Dimensions { K: 1000, C: 512, R: 1, S: 1, Y: 13, X: 13 } 131 | } 132 | } -------------------------------------------------------------------------------- /data/model/vgg16_model.m: -------------------------------------------------------------------------------- 1 | Network vgg16 { 2 | Layer CONV1 { 3 | Type: CONV 4 | Stride { X: 1, Y: 1 } 5 | Dimensions { K 64,C 3,R 3,S 3,Y 224,X 224 } 6 | } 7 | 8 | Layer CONV2 { 9 | Type: CONV 10 | Dimensions { K 64,C 64,R 3,S 3,Y 224,X 224 } 11 | } 12 | 13 | Layer CONV3 { 14 | Type: CONV 15 | Dimensions { K 128,C 64,R 3,S 3,Y 112,X 112 } 16 | 17 | } 18 | 19 | Layer CONV4 { 20 | Type: CONV 21 | Dimensions { K 128,C 128,R 3,S 3,Y 112,X 112 } 22 | 23 | } 24 | 25 | Layer CONV5 { 26 | Type: CONV 27 | Dimensions { K 256,C 128,R 3,S 3,Y 56,X 56 } 28 | 29 | } 30 | 31 | Layer CONV6 { 32 | Type: CONV 33 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 34 | } 35 | 36 | Layer CONV7 { 37 | Type: CONV 38 | Dimensions { K 256,C 256,R 3,S 3,Y 56,X 56 } 39 | 40 | } 41 | 42 | Layer CONV8 { 43 | Type: CONV 44 | Dimensions { K 512,C 256,R 3,S 3,Y 28,X 28 } 45 | 46 | } 47 | 48 | Layer CONV9 { 49 | Type: CONV 50 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 51 | 52 | } 53 | 54 | Layer CONV10 { 55 | Type: CONV 56 | Dimensions { K 512,C 512,R 3,S 3,Y 28,X 28 } 57 | } 58 | 59 | Layer CONV11 { 60 | Type: CONV 61 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 62 | } 63 | 64 | 65 | Layer CONV12 { 66 | Type: CONV 67 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 68 | 69 | } 70 | 71 | Layer CONV13 { 72 | Type: CONV 73 | Dimensions { K 512,C 512,R 3,S 3,Y 14,X 14 } 74 | 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /docs/frontend_tutorial.md: -------------------------------------------------------------------------------- 1 | # How to generate a mapping (Maestro input file) 2 | A mapping is a Maestro input file which contains a DNN model and the dataflow for each layer. 3 | 4 | This tutorial is written to provide an easy way to generate a mapping from a PyTorch/Keras model. 5 | 6 | 1. Generate a Maestro DNN Model file from a Pytorch/Keras model. 7 | 2. Generate a Maestro Mapping file with the Maestro DNN Model file and specific dataflow. 8 | 3. Run Maestro with the generated mapping. 9 | 10 | For the syntax of the mapping file, please refer to example mapping files in data/mapping. 11 | 12 | Supported pre-trained models are provided in the following links: 13 | 14 |
    15 |
  • PyTorch: [torchvision.models](https://pytorch.org/docs/stable/torchvision/models.html)
  • 16 |
  • Keras: [tensorflow.keras.applications](https://www.tensorflow.org/api_docs/python/tf/keras/applications) 17 | 18 | *tensorflow 2.0 should be installed.*
  • 19 |
20 | 21 | ## 1. Generate a Maestro DNN Model file from a Pytorch/Keras model. 22 | > cd tools/frontend 23 | 24 | Check the messages from the help for the future reference. 25 | > python frameworks_to_modelfile_maestro.py --help 26 | 27 | > python frameworks_to_modelfile_maestro.py --api_name pytorch --input_size 3,224,224 --model mobilenet_v2 --outfile dnn_model.m 28 | ``` 29 | --api_name: the API name, choose from "pytorch, keras" 30 | 31 | --input_size: the input image size of the first layer 32 | 33 | --model: the model name from torchvision.models (or tensorflow.keras.applications) 34 | TO use a custom model, enter custom for this argument. 35 | 36 | --custom: Enter the custom network python file name here. 37 | The file should have a function whose name is same as the file name and returns the model. 38 | (This option is working only for keras now) 39 | 40 | --outfile: the MAESTRO model output file name 41 | ``` 42 | The Maestro DNN Model, dnn_model.m, will be generated in ../../data/model: 43 | 44 | ## 2. Generate a Maestro Mapping file with the Maestro DNN Model file and specific dataflow. 45 | Check the messages from the help for the future reference. 46 | > python modelfile_to_mapping.py --help 47 | 48 | > python modelfile_to_mapping.py --model_file dnn_model.m --dataflow os --outfile out.m 49 | ``` 50 | --model_file: The model file supported by maestro as specified by the user or generated by the above given script. 51 | 52 | --dataflow: the dataflow for each layer, choose from "os, ws, rs, dla" 53 | 54 | --outfile: the MAESTRO DFSL output file 55 | ``` 56 | 57 | The mapping file, out.m, will be generated in ../../data/mapping: 58 | 59 | ## 3. Run Maestro with the generated mapping. 60 | 61 | Go back to the maestro-dev directory. 62 | 63 | > cd ../../ 64 | 65 | Change the contents of "run_example.sh" to use the mapping file generated. 66 | 67 | --DFSL_file='data/mapping/out.m' 68 | 69 | Run MAESTRO 70 | 71 | > ./run_example.sh 72 | -------------------------------------------------------------------------------- /maestro-top.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "BASE_constants.hpp" 31 | #include "BASE_base-objects.hpp" 32 | #include "option.hpp" 33 | 34 | #include "DFA_tensor.hpp" 35 | 36 | #include "AHW_noc-model.hpp" 37 | 38 | #include "CA_cost-analysis-results.hpp" 39 | 40 | #include "API_configuration.hpp" 41 | #include "API_user-interface-v2.hpp" 42 | 43 | 44 | #include "DSE_cost-database.hpp" 45 | #include "DSE_design_point.hpp" 46 | #include "DSE_hardware_modules.hpp" 47 | #include "DSE_csv_writer.hpp" 48 | 49 | int main(int argc, char** argv) 50 | { 51 | 52 | maestro::Options option; 53 | bool success = option.parse(argc, argv); 54 | 55 | if(!success) { 56 | std::cout << "[MAESTRO] Failed to parse program options" << std::endl; 57 | } 58 | 59 | maestro::InitializeBaseObjects(option.message_print_lv); 60 | 61 | int num_pes = option.np; 62 | 63 | 64 | /* 65 | * Hard coded part; will Fix it 66 | */ 67 | 68 | if(option.bw_sweep && option.top_bw_only) { 69 | int min_bw = option.bw_tick; 70 | 71 | for(int bw = option.min_noc_bw; bw <= option.max_noc_bw; bw += option.bw_tick) { 72 | std::shared_ptr> noc_multcast = std::make_shared>(); 73 | std::shared_ptr> noc_latency = std::make_shared>(); 74 | std::shared_ptr> noc_bw = std::make_shared>(); 75 | 76 | if(option.top_bw_only) { 77 | noc_bw->push_back(bw); 78 | noc_bw->push_back(70000); 79 | noc_bw->push_back(70000); 80 | noc_bw->push_back(70000); 81 | noc_bw->push_back(70000); 82 | noc_bw->push_back(70000); 83 | 84 | noc_latency->push_back(option.hop_latency * option.hops); 85 | noc_latency->push_back(1); 86 | noc_latency->push_back(1); 87 | noc_latency->push_back(1); 88 | noc_latency->push_back(1); 89 | noc_latency->push_back(1); 90 | 91 | noc_multcast->push_back(option.mc); 92 | noc_multcast->push_back(true); 93 | noc_multcast->push_back(true); 94 | noc_multcast->push_back(true); 95 | noc_multcast->push_back(true); 96 | noc_multcast->push_back(true); 97 | } 98 | 99 | auto config = std::make_shared( 100 | option.dfsl_file_name, 101 | option.hw_file_name, 102 | noc_bw, 103 | noc_latency, 104 | noc_multcast, 105 | option.np, 106 | option.num_simd_lanes, 107 | option.bw, 108 | option.l1_size, 109 | option.l2_size, 110 | option.offchip_bw 111 | ); 112 | 113 | auto api = std::make_shared(config); 114 | auto res = api->AnalyzeNeuralNetwork(option.print_res_to_screen, true); 115 | 116 | } 117 | } 118 | else { 119 | std::shared_ptr> noc_multcast = std::make_shared>(); 120 | std::shared_ptr> noc_latency = std::make_shared>(); 121 | std::shared_ptr> noc_bw = std::make_shared>(); 122 | 123 | //felix 124 | 125 | noc_bw->push_back(option.bw); 126 | noc_bw->push_back(option.bw); 127 | noc_bw->push_back(option.bw); 128 | noc_bw->push_back(option.bw); 129 | 130 | 131 | noc_latency->push_back(option.hop_latency * option.hops); 132 | noc_latency->push_back(option.hop_latency * option.hops); 133 | noc_latency->push_back(option.hop_latency * option.hops); 134 | noc_latency->push_back(option.hop_latency * option.hops); 135 | 136 | noc_multcast->push_back(true); 137 | noc_multcast->push_back(true); 138 | noc_multcast->push_back(true); 139 | noc_multcast->push_back(true); 140 | 141 | auto config = std::make_shared( 142 | option.dfsl_file_name, 143 | option.hw_file_name, 144 | noc_bw, 145 | noc_latency, 146 | noc_multcast, 147 | option.np, 148 | option.num_simd_lanes, 149 | option.bw, 150 | option.l1_size, 151 | option.l2_size, 152 | option.offchip_bw 153 | ); 154 | 155 | auto api = std::make_shared(config); 156 | 157 | auto res = api->AnalyzeNeuralNetwork(option.print_res_to_screen, option.print_res_to_csv_file, option.print_log_file); 158 | } 159 | ///////////////////////////////////////////////////////////////// 160 | 161 | 162 | 163 | return 0; 164 | } 165 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas==0.23.4 2 | numpy==1.15.4 3 | matplotlib==3.0.2 4 | watermark==2.0.2 5 | ipython>=3.2.1 6 | jupyterlab==2.2.6 7 | -------------------------------------------------------------------------------- /run_eval.sh: -------------------------------------------------------------------------------- 1 | ./maestro \ 2 | --Mapping_file='gammasolx.m' \ 3 | --print_res=true \ 4 | --print_res_csv_file=true \ 5 | --print_log_file=false \ 6 | --noc_bw=1000000000 \ 7 | --noc_hop_latency=0 \ 8 | --noc_mc_support=true \ 9 | --num_pes=256 \ 10 | --num_simd_lanes=1 \ 11 | --l1_size=5120 \ 12 | --l2_size=1024000 \ 13 | --do_implicit_reduction=true \ 14 | --do_fg_sync=false \ 15 | --do_reduction_op=true \ 16 | --do_dse=false \ 17 | 18 | 19 | -------------------------------------------------------------------------------- /run_example.sh: -------------------------------------------------------------------------------- 1 | ./maestro --HW_file='data/hw/accelerator_1.m' \ 2 | --Mapping_file='data/mapping/Resnet50_kcp_ws.m' \ 3 | --print_res=true \ 4 | --print_res_csv_file=true \ 5 | --print_log_file=false \ 6 | -------------------------------------------------------------------------------- /run_example2.sh: -------------------------------------------------------------------------------- 1 | ./maestro --num_pes=256 \ 2 | --l1_size_cstr=100 \ 3 | --l2_size_cstr=3000 \ 4 | --offchip_bw_cstr=50 \ 5 | --Mapping_file='data/mapping/Resnet50_kcp_ws.m' \ 6 | --print_res=true \ 7 | --print_res_csv_file=true \ 8 | --print_log_file=false \ 9 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/dpt.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | SpatialMap(1,1) C; 3 | TemporalMap(Sz(R),1) Y; 4 | TemporalMap(Sz(S),1) X; 5 | TemporalMap(Sz(R),Sz(R)) R; 6 | TemporalMap(Sz(S),Sz(S)) S; 7 | } 8 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/kcp_ws.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | // This is a NVDLA-like dataflow 3 | SpatialMap(1,1) K; 4 | TemporalMap(64,64) C; 5 | TemporalMap(Sz(R),Sz(R)) R; 6 | TemporalMap(Sz(S),Sz(S)) S; 7 | TemporalMap(Sz(R),1) Y; 8 | TemporalMap(Sz(S),1) X; 9 | Cluster(64, P); 10 | SpatialMap(1,1) C; 11 | TemporalMap(Sz(R),1) Y; 12 | TemporalMap(Sz(S),1) X; 13 | TemporalMap(Sz(R),Sz(R)) R; 14 | TemporalMap(Sz(S),Sz(S)) S; 15 | } 16 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/maeri.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | // Only one spatial map can be applied except on R and S 3 | TemporalMap(1,1) C; // Flexible (Mapping size/offset, spatial/temporal) 4 | SpatialMap(1,1) K; // Flexible (Mapping size/offset, spatial/temporal) 5 | TemporalMap(1,1) Y’; // Flexible (Mapping size/offset, spatial/temporal) 6 | TemporalMap(1,1) X’; // Flexible (Mapping size/offset, spatial/temporal) 7 | TemporalMap(Sz(R),Sz(R)) R; // This cannot be changed 8 | TemporalMap(Sz(S),Sz(S)) S; // This cannot be changed 9 | // Virtual Neuron of size Sz(R) x Sz(S): 10 | Cluster(Sz(R),P); 11 | SpatialMap(1,1) Y; 12 | SpatialMap(1,1) R; 13 | Cluster(Sz(S),P); 14 | SpatialMap(1,1) X; 15 | SpatialMap(1,1) S; 16 | } 17 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/rs.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | // This is an Eyeriss-like row-stationary dataflow” 3 | SpatialMap(1,1) Y'; 4 | TemporalMap(1,1) X'; 5 | TemporalMap(1,1) C; 6 | TemporalMap(16,16) K; 7 | TemporalMap(Sz(R),Sz(R)) R; 8 | TemporalMap(Sz(S),Sz(S)) S; 9 | Cluster(Sz(R),P); 10 | SpatialMap(1,1) Y; 11 | SpatialMap(1,1) R; 12 | TemporalMap(Sz(S),Sz(S)) S; 13 | } 14 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/xp_ws.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | TemporalMap (1,1) K; 3 | TemporalMap (1,1) C; 4 | TemporalMap (Sz(R),1) Y; 5 | SpatialMap (Sz(S),1) X; 6 | TemporalMap (Sz(R),Sz(R)) R; 7 | TemporalMap (Sz(S),Sz(S)) S; 8 | } 9 | -------------------------------------------------------------------------------- /tools/frontend/dataflow/ykp_os.m: -------------------------------------------------------------------------------- 1 | Dataflow { 2 | TemporalMap(16,16) K; 3 | SpatialMap(Sz(R),1) Y; 4 | TemporalMap(Sz(S),1) X; 5 | TemporalMap(1,1) C; 6 | Cluster(16, P); 7 | SpatialMap(1,1) K; 8 | TemporalMap(Sz(R),1) Y; 9 | TemporalMap(Sz(S),1) X; 10 | TemporalMap(Sz(R),7) R; 11 | TemporalMap(Sz(S),7) S; 12 | } 13 | -------------------------------------------------------------------------------- /tools/frontend/frameworks_to_modelfile_maestro.py: -------------------------------------------------------------------------------- 1 | import re 2 | import argparse 3 | from argparse import RawTextHelpFormatter 4 | 5 | # inception_v3 input should be 3, 299, 299 6 | 7 | 8 | if __name__ == "__main__": 9 | parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter) 10 | parser.add_argument('--api_name', type=str, default="pytorch", help="api choices: pytorch, keras") 11 | parser.add_argument('--input_size', type=str, default="3,224,224", help='input size') 12 | parser.add_argument('--model', type=str, default="mobilenet_v2", 13 | help='model from torchvision choices: \n' 14 | 'resnet18, alexnet, vgg16, squeezenet, densenet, \n' 15 | 'inception_v3, googlenet, shufflenet, \n' 16 | 'mobilenet_v2, wide_resnet50_2, mnasnet,\n' 17 | '-----\n' 18 | 'model from tensorflow.keras.applications choices: \n' 19 | 'xception, vgg16, vgg19, resnet50, resnet101, \n' 20 | 'resnet152, resnet50_v2, resnet101_v2, resnet152_v2, \n' 21 | 'inception_v3, inception_resnet_v2, mobilenet, mobilenet_v2,\n' 22 | 'densenet121, densenet169, densenet201, nasnet_large, \n' 23 | 'nasnet_mobile\n' 24 | '-----\n' 25 | 'To use a custom model, enter custom for this arguement') 26 | parser.add_argument('--custom', type=str, default="none", 27 | help='Enter the custom network python file name here.\n' 28 | 'The file should have a function with same file name\n ' 29 | 'which returns the model. Also put this file in keras_example\n' 30 | '(This option is working only for keras)\n') 31 | 32 | 33 | parser.add_argument('--outfile', type=str, default="dnn_model.m", help='output file name') 34 | opt = parser.parse_args() 35 | INPUT_SIZE = tuple((int(d) for d in str.split(opt.input_size, ","))) 36 | 37 | print('Begin processing') 38 | print('API name: ' + str(opt.api_name)) 39 | if(opt.model == 'custom'): 40 | print('Model name: ' + str(opt.custom)) 41 | else: 42 | print('Model name: ' + str(opt.model)) 43 | print('Input size: ' + str(INPUT_SIZE)) 44 | if(opt.api_name =='keras'): 45 | from helpers.keras_helper import get_model 46 | from helpers.keras_maestro_summary import summary 47 | 48 | model = None 49 | if opt.model == 'custom': 50 | print(opt.custom) 51 | module_name = 'keras-example.' + opt.custom 52 | new_module = __import__(module_name, fromlist=[opt.custom]) 53 | model = getattr(new_module, opt.custom)() 54 | else: 55 | model = get_model(opt.model, INPUT_SIZE[::-1]) 56 | 57 | mae_summary = summary(model) 58 | 59 | with open("../../data/model/"+opt.outfile, "w") as fo: 60 | fo.write("Network {} {{\n".format(model.name)) 61 | for key, val in mae_summary.items(): 62 | pc = re.compile("^CONV") 63 | pd = re.compile("^DSCONV") 64 | pf = re.compile("^Dense") 65 | 66 | match_pc = pc.match(val['type']) 67 | match_pd = pd.match(val['type']) 68 | match_pf = pf.match(val['type']) 69 | 70 | if match_pc or match_pd or match_pf: 71 | fo.write("Layer {} {{\n".format(key)) 72 | type = val["type"] 73 | if match_pf: 74 | fo.write("Type: CONV\n") 75 | if not match_pf: 76 | fo.write("Type: {}\n".format(type)) 77 | fo.write("Stride {{ X: {}, Y: {} }}\n".format(*val["strides"])) 78 | 79 | fo.write("Dimensions {{ K: {}, C: {}, R: {}, S: {}, Y: {}, X: {} }}\n".format( 80 | *val["dimension_ic"][1:])) 81 | fo.write("}\n") 82 | fo.write("}") 83 | 84 | if(opt.api_name == 'pytorch'): 85 | import torch 86 | import torchvision.models as models 87 | from helpers.torch_maestro_summary import summary 88 | 89 | device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') 90 | model = getattr(models, opt.model)() 91 | model = model.to(device) 92 | mae_summary = summary(model, INPUT_SIZE) 93 | with open("../../data/model/"+opt.outfile, "w") as fo: 94 | fo.write("Network {} {{\n".format(model.__module__)) 95 | for key, val in mae_summary.items(): 96 | pc = re.compile("^Conv") 97 | pl = re.compile("^Linear") 98 | match_pc = pc.match(key) 99 | match_pl = pl.match(key) 100 | if match_pc or match_pl: 101 | fo.write("Layer {} {{\n".format(key)) 102 | type = val["type"] 103 | fo.write("Type: {}\n".format(type)) 104 | if not match_pl: 105 | fo.write("Stride {{ X: {}, Y: {} }}\n".format(*val["stride"])) 106 | fo.write("Dimensions {{ K: {}, C: {}, R: {}, S: {}, Y: {}, X: {} }}\n".format( 107 | *val["dimension_ic"][1:])) 108 | fo.write("}\n") 109 | fo.write("}") 110 | 111 | print("Done converting to the Maestro DNN MODEL file") 112 | -------------------------------------------------------------------------------- /tools/frontend/helpers/keras_helper.py: -------------------------------------------------------------------------------- 1 | import tensorflow.keras.applications as keras_models 2 | 3 | ''' 4 | Available model from tf 2.0: 5 | Xception 6 | VGG16 7 | VGG19 8 | ResNet, ResNetV2 9 | InceptionV3 10 | InceptionResNetV2 11 | MobileNet 12 | MobileNetV2 13 | DenseNet 14 | NASNet 15 | ''' 16 | 17 | def get_model(model_name, input_shape): 18 | keras_model_name = '' 19 | if(model_name == 'xception'): 20 | keras_model_name = 'Xception' 21 | 22 | elif(model_name == 'vgg16'): 23 | keras_model_name = 'VGG16' 24 | elif(model_name == 'vgg19'): 25 | keras_model_name = 'VGG19' 26 | 27 | elif(model_name == 'resnet50'): 28 | keras_model_name = 'ResNet50' 29 | elif(model_name == 'resnet101'): 30 | keras_model_name = 'ResNet101' 31 | elif(model_name == 'resnet152'): 32 | keras_model_name = 'ResNet152' 33 | elif(model_name == 'resnet50_v2'): 34 | keras_model_name = 'ResNet50V2' 35 | elif(model_name == 'resnet101_v2'): 36 | keras_model_name = 'ResNet101V2' 37 | elif(model_name == 'resnet152_v2'): 38 | keras_model_name = 'ResNet152V2' 39 | 40 | elif(model_name == 'inception_v3'): 41 | keras_model_name = 'InceptionV3' 42 | elif(model_name == 'inception_resnet_v2'): 43 | keras_model_name = 'InceptionResNetV2' 44 | 45 | elif(model_name == 'mobilenet'): 46 | keras_model_name = 'MobileNet' 47 | elif(model_name == 'mobilenet_v2'): 48 | keras_model_name = 'MobileNetV2' 49 | 50 | elif(model_name == 'densenet121'): 51 | keras_model_name = 'DenseNet121' 52 | elif(model_name == 'densenet169'): 53 | keras_model_name = 'DenseNet169' 54 | elif(model_name == 'densenet201'): 55 | keras_model_name = 'DenseNet201' 56 | 57 | elif(model_name == 'nasnet_large'): 58 | keras_model_name = 'NASNetLarge' 59 | elif(model_name == 'nasnet_mobile'): 60 | keras_model_name = 'NASNetMobile' 61 | 62 | else: 63 | raise NotImplementedError('Not supported model') 64 | keras_model = getattr(keras_models, keras_model_name)(weights=None, include_top=True, input_shape=input_shape) 65 | print('Get the keras model: ' + keras_model_name) 66 | 67 | return keras_model 68 | -------------------------------------------------------------------------------- /tools/frontend/helpers/keras_maestro_summary.py: -------------------------------------------------------------------------------- 1 | def summary(model): 2 | mae_summary = {} 3 | 4 | for i in range(len(model.layers)): 5 | cur_config = model.layers[i].get_config() 6 | cur_config['type'] = model.layers[i].__class__.__name__ 7 | 8 | is_conv2d = cur_config['type'] == 'Conv2D' 9 | is_dwconv2d = cur_config['type'] == 'DepthwiseConv2D' 10 | is_dense = cur_config['type'] == 'Dense' 11 | 12 | if is_conv2d: 13 | cur_config['type'] = 'CONV' 14 | if is_dwconv2d: 15 | cur_config['type'] = 'DSCONV' 16 | 17 | if(is_conv2d or is_dwconv2d or is_dense): 18 | cur_ic = [] 19 | cur_ic.append(None) 20 | if(is_conv2d): 21 | cur_ic.append(model.layers[i].output_shape[3]) 22 | elif(is_dwconv2d): 23 | cur_ic.append(1) 24 | elif(is_dense): 25 | cur_ic.append(model.layers[i].output_shape[1]) 26 | 27 | if(is_dense): 28 | cur_ic.append(model.layers[i].input_shape[1]) 29 | for _ in range(4): 30 | cur_ic.append(1) 31 | else: 32 | cur_ic.append(model.layers[i].input_shape[3]) 33 | cur_ic.append(model.layers[i].kernel_size[0]) 34 | cur_ic.append(model.layers[i].kernel_size[1]) 35 | cur_ic.append(model.layers[i].input_shape[1]) 36 | cur_ic.append(model.layers[i].input_shape[2]) 37 | 38 | cur_config['dimension_ic'] = cur_ic 39 | mae_summary[model.layers[i].get_config()['name']] = cur_config 40 | 41 | return mae_summary 42 | -------------------------------------------------------------------------------- /tools/frontend/helpers/torch_maestro_summary.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Variable 4 | 5 | from collections import OrderedDict 6 | import numpy as np 7 | import re 8 | 9 | def summary(model, input_size, batch_size=-1, device="cuda", silent=True): 10 | 11 | def register_hook(module): 12 | 13 | def hook(module, input, output): 14 | class_name = str(module.__class__).split(".")[-1].split("'")[0] 15 | module_idx = len(summary) 16 | pc = re.compile(".*conv$") 17 | pl = re.compile(".*linear$") 18 | key = module.__module__ 19 | match_pc = pc.match(key) 20 | match_pl = pl.match(key) 21 | if match_pc or match_pl: 22 | 23 | m_key = "%s-%i" % (class_name, module_idx + 1) 24 | summary[m_key] = OrderedDict() 25 | summary[m_key]["type"] = "CONV" 26 | summary[m_key]["input_shape"] = list(input[0].size()) 27 | summary[m_key]["input_shape"][0] = batch_size 28 | if isinstance(output, (list, tuple)): 29 | summary[m_key]["output_shape"] = [ 30 | [-1] + list(o.size())[1:] for o in output 31 | ] 32 | else: 33 | summary[m_key]["output_shape"] = list(output.size()) 34 | summary[m_key]["output_shape"][0] = batch_size 35 | 36 | params = 0 37 | if hasattr(module, "weight") and hasattr(module.weight, "size"): 38 | params += torch.prod(torch.LongTensor(list(module.weight.size()))) 39 | summary[m_key]["trainable"] = module.weight.requires_grad 40 | if hasattr(module, "bias") and hasattr(module.bias, "size"): 41 | params += torch.prod(torch.LongTensor(list(module.bias.size()))) 42 | 43 | summary[m_key]["nb_params"] = params 44 | N = batch_size 45 | if len(module.weight.size()) == 4: 46 | groups = module.groups 47 | _,C, Y, X = input[0].size() 48 | _,K, Yo, Xo = output.size() 49 | _, _, R, S = module.weight.size() 50 | summary[m_key]["stride"] = module.stride 51 | if groups == C: 52 | summary[m_key]["type"]= "DSCONV" 53 | K = 1 54 | else: 55 | K, C = module.weight.size() 56 | X, Xo, Y, Yo, R, S = 1,1,1,1,1,1 57 | summary[m_key]["stride"] = None 58 | summary[m_key]["dimension_ic"] = (N, K, C, R, S, Y, X) 59 | summary[m_key]["dimension_oc"] = (N, K, C, R, S, Yo, Xo) 60 | 61 | 62 | if ( 63 | not isinstance(module, nn.Sequential) 64 | and not isinstance(module, nn.ModuleList) 65 | and not (module == model) 66 | ): 67 | hooks.append(module.register_forward_hook(hook)) 68 | 69 | device = device.lower() 70 | assert device in [ 71 | "cuda", 72 | "cpu", 73 | ], "Input device is not valid, please specify 'cuda' or 'cpu'" 74 | 75 | if device == "cuda" and torch.cuda.is_available(): 76 | dtype = torch.cuda.FloatTensor 77 | else: 78 | dtype = torch.FloatTensor 79 | 80 | # multiple inputs to the network 81 | if isinstance(input_size, tuple): 82 | input_size = [input_size] 83 | 84 | # batch_size of 2 for batchnorm 85 | x = [torch.rand(2, *in_size).type(dtype) for in_size in input_size] 86 | # print(type(x[0])) 87 | 88 | # create properties 89 | summary = OrderedDict() 90 | hooks = [] 91 | 92 | # register hook 93 | model.apply(register_hook) 94 | 95 | # make a forward pass 96 | # print(x.shape) 97 | model(*x) 98 | 99 | # remove these hooks 100 | for h in hooks: 101 | h.remove() 102 | if not silent: 103 | print("----------------------------------------------------------------") 104 | line_new = "{:>20} {:>25} {:>15}".format("Layer (type)", "Output Shape", "Param #") 105 | print(line_new) 106 | print("================================================================") 107 | total_params = 0 108 | total_output = 0 109 | trainable_params = 0 110 | for layer in summary: 111 | # input_shape, output_shape, trainable, nb_params 112 | line_new = "{:>20} {:>25} {:>15}".format( 113 | layer, 114 | str(summary[layer]["output_shape"]), 115 | "{0:,}".format(summary[layer]["nb_params"]), 116 | ) 117 | total_params += summary[layer]["nb_params"] 118 | total_output += np.prod(summary[layer]["output_shape"]) 119 | if "trainable" in summary[layer]: 120 | if summary[layer]["trainable"] == True: 121 | trainable_params += summary[layer]["nb_params"] 122 | print(line_new) 123 | 124 | # assume 4 bytes/number (float on cuda). 125 | total_input_size = abs(np.prod(input_size) * batch_size * 4. / (1024 ** 2.)) 126 | total_output_size = abs(2. * total_output * 4. / (1024 ** 2.)) # x2 for gradients 127 | total_params_size = abs(total_params.numpy() * 4. / (1024 ** 2.)) 128 | total_size = total_params_size + total_output_size + total_input_size 129 | 130 | print("================================================================") 131 | print("Total params: {0:,}".format(total_params)) 132 | print("Trainable params: {0:,}".format(trainable_params)) 133 | print("Non-trainable params: {0:,}".format(total_params - trainable_params)) 134 | print("----------------------------------------------------------------") 135 | print("Input size (MB): %0.2f" % total_input_size) 136 | print("Forward/backward pass size (MB): %0.2f" % total_output_size) 137 | print("Params size (MB): %0.2f" % total_params_size) 138 | print("Estimated Total Size (MB): %0.2f" % total_size) 139 | print("----------------------------------------------------------------") 140 | return summary 141 | -------------------------------------------------------------------------------- /tools/frontend/helpers/torch_to_maestro.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torchvision.models as models 3 | from maestro_summary import summary 4 | import re 5 | import argparse 6 | 7 | 8 | 9 | device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') 10 | 11 | 12 | 13 | if __name__ == "__main__": 14 | parser = argparse.ArgumentParser() 15 | parser.add_argument('--input_size', type=str, default="3,224,224", help='input size') 16 | parser.add_argument('--model', type=str, default="mobilenet_v2", help='model from torchvision choces: \ 17 | resnet18, alexnet, vgg16, squeezenet, densenet, \ 18 | inception, googlenet, shufflenet, mobilenet,\ 19 | wide_resnet50_2, mnasnet') 20 | 21 | parser.add_argument('--dataflow', type=str, default="os", help='dataflow choices: dla, os, ws, rs') 22 | parser.add_argument('--outfile', type=str, default="out.m", help='output file name') 23 | opt = parser.parse_args() 24 | INPUT_SIZE = tuple((int(d) for d in str.split(opt.input_size, ","))) 25 | model = getattr(models, opt.model)() 26 | model = model.to(device) 27 | mae_summary = summary(model, INPUT_SIZE) 28 | 29 | with open(opt.dataflow + ".m", "r") as fd: 30 | with open("util/dpt.m", "r") as fdpt: 31 | with open("out/"+opt.outfile, "w") as fo: 32 | fo.write("Network {} {{\n".format(model.__module__)) 33 | for key, val in mae_summary.items(): 34 | pc = re.compile("^Conv") 35 | pl = re.compile("^Linear") 36 | match_pc = pc.match(key) 37 | match_pl = pl.match(key) 38 | if match_pc or match_pl: 39 | fo.write("Layer {} {{\n".format(key)) 40 | type = val["type"] 41 | fo.write("Type: {}\n".format(type)) 42 | if not match_pl: 43 | fo.write("Stride {{ X: {}, Y: {} }}\n".format(*val["stride"])) 44 | fo.write("Dimensions {{ K: {}, C: {}, R: {}, S: {}, Y: {}, X: {} }}\n".format( 45 | *val["dimension_ic"][1:])) 46 | if type == "CONV": 47 | fd.seek(0) 48 | fo.write(fd.read()) 49 | else: 50 | fdpt.seek(0) 51 | fo.write(fdpt.read()) 52 | fo.write("}\n") 53 | fo.write("}") -------------------------------------------------------------------------------- /tools/frontend/keras-example/alexnet.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | 3 | layer = tf.keras.layers 4 | seq = tf.keras.models.Sequential 5 | 6 | def alexnet(): 7 | model = seq([ 8 | layer.Conv2D(96, kernel_size=(11,11), strides=(4,4), activation='relu', input_shape=(224,224,3)), 9 | layer.MaxPooling2D(pool_size=(3, 3), strides=(2,2)), 10 | 11 | layer.Conv2D(256, kernel_size=(5,5), strides=(1,1), activation='relu'), 12 | layer.MaxPooling2D(pool_size=(3,3), strides=(2,2)), 13 | 14 | layer.Conv2D(384, kernel_size=(3, 3), strides=(1, 1), activation='relu'), 15 | 16 | layer.Conv2D(384, kernel_size=(3, 3), strides=(1, 1), activation='relu'), 17 | 18 | layer.Conv2D(256, kernel_size=(3, 3), strides=(1, 1), activation='relu'), 19 | layer.MaxPooling2D(pool_size=(3,3), strides=(2,2)), 20 | 21 | layer.Flatten(), 22 | layer.Dense(4096, input_shape=(224*224*3,), activation='relu'), 23 | layer.Dropout(0.4), 24 | 25 | layer.Dense(4096, activation='relu'), 26 | layer.Dense(4096, activation='relu'), 27 | layer.Dropout(0.4), 28 | 29 | layer.Dense(1, activation='softmax') 30 | ]) 31 | 32 | model.compile(optimizer='adam', 33 | loss='binary_crossentropy', 34 | metrics=['accuracy']) 35 | return model 36 | -------------------------------------------------------------------------------- /tools/frontend/keras-example/my_model.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | 3 | def my_model(): 4 | model = tf.keras.models.Sequential([ 5 | tf.keras.layers.Conv2D(1, 3, input_shape=[28,28,1]), 6 | tf.keras.layers.Conv2D(1, 3), 7 | tf.keras.layers.Flatten(), 8 | tf.keras.layers.Dense(128, activation='relu'), 9 | tf.keras.layers.Dropout(0.2), 10 | tf.keras.layers.Dense(10, activation='softmax') 11 | ]) 12 | return model 13 | 14 | if __name__ == "__main__": 15 | mnist = tf.keras.datasets.mnist 16 | 17 | (x_train, y_train), (x_test, y_test) = mnist.load_data() 18 | x_train, x_test = x_train / 255.0, x_test / 255.0 19 | 20 | print(x_train.shape) 21 | x_train = tf.reshape(x_train, [x_train.shape[0], 28, 28, 1]) 22 | x_test = tf.reshape(x_test, [x_test.shape[0], 28, 28, 1]) 23 | 24 | model = my_model() 25 | 26 | print(model.summary()) 27 | model.compile(optimizer='adam', 28 | loss='sparse_categorical_crossentropy', 29 | metrics=['accuracy']) 30 | 31 | model.fit(x_train, y_train, batch_size=16,epochs=5) 32 | 33 | print("Now begin evaluation") 34 | model.evaluate(x_test, y_test, verbose=2) 35 | print("Using tf version: " + tf.__version__) 36 | -------------------------------------------------------------------------------- /tools/frontend/mapping_to_modelfile.py: -------------------------------------------------------------------------------- 1 | import re 2 | import argparse 3 | import os.path 4 | from argparse import RawTextHelpFormatter 5 | 6 | if __name__ == "__main__": 7 | parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter) 8 | parser.add_argument('--mapping_file', type=str, default="Resnet50_kcp_ws.m", help="") 9 | parser.add_argument('--outfile', type=str, default="out.m", help='output file name') 10 | opt = parser.parse_args() 11 | print('Begin processing') 12 | base_path = '../../data/' 13 | check = 0 14 | if os.path.exists(base_path + 'mapping/' + opt.mapping_file): 15 | with open(base_path + 'model/' + opt.outfile, "w") as fo: 16 | with open(base_path + 'mapping/' + opt.mapping_file, "r") as fm: 17 | for line in fm: 18 | if(re.search("Dataflow",line) or re.search("SpatialMap",line) or re.search("TemporalMap",line) or re.search("Cluster",line)): 19 | check = 1 20 | continue 21 | elif check == 1: 22 | check = 0 23 | continue 24 | else: 25 | fo.write(line) 26 | print("Model file created") 27 | else: 28 | print("Mapping file not found, please provide one") 29 | -------------------------------------------------------------------------------- /tools/frontend/modelfile_to_mapping.py: -------------------------------------------------------------------------------- 1 | import re 2 | import argparse 3 | import os.path 4 | from argparse import RawTextHelpFormatter 5 | 6 | if __name__ == "__main__": 7 | parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter) 8 | parser.add_argument('--model_file', type=str, default="dnn_model", help="") 9 | parser.add_argument('--dataflow', type=str, default="ykp_os", help='dataflow choices: ykp_os, kcp_ws, xp_ws, rs') 10 | parser.add_argument('--outfile', type=str, default="out.m", help='output file name') 11 | opt = parser.parse_args() 12 | print('Begin processing') 13 | dsconv = 0 14 | base_path = '../../data/' 15 | if os.path.exists(base_path + 'model/' + opt.model_file): 16 | with open('./dataflow/' + opt.dataflow + ".m" ,"r") as fd: 17 | with open('./dataflow/'+ 'dpt.m' , "r") as fdpt: 18 | with open(base_path + 'mapping/' + opt.outfile, "w") as fo: 19 | with open(base_path + 'model/' + opt.model_file, "r") as fm: 20 | for line in fm: 21 | if(re.search("DSCONV",line)): 22 | dsconv = 1 23 | if(re.search("Dimensions",line)): 24 | fo.write(line) 25 | if(dsconv): 26 | fdpt.seek(0) 27 | fo.write(fdpt.read()) 28 | else: 29 | fd.seek(0) 30 | fo.write(fd.read()) 31 | dsconv=0 32 | else: 33 | fo.write(line) 34 | 35 | print("Mapping file created") 36 | else: 37 | print("Model file not found, please provide one") 38 | -------------------------------------------------------------------------------- /tools/frontend/run_frontend.sh: -------------------------------------------------------------------------------- 1 | python frameworks_to_modelfile_maestro.py --api_name keras --model custom --custom alexnet --outfile alexnet_keras_custom.m 2 | -------------------------------------------------------------------------------- /tools/jupyter_notebook/README.md: -------------------------------------------------------------------------------- 1 | # maestro_result_analysis 2 | To explore the MAESTRO result analysis example, launch the binder below and open tools/jupyter_notebook/maestro_output_analysis.ipynb. 3 | 4 | 5 | 6 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/maestro-project/maestro/master) 7 | -------------------------------------------------------------------------------- /tools/jupyter_notebook/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maestro-project/maestro/4eb08d17c87caf1ee3f3a351b10eb9b8ef70dd87/tools/jupyter_notebook/__init__.py -------------------------------------------------------------------------------- /tools/jupyter_notebook/graph_util.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import matplotlib.pyplot as plt 4 | 5 | def draw_graph(df, y, x, color, figsize, legend, title, xlabel, ylabel, start_layer, end_layer): 6 | df.columns = df.columns.str.strip() 7 | if(end_layer == "all"): 8 | df_new = df 9 | else: 10 | df_new = df[start_layer:end_layer] 11 | my_plot = df_new.plot(kind='bar', y = y, x = x, color = color, figsize = figsize, legend = legend) 12 | my_plot.set_title(title, fontsize=15) 13 | my_plot.set_xlabel(xlabel) 14 | my_plot.set_ylabel(ylabel) 15 | my_plot.ticklabel_format(axis='y', scilimits=(-3,3)) 16 | return my_plot 17 | 18 | 19 | def draw_two_graph(df1, df2, y, x, color, figsize, legend, title, xlabel, ylabel, start_layer, end_layer): 20 | df1.columns = df1.columns.str.strip() 21 | if(end_layer == "all"): 22 | df1 = df1 23 | else: 24 | df1 = df1[start_layer:end_layer] 25 | 26 | df2.columns = df2.columns.str.strip() 27 | if(end_layer == "all"): 28 | df2 = df2 29 | else: 30 | df2 = df2[start_layer:end_layer] 31 | 32 | df1.plot(kind='Line', y = y, x = x, color = 'red', figsize = figsize, legend = legend, ax=axes) 33 | df2.plot(kind='Line', y = y, x = x, color = 'blue', figsize = figsize, legend = legend, ax=axes) 34 | 35 | #my_plot = df_new.plot(kind='bar', y = y, x = x, color = color, figsize = figsize, legend = legend) 36 | #fig.set_title(title) 37 | #fig.set_xlabel(xlabel) 38 | #fig.set_ylabel(ylabel) 39 | return fig -------------------------------------------------------------------------------- /tools/jupyter_notebook/requirements.txt: -------------------------------------------------------------------------------- 1 | pandas==0.23.4 2 | numpy==1.15.4 3 | import_ipynb==0.1.3 4 | matplotlib==3.0.2 5 | watermark==2.0.2 6 | -------------------------------------------------------------------------------- /validation/eyeriss/alexnet_rs_validation.m: -------------------------------------------------------------------------------- 1 | Network alexnet { 2 | 3 | Layer CONV1 { 4 | Type: CONV 5 | Stride { X: 4, Y: 4 } 6 | Dimensions { N 4, K 96, C 3, R 11, S 11, Y 227, X 227 } 7 | Dataflow { 8 | SpatialMap(1,1) Y'; 9 | TemporalMap(1,1) X'; 10 | TemporalMap(1,1) N; 11 | TemporalMap(1,1) C; 12 | TemporalMap(16,16) K; 13 | TemporalMap(Sz(R),Sz(R)) R; 14 | TemporalMap(Sz(S),Sz(S)) S; 15 | Cluster(Sz(R),P); 16 | TemporalMap(1,1) N; 17 | TemporalMap(1,1) C; 18 | TemporalMap(2,2) K; 19 | SpatialMap(1,1) Y; 20 | SpatialMap(1,1) R; 21 | TemporalMap(Sz(S),Sz(S)) S; 22 | } 23 | } 24 | 25 | Layer CONV2 { 26 | Type: CONV 27 | Dimensions { N 4, K 256, C 48, R 5, S 5, Y 31, X 31 } 28 | Dataflow { 29 | SpatialMap(1,1) Y'; 30 | TemporalMap(1,1) X'; 31 | TemporalMap(1,1) N; 32 | TemporalMap(2,2) C; 33 | TemporalMap(16,16) K; 34 | TemporalMap(Sz(R),Sz(R)) R; 35 | TemporalMap(Sz(S),Sz(S)) S; 36 | Cluster(Sz(R),P); 37 | TemporalMap(1,1) C; 38 | SpatialMap(1,1) Y; 39 | SpatialMap(1,1) R; 40 | TemporalMap(Sz(S),Sz(S)) S; 41 | } 42 | } 43 | 44 | Layer CONV3 { 45 | Type: CONV 46 | Dimensions { N 4, K 384, C 256, R 3, S 3, Y 15, X 15 } 47 | Dataflow { 48 | TemporalMap(4,4) N; 49 | SpatialMap(16,16) K; 50 | TemporalMap(4,4) C; 51 | TemporalMap(13,13) Y'; 52 | TemporalMap(15,13) X; 53 | TemporalMap(Sz(R),Sz(R)) R; 54 | TemporalMap(Sz(S),Sz(S)) S; 55 | Cluster(13, P); 56 | TemporalMap(4,4) N; 57 | TemporalMap(16,16) K; 58 | TemporalMap(4,4) C; 59 | SpatialMap(1,1) Y'; 60 | TemporalMap(15,13) X; 61 | TemporalMap(Sz(R),Sz(R)) R; 62 | TemporalMap(Sz(S),Sz(S)) S; 63 | Cluster(Sz(R),P); 64 | TemporalMap(4,4) N; 65 | TemporalMap(4,4) C; 66 | TemporalMap(16,16) K; 67 | TemporalMap(13,13) X'; 68 | SpatialMap(1,1) Y; 69 | SpatialMap(1,1) R; 70 | TemporalMap(Sz(S), Sz(S)) S; 71 | } 72 | } 73 | 74 | Layer CONV4 { 75 | Type: CONV 76 | Dimensions { N 4, K 384,C 192, R 3, S 3, Y 15, X 15 } 77 | Dataflow { 78 | TemporalMap(4,4) N; 79 | TemporalMap(6,6) C; 80 | SpatialMap(16,16) K; 81 | TemporalMap(13,13) Y'; 82 | TemporalMap(13,13) X'; 83 | TemporalMap(Sz(R),Sz(R)) R; 84 | TemporalMap(Sz(S),Sz(S)) S; 85 | Cluster(2, P); 86 | TemporalMap(4,4) N; 87 | SpatialMap(3,3) C; 88 | TemporalMap(16,16) K; 89 | TemporalMap(13,13) Y'; 90 | TemporalMap(1,1) X'; 91 | TemporalMap(Sz(R),Sz(R)) R; 92 | TemporalMap(Sz(S),Sz(S)) S; 93 | Cluster(13, P); 94 | TemporalMap(4,4) N; 95 | TemporalMap(3,3) C; 96 | TemporalMap(16,16) K; 97 | SpatialMap(1,1) Y'; 98 | TemporalMap(1,1) X'; 99 | TemporalMap(Sz(R),Sz(R)) R; 100 | TemporalMap(Sz(S),Sz(S)) S; 101 | Cluster(Sz(R),P); 102 | TemporalMap(1,1) N; 103 | TemporalMap(1,1) C; 104 | TemporalMap(1,1) K; 105 | TemporalMap(1,1) X'; 106 | SpatialMap(1,1) Y; 107 | SpatialMap(1,1) R; 108 | TemporalMap(Sz(S), Sz(S)) S; 109 | } 110 | } 111 | 112 | Layer CONV5 { 113 | Type: CONV 114 | Dimensions { N 4, K 256, C 192 , R 3, S 3, Y 15, X 15 } 115 | Dataflow { 116 | TemporalMap(4,4) N; 117 | TemporalMap(6,6) C; 118 | SpatialMap(16,16) K; 119 | TemporalMap(13,13) Y'; 120 | TemporalMap(13,13) X'; 121 | TemporalMap(Sz(R),Sz(R)) R; 122 | TemporalMap(Sz(S),Sz(S)) S; 123 | Cluster(2, P); 124 | TemporalMap(4,4) N; 125 | SpatialMap(3,3) C; 126 | TemporalMap(16,16) K; 127 | TemporalMap(13,13) Y'; 128 | TemporalMap(8,8) X'; 129 | TemporalMap(Sz(R),Sz(R)) R; 130 | TemporalMap(Sz(S),Sz(S)) S; 131 | Cluster(13, P); 132 | TemporalMap(1,1) N; 133 | TemporalMap(3,3) C; 134 | TemporalMap(16,16) K; 135 | SpatialMap(1,1) Y'; 136 | TemporalMap(1,1) X'; 137 | TemporalMap(Sz(R),Sz(R)) R; 138 | TemporalMap(Sz(S),Sz(S)) S; 139 | Cluster(Sz(R),P); 140 | TemporalMap(1,1) N; 141 | TemporalMap(1,1) C; 142 | TemporalMap(2,2) K; 143 | TemporalMap(1,1) X'; 144 | SpatialMap(1,1) Y; 145 | SpatialMap(1,1) R; 146 | TemporalMap(Sz(S), Sz(S)) S; 147 | } 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /validation/eyeriss/run_eval_alexnet_rs.sh: -------------------------------------------------------------------------------- 1 | ./maestro \ 2 | --Mapping_file='alexnet_rs_validation.m' \ 3 | --print_res=true \ 4 | --print_res_csv_file=true \ 5 | --print_log_file=false \ 6 | --noc_bw=14 \ 7 | --noc_hop_latency=1 \ 8 | --noc_mc_support=true \ 9 | --num_pes=168 \ 10 | --num_simd_lanes=1 \ 11 | --l1_size=5120 \ 12 | --l2_size=1024000 \ 13 | --do_implicit_reduction=false \ 14 | --do_fg_sync=false \ 15 | --do_reduction_op=true \ 16 | --do_dse=false \ 17 | 18 | 19 | -------------------------------------------------------------------------------- /validation/maeri/run_eval_Resnet50_maeri.sh: -------------------------------------------------------------------------------- 1 | ./maestro \ 2 | --Mapping_file='Resnet50_maeri.m' \ 3 | --print_res=true \ 4 | --print_res_csv_file=true \ 5 | --print_log_file=false \ 6 | --noc_bw=1000000000 \ 7 | --noc_hop_latency=0 \ 8 | --noc_mc_support=true \ 9 | --num_pes=256 \ 10 | --num_simd_lanes=1 \ 11 | --l1_size=5120 \ 12 | --l2_size=1024000 \ 13 | --do_implicit_reduction=true \ 14 | --do_fg_sync=false \ 15 | --do_reduction_op=true \ 16 | --do_dse=false \ 17 | 18 | 19 | -------------------------------------------------------------------------------- /validation/maeri/run_eval_vgg16_maeri.sh: -------------------------------------------------------------------------------- 1 | ./maestro \ 2 | --Mapping_file='vgg16_maeri.m' \ 3 | --print_res=true \ 4 | --print_res_csv_file=true \ 5 | --print_log_file=false \ 6 | --noc_bw=1000000000 \ 7 | --noc_hop_latency=0 \ 8 | --noc_mc_support=true \ 9 | --num_pes=256 \ 10 | --num_simd_lanes=1 \ 11 | --l1_size=5120 \ 12 | --l2_size=1024000 \ 13 | --do_implicit_reduction=true \ 14 | --do_fg_sync=false \ 15 | --do_reduction_op=true \ 16 | --do_dse=false \ 17 | 18 | 19 | --------------------------------------------------------------------------------