quic-sanirudh commented on code in PR #17214: URL: https://github.com/apache/tvm/pull/17214#discussion_r1703607486
########## python/tvm/contrib/hexagon/generate_take_op.py: ########## @@ -0,0 +1,86 @@ +# 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. +# pylint: disable=missing-docstring, invalid-name, unnecessary-comprehension, unused-argument + +import tvm +import tvm.testing +from tvm import relax +from tvm.contrib.hexagon import hexagon_unary_ops + + +def op_replace(call_node): + def is_op(op_name: str, call_node: relax.Call) -> bool: + if not isinstance(call_node, relax.Call): + return False + call_tir_op = tvm.ir.Op.get("relax.call_tir") + if call_node.op != call_tir_op: + return False + global_var = call_node.args[0] + return op_name in global_var.name_hint Review Comment: @jverma-quic I agree that `operator_name` is not the best solution either, and yeah @Lunderberg's solution is certainly the best, but yes, since we translate a relay graph to relax, we don't have that option. My only concern was that, atleast with an attribute like `operator_name`, it has to be deliberately annotated if the pass has to work. If we use the function name instead, there could potentially be a case where someone could apply the pass on some fused op that has say something like `add_tanh` and that might get replaced and result in correctness errors. That being said, since this pass isn't added to any pipeline, and has to be consciously applied by someone, I think this might also be okay. As for @Lunderberg's suggestion, we could perhaps support both types of ops (legalized and direct relax ops). -- 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]
