Skip to content

Commit

Permalink
Changed ff_dim to ff_dim_t, added in nonnegative_int type
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Li committed Nov 8, 2024
1 parent 1d5140d commit 670fb62
Show file tree
Hide file tree
Showing 28 changed files with 504 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "kernels/legion_dim.h"
#include "op-attrs/datatype.h"
#include "op-attrs/ff_dim.h"
#include "op-attrs/ff_dim_t.h"
#include "op-attrs/tensor_shape.dtg.h"
#include "utils/stack_vector.h"
#include "utils/visitable.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/local-execution/src/ops/linear.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "linear.h"
#include "kernels/linear_kernels.h"
#include "local-execution/task_argument_accessor.h"
#include "op-attrs/ff_dim.h"
#include "op-attrs/ff_dim_t.h"
#include "op-attrs/get_output_shapes.h"
#include "utils/exception.h"
#include "utils/hash-utils.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/op-attrs/include/op-attrs/dim_ordered/dim_ordered.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _FLEXFLOW_OPATTRS_INCLUDE_OPATTRS_FF_STACK_VECTOR_H
#define _FLEXFLOW_OPATTRS_INCLUDE_OPATTRS_FF_STACK_VECTOR_H

#include "op-attrs/ff_dim.dtg.h"
#include "op-attrs/ff_dim_t.dtg.h"
#include "utils/fmt/vector.h"
#include "utils/stack_vector.h"
#include <nlohmann/json.hpp>
Expand Down
18 changes: 0 additions & 18 deletions lib/op-attrs/include/op-attrs/ff_dim.h

This file was deleted.

14 changes: 14 additions & 0 deletions lib/op-attrs/include/op-attrs/ff_dim_t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_FF_DIM_T_H
#define _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_FF_DIM_T_H

#include "op-attrs/ff_dim_t.dtg.h"
#include "rapidcheck.h"

namespace rc {
template <>
struct Arbitrary<FlexFlow::ff_dim_t> {
static Gen<FlexFlow::ff_dim_t> arbitrary();
};
} // namespace rc

#endif // _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_FF_DIM_T_H
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/combine_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/concat_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h"
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h"
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/flat_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ features = [

includes = [
"<optional>",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.dtg.h",
]

src_includes = [
"utils/fmt/optional.h",
"utils/json/optional.h",
"utils/rapidcheck/optional.h",
"op-attrs/ff_dim.h",
"op-attrs/ff_dim_t.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/gather_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h"
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h"
]

[[fields]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
"utils/stack_vector.h",
]

Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/reduce_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ features = [

includes = [
"op-attrs/operator_type.dtg.h",
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
"utils/stack_vector.h",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/reverse_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/softmax_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/split_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ features = [

includes = [
"utils/stack_vector.h",
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
]

[[fields]]
Expand Down
4 changes: 2 additions & 2 deletions lib/op-attrs/include/op-attrs/ops/transpose_attrs.struct.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ features = [
]

includes = [
"op-attrs/ff_dim.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.h",
"op-attrs/ff_dim_t.dtg.h",
"op-attrs/dim_ordered/dim_ordered.h",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ features = [
]

includes = [
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.dtg.h",
"op-attrs/replica_type.dtg.h",
]

Expand Down
14 changes: 14 additions & 0 deletions lib/op-attrs/include/op-attrs/relative_ff_dim_t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_RELATIVE_FF_DIM_T_H
#define _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_RELATIVE_FF_DIM_T_H

#include "op-attrs/relative_ff_dim_t.dtg.h"
#include "rapidcheck.h"

namespace rc {
template <>
struct Arbitrary<FlexFlow::relative_ff_dim_t> {
static Gen<FlexFlow::relative_ff_dim_t> arbitrary();
};
} // namespace rc

#endif // _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_RELATIVE_FF_DIM_T_H
14 changes: 14 additions & 0 deletions lib/op-attrs/include/op-attrs/relative_ff_dim_t.struct.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace = "FlexFlow"
name = "relative_ff_dim_t"

features = [
"eq",
"ord",
"hash",
"json",
"fmt",
]

[[fields]]
name = "value"
type = "int"
8 changes: 8 additions & 0 deletions lib/op-attrs/src/op-attrs/ff_dim_t.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "op-attrs/ff_dim_t.h"

namespace rc {
Gen<FlexFlow::ff_dim_t> Arbitrary<FlexFlow::ff_dim_t>::arbitrary() {
return gen::construct<FlexFlow::ff_dim_t>(
gen::inRange<int>(0, MAX_TENSOR_DIM));
}
} // namespace rc
10 changes: 10 additions & 0 deletions lib/op-attrs/src/op-attrs/relative_ff_dim_t.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "op-attrs/relative_ff_dim_t.h"
#include "rapidcheck.h"

namespace rc {
Gen<FlexFlow::relative_ff_dim_t>
Arbitrary<FlexFlow::relative_ff_dim_t>::arbitrary() {
return gen::construct<FlexFlow::relative_ff_dim_t>(
gen::inRange<int>(-MAX_TENSOR_DIM, MAX_TENSOR_DIM));

Check warning on line 8 in lib/op-attrs/src/op-attrs/relative_ff_dim_t.cc

View check run for this annotation

Codecov / codecov/patch

lib/op-attrs/src/op-attrs/relative_ff_dim_t.cc#L6-L8

Added lines #L6 - L8 were not covered by tests
}
} // namespace rc
2 changes: 1 addition & 1 deletion lib/op-attrs/test/src/op-attrs/dim_ordered/zip.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "op-attrs/dim_ordered/zip.h"
#include "op-attrs/ff_dim.dtg.h"
#include "op-attrs/ff_dim_t.dtg.h"
#include "test/utils/doctest/fmt/pair.h"
#include <doctest/doctest.h>

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/src/parallel_op_info.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _FLEXFLOW_PARALLEL_OPS_PARALLEL_OP_INFO_H
#define _FLEXFLOW_PARALLEL_OPS_PARALLEL_OP_INFO_H

#include "op-attrs/ff_dim.h"
#include "op-attrs/ff_dim_t.h"
#include "op-attrs/operator_type.h"
#include "utils/visitable.h"
#include <functional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ includes = [
"<vector>",
"<optional>",
"op-attrs/operator_type.dtg.h",
"op-attrs/ff_dim.dtg.h",
"op-attrs/ff_dim_t.dtg.h",
"op-attrs/activation.dtg.h",
"op-attrs/aggregate_op.dtg.h",
"op-attrs/regularizer_attrs.dtg.h",
Expand Down
65 changes: 65 additions & 0 deletions lib/utils/include/utils/nonnegative_int/nonnegative_int.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_NONNEGATIVE_INT_NONNEGATIVE_INT_H
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_NONNEGATIVE_INT_NONNEGATIVE_INT_H

#include "rapidcheck.h"

#include <any>
#include <fmt/format.h>
#include <functional>
#include <nlohmann/json.hpp>
#include <string>

namespace FlexFlow {
class nonnegative_int {
public:
nonnegative_int() = delete;
explicit nonnegative_int(int value);

explicit operator int() const noexcept;

bool operator<(nonnegative_int const &other) const;
bool operator==(nonnegative_int const &other) const;
bool operator>(nonnegative_int const &other) const;
bool operator<=(nonnegative_int const &other) const;
bool operator!=(nonnegative_int const &other) const;
bool operator>=(nonnegative_int const &other) const;

bool operator<(int const &other) const;
bool operator==(int const &other) const;
bool operator>(int const &other) const;
bool operator<=(int const &other) const;
bool operator!=(int const &other) const;
bool operator>=(int const &other) const;

friend bool operator<(int const &lhs, nonnegative_int const &rhs);
friend bool operator==(int const &lhs, nonnegative_int const &rhs);
friend bool operator>(int const &lhs, nonnegative_int const &rhs);
friend bool operator<=(int const &lhs, nonnegative_int const &rhs);
friend bool operator!=(int const &lhs, nonnegative_int const &rhs);
friend bool operator>=(int const &lhs, nonnegative_int const &rhs);

friend std::ostream &operator<<(std::ostream &os, nonnegative_int const &n);

int get_value() const;

private:
int value_;
};
} // namespace FlexFlow

namespace nlohmann {
template <>
struct adl_serializer<::FlexFlow::nonnegative_int> {
static ::FlexFlow::nonnegative_int from_json(json const &j);
static void to_json(json &j, ::FlexFlow::nonnegative_int t);
};
} // namespace nlohmann

namespace std {
template <>
struct hash<FlexFlow::nonnegative_int> {
std::size_t operator()(FlexFlow::nonnegative_int const &n) const noexcept;
};
} // namespace std

#endif
Loading

0 comments on commit 670fb62

Please sign in to comment.