Add Transpose Optimizer and modify nhwc optimizer to use it. (#9284)
* Add Transpose Optimizer and modify nhwc optimizer to use it.
* Fix casts
* Fix casts2
* Fix move
* Add tests
* Add headers
* Fixes and tests
* Remove explicit template instantiation
* Fix build warning
* Name unit tests
* Code review fixes
* Add some comments
* Fix some casts
* Make optimization slightly less agressive
* Some unit test fixes
* Update Attention pattern to work with transpose optimizer
* Update attention fuser
* Fix attention fusion python script
* Improve transpose optimizer documentation
* Create OptimizerCtx struct
* Disable Slice handler for testing
* Implement Slice int32
* Only push transposes leading up to other transposes
* Improve optimization heuristic
* Add exemption for MaxPool
* Document transpose optimizer api.h
* Revert fusion tests to master
* Remove temp files
* Replace typedef with using
* Trim trailing whitespace
* Move class declarations from api_impl.h to api_impl.cc
* Remove copy constructors and move allocator
* Alphabetize headers
* Add override keyword
* Comments for nhwc_transformer
* Rename OrtGraph to ApiGraph, etc.
* Wrap line
* Remove extra qualifier on ApiGraph
* Refector attention fusion
* Remove c-style casts from api_impl.cc
* Improve documentation
* Avoid printing vector in ORT_ENSURES
* Revert attention fusion refactor
* Remove duplicate cost heuristics and improve documentation
* Fix size_t casts
* Fixes from Scott's review
* Unrevert attention refactor and more updates from Scott's review
* Revert api_impl.cc ValueInfo change
* only optimize first transpose input
* Unrevert api_impl.cc changes
* Make vector call reserve
* transpose_optimizer.cc update from Scott's comments
* Rename api::Graph to api::GraphRef etc.
* Consider domains 'onnx.ai' and '' equal
* Replace AddInput with SetInput
* Improve tests
* quantization and heuristic tests
* Comments for tests
* Replace const string_view with string_view and update tests
* Fixes requested by Edward
* Fix std::string to string_view conversion
* Add <string> to includes
* Fix bug for broadcasting ops with unknown rank. Slight safety improvements
* Changes requested by Edward
* Fix formatting
* Improve description of cost metric