forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_validation.h
More file actions
51 lines (44 loc) · 1.44 KB
/
program_validation.h
File metadata and controls
51 lines (44 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <executorch/runtime/core/error.h>
// Forward declare flatbuffer types.
namespace executorch_flatbuffer {
struct ExecutionPlan;
struct Program;
struct Tensor;
struct TensorList;
} // namespace executorch_flatbuffer
namespace executorch {
namespace runtime {
/**
* Validates that a tensor's metadata is semantically valid: sizes are
* non-negative, scalar type is valid, and computing numel/nbytes will not
* overflow.
*
* @param[in] tensor The flatbuffer Tensor to validate.
* @return Error::Ok if validation passes, Error::InvalidProgram otherwise.
*/
ET_NODISCARD Error validate_tensor(const executorch_flatbuffer::Tensor* tensor);
/**
* Performs validation of all tensors and lists in the program, checking that
* their metadata is semantically valid and will not cause issues during
* execution.
*
* Currently validates:
* - Tensor numel overflow (all tensors)
* - TensorList element types (all TensorLists)
*
* @param[in] program The flatbuffer Program to validate.
* @return Error::Ok if validation passes, Error::InvalidProgram if any
* validation check fails.
*/
ET_NODISCARD Error
validate_program(const executorch_flatbuffer::Program* program);
} // namespace runtime
} // namespace executorch