Closed ehsantn closed 7 years ago
looks like the said function was called with Any
type for its second argument. Please double check if the source had any thing with Any
type.
The program hasn't changed from before. input parameters are typed properly also.
Looks like the second input of the subtraction in the first comprehension is not typed properly. Could it because of :
operator in ParallelAccelerator.API.getindex
?
SSAValue(7) = (ParallelAccelerator.API.sqrt)((ParallelAccelerator.API.sum)(($(Expr(:invoke, LambdaInfo for getindex(::Array{Float64,2}, ::Colon, ::Vararg{Any,N}), :(ParallelAccelerator.API.getindex), :((Core.getfield)(_1,:points)::Array{Float64,2}), :(Main.:), :(_2))) - (ParallelAccelerator.API.getindex)((Core.getfield)((Core.getfield)(_1,:centroids)::Core.Box,:contents),Main.:,_7)) .^ 2))
@acc hpat function kmeans(numCenter, iterNum, file_name)
points = DataSource(Matrix{Float64},HDF5,"/points", file_name)
D,N = size(points) # number of features, instances
centroids = rand(D, numCenter)
for l in 1:iterNum
dist = [ Float64[sqrt(sum((points[:,i]-centroids[:,j]).^2)) for j in 1:numCenter] for i in 1:N]
labels = Int[indmin(dist[i]) for i in 1:N]
centroids = Float64[ sum(points[j,labels.==i])/sum(labels.==i) for j in 1:D, i in 1:numCenter]
end
return centroids
end
Once we bring the k-means.jl
source from HAT to match the one in ParallelAccelerator, the inference issue is gone.
Our comprehension translation relies on some type hack for Julia 0.5, so it is advised to annotate the LHS with precise type in case something fails due to Any type.
After the change, now it triggers some other error further down in HPAT pipeline. You may want to take a look. @ehsantn
It's sad that we need this much type annotation now. I will investigate the HPAT problems.
I think this problem is resolved.
DomainIR throws an error for kmeans example of HPAT on Julia 0.5-rc3.