Skip to content

Commit

Permalink
fix: minor build bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhuofu committed Nov 1, 2024
1 parent 1d5140d commit d416c27
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
27 changes: 14 additions & 13 deletions lib/kernels/test/src/test_concat_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ TEST_SUITE(FF_TEST_SUITE) {
Allocator allocator = create_local_cuda_memory_allocator();

SUBCASE("forward_kernel") {
std::vector<GenericTensorAccessorR> input_accessors =
repeat(num_inputs, [&]() {
return read_only_accessor_from_write_accessor(
create_random_filled_accessor_w(input_shape, allocator));
});
std::vector<GenericTensorAccessorR> input_accessors(num_inputs);
generate_n(input_accessors.begin(), num_inputs, [&]() {
return read_only_accessor_from_write_accessor(
create_random_filled_accessor_w(input_shape, allocator));
});
GenericTensorAccessorW output_accessor =
allocator.allocate_tensor(output_shape);

Expand All @@ -44,13 +44,14 @@ TEST_SUITE(FF_TEST_SUITE) {
GenericTensorAccessorR output_grad_accessor =
read_only_accessor_from_write_accessor(
create_random_filled_accessor_w(output_shape, allocator));
std::vector<GenericTensorAccessorW> input_grad_accessors = repeat(
num_inputs, [&]() { return allocator.allocate_tensor(input_shape); });

Kernels::Concat::backward_kernel(managed_stream.raw_stream(),
output_grad_accessor,
input_grad_accessors,
concat_axis);
std::vector<GenericTensorAccessorW> input_grad_accessors(num_inputs);
generate_n(input_grad_accessors.begin(), num_inputs, [&]() {
return allocator.allocate_tensor(input_shape);

Kernels::Concat::backward_kernel(managed_stream.raw_stream(),
output_grad_accessor,
input_grad_accessors,
concat_axis);
}
}
}
}
2 changes: 1 addition & 1 deletion lib/kernels/test/src/test_dropout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST_SUITE(FF_TEST_SUITE) {
managed_handle.raw_handle(), dropout_rate, seed, shape, allocator);

auto get_zero_count = [](std::vector<float> const &data) {
return count(data, [](float x) { return x == 0.0f; });
return count(data.begin(), data.end(), [](float x) { return x == 0.0f; });
};

SUBCASE("forward_kernel") {
Expand Down
3 changes: 2 additions & 1 deletion lib/kernels/test/src/test_split_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ TEST_SUITE(FF_TEST_SUITE) {
GenericTensorAccessorW input_accessor =
create_random_filled_accessor_w(input_shape, allocator);

std::vector<float *> output_ptrs = repeat(num_outputs, [&]() {
std::vector<float *> output_ptrs(num_outputs);
generate_n(output_ptrs.begin(), num_outputs, [&]() {
GenericTensorAccessorW output_accessor =
allocator.allocate_tensor(output_shape);
return output_accessor.get_float_ptr();
Expand Down
5 changes: 4 additions & 1 deletion lib/kernels/test/src/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "kernels/managed_per_device_ff_handle.h"
#include <random>

using namespace FlexFlow;

GenericTensorAccessorW create_random_filled_accessor_w(TensorShape const &shape,
Allocator &allocator,
bool cpu_fill = false);
Expand Down Expand Up @@ -42,7 +44,8 @@ std::vector<T> load_data_to_host_from_device(GenericTensorAccessorR accessor) {

template <typename T>
bool contains_non_zero(std::vector<T> &data) {
return !all_of(data, [](T const &val) { return val == 0; });
return !all_of(
data.begin(), data.end(), [](T const &val) { return val == 0; });
}

#endif

0 comments on commit d416c27

Please sign in to comment.