slyubomirsky commented on code in PR #14394:
URL: https://github.com/apache/tvm/pull/14394#discussion_r1148451991


##########
tests/python/relax/test_analysis_contains_impure_call.py:
##########
@@ -0,0 +1,104 @@
+# 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.
+
+import tvm
+import tvm.testing
+from tvm import relax as rx
+from tvm.relax.analysis import contains_impure_call
+from tvm.script import relax as R
+
+
+def test_simple_pure_case():
+    @tvm.script.ir_module
+    class PureTest:
+        @R.function
+        def pure_func(x: R.Tensor((), "int32")) -> R.Tensor((), "int32"):
+            y = R.add(x, x)
+            z = R.multiply(x, y)
+            return R.add(z, R.const(1, "int32"))
+
+    assert not contains_impure_call(PureTest["pure_func"])
+
+
+def test_simple_impure_case():
+    @tvm.script.ir_module
+    class ImpureTest:
+        @R.function
+        def impure_func() -> R.Object:
+            R.func_attr({"IsPure": False})

Review Comment:
   I plan on adding syntactic sugar for the purity attributes (`IsPure` and 
`ForcePure`).



-- 
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]

Reply via email to