|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "../device.hpp" |
| 4 | +#include "common/op.hpp" |
| 5 | + |
| 6 | +namespace infinicore::op { |
| 7 | + |
| 8 | +class FloatPower { |
| 9 | +public: |
| 10 | + // ========================================================== |
| 11 | + // Dispatcher Schemas |
| 12 | + // ========================================================== |
| 13 | + |
| 14 | + // Output = Input ^ Scalar (scalar must be double!) |
| 15 | + using schema_scalar = void (*)(Tensor output, |
| 16 | + Tensor input, |
| 17 | + double exponent); |
| 18 | + |
| 19 | + // Output = Input ^ Tensor |
| 20 | + using schema_tensor = void (*)(Tensor output, |
| 21 | + Tensor input, |
| 22 | + Tensor exponent); |
| 23 | + |
| 24 | + // ========================================================== |
| 25 | + // Execute Entry Points (called by functional interface) |
| 26 | + // ========================================================== |
| 27 | + |
| 28 | + static void execute(Tensor output, |
| 29 | + Tensor input, |
| 30 | + double exponent); |
| 31 | + |
| 32 | + static void execute(Tensor output, |
| 33 | + Tensor input, |
| 34 | + Tensor exponent); |
| 35 | + |
| 36 | + // ========================================================== |
| 37 | + // Dispatchers |
| 38 | + // ========================================================== |
| 39 | + |
| 40 | + static common::OpDispatcher<schema_scalar>& dispatcher_scalar(); |
| 41 | + static common::OpDispatcher<schema_tensor>& dispatcher_tensor(); |
| 42 | +}; |
| 43 | + |
| 44 | +// ======================================================================= |
| 45 | +// Functional Interface (Python-visible semantics) |
| 46 | +// ======================================================================= |
| 47 | + |
| 48 | +// ------------------------------- |
| 49 | +// 1. Scalar Exponent |
| 50 | +// ------------------------------- |
| 51 | + |
| 52 | +// out-of-place: ALWAYS float64 |
| 53 | +Tensor float_power(Tensor input, double exponent); |
| 54 | + |
| 55 | +// in-place |
| 56 | +void float_power_(Tensor output, Tensor input, double exponent); |
| 57 | + |
| 58 | +// ------------------------------- |
| 59 | +// 2. Tensor Exponent |
| 60 | +// ------------------------------- |
| 61 | + |
| 62 | +// out-of-place: ALWAYS float64 |
| 63 | +Tensor float_power(Tensor input, Tensor exponent); |
| 64 | + |
| 65 | +// in-place |
| 66 | +void float_power_(Tensor output, Tensor input, Tensor exponent); |
| 67 | + |
| 68 | +} // namespace infinicore::op |
0 commit comments