#include "Halide.h"
#include <stdio.h>
int main(int argc, char **argv) {
Type valid_halide_types[] = {
{
assert(
UInt(8).bits() == 8);
assert(type_of<float>() ==
Float(32));
assert(cast<uint8_t>(x).type() ==
UInt(8));
f1(x) = cast<uint8_t>(x);
assert(f2.types()[0] ==
Int(32) &&
f2.types()[1] ==
Float(32));
}
{
Expr s8 = cast<int8_t>(x);
Expr s16 = cast<int16_t>(x);
Expr s32 = cast<int32_t>(x);
Expr s64 = cast<int64_t>(x);
for (
Type t : valid_halide_types) {
assert((e + e).type() == e.
type());
}
assert((
f32 + s64).type() ==
Float(32));
assert((
f64 + s32).type() ==
Float(64));
assert((
u32 + 3).type() ==
UInt(32));
assert((3 + s16).type() ==
Int(16));
assert((s16 + s64).type() ==
Int(64));
assert((
u8 + s32).type() ==
Int(32));
assert((
u32 + s8).type() ==
Int(32));
assert((
u32 + s32).type() ==
Int(32));
int32_t result32 = evaluate<int>(cast<int32_t>(cast<uint8_t>(255)));
assert(result32 == 255);
uint16_t result16 = evaluate<uint16_t>(cast<uint16_t>(cast<int8_t>(-1)));
assert(result16 == 65535);
}
{
assert(type_of<void *>() ==
Handle());
assert(type_of<const char *const **>() ==
Handle());
assert(
Handle().bits() == 64);
}
{
assert(average(cast<float>(x), 3.0f).type() ==
Float(32));
assert(average(x, 3).type() ==
Int(32));
assert(average(cast<uint8_t>(x), cast<uint8_t>(3)).type() ==
UInt(8));
}
printf("Success!\n");
return 0;
}
return (a + b) / 2;
}
return cast(narrow, (a + b) / 2);
}