Skip to content

[Bug] cuda code compilation error #89

@soodoshll

Description

@soodoshll

I have the following cuda code generated by hidet:

#include <cuda_fp16.h>
#include <cuda_bf16.h>
#include <hidet/runtime/cuda_context.h>
#include <hidet/runtime/cpu_context.h>
typedef float tfloat32_t;
#define __float_to_tf32(x) (x)
/*
Task(
  name: clip
  parameters:
    x: tensor(int64, [1, 4, 1, 1])
    y: tensor(int64, [1, 4, 1, 1])
  inputs: [x]
  outputs: [y]
  computations:
    x: tensor(int64, [1, 4, 1, 1])
    y: int64[1, 4, 1, 1] where y[v, v_1, v_2, v_3] = generic_min(generic_max(x[v, v_1, v_2, v_3], int64(-1)), int64(1))
  attributes: {}
)
*/
extern "C" {

__global__ void __launch_bounds__(500) hidet_compute_y(int64_t * __restrict__ x, int64_t * __restrict__ y) {
  if ((int)threadIdx.x < 4) {
    y[((int)threadIdx.x % 4)] = min(max(x[((int)threadIdx.x % 4)], -1ll), 1ll);
  }
}

__host__ void hidet_clip(int32_t num_args, int32_t * __restrict__ arg_types, void* * __restrict__ args) {
  hidet_compute_y<<<1, 500, 0, (cudaStream_t)get_cuda_stream()>>>(((int64_t*)(args[0])), ((int64_t*)(args[1])));
}

}

And nvcc raises an error:

 error: more than one instance of overloaded function "max" matches the argument list:
            function "max(long, long)"
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(1008): here
            function "max(long, unsigned long)"
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(1043): here
            function "max(long long, long long)"
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(1077): here
            function "max(unsigned long long, long long)"
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(1092): here
            argument types are: (int64_t, long long)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions