Huawei HCIA-AI study materials
Huawei HCIA-AI study resources

Huawei HCIA-AI: Mainstream AI Development Frameworks (TensorFlow, MindSpore)

Huawei HCIA-AI · Work through your exam, one topic at a time.

All guide sections

Mainstream AI Development Frameworks (TensorFlow, MindSpore)

This domain compares TensorFlow and MindSpore at the programming-model level: how graphs are built, how gradients are obtained, how models are saved, and how hardware is targeted.

TensorFlow essentials

  • Tensors are the core data type; eager execution runs operations immediately.
  • tf.function traces Python code into a graph for performance.
  • Keras provides high-level layers, models, and training loops.
  • SavedModel is the standard deployment artifact.

MindSpore essentials

  • Models subclass nn.Cell and define logic in construct, not call.
  • Operations come from mindspore.ops; context sets the device target such as Ascend, GPU, or CPU.
  • It supports both dynamic-graph and static-graph modes.
  • Automatic differentiation and automatic parallelism are headline capabilities.
  • MindIR is MindSpore's intermediate representation for cross-platform deployment.

Worked example

Port a small classifier to MindSpore for an Ascend server. Reasoning: define a class inheriting nn.Cell, declare layers in init, and write the forward pass in construct. Replace framework-specific tensor operations with mindspore.ops equivalents, set context(device_target='Ascend'), wrap the loss with GradOperation or use the Model API, then export MindIR. Keeping NumPy-only operations inside construct can break graph tracing, so convert them to MindSpore operations.

Traps

Calling a MindSpore model directly with model(x) instead of relying on the framework's call path is a common mistake. Assuming TensorFlow code runs unchanged on Ascend ignores CANN and MindSpore integration. Confusing MindIR with SavedModel, or automatic parallelism with data parallelism, also loses marks.