Skip to content

Commit 47e9b47

Browse files
authored
[onert] Add validator for backends (#16222)
This commit adds Validator class to validate operations in CPU, ACL-CL/NEON, ruy backend. The validator uses the operation list macro. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
1 parent 4249da3 commit 47e9b47

File tree

10 files changed

+232
-0
lines changed

10 files changed

+232
-0
lines changed

runtime/onert/backend/acl_cl/Backend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "TensorManager.h"
2828
#include "Optimizer.h"
2929
#include "AclTensorRegistry.h"
30+
#include "Validator.h"
3031

3132
namespace onert::backend::acl_cl
3233
{
@@ -56,6 +57,11 @@ class Backend : public ::onert::backend::Backend
5657
return context;
5758
}
5859

60+
std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
61+
{
62+
return std::make_unique<Validator>(graph);
63+
}
64+
5965
private:
6066
std::shared_ptr<IConfig> _config;
6167
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_ACL_CL_VALIDATOR_H__
18+
#define __ONERT_BACKEND_ACL_CL_VALIDATOR_H__
19+
20+
#include <backend/ValidatorBase.h>
21+
22+
namespace onert::backend::acl_cl
23+
{
24+
25+
// TODO Validate inputs, outputs, and parameters of each operation
26+
class Validator : public backend::ValidatorBase
27+
{
28+
public:
29+
virtual ~Validator() = default;
30+
Validator(const ir::Graph &graph) : backend::ValidatorBase(graph) {}
31+
32+
private:
33+
#define OP(InternalName) \
34+
void visit(const ir::operation::InternalName &) override { _supported = true; }
35+
#include "Operation.lst"
36+
#undef OP
37+
};
38+
39+
} // namespace onert::backend::acl_cl
40+
41+
#endif // __ONERT_BACKEND_ACL_CL_VALIDATOR_H__

runtime/onert/backend/acl_neon/Backend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "KernelGenerator.h"
2828
#include "TensorManager.h"
2929
#include "Optimizer.h"
30+
#include "Validator.h"
3031

3132
namespace onert::backend::acl_neon
3233
{
@@ -56,6 +57,11 @@ class Backend : public ::onert::backend::Backend
5657
return context;
5758
}
5859

60+
std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
61+
{
62+
return std::make_unique<Validator>(graph);
63+
}
64+
5965
private:
6066
std::shared_ptr<IConfig> _config;
6167
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_ACL_NEON_VALIDATOR_H__
18+
#define __ONERT_BACKEND_ACL_NEON_VALIDATOR_H__
19+
20+
#include <backend/ValidatorBase.h>
21+
22+
namespace onert::backend::acl_neon
23+
{
24+
25+
// TODO Validate inputs, outputs, and parameters of each operation
26+
class Validator : public backend::ValidatorBase
27+
{
28+
public:
29+
virtual ~Validator() = default;
30+
Validator(const ir::Graph &graph) : backend::ValidatorBase(graph) {}
31+
32+
private:
33+
#define OP(InternalName) \
34+
void visit(const ir::operation::InternalName &) override { _supported = true; }
35+
#include "Operation.lst"
36+
#undef OP
37+
};
38+
39+
} // namespace onert::backend::acl_neon
40+
41+
#endif // __ONERT_BACKEND_ACL_NEON_VALIDATOR_H__

runtime/onert/backend/cpu/Backend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "Config.h"
2222
#include "KernelGenerator.h"
2323
#include "SharedMemoryOperands.h"
24+
#include "Validator.h"
2425

2526
#include <backend/Backend.h>
2627

@@ -49,6 +50,11 @@ class Backend : public ::onert::backend::Backend
4950
return context;
5051
}
5152

53+
std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
54+
{
55+
return std::make_unique<Validator>(graph);
56+
}
57+
5258
private:
5359
std::shared_ptr<IConfig> _config;
5460
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_CPU_VALIDATOR_H__
18+
#define __ONERT_BACKEND_CPU_VALIDATOR_H__
19+
20+
#include <backend/ValidatorBase.h>
21+
22+
namespace onert::backend::cpu
23+
{
24+
25+
// TODO Validate inputs, outputs, and parameters of each operation
26+
class Validator : public backend::ValidatorBase
27+
{
28+
public:
29+
virtual ~Validator() = default;
30+
Validator(const ir::Graph &graph) : backend::ValidatorBase(graph) {}
31+
32+
private:
33+
#define OP(InternalName) \
34+
void visit(const ir::operation::InternalName &) override { _supported = true; }
35+
#include "Operation.lst"
36+
#undef OP
37+
};
38+
39+
} // namespace onert::backend::cpu
40+
41+
#endif // __ONERT_BACKEND_CPU_VALIDATOR_H__

runtime/onert/backend/ruy/Backend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "BackendContext.h"
2121
#include "Config.h"
2222
#include "KernelGenerator.h"
23+
#include "Validator.h"
2324

2425
#include <backend/Backend.h>
2526

@@ -48,6 +49,11 @@ class Backend : public ::onert::backend::Backend
4849
return context;
4950
}
5051

52+
std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
53+
{
54+
return std::make_unique<Validator>(graph);
55+
}
56+
5157
private:
5258
std::shared_ptr<IConfig> _config;
5359
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_RUY_VALIDATOR_H__
18+
#define __ONERT_BACKEND_RUY_VALIDATOR_H__
19+
20+
#include <backend/ValidatorBase.h>
21+
22+
namespace onert::backend::ruy
23+
{
24+
25+
// TODO Validate inputs, outputs, and parameters of each operation
26+
class Validator : public backend::ValidatorBase
27+
{
28+
public:
29+
virtual ~Validator() = default;
30+
Validator(const ir::Graph &graph) : backend::ValidatorBase(graph) {}
31+
32+
private:
33+
#define OP(InternalName) \
34+
void visit(const ir::operation::InternalName &) override { _supported = true; }
35+
#include "Operation.lst"
36+
#undef OP
37+
};
38+
39+
} // namespace onert::backend::ruy
40+
41+
#endif // __ONERT_BACKEND_RUY_VALIDATOR_H__

runtime/onert/backend/trix/Backend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "BackendContext.h"
2121
#include "Config.h"
2222
#include "KernelGenerator.h"
23+
#include "Validator.h"
2324

2425
#include <backend/Backend.h>
2526

@@ -47,6 +48,11 @@ class Backend : public ::onert::backend::Backend
4748
return context;
4849
}
4950

51+
std::unique_ptr<ValidatorBase> validator(const ir::Graph &graph) const override
52+
{
53+
return std::make_unique<Validator>(graph);
54+
}
55+
5056
private:
5157
std::shared_ptr<IConfig> _config;
5258
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef __ONERT_BACKEND_TRIX_VALIDATOR_H__
18+
#define __ONERT_BACKEND_TRIX_VALIDATOR_H__
19+
20+
#include <backend/ValidatorBase.h>
21+
22+
namespace onert::backend::trix
23+
{
24+
25+
// TODO Validate inputs, outputs, and parameters of each operation
26+
class Validator : public backend::ValidatorBase
27+
{
28+
public:
29+
virtual ~Validator() = default;
30+
Validator(const ir::Graph &graph) : backend::ValidatorBase(graph) {}
31+
32+
private:
33+
void visit(const ir::operation::Bulk &) override { _supported = true; }
34+
};
35+
36+
} // namespace onert::backend::trix
37+
38+
#endif // __ONERT_BACKEND_TRIX_VALIDATOR_H__

0 commit comments

Comments
 (0)