怎么把uint8转换成Eigen:half?

时间:2019-09-18 16:43:04

标签: tensorflow eigen

我正在tensorflow中构建一个c ++ op。是否需要将// App.vue data() { return { healthScore: 0, storedHealthScore: 0 } }, methods: { setHealthScore() { localStorage.setItem('HealthScore', this.healthScore) }, getHealthScore() { this.storedHealthScore = localStorage.getItem('HealthScore') }, removeHealthScore() { localStorage.removeItem('HealthScore') } } 的值转换为uint8?但是,我没有找到执行此操作的函数。但我确实注意到有一个Eigen::half。本征库中是否有类似的功能half_to_float()

1 个答案:

答案 0 :(得分:1)

您可以直接从uint8_t投射到Eigen::half

Eigen::half foo(uint8_t x)
{
    return Eigen::half(x);
}

转换可能不太有效,但应该可以:https://godbolt.org/z/Wc_j3X

如果您非常需要这样做,可以考虑实现一个小的查询表。