| 448 | struct Log2Checked { |
| 449 | template <typename T, typename Arg> |
| 450 | static enable_if_floating_value<Arg, T> Call(KernelContext*, Arg arg, Status* st) { |
| 451 | static_assert(std::is_same<T, Arg>::value, ""); |
| 452 | if (arg == 0.0) { |
| 453 | *st = Status::Invalid("logarithm of zero"); |
| 454 | return arg; |
| 455 | } else if (arg < 0.0) { |
| 456 | *st = Status::Invalid("logarithm of negative number"); |
| 457 | return arg; |
| 458 | } |
| 459 | return std::log2(arg); |
| 460 | } |
| 461 | }; |
| 462 | |
| 463 | struct Log1p { |