Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/dttest/api/python/ge/ge/custom_op/base.py: 88%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-04 11:36 +0800

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3# ----------------------------------------------------------------------------------------------------------- 

4# Copyright (c) 2026 Huawei Technologies Co., Ltd. 

5# This program is free software, you can redistribute it and/or modify it under the terms and conditions of 

6# CANN Open Software License Agreement Version 2.0 (the "License"). 

7# Please refer to the License for details. You may not use this file except in compliance with the License. 

8# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, 

9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 

10# See LICENSE in the root of the software repository for the full text of the License. 

11# ----------------------------------------------------------------------------------------------------------- 

12 

13"""Base definitions for Python GE custom ops.""" 

14 

15from __future__ import annotations 

16from abc import ABC, abstractmethod 

17 

18from ._native import EagerOpExecutionContext as EagerOpExecutionContext 

19 

20 

21class BaseCustomOp(ABC): 

22 """Base class for Python custom ops.""" 

23 

24 

25class EagerExecuteOp(BaseCustomOp): 

26 """Base class for Python eager execute custom ops.""" 

27 

28 @abstractmethod 

29 def execute(self, *args, **kwargs) -> None: 

30 """Execute with either the legacy context or schema-bound arguments.""" 

31 raise NotImplementedError