diff --git a/src/target/source/codegen_opencl.cc b/src/target/source/codegen_opencl.cc index 55d9e70be25a4..21e5ed66403f0 100644 --- a/src/target/source/codegen_opencl.cc +++ b/src/target/source/codegen_opencl.cc @@ -230,7 +230,7 @@ std::string CodeGenOpenCL::CastFromTo(std::string value, DataType from, DataType } void CodeGenOpenCL::VisitExpr_(const CallNode* op, std::ostream& os) { - if (op->is_intrinsic(intrinsic::tvm_address_of)) { + if (op->op.same_as(builtin::address_of())) { // Overload tvm_address_of to add storage scope (e.g. __global). const LoadNode* load = op->args[0].as(); CHECK(op->args.size() == 1 && load); @@ -243,9 +243,10 @@ void CodeGenOpenCL::VisitExpr_(const CallNode* op, std::ostream& os) { os << " *)" << this->GetVarID(load->buffer_var.get()) << " + "; this->PrintExpr(load->index, os); os << ')'; - } else if (op->call_type == CallNode::Extern || op->call_type == CallNode::PureExtern) { + } else if (op->op.same_as(builtin_call_extern_)) { + auto func = Downcast(op->args[0]); // Enable atomics extension if used. - if (op->name == "atomic_add") { + if (func->value == "atomic_add") { enable_atomics_ = true; } CodeGenC::VisitExpr_(op, os); diff --git a/tests/python/relay/test_op_level5.py b/tests/python/relay/test_op_level5.py index 14d43c0a5fca2..42d10f6c9df86 100644 --- a/tests/python/relay/test_op_level5.py +++ b/tests/python/relay/test_op_level5.py @@ -270,8 +270,8 @@ def verify_get_valid_counts(dshape, score_threshold, id_index, score_index): intrp = relay.create_executor("debug", ctx=ctx, target=target) out = intrp.evaluate(func)(np_data) tvm.testing.assert_allclose(out[0].asnumpy(), np_out1, rtol=1e-3, atol=1e-04) - # get_valid_count for cuda doesn't do data rearrangement - if target == 'cuda': + # get_valid_count for cuda, opencl doesn't do data rearrangement + if target in ['cuda', 'opencl']: return tvm.testing.assert_allclose(out[1].asnumpy(), np_out2, rtol=1e-3, atol=1e-04) tvm.testing.assert_allclose(out[2].asnumpy(), np_out3, rtol=1e-3, atol=1e-04)