Skip to content

Commit 727fd85

Browse files
author
Victor Li
committed
Adding value_type and ordered_value_type to some files
1 parent 0c93abe commit 727fd85

File tree

7 files changed

+94
-22
lines changed

7 files changed

+94
-22
lines changed
Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1-
#ifndef _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_DIM_ORDERED_SLICE_H
2-
#define _FLEXFLOW_LIB_OP_ATTRS_INCLUDE_OP_ATTRS_DIM_ORDERED_SLICE_H
3-
41
#include "op-attrs/dim_ordered/slice.h"
52
#include "utils/archetypes/value_type.h"
63

74
namespace FlexFlow {
85

96
using T = value_type<0>;
107

11-
template
12-
FFOrdered<T> ff_dim_t_nonoverloaded_slice(FFOrdered<T> const &d,
13-
std::optional<ff_dim_t> const &start,
14-
std::optional<ff_dim_t> const &end);
8+
template FFOrdered<T>
9+
ff_dim_t_nonoverloaded_slice(FFOrdered<T> const &d,
10+
std::optional<ff_dim_t> const &start,
11+
std::optional<ff_dim_t> const &end);
1512

16-
template
17-
FFOrdered<T> relative_ff_dim_t_nonoverloaded_slice(
13+
template FFOrdered<T> relative_ff_dim_t_nonoverloaded_slice(
1814
FFOrdered<T> const &d,
1915
std::optional<relative_ff_dim_t> const &start,
2016
std::optional<relative_ff_dim_t> const &end);
2117

22-
template
23-
FFOrdered<T> slice(FFOrdered<T> const &d,
24-
std::optional<ff_dim_t> const &start,
25-
std::optional<ff_dim_t> const &end);
18+
template FFOrdered<T> slice(FFOrdered<T> const &d,
19+
std::optional<ff_dim_t> const &start,
20+
std::optional<ff_dim_t> const &end);
2621

27-
template
28-
FFOrdered<T> slice(FFOrdered<T> const &d,
29-
std::optional<relative_ff_dim_t> const &start,
30-
std::optional<relative_ff_dim_t> const &end);
22+
template FFOrdered<T> slice(FFOrdered<T> const &d,
23+
std::optional<relative_ff_dim_t> const &start,
24+
std::optional<relative_ff_dim_t> const &end);
3125

3226
} // namespace FlexFlow
33-
34-
#endif
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_ARCHETYPES_ORDERED_VALUE_TYPE_H
2+
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_ARCHETYPES_ORDERED_VALUE_TYPE_H
3+
4+
#include <cassert>
5+
#include <functional>
6+
7+
namespace FlexFlow {
8+
9+
template <int TAG>
10+
struct ordered_value_type {
11+
ordered_value_type() = delete;
12+
13+
ordered_value_type(ordered_value_type const &) {
14+
assert(false);
15+
}
16+
ordered_value_type &operator=(ordered_value_type const &) {
17+
assert(false);
18+
}
19+
20+
ordered_value_type(ordered_value_type &&) {
21+
assert(false);
22+
}
23+
ordered_value_type &operator=(ordered_value_type &&) {
24+
assert(false);
25+
}
26+
27+
bool operator==(ordered_value_type const &) const {
28+
assert(false);
29+
}
30+
bool operator!=(ordered_value_type const &) const {
31+
assert(false);
32+
}
33+
34+
bool operator<(ordered_value_type const &) const {
35+
assert(false);
36+
}
37+
bool operator>(ordered_value_type const &) const {
38+
assert(false);
39+
}
40+
};
41+
42+
} // namespace FlexFlow
43+
44+
namespace std {
45+
46+
template <int TAG>
47+
struct hash<::FlexFlow::ordered_value_type<TAG>> {
48+
size_t operator()(::FlexFlow::ordered_value_type<TAG> const &) const {
49+
assert(false);
50+
};
51+
};
52+
53+
} // namespace std
54+
55+
#endif

lib/utils/include/utils/stack_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct stack_basic_string {
5959

6060
friend fmt::basic_string_view<Char>
6161
format_as(stack_basic_string<Char, MAXSIZE> const &s) {
62-
return {s.contents.data(), s.length()};
62+
return {s.contents.stack_contents().data(), s.length()};
6363
}
6464

6565
private:

lib/utils/include/utils/stack_vector/stack_vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ struct stack_vector {
292292
return (this->m_size == 0);
293293
}
294294

295-
T const *data() const {
296-
return this->contents.data();
295+
std::array<element_type, MAXSIZE> stack_contents() const {
296+
return this->contents;
297297
}
298298

299299
friend std::string format_as(stack_vector<T, MAXSIZE> const &v) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "utils/archetypes/ordered_value_type.h"
2+
3+
namespace FlexFlow {
4+
5+
template struct ordered_value_type<0>;
6+
7+
} // namespace FlexFlow
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
#include "utils/stack_vector/stack_vector.h"
2+
#include "utils/archetypes/ordered_value_type.h"
3+
4+
namespace FlexFlow {
5+
6+
using T = ordered_value_type<0>;
7+
8+
template struct stack_vector<T, 5>;
9+
10+
} // namespace FlexFlow
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
#include "utils/stack_vector/stack_vector_of.h"
2+
#include "utils/archetypes/ordered_value_type.h"
3+
4+
namespace FlexFlow {
5+
6+
using T = ordered_value_type<0>;
7+
8+
template stack_vector<T, 5> stack_vector_of<5>(std::vector<T> const &vector);
9+
10+
} // namespace FlexFlow

0 commit comments

Comments
 (0)