Skip to content

Commit bc930d3

Browse files
committed
fix string issue
1 parent 7d7b505 commit bc930d3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

deep-gemm/csrc/jit_kernels/impls/runtime_utils.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <cmath>
4+
#include <cstdio>
35
#include <cuda.h>
46
#include "../../utils/torch_compat.hpp"
57

@@ -64,8 +66,12 @@ static std::string to_string(const at::ScalarType& dtype) {
6466
static std::string to_string(const float& v) {
6567
if (std::isfinite(v)) {
6668
char buffer[32];
67-
std::snprintf(buffer, sizeof(buffer), "%.9gf", v);
68-
return buffer;
69+
std::snprintf(buffer, sizeof(buffer), "%.9g", v);
70+
std::string literal = buffer;
71+
if (literal.find_first_of(".eE") == std::string::npos)
72+
literal += ".0";
73+
literal += "f";
74+
return literal;
6975
} else if (std::isinf(v)) {
7076
return v > 0 ? "cute::numeric_limits<float>::infinity()"
7177
: "-cute::numeric_limits<float>::infinity()";

0 commit comments

Comments
 (0)