You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Operation.Control.cs 2.2 kB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*****************************************************************************
  2. Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ******************************************************************************/
  13. using Tensorflow.Operations;
  14. namespace Tensorflow
  15. {
  16. public partial class Operation
  17. {
  18. private ControlFlowContext _control_flow_context;
  19. /// <summary>
  20. /// Add this op to its control flow context.
  21. ///
  22. /// This may add new ops and change this op's inputs. self.inputs must be
  23. /// available before calling this method.
  24. /// </summary>
  25. public void _control_flow_post_processing()
  26. {
  27. foreach (Tensor input_tensor in inputs)
  28. control_flow_util.CheckInputFromValidContext(this, input_tensor.op);
  29. if (_control_flow_context != null)
  30. _control_flow_context.AddOp(this);
  31. }
  32. public void _add_control_input(Operation op)
  33. {
  34. // c_api.TF_AddControlInput(_opDesc, op);
  35. //c_api.AddControlInput(graph, _handle, op);
  36. }
  37. public void _add_control_inputs(Operation[] ops)
  38. {
  39. foreach (var op in ops)
  40. _add_control_input(op);
  41. }
  42. public void _set_control_flow_context(ControlFlowContext ctx)
  43. {
  44. _control_flow_context = ctx;
  45. }
  46. public ControlFlowContext _get_control_flow_context()
  47. {
  48. return _control_flow_context;
  49. }
  50. public WhileContext GetWhileContext()
  51. {
  52. return _control_flow_context as WhileContext;
  53. }
  54. }
  55. }