You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/10/17 10:42:32 UTC
[GitHub] [tvm] mbaret opened a new pull request, #13095: [AOT] Add CreateFunctionMetadata analysis pass
mbaret opened a new pull request, #13095:
URL: https://github.com/apache/tvm/pull/13095
Tracking issue: https://github.com/apache/tvm/issues/12548
AOT requires FunctionInfo to be defined for all the functions in the module. This stores information on how much memory the functions use. This commit adds a separate analysis pass to create all the FunctionInfos + some tests for the new pass.
cc @Mousius @ekalda @lhutton1 @areusch
(apologies for late follow-up, have been away for a while)
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] lhutton1 commented on pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
lhutton1 commented on PR #13095:
URL: https://github.com/apache/tvm/pull/13095#issuecomment-1289579335
Thanks @mbaret @areusch!
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] mbaret commented on pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
mbaret commented on PR #13095:
URL: https://github.com/apache/tvm/pull/13095#issuecomment-1280658023
cc also @ekalda
(apologies for late follow-up, have been away for a while)
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on a diff in pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #13095:
URL: https://github.com/apache/tvm/pull/13095#discussion_r997302459
##########
src/relay/backend/aot/create_function_metadata.cc:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file src/relay/backend/aot/create_function_metadata.cc
+ * \brief Create FunctionInfo metadata from a lowered TIR module.
+ */
+#include "./create_function_metadata.h"
+
+#include <tvm/ir/expr.h>
+#include <tvm/ir/module.h>
+#include <tvm/runtime/container/array.h>
+#include <tvm/runtime/container/map.h>
+#include <tvm/runtime/container/string.h>
+#include <tvm/runtime/data_type.h>
+#include <tvm/runtime/module.h>
+#include <tvm/target/target_kind.h>
+#include <tvm/tir/analysis.h>
+#include <tvm/tir/function.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/usmp/utils.h>
+
+#include "../utils.h"
+
+namespace tvm {
+namespace relay {
+namespace backend {
+namespace aot {
+
+/*!
+ * \brief Calculate FunctionInfo for all the PrimFuncs in a module.
+ */
+Map<String, backend::FunctionInfo> CalculateFunctionInfos(const IRModule& mod,
+ Integer workspace_byte_alignment,
+ Integer constant_byte_alignment) {
+ Map<String, backend::FunctionInfo> function_metadata;
+ for (const auto& kv : mod->functions) {
+ GlobalVar global_var = kv.first;
+ BaseFunc base_func = kv.second;
+ if (base_func->IsInstance<tir::PrimFuncNode>()) {
+ tir::PrimFunc pfunc = Downcast<tir::PrimFunc>(base_func);
+ Target tgt = pfunc->GetAttr<Target>(tvm::attr::kTarget).value();
+ // Determine the size of input/output buffers
+ auto params = pfunc->params;
+ int64_t ios = 0;
Review Comment:
can you expand the var name? maybe `total_io_bytes` or something to map to the FunctionInfo member?
##########
src/relay/backend/aot/create_function_metadata.cc:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file src/relay/backend/aot/create_function_metadata.cc
+ * \brief Create FunctionInfo metadata from a lowered TIR module.
+ */
+#include "./create_function_metadata.h"
+
+#include <tvm/ir/expr.h>
+#include <tvm/ir/module.h>
+#include <tvm/runtime/container/array.h>
+#include <tvm/runtime/container/map.h>
+#include <tvm/runtime/container/string.h>
+#include <tvm/runtime/data_type.h>
+#include <tvm/runtime/module.h>
+#include <tvm/target/target_kind.h>
+#include <tvm/tir/analysis.h>
+#include <tvm/tir/function.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/usmp/utils.h>
+
+#include "../utils.h"
+
+namespace tvm {
+namespace relay {
+namespace backend {
+namespace aot {
+
+/*!
+ * \brief Calculate FunctionInfo for all the PrimFuncs in a module.
+ */
+Map<String, backend::FunctionInfo> CalculateFunctionInfos(const IRModule& mod,
+ Integer workspace_byte_alignment,
+ Integer constant_byte_alignment) {
+ Map<String, backend::FunctionInfo> function_metadata;
+ for (const auto& kv : mod->functions) {
+ GlobalVar global_var = kv.first;
+ BaseFunc base_func = kv.second;
+ if (base_func->IsInstance<tir::PrimFuncNode>()) {
+ tir::PrimFunc pfunc = Downcast<tir::PrimFunc>(base_func);
+ Target tgt = pfunc->GetAttr<Target>(tvm::attr::kTarget).value();
Review Comment:
should we CHECK() here rather than letting `.value()` do it for us?
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tvm-bot commented on pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
tvm-bot commented on PR #13095:
URL: https://github.com/apache/tvm/pull/13095#issuecomment-1280656925
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* cc @Mousius, @alanmacd, @areusch, @lhutton1 <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] mbaret commented on pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
mbaret commented on PR #13095:
URL: https://github.com/apache/tvm/pull/13095#issuecomment-1289520476
@lhutton1 Andrew's on holiday for a couple of weeks, so would it be OK to merge without his approval? Think I addressed his comments :)
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] lhutton1 merged pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
lhutton1 merged PR #13095:
URL: https://github.com/apache/tvm/pull/13095
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] mbaret commented on pull request #13095: [AOT] Add CreateFunctionMetadata analysis pass
Posted by GitBox <gi...@apache.org>.
mbaret commented on PR #13095:
URL: https://github.com/apache/tvm/pull/13095#issuecomment-1288987968
@lhutton1 @areusch anything else needed here or are we good to merge?
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org