Mousius commented on code in PR #11224:
URL: https://github.com/apache/tvm/pull/11224#discussion_r868408972


##########
tests/python/relay/test_target_hooks.py:
##########
@@ -73,4 +73,5 @@ def test_runtime_module_generation(check_result):
 
 
 if __name__ == "__main__":
-    sys.exit(pytest.main([__file__] + sys.argv[1:]))
+    # sys.exit(pytest.main([__file__] + sys.argv[1:]))

Review Comment:
   I don't think you meant to leave this change in?



##########
tests/python/relay/test_ir_parser.py:
##########
@@ -172,6 +172,23 @@ def test_int_literal():
     assert get_scalar(parse_text("-05")) == -5
     assert get_scalar(parse_text("9223372036854775807")) == 9223372036854775807
 
+    assert get_scalar(parse_text("-42i")) == -42
+    assert get_scalar(parse_text("-42i16")) == -42
+    assert get_scalar(parse_text("-42i32")) == -42
+    assert get_scalar(parse_text("-42i64")) == -42
+
+    assert_parses_as("-42i16", relay.const(-42, "int16"))
+    assert_parses_as("-42i32", relay.const(-42, "int32"))
+    assert_parses_as("-42i", relay.const(-42, "int32"))
+    assert_parses_as("-42", relay.const(-42, "int32"))
+    assert_parses_as("-42i64", relay.const(-42, "int64"))
+    assert_parses_as("2147483647", relay.const(2147483647, "int32"))
+    assert_parses_as("2147483648", relay.const(2147483648, "int64"))
+
+    with pytest.raises(tvm.error.DiagnosticError):
+        parse_text("2147483648i32")
+        parse_text("32768i16")

Review Comment:
   I think this needs two blocks as the first error will be consumed by the 
context
   
   ```suggestion
       with pytest.raises(tvm.error.DiagnosticError):
           parse_text("2147483648i32")
       with pytest.raises(tvm.error.DiagnosticError):
           parse_text("32768i16")
   ```



##########
tests/python/relay/test_ir_text_printer.py:
##########
@@ -47,16 +47,28 @@ def show(text):
         print(text)
 
 
-# Commented due to weird memory allocation error
-# def test_large_graph():
-#    x = relay.var("x", shape=(3, 2))
-#    y = relay.var("y")
-#    one = relay.const(10e10, dtype="float32")
-#    z = relay.add(x, one)
-#    for i in range(int(9e5)):
-#        z = relay.add(z, one)
-#    f = relay.Function([x, y], z)
-#    show(astext(f))
+def assert_prints_as(expr, str):
+    assert astext(expr) == SEMVER + str
+
+
+def test_scalars():
+    assert_prints_as(relay.const(42, "int16"), "42i16")
+    assert_prints_as(relay.const(42, "int32"), "42")
+    assert_prints_as(relay.const(42, "int64"), "42i64")
+    assert_prints_as(relay.const(3.0, "float16"), "3f16")
+    assert_prints_as(relay.const(3.0, "float32"), "3f")
+    assert_prints_as(relay.const(3.0, "float64"), "3f64")
+
+
+def test_large_graph():

Review Comment:
   Good job on fixing the "weird memory allocation error" 😸 



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