Skip to content

Commit 43355de

Browse files
committed
More fixes and enablement
1 parent bb697ae commit 43355de

File tree

18 files changed

+130
-77
lines changed

18 files changed

+130
-77
lines changed

.ci/scripts/unittest-windows.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if ($LASTEXITCODE -ne 0) {
2929
exit $LASTEXITCODE
3030
}
3131

32-
ctest -j8
32+
ctest -j8 . --config $buildMode --output-on-failure
3333
if ($LASTEXITCODE -ne 0) {
3434
Write-Host "CTest run was unsuccessful. Exit code: $LASTEXITCODE."
3535
exit $LASTEXITCODE

extension/evalue_util/test/print_evalue_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ TEST(PrintEvalueTest, UnelidedBoolLists) {
267267
// case; the other scalar types use the same underlying code, so they don't
268268
// need to test this again.
269269
{
270-
EValue value(ArrayRef<bool>(list.data(), 0ul));
270+
EValue value(ArrayRef<bool>(list.data(), (size_t)0ul));
271271
expect_output(value, "(len=0)[]");
272272
}
273273
{
@@ -419,7 +419,7 @@ TEST(PrintEvalueTest, UnelidedDoubleLists) {
419419
std::array<double, 6> list = {-2.2, -1, 0, INFINITY, NAN, 3.3};
420420

421421
{
422-
EValue value(ArrayRef<double>(list.data(), 0ul));
422+
EValue value(ArrayRef<double>(list.data(), (size_t)0ul));
423423
expect_output(value, "(len=0)[]");
424424
}
425425
{

extension/flat_tensor/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add_custom_command(
2323
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
2424
COMMAND
2525
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul"
26-
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
26+
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}"
2727
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
2828
)
2929

extension/module/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ add_custom_command(
2424
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.pte"
2525
"${CMAKE_CURRENT_BINARY_DIR}/ModuleAddMulProgram.ptd"
2626
COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules
27-
"ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
27+
"ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}"
2828
COMMAND
2929
${PYTHON_EXECUTABLE} -m test.models.export_program --modules "ModuleAddMul"
30-
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
30+
--external-constants --outdir "${CMAKE_CURRENT_BINARY_DIR}"
3131
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
3232
)
3333

extension/runner_util/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include(${EXECUTORCH_ROOT}/tools/cmake/Test.cmake)
2020
add_custom_command(
2121
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ModuleAdd.pte"
2222
COMMAND ${PYTHON_EXECUTABLE} -m test.models.export_program --modules
23-
"ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}" 2> /dev/null
23+
"ModuleAdd" --outdir "${CMAKE_CURRENT_BINARY_DIR}"
2424
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
2525
)
2626

extension/testing_util/temp_file.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
#pragma once
1010

1111
#include <array>
12+
#include <fstream>
1213
#include <memory>
1314
#include <string>
1415

1516
#include <fcntl.h> // open()
16-
#include <stdio.h> // tmpnam(), remove()
17-
#include <unistd.h> // write(), close()
18-
1917
#include <gtest/gtest.h>
2018

2119
namespace executorch {
@@ -72,19 +70,13 @@ class TempFile {
7270
}
7371

7472
// Write the contents to the file.
75-
int fd = open(
76-
path.c_str(),
77-
// O_EXCL ensures that we are the ones creating this file, to help
78-
// protect against race conditions.
79-
O_CREAT | O_EXCL | O_RDWR,
80-
// User can read and write, group can read.
81-
S_IRUSR | S_IWUSR | S_IRGRP);
82-
ASSERT_GE(fd, 0) << "open(" << path << ") failed: " << strerror(errno);
83-
84-
ssize_t nwrite = write(fd, data, size);
85-
ASSERT_EQ(nwrite, size) << "Failed to write " << size << " bytes (wrote "
86-
<< nwrite << "): " << strerror(errno);
87-
close(fd);
73+
std::ofstream file(path, std::ios::out | std::ios::binary);
74+
ASSERT_TRUE(file.is_open())
75+
<< "open(" << path << ") failed: " << strerror(errno);
76+
77+
file.write((const char*)data, size);
78+
ASSERT_TRUE(file.good())
79+
<< "Failed to write " << size << " bytes: " << strerror(errno);
8880

8981
*out_path = path;
9082
}

kernels/portable/cpu/op_argmax.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ Tensor& argmax_out(
4949
static constexpr const char op_name[] = "argmax.out";
5050

5151
ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, op_name, CTYPE, [&] {
52-
long* out_data = out.mutable_data_ptr<long>();
52+
int64_t* out_data = out.mutable_data_ptr<int64_t>();
5353

5454
const bool success = parallel_for_each_reduce_over_dim_output_index(
5555
in, dim, out, [&](const auto begin, const auto end) {
5656
for (const auto out_ix : c10::irange(begin, end)) {
57-
std::tuple<CTYPE, long> acc = reduce_over_dim<CTYPE>(
58-
[](CTYPE v, long ix, CTYPE acc_val, long acc_ix) {
57+
std::tuple<CTYPE, int64_t> acc = reduce_over_dim<CTYPE>(
58+
[](CTYPE v, int64_t ix, CTYPE acc_val, int64_t acc_ix) {
5959
// the below condition as written is equivalent to
6060
// !isnan(accval) && (isnan(v) || v > acc_val). See
6161
// argument in op_argmin.cpp.
6262
if (!utils::isnan_override(acc_val) && !(v <= acc_val)) {
6363
acc_val = v;
6464
acc_ix = ix;
6565
}
66-
return std::tuple<CTYPE, long>{acc_val, acc_ix};
66+
return std::tuple<CTYPE, int64_t>{acc_val, acc_ix};
6767
},
6868
in,
6969
dim,

kernels/portable/cpu/op_argmin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ Tensor& argmin_out(
4949
static constexpr const char op_name[] = "argmin.out";
5050

5151
ET_SWITCH_REALHBF16_TYPES(in.scalar_type(), ctx, op_name, CTYPE, [&] {
52-
long* out_data = out.mutable_data_ptr<long>();
52+
int64_t* out_data = out.mutable_data_ptr<int64_t>();
5353

5454
const bool success = parallel_for_each_reduce_over_dim_output_index(
5555
in, dim, out, [&](const auto begin, const auto end) {
5656
for (const auto out_ix : c10::irange(begin, end)) {
57-
std::tuple<CTYPE, long> acc = reduce_over_dim<CTYPE>(
58-
[](CTYPE v, long ix, CTYPE acc_val, long acc_ix) {
57+
std::tuple<CTYPE, int64_t> acc = reduce_over_dim<CTYPE>(
58+
[](CTYPE v, int64_t ix, CTYPE acc_val, int64_t acc_ix) {
5959
// the below condition as written is equivalent to
6060
// !isnan(accval) && (isnan(v) || v < acc_val). cases:
6161
// - if neither acc_val nor v is NaN, !(v >= acc_val) is
@@ -70,7 +70,7 @@ Tensor& argmin_out(
7070
acc_val = v;
7171
acc_ix = ix;
7272
}
73-
return std::tuple<CTYPE, long>{acc_val, acc_ix};
73+
return std::tuple<CTYPE, int64_t>{acc_val, acc_ix};
7474
},
7575
in,
7676
dim,

kernels/portable/cpu/op_clamp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ ET_NODISCARD bool check_bounds(
4545
static constexpr const char op_name[] = "clamp.out";
4646

4747
if (isIntegralType(out_type, /*includeBool=*/false)) {
48-
const long val_long = utils::scalar_to<long>(val_scalar);
48+
const int64_t val_long = utils::scalar_to<int64_t>(val_scalar);
4949
ET_SWITCH_INT_TYPES(out_type, ctx, op_name, CTYPE_OUT, [&]() {
50-
if (is_out_of_bounds<CTYPE_OUT, long>(val_long)) {
50+
if (is_out_of_bounds<CTYPE_OUT, int64_t>(val_long)) {
5151
ET_LOG(Error, "%s value out of bounds", val_name);
5252
is_valid = false;
5353
}

kernels/portable/cpu/op_gather.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void gather_helper(
3030
Tensor& out,
3131
int64_t dim) {
3232
const CTYPE* in_data = in.const_data_ptr<CTYPE>();
33-
const long* index_data = index.const_data_ptr<long>();
33+
const int64_t* index_data = index.const_data_ptr<int64_t>();
3434
CTYPE* out_data = out.mutable_data_ptr<CTYPE>();
3535

3636
if (index.dim() == 0) {

0 commit comments

Comments
 (0)