ashutosh-arm commented on a change in pull request #9338: URL: https://github.com/apache/tvm/pull/9338#discussion_r734381363
########## File path: src/relay/backend/contrib/cmsisnn/compiler_attrs.cc ########## @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include "compiler_attrs.h" + +#include <tvm/ir/attrs.h> +#include <tvm/ir/transform.h> + +#include <string> + +namespace tvm { +namespace relay { +namespace contrib { +namespace cmsisnn { + +static const char* mveCPUs[] = {"cortex-m55"}; +static const char* dspCPUs[] = {"cortex-m7", "cortex-m33", "cortex-m35p"}; + +TVM_REGISTER_NODE_TYPE(CMSISNNCompilerConfigNode); +TVM_REGISTER_PASS_CONFIG_OPTION("relay.ext.cmsisnn.options", CMSISNNCompilerConfig); + +template <typename Container> +static inline bool MatchesCpu(std::string mcpu, const Container& cpus) { + auto matches_cpu = [mcpu](const char* cpu) { return mcpu.find(cpu) == 0; }; + return std::find_if(std::begin(cpus), std::end(cpus), matches_cpu) != std::end(cpus); +} + +static inline bool HasFlag(std::string attr, std::string flag) { + return attr.find(flag) != std::string::npos; +} + +CMSISNNFlags GetCompilerFlags(const tvm::transform::PassContext& ctx) { + auto cfg = ctx->GetConfig<CMSISNNCompilerConfig>("relay.ext.cmsisnn.options"); + if (!cfg.defined()) { + return {false, false}; Review comment: Can we use variable names instead of {false,true} etc for clarity? ########## File path: tests/cpp/relay/backend/contrib/cmsisnn/compiler_attrs_test.cc ########## @@ -0,0 +1,125 @@ +/* Review comment: should we add tvmc tests for some combinations of attrs as well? ########## File path: tests/python/relay/aot/aot_test_utils.py ########## @@ -140,6 +140,11 @@ class AOTTestRunner(NamedTuple): """, includes=["uart.h"], parameters={"NPU_VARIANT": "256"}, + pass_config={ Review comment: For my understanding, how are the flags (mcpu, mattr) being passed down to the fvp? Based on the mattr the op implementations do change. ########## File path: src/relay/backend/contrib/cmsisnn/buffer_size.cc ########## @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include <tvm/ir/attrs.h> +#include <tvm/ir/transform.h> + +#include "compiler_attrs.h" + +namespace tvm { +namespace relay { +namespace contrib { +namespace cmsisnn { + +int Conv2dBufferSize(CMSISNNFlags flags, int32_t padding_w, int32_t padding_h, int32_t input_n, Review comment: CMSISNNDimensions proposed in #9331 can be used to reduce the list of args -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
