From 4c3353bb1bc096c835c322ade2778ad9fdd02a5f Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Mon, 8 Jul 2019 16:29:19 -0700 Subject: [PATCH 1/3] Added bool to float conversion support to spirv ir builder. --- src/codegen/spirv/ir_builder.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/codegen/spirv/ir_builder.cc b/src/codegen/spirv/ir_builder.cc index 72b68807a7d9..d6ba9e40c123 100644 --- a/src/codegen/spirv/ir_builder.cc +++ b/src/codegen/spirv/ir_builder.cc @@ -462,6 +462,9 @@ Value IRBuilder::Cast(const SType& dst_type, spirv::Value value) { return Select(value, IntImm(dst_type, 1), IntImm(dst_type, 0)); } else if (to.is_uint()) { return Select(value, UIntImm(dst_type, 1), UIntImm(dst_type, 0)); + } else if (to.is_float()) { + return MakeValue(spv::OpConvertUToF, dst_type, + Select(value, UIntImm(t_uint32_, 1), UIntImm(t_uint32_, 0))); } else { LOG(FATAL) << "cannot cast from " << from << " to " << to; return Value(); From 7a6216622ac3473c084035a8948a3a4011482a43 Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Mon, 8 Jul 2019 17:03:40 -0700 Subject: [PATCH 2/3] Added unittest for vulkan bool conversion. --- tests/python/unittest/test_codegen_bool.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/python/unittest/test_codegen_bool.py b/tests/python/unittest/test_codegen_bool.py index 0a9f8fb8331b..934812b36a6a 100644 --- a/tests/python/unittest/test_codegen_bool.py +++ b/tests/python/unittest/test_codegen_bool.py @@ -24,7 +24,8 @@ def test_cmp_load_store(): A = tvm.placeholder((n,), name='A') B = tvm.placeholder((n,), name='B') C = tvm.compute(A.shape, lambda *i: A(*i) > B(*i), name='C') - D = tvm.compute(C.shape, lambda *i: tvm.all(C(*i), A(*i) > 1), name="D") + D = tvm.compute(C.shape, lambda *i: tvm.all(C(*i), + A(*i) > 1).astype('float32'), name="D") def check_llvm(): @@ -43,7 +44,7 @@ def check_llvm(): d = tvm.nd.array(np.zeros(n, dtype=D.dtype), ctx) f(a, b, d) np.testing.assert_equal( - d.asnumpy(), np.logical_and(a.asnumpy()> b.asnumpy(), a.asnumpy() > 1)) + d.asnumpy(), np.logical_and(a.asnumpy() > b.asnumpy(), a.asnumpy() > 1).astype('float32')) def check_device(device): ctx = tvm.context(device, 0) @@ -61,7 +62,7 @@ def check_device(device): d = tvm.nd.array(np.zeros(n, dtype=D.dtype), ctx) f(a, b, d) np.testing.assert_equal( - d.asnumpy(), np.logical_and(a.asnumpy()> b.asnumpy(), a.asnumpy() > 1)) + d.asnumpy(), np.logical_and(a.asnumpy() > b.asnumpy(), a.asnumpy() > 1).astype('float32')) check_llvm() From aa34acf541422c47e135a183f8671266dc4d08bc Mon Sep 17 00:00:00 2001 From: Josh Fromm Date: Mon, 8 Jul 2019 18:05:28 -0700 Subject: [PATCH 3/3] Typo fix. --- src/runtime/vulkan/vulkan_device_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/vulkan/vulkan_device_api.cc b/src/runtime/vulkan/vulkan_device_api.cc index 7ebe278f3032..da04acdcbc31 100644 --- a/src/runtime/vulkan/vulkan_device_api.cc +++ b/src/runtime/vulkan/vulkan_device_api.cc @@ -683,7 +683,7 @@ void VulkanWorkspace::Init() { try { instance_ = CreateInstance(); context_ = GetContext(instance_); - LOG(INFO) << "Initialzie Vulkan with " << context_.size() << " devices.."; + LOG(INFO) << "Initialize Vulkan with " << context_.size() << " devices.."; for (size_t i = 0; i < context_.size(); ++i) { LOG(INFO) << "vulkan(" << i << ")=\'" << context_[i].phy_device_prop.deviceName