diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-12-22 15:27:52 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:49:16 +0000 |
commit | d8734b55d89f05901ba9a75349761a9c955d9243 (patch) | |
tree | e23d53a0fb73251f7416993e4d3a7241e533e79e /arm_compute/graph2/mutators | |
parent | 7390e05561a5c49306ebbf2eb2dcb1848546f201 (diff) | |
download | ComputeLibrary-d8734b55d89f05901ba9a75349761a9c955d9243.tar.gz |
COMPMID-793 : Add graph intermediate representation
Change-Id: Ic1685de4e19e0ac79669ef2da64e1dc96c7ea0bf
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/115248
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/graph2/mutators')
-rw-r--r-- | arm_compute/graph2/mutators/DepthConcatSubTensorMutator.h | 46 | ||||
-rw-r--r-- | arm_compute/graph2/mutators/GraphMutators.h | 31 | ||||
-rw-r--r-- | arm_compute/graph2/mutators/InPlaceOperationMutator.h | 43 | ||||
-rw-r--r-- | arm_compute/graph2/mutators/NodeFusionMutator.h | 52 |
4 files changed, 172 insertions, 0 deletions
diff --git a/arm_compute/graph2/mutators/DepthConcatSubTensorMutator.h b/arm_compute/graph2/mutators/DepthConcatSubTensorMutator.h new file mode 100644 index 0000000000..bdf2e01edb --- /dev/null +++ b/arm_compute/graph2/mutators/DepthConcatSubTensorMutator.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_GRAPH2_DEPTH_CONCAT_SUBTENSOR_MUTATOR_H__ +#define __ARM_COMPUTE_GRAPH2_DEPTH_CONCAT_SUBTENSOR_MUTATOR_H__ + +#include "arm_compute/graph2/IGraphMutator.h" + +namespace arm_compute +{ +namespace graph2 +{ +/** Mutation pass to optimize depth concatenation operations by using sub-tensors + * + * @warning Always run as one of the last mutation pass as optimizations might change the parent of sub-tensors. + **/ +class DepthConcatSubTensorMutator final : public IGraphMutator +{ +public: + // Inherited methods overridden + virtual void mutate(Graph &g) override; + const char *name() override; +}; +} // namespace graph2 +} // namespace arm_compute +#endif /* __ARM_COMPUTE_GRAPH2_DEPTH_CONCAT_SUBTENSOR_MUTATOR_H__ */ diff --git a/arm_compute/graph2/mutators/GraphMutators.h b/arm_compute/graph2/mutators/GraphMutators.h new file mode 100644 index 0000000000..b432e329e2 --- /dev/null +++ b/arm_compute/graph2/mutators/GraphMutators.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_GRAPH2_GRAPH_MUTATORS_H__ +#define __ARM_COMPUTE_GRAPH2_GRAPH_MUTATORS_H__ + +#include "arm_compute/graph2/mutators/DepthConcatSubTensorMutator.h" +#include "arm_compute/graph2/mutators/InPlaceOperationMutator.h" +#include "arm_compute/graph2/mutators/NodeFusionMutator.h" + +#endif /* __ARM_COMPUTE_GRAPH2_GRAPH_MUTATORS_H__ */ diff --git a/arm_compute/graph2/mutators/InPlaceOperationMutator.h b/arm_compute/graph2/mutators/InPlaceOperationMutator.h new file mode 100644 index 0000000000..7e4018a736 --- /dev/null +++ b/arm_compute/graph2/mutators/InPlaceOperationMutator.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_GRAPH2_INPLACE_OPERATION_MUTATOR_H__ +#define __ARM_COMPUTE_GRAPH2_INPLACE_OPERATION_MUTATOR_H__ + +#include "arm_compute/graph2/IGraphMutator.h" + +namespace arm_compute +{ +namespace graph2 +{ +/** Mutation pass to optimize operations that can be performed in-place */ +class InPlaceOperationMutator final : public IGraphMutator +{ +public: + // Inherited methods overridden + virtual void mutate(Graph &g) override; + const char *name() override; +}; +} // namespace graph2 +} // namespace arm_compute +#endif /* __ARM_COMPUTE_GRAPH2_INPLACE_OPERATION_MUTATOR_H__ */ diff --git a/arm_compute/graph2/mutators/NodeFusionMutator.h b/arm_compute/graph2/mutators/NodeFusionMutator.h new file mode 100644 index 0000000000..4371bd3ebe --- /dev/null +++ b/arm_compute/graph2/mutators/NodeFusionMutator.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_GRAPH2_NODE_FUSION_MUTATOR_H__ +#define __ARM_COMPUTE_GRAPH2_NODE_FUSION_MUTATOR_H__ + +#include "arm_compute/graph2/IGraphMutator.h" + +namespace arm_compute +{ +namespace graph2 +{ +namespace detail +{ +/** Fused batch normalization with activation + * + * @param[in] g Graph to perform operation fusion on + */ +void fuse_batch_norm_with_activation(Graph &g); +} // namespace detail + +/** Mutation pass to fuss nodes */ +class NodeFusionMutator final : public IGraphMutator +{ +public: + // Inherited methods overridden + virtual void mutate(Graph &g) override; + const char *name() override; +}; +} // namespace graph2 +} // namespace arm_compute +#endif /* __ARM_COMPUTE_GRAPH2_NODE_FUSION_MUTATOR_H__ */ |